javascript - Google maps Icon -
i'm trying set google maps icon depending on integer. i.e. if variable 3 set icon brown image marker. i've followed tutorial found here https://developers.google.com/maps/documentation/javascript/examples/icon-simple , here
how can change color of google maps marker?
this code, images located in same directory when load page error saying unexpected identifier @ icon: image. whats problem?
function getlocations(){ var data = <?php echo getjson(); ?>; var = 0; var locations = new array(); for(i; < data.length; i++){ var dataholder = [data[i].misc, parsefloat(data[i].lat), parsefloat(data[i].lng), parseint(data[i].status)]; locations.push(dataholder); } return locations; } function createmap() { var locations = getlocations(); var map = new google.maps.map(document.getelementbyid('map'), { zoom: 13, center: new google.maps.latlng(47.624561, -122.356445), maptypeid: google.maps.maptypeid.roadmap }); var infowindow = new google.maps.infowindow(); var marker, i; var markers = new array(); var image; (i = 0; < locations.length; i++) { if (locations[i][3] == 3) { image = 'brown_markera.png'; } else if (locations[i][3] == 4) { image = 'brown_markerb.png'; } else { image = 'brown_markerc.png'; } marker = new google.maps.marker({ position: new google.maps.latlng(locations[i][1], locations[i][2]), map: map icon: image }); markers.push(marker); google.maps.event.addlistener(marker, 'click', (function (marker, i) { return function () { infowindow.setcontent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); } function autocenter() { var bounds = new google.maps.latlngbounds(); $.each(markers, function (index, marker) { bounds.extend(marker.position); }); map.fitbounds(bounds); } autocenter(); }
credit goes craicerjack pointed out missing comma after map: map.
Comments
Post a Comment