Jihad Mahfouz Jihad Mahfouz - 5 months ago 20
PHP Question

how to drawing shapes in google map (1 or more) using JavaScript

i'm using google map to draw shapes
but i get error when i'm trying to get lat and lng from database and assign it to map

i have format data correctly after get it from database

for (var s = 0; s < array_points.length; s++) {
var shapeCoordinates = array_points[s];
var shap = Array();
for (var sh = 0; sh < shapeCoordinates.length; sh++) {
shap.push({lat: shapeCoordinates[sh]['lat'], lng: shapeCoordinates[sh]['lng']});

var drawingManager = new google.maps.Polygon({
paths: shap,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35
});
}
}


i get the following error

Uncaught InvalidValueError: at index 0: not a LatLng or LatLngLiteral: in property lat: not a number


array_points have 3 shapes

shapeCoordinates have coordinates of the shape

Answer

Please convert this variable to integer it will solve your issue.

 parseFloat(shapeCoordinates[sh]['lat'])