Friday, July 25, 2008

Google Maps : How to set Marker with mouse click

In Google maps, its just a click away to setup the marker.

Converting from mouse click position to Latitude and Longitude is

and from lat and long setting a marker is as simple as that...

var latlng: LatLng = map.fromViewPortPointToLatLng (new Point (map.mouseX, map.mouseY));
var marker: Marker = new Marker (latlng, new MarkerOptions ((draggable: false, iconAlignment: MarkerOptions.ALIGN_HORIZONTAL_CENTER, hasShadow: true) ));
// Icon set up map.addOverlay (marker);



Click to launch the application...

No comments: