Adding image to google maps marker for this code -
i'm trying add custom image marker on code don't know how. tryed adding new var z , put image it's not working. found more , more codes similar thing looks easy , i'm quite new in area start not complicated.
i found code here: http://stiern.com/tutorials/adding-custom-google-maps-to-your-website/
function initialize() { var map_options = { center: new google.maps.latlng(45.813029,15.977895), <!-- centar mape --> zoom: 14, maptypeid: google.maps.maptypeid.roadmap }; var google_map = new google.maps.map(document.getelementbyid("map_canvas"), map_options); var info_window = new google.maps.infowindow({ content: 'loading' }); var t = []; var x = []; var y = []; var h = []; t.push('klinček'); x.push(45.812619); y.push(16.007195); h.push('<p><strong>caffe bar klinček</strong><br/>cijena: 15kn (ožujsko točeno)<br/> adresa: kušlanova 52</p>'); var = 0; ( item in t ) { var m = new google.maps.marker({ map: google_map, animation: google.maps.animation.drop, title: t[i], position: new google.maps.latlng(x[i],y[i]), html: h[i] }); google.maps.event.addlistener(m, 'click', function() { info_window.setcontent(this.html); info_window.open(google_map, this); }); i++; } }
initialize();
i modified piece of code above posted code.
var = 0; var image1 = 'beachflag.png'; var image2 = 'roadflag.png'; var image3 = 'railflag.png'; var image; ( item in t ) { if(condition1){ image = image1; } if(condition2){ image = image2; } if(condition3){ image = image3; } var m = new google.maps.marker({ map: google_map, animation: google.maps.animation.drop, title: t[i], position: new google.maps.latlng(x[i],y[i]), html: h[i], icon: image }); ......... }//for loop ends
for more info https://developers.google.com/maps/documentation/javascript/overlays#icons
Comments
Post a Comment