javascript - Google maps markers aren't showing up -
i seem have searched every question , google maps api can't see why markers aren't showing on map. i've taken code other areas , console isn't showing errors. code
<script type="text/javascript"> //declare namespace var up206b = {}; //declare map var map; //set geocoder var geocoder = new google.maps.geocoder(); function trace(message) { if (typeof console != 'undefined') { console.log(message); } } //function gets run when document loads up206b.initialize = function() { var latlng = new google.maps.latlng(-31.954465, 115.859586); var myoptions = { zoom: 13, center: latlng, maptypeid: google.maps.maptypeid.roadmap }; map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); // buggles marker location var locations = [ ['test 1', -31.9522, 115.8589], ['test 2', -31.1522, 115.4589], ['test 3', -31.9322, 115.1589], ['test 4', -31.5522, 115.9589], ['test 5', -32.9522, 115.2589] ]; var infowindow = new google.maps.infowindow(); var marker, i; (i = 0; < locations.length; i++) { marker = new google.maps.marker({ position: new google.maps.latlng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addlistener(marker, 'click', (function (marker, i) { return function () { infowindow.setcontent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); } } //geocode function up206b.geocode = function() { var address = $('#location').val(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { map.setcenter(results[0].geometry.location); var marker = new google.maps.marker({ map: map, position: results[0].geometry.location }); $('#buggles-locations').removeclass('hidden'); } else { alert("geocode not successful following reason: " + status); } }); } </script>
and example followed included in body load function
<body onload="up206b.initialize()">
the example here http://buggles.crushme.com.au/index.php have ideas why might not working?
thanks
this code
google.maps.event.addlistener(marker, 'click', (function (marker, i) { return function () { infowindow.setcontent(locations[i][0]); infowindow.open(map, marker); } })(marker, i));
value of = max length of locations, can save label of marker
marker = new google.maps.marker({ position : mylatlng, map : map, title: i.tostring(), }); google.maps.event.addlistener(marker, 'click', function () { infowindow.setcontent(partint(locations[this.gettitle())][0]); infowindow.open(map, this); });
Comments
Post a Comment