Getting google maps latlng Array from JSON
Dear forum-members,
I'm new to this forum and pretty new to JQuery and I have an issue that I can't solve by myself even after long research.
Currently I'm loading coordinates into an array directly in my html-file:
- var AreaCoords = [
- new google.maps.LatLng(48.250118898964146, 16.542320251464843),
- new google.maps.LatLng(48.25304504692614, 16.472831717692315),
- new google.maps.LatLng(48.20913525537747, 16.440147397806868),
- new google.maps.LatLng(48.190462182620756, 16.468437190633267),
- new google.maps.LatLng(48.18167250808985, 16.549736014567315),
- new google.maps.LatLng(48.21059952074874, 16.592033382039517)
- ];
With this variable, I'm later creating a google.maps.polygon:
- var Area = new google.maps.Polygon({
- paths: AreaCoords
- });
I know want to load the coordinates from a JSon file and I've thought about creating a JSON-File like this:
- {
- "coordinates": [
- {
- "lat": "48.250118898964146",
- "lng": "16.542320251464843"
- },
- {
- "lat": "48.25304504692614",
- "lng": "16.472831717692315"
- },
- {
- "lat": "48.20913525537747",
- "lng": "16.440147397806868"
- }
- ]
- }
I don't know how to load this JSON into a variable, I've tried the getJSON function but it didn't work at all.
I would appreciate any help or hint!
Thank you very very much!
-Robert