On Oct 21, 10:12 am, phicarre <[email protected]> wrote:
> 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 ?

That's strange. I do that all the time, I just use json_encode and
pass the data to a Javascript function.  And this is data including
points, html, and all kinds of other things. It always gives me the
correct length. I've found it to be a very simple and efficient way to
pass data.

You may want to do a print_r and make sure the indexes of the arrays
you are passing in all are sequential and start with zero.

Could you describe what you mean by this?
"I transform $points in array: $myarray"

What exactly are you "transforming?"




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