Hi.
I am playing around with Google Maps for the first time. And I am struggling to extact some information about the location where the marker is.
I have set up an example for you to see. The problem happens when I drag the A-node, the getGeocode() returns undefined?
I need to extract zip-code, city, and address from the node when I drag it around.
Please see http://dev.korebogen.dk/gmap/
Thanks in advance!
Update
I edited my code from the responses - and now I get both addresses out (still need to strip it so I get the info in seperate variables) but for some reason my direction output turns out to be "0" and "1" (array) do I really need to reverse geocode that aswell?
And is it possible to make a click event on the map to add A and B markers (if there is no directions when loading?) http://dev.korebogen.dk/gmap/ is updated!
It comes from:
var param = i + "@" + newMarkers[i].getLatLng().y + "," + newMarkers[i].getLatLng().x;
This is the updated part:
GEvent.addListener(newMarkers[i], "dragend", function() {
var points = [];
for (var i = 0; i < newMarkers.length; i++) {
var param = i + "@" + newMarkers[i].getLatLng().y + "," + newMarkers[i].getLatLng().x;
//points[i] = newMarkers[i].getLatLng();
points.push(param);
if (!i) {
var x = new GClientGeocoder();
x.getLocations(newMarkers[0].getLatLng(), function(addresses) {
if (addresses.Status.code == 200) {
var address = addresses.Placemark[0].address;
document.getElementById("start").innerHTML = address;
}
});
x.getLocations(newMarkers[1].getLatLng(), function(addresses) {
if (addresses.Status.code == 200) {
var address = addresses.Placemark[0].address;
document.getElementById("end").innerHTML = address;
}
});
}
}
gdir.loadFromWaypoints(points);
});