javascript - Google Map Marker Missing On Custom Map -
i managed customize colors of google map through javascript, legend , marker won't appear. i'm not worried legend, i'm focusing on marker appearing. tried putting in custom-made marker. why doesn't marker appear? it's right size, png transparency. please!
<script type="text/javascript"> window.onload = function () { } function initialize() { var mapoptions = { center: new google.maps.latlng(32.817323, -96.788059), zoom: 16, maptypeid: google.maps.maptypeid.map }; var map = new google.maps.map(document.getelementbyid("map"), mapoptions); var point = new google.maps.latlng(32.817323, -96.788059); var marker = new google.maps.marker({ position: point, map: map, title: "commercial ideas" }); } var latlng = new google.maps.latlng(32.817323, -96.788059); var styles = [ { featuretype: "landscape", stylers: [ { color: '#ffffff' } ] },{ featuretype: 'road', elementtype: 'geometry', stylers: [ { color: '#d90000' }, { weight: .1 } ] },{ featuretype: "natural", stylers: [ { hue: '#ff0000' } ] },{ featuretype: "road", stylers: [ { hue: '#610000' }, { saturation: -60 } ] }, { featuretype: 'road', elementtype: 'labels', stylers: [ { saturation: -50 }, ] },{ featuretype: "building", elementtype: "labels", stylers: [ { hue: '#fc7067' } ] },{ featuretype: "poi", //points of interest stylers: [ { hue: '#d90000' } ] } ]; var myoptions = { zoom: 14, center: latlng, maptypeid: google.maps.maptypeid.roadmap, disabledefaultui: true, styles: styles }; map = new google.maps.map(document.getelementbyid('map'), myoptions); } var iconbase = 'images/assets/icons/'; var marker = new google.maps.marker({ position: mylatlng, map: map, icon: iconbase + 'mapmarker.png', shadow: iconbase + 'mapmarkershadow.png' }); </script>
i linked out url . did link out wrong one? map show up.
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script>
the html within body so:
<div id="map"></div>
the css styling map id so:
#map { width: 100%; height: 600px; margin-bottom:15px; }
the custom marker doesn't appear, assuming url of image correct , image exists there, because mylatlng not defined, should obvious errors reported in javascript console.
change this:
var marker = new google.maps.marker({ position: mylatlng, map: map, icon: iconbase + 'mapmarker.png', shadow: iconbase + 'mapmarkershadow.png' });
to this:
var marker = new google.maps.marker({ position: latlng, map: map, icon: iconbase + 'mapmarker.png', shadow: iconbase + 'mapmarkershadow.png' });
Comments
Post a Comment