Sunday, July 24, 2011

[Google Maps API v2] Additional Parameter for GClientGeocoder.getLatLng not working

Hello,

I read some interesting articles about how to pass additional
parameters to a callback function. In my special case I need to
retrieve geocodes of many addresses and place a marker to that
location. So I use the getLatLng function, but I need to pass the
marker as an additional parameter. So this was my approach:


GDownloadUrl("markers2.xml", function(data) {
var xml = GXml.parse(data);
var markers =
xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var address = markers[i].getAttribute("address");
var mymarker = markers[i];
var geocoder = new GClientGeocoder();
geocoder.getLatLng(address, function(point, mymarker){
alert(mymarker);
getLatLngExtended(point, mymarker);
});
}
});

function getLatLngExtended(point, mymarker){
var address = mymarker.getAttribute("address");
var name = mymarker.getAttribute("name");
var type = mymarker.getAttribute("type");
var marker = createMarker(point, name, address, type);
map.addOverlay(marker);
}

Unfortunately, this doesn't work. The variable "mymarker" is always
undefined as soon as it hits the "getLatLngExtended" function. It
doesn't seem to get passed to that function.
Where is the error?
Any help is greatly appreciated.

Regards,
Tustle

--
You received this message because you are subscribed to the Google Groups "Google Maps API V2" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate