Wednesday, October 21, 2009

How to pass a list of points from php to a javascript function ?

Hi,
I extract in PHP a list of points (= polygon) from a mysql database.
$points = $row['Points'];

The $points format is (val1,val2),(val3,val4), ...

Now I would like to pass these points to a javascript function. I do:
echo "my_function($points);";

from client side:
function my_function(pt)
{
...
}

I receive a message "undefined" for pt !

I tried this:
- I transform $points in array: $myarray
- I define $myjarray=json_encode($myarray);
- I call echo "my_function($myjarray);";

Its "better" but I don't see how to extract the couple of coordinates
pt.length return 1 !!!!

Finally, do you know a good method to pass a list of points (lat+lng)
from PHP to a javascript function without using XML format ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Google Maps API" 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