I have localizations of a polygon saved in a DB. Return these locations to JavaScript by a JSON like this:
[{"lat":"-21.9838014173847","lng":"-49.409637451171875"},{"lat":"-20.3034175184893","lng":"-45.410614013671875"},{"lat":"-23.725011735951796","lng":"-44.180145263671875"},{"lat":"-24.966140159912964","lng":"-48.574676513671875"}]
I am writing this information to the variable var newCoods
, so I need to return this polygon on screen when the Visualizar
button is clicked. The return method is being done as follows:
var returnPolygon = new google.maps.Polygon({
map: map,
paths: newCoords,
strokeColor: '#FFD700',
strokeWeight: 3,
fillColor: '#FFD700',
fillOpacity: 0.10
});
returnPolygon.setMap(map);
When I click the button to return, I get the following error:
Uncaught mc {message: "not an Array", name: "InvalidValueError", stack: "Error↵ at new mc ..."}
How do I pass the parameters to return the polygon?