I'm able to load a JSON file into a page (currently using jQuery), and set the content as a variable in the page.
The JSON includes references to building outlines, as follows;
[
{
"buildingNumber":"7",
"buildingDescription":"Building Seven",
"spatial":{
"points":
[
"-1.2345678,50.9876543",
"-1.2345677,50.9876544",
"-1.2345676,50.9876545",
"-1.2345675,50.9876546"
]
}
}
]
Using jQuery's $.each
, I can load the variable and iterate through the buildings, additionally, per building, I can iterate through the points quite simply.
The problem comes with the fact that Google only appear to document the following method for describing polygons;
var triangleCoords = [
new google.maps.LatLng(25.774252, -80.190262),
new google.maps.LatLng(18.466465, -66.118292),
new google.maps.LatLng(32.321384, -64.75737)
];
That makes sense, but I can't see how to get from the arrays I currently have to this format. I'd really appreciate any pointers on where to start in moving from one to the other, or another way to describe the polygons.
I've looked into the array.push()
function, and while it seems like the locical way to go, I can't see how to dynamically create variables based on the iterative values from the array.
Thanks