On Apr 22, 4:48 am, ragulka <[email protected]> wrote:
> Hi, I'm trying to pass the geocoding getLocations() callback function
> an additional parameter, however I don't seem to have success. Maybe
> I'm missing out something really obvious or basic, but I can't figure
> it out on my own so that's why I'm asking for help.
>
> This is my code:
>

Please follow the posting guidelines and post a link to your map that
shows the problem, not code.


> for(var i=0; i<noortekad.length; i++) {
>
>                 var noortekas = noortekad[i];
>
>                 // Create new geocoding object
>                 geocoder = new GClientGeocoder();
>
>                 // Retrieve location information, pass it to addToMap()
>                 geocoder.getLocations(noortekas.address, addToMap(noortekas));

The second argument to GClientGeocoder.getLocations is a function
pointer.
http://code.google.com/apis/maps/documentation/reference.html#GClientGeocoder.getLocations

Look at the examples, you can't pass arguments with a function
pointer.

>         }
>
>                 // This function adds the point to the map
>
>                    function addToMap(response, noortekas)
>                    {
>                       alert(noortekas.nimi);
>                       // Retrieve the object
>                       place = response.Placemark[0];
>                       // etc...
>                     }
>
> What happens is that the script correctly alerts the noortekas.nimi,
> but then I get a Javascript error saying that response is not defined.

Actually what happens is that the function executes immediately,
before the results are back and the return value (null I suspect, but
you didn't provide that in your snippet) is used as the callback
function.

You can use function closure or an anonymous function which calls your
function with the extra arguments.  This has been discussed before.
If you really don't want to post a link to your map, search the group
for the previous discussions.

  -- Larry
--~--~---------~--~----~------------~-------~--~----~
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