have a look at the documentation for the click event: http://code.google.com/apis/maps/documentation/reference.html#GMap2.click
The second parameter passed will be a GLatLng object. (unless clicked on a feature/overlay, where you can grab the lat/long of that feature) On 30/03/2009, Icy <[email protected]> wrote: > > Hi, > > I am here to enquire on how will I be able to get the Current LatLon > from Google MAP on mouse click? > > I know that we have to add an event listener. I've done that. I am on > the last step to the success of this question. > > I used the "fromDivPixelToLatLng" method provided by the Google Map > API. > > However, right now, I am using 1,1 as the pixel. Which I believe it's > not right. How can I get my pixel (the point whereby my mouse is > clicking) from the map? > > function initialize() { > map = new GMap2(document.getElementById("map_canvas")); > map.setCenter(new GLatLng(37.4419, -122.1419), 13); > map.setUIToDefault(); > GEvent.addListener(map, "click", GetLatLng); > > } > > function GetLatLng(e) { > var pixel = new GPoint(1, 1); <--- RIGHT HERE. > var GLatLng = map.fromDivPixelToLatLng(pixel); > document.getElementById("tbxLat").value = GLatLng.lat(); > document.getElementById("tbxLong").value = GLatLng.lng(); > } > > > > -- Barry - www.nearby.org.uk - www.geograph.org.uk - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
