0
votes

I can successfully build and display a Google Maps (API 3) Polygon with constants/literals - like this:

Coordinates =
   [
    new google.maps.LatLng(51.494994,-0.094739),
    new google.maps.LatLng(51.507671,-0.094739),
    new google.maps.LatLng(51.507671,-0.102660),
    new google.maps.LatLng(51.494994,-0.102660)
   ];

What I need to do, though, is use variables for the LatLng 'string' as/for the co-ordinates; I successfully derive those from an earlier array like this:

coordinates1 = districtsArray[i][1][0];
coordinates2 = districtsArray[i][1][1];

such that the variable coordinates1 is indeed "51.494994,-0.094739"

I suspect that:

new google.maps.LatLng(coordinates1),
etc

fails because "(coordinates1)" is not a legitimate array element.

(How) can I make it one, please?