On Oct 21, 10:25 am, Alexander <[email protected]> wrote:
> Hi:
> I don't speak very well the English.
> I have a problem with the Google Maps API.
>
> I have a variable (pmaps) that have the point ->
> -12.200694,-76.932535,16 (without spaces) where they are Lnt, Lng,
> Zoom. Then I split(in past) it with ptos = pmaps.value.split(',');
>
> Then my code is:
>
> ptos = pmaps.value.split(',');
> var point = new GLatLng(ptos[0],ptos[1]);
> map.setCenter(point, ptos[2]);
>
> If I put a "number" (for example 12) instead of ptos[2] it works! but
> with it variable it doesn't work..
>
> I have validated that the variable ptos[2] have the value 16 and yes.
>
> Could you help me?


The way to convert strings to numbers is parseInt for integers (like
the zoom), parseFloat for floating point numbers (like the latitude
and longitude).  Passing strings instead of numbers into API function
can cause issues.

Try:
var point = new GLatLng(parseFloat(ptos[0]),parseFloat(ptos[1]));
map.setCenter(point, parseInt(ptos[2]));

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