javascript - Drawing Library: Dynamically drawing different markers in Google maps api 3 -
javascript - Drawing Library: Dynamically drawing different markers in Google maps api 3 -
i using google maps api 3 allow user dynamically draw markers map using drawing tools. (ref. here)
i want user able draw multiple markers having different icons. e.g, should able draw school marker, hospital marker, etc. each of icon different.
this want user draw.
in docs, shows markers have same icon.
code:
$(document).ready(function(){ var drawingmanager; var marker = new google.maps.marker({}); var map; function initialize() { var mapoptions = { center: new google.maps.latlng(21.0000, 78.0000), zoom: 4 }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); drawingmanager = new google.maps.drawing.drawingmanager({ drawingmode: google.maps.drawing.overlaytype.marker, drawingcontrol: true, markeroptions:{ draggable: true, }, drawingcontroloptions: { position: google.maps.controlposition.top_center, drawingmodes: [ google.maps.drawing.overlaytype.marker ] } }); drawingmanager.setmap(map); google.maps.event.addlistener(drawingmanager, 'overlaycomplete', function(event) { var latlng = event.overlay.getposition() console.log(latlng); }); } google.maps.event.adddomlistener(window, 'load', initialize);
});
is there workaround?
update markeroptions
-property of drawingmanager
-instance desired icon
basic usage:
drawingmanagerinstance.setoptions({markeroptions: {icon:'path/to/another/marker.png'}});
demo: http://jsfiddle.net/doktormolle/a2xhv/
javascript google-maps google-maps-api-3 markers
Comments
Post a Comment