Return address from marker
I'm very new to reverse geocoding. I have managed to place a dragable marker on a map which when dropped returns the Lat/Long to text boxes on a form using the code below:
div id="map" style="width: 600px; height: 467px"></div>
<script type="text/javascript" src="http://maps.google.com/maps?
file=api&v=2&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></script>
<script type="text/javascript">
<!--
if (GBrowserIsCompatible())
{
// create map and add controls
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom();
//map.enableGoogleBar();
// set centre point of map
var centrePoint = new GLatLng('53.767789993998804', '-2.7046966552734375');
map.setCenter(centrePoint, 10);
// add a draggable marker
var marker = new GMarker(centrePoint, {draggable: true});
map.addOverlay(marker);
// add a drag listener to the map
GEvent.addListener(marker, "dragend", function() {
var point = marker.getPoint();
map.panTo(point);
document.getEleme开发者_StackOverflow社区ntById("latitude").value = point.lat().toFixed(5);
document.getElementById("longitude").value = point.lng().toFixed(5);
});
}
</script>
This works fine but I would also like to capture the street name to a text box but am lost. I know I can't do it using 'point' and have to define a function but am completely lost and google searches have turned up nothing of use to someone starting out like me.
Any pointers would be appreciated.
Thanks
I reckon the answer is here: http://code.google.com/apis/maps/documentation/javascript/services.html#ReverseGeocoding
But you'll need to upgrade to version 3 of Google Maps API.
精彩评论