On Jul 26, 8:34 am, sboehm85 <[email protected]> wrote:
> Hi guys,
>
> I have a problem with the asynchronous aspect of the GClientGeocoder.
> I have an object inlcuding optional geo coordinates and an address for
> the case that no geo coordinates exist to resolve them. I'm using the
> following code:
>
> function someFunction(lat, lng, address) {
>   var pin = new Pin();
>   if (lat && lng) {
>     //if having lat and lng there is no problem
>     pin.setLatLng(new google.maps.LatLng(lat,lng));
>   } else {
>     //lat and lgn has to be resolved
>     var clientGeocoder = new google.maps.ClientGeocoder();
>     clientGeocoder.getLatLng(address, function(latLng) {
>       pin.latLng = latLng;
>     });
>   }
>   return pin;
>
> }
>
> Now the problem is, that he callback function does not know the pin
> object and is does not get the geo coordinates. The object may not
> have the coordinate while returning but at some time it shall get
> them.
>
> Does anyone has a solution?

You can't return the marker from that function (because it might not
exist if the address needs to be geocoded).  But you could rearrange
you code so that isn't necessary.  You didn't provide a link to your
map so there is no context to make suggestion on the best way to do
that (there are an infinite number of ways).

  -- Larry

>
> Thanks

-- 
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.

Reply via email to