Reputation: 127
hi i have a big problem i try 3 weaks to solve it but i didn't make anything i have or an errors or i don't take nothing from the results. i pas an array from query ST_AsGeoJSON from a php code in the javascript code. there are in the same file html this two codes i get the array from php to javascrypt with this line of code
var jsonAr= <?php echo json_encode($Arresu) ?>;
if i print the jsonAr i receve with document.write(jsonAr);
it is give me this format
{ "type":"LineString","coordinates":[[25.9980559326738,39.2420282528175],......,,[26.0486275566016,39.2291388086281]]},{"type":"LineString","coordinates":[[26.0486275566016,39.2291388086281],......[]]}
if i try to take the coordinates and pot it in an array i try this jsonAr.coordinates[0][0]
but i did not take any result , i don't know how i take the coordinates
Upvotes: 0
Views: 64
Reputation: 1095
It looks like you want to assign two values to your variable
jsonAr = {...},{...}
Maby you want to try somethig like this:
jsonAr = [{...},{...}]
jsonAr[0].coordinates[0][0] //25.9980559326738
Or
jsonAr = [{...},{...}]
draw_function(jsonAr[0].coordinates[0][0],jsonAr[1].coordinates[0][0]) //25.9980559326738,26.0486275566016
Upvotes: 0
Reputation: 2085
jsonAr.coordinates[0]
will give you the first coordinate. jsonAr.coordinates[0][0]
only gives you the first number of the first coordinate.
Upvotes: 1