I have a static variable in my webform class, which are coordinates for a Google map
public static string Query = "19.475 -91.97500000 19.475 -91.98333333 19.4833333 -91.98333333 19.4833333 -92.01666666 19.5 -92.01666666 19.5 -92.025 19.5333333 -92.025 19.5333333 -91.99166666 19.5166667 -91.99166666 19.525 -91.98333333 19.5 -91.98333333 19.5 -91.97500000 19.475 -91.97500000";
In my Javascript block I need an arrangement like this:
var cuadrado = [
{ lat: 25.774, lng: -80.190 },
{ lat: 18.466, lng: -66.118 },
{ lat: 32.321, lng: -64.757 },
{ lat: 25.774, lng: -80.190 }
];
In my javascript code send that static variable
var coords = "<%=Query %>";
To my var called coords I do split to replace the spaces with commas ",". and I send it to print on my browser (Google Chrome)
var myArray = coords.split(" ");
alert(myArray);
I put the coordinates in an array to go through the array and concatenate the words "lat:" latitu ", lng:" length ""
for(var d=0; d<myArray.length; d++)
{
myArray[i] = +myArray[i];
}
I go through the arrangement and concatenate the words
for(var i=0; i<myArray.length; i++)
{
for(var j=0; j<myArray.length;j++)
{
var triangleCoords=[
{lat: myArray[i], lng:myArray[j]},
];
}
}
And I need to form a block like that, but it's not printed by the nested cycle, Help please
var cuadrado = [
{ lat: 25.774, lng: -80.190 },
{ lat: 18.466, lng: -66.118 },
{ lat: 32.321, lng: -64.757 },
{ lat: 25.774, lng: -80.190 }
];