javascript - Gmap with multiple marker -
hi have code used map contact , want add 2 more places on can me please:
/* --- google map --- */ var mapoptions = { center: new google.maps.latlng(49.5564021,5.8628159), zoom: 15, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("map-canvas"),mapoptions); var image = "img/marker.png"; var marker = new google.maps.marker({ position: mapoptions.center, map: map, icon: image });
you need define position second , third markers , add them added first one
var image = "img/marker.png"; var marker = new google.maps.marker({ position: mapoptions.center, map: map, icon: image }); var position2={lat:49.555,lng:5.861}; var marker2 = new google.maps.marker({ position: position2, map: map, icon: image }); var position3={lat:49.557,lng:5.863}; var marker3 = new google.maps.marker({ position: position3, map: map, icon: image });
and of course, there's room improvement if add markers within loop or declare function encapsule task.
Comments
Post a Comment