(excuse me for my bad english) the tops of my polygon are stored into my database (latitude, longitude). so I recovered the latitude and longitude in a table and then I draw my polygon. my problem is that with 3 tops it works fine, but when it is more then 3 it gives this result:
this is my code :
success: function(data) {
// alert(data);
var tableauPointsPolygone = new Array ();
var j=0;
var somme=0;
$.each(data, function(i, item) {
tableauPointsPolygone.push(new google.maps.LatLng(item.latitude, item.longitude));
somme+= parseInt(item.valeur);
j++;
addMarker(item.latitude,item.longitude,item.adr);
center = bounds.getCenter();
map.fitBounds(bounds);
// alert(item.latitude);
});
var monPolygone = new google.maps.Polygon();
monPolygone.setPaths( tableauPointsPolygone );
monPolygone.setMap( map );
if (somme/j<5)
monPolygone.setOptions({strokeWeight: 3,strokeColor: '#582900' ,fillColor: '#1FA055'});
else
monPolygone.setOptions({strokeWeight: 3,strokeColor: '#582900' ,fillColor: '#A91101'});
},
Polygon mapping is the cartographic display of regularly or irregularly shaped polygons and their attributes. Typically, this capability includes shading, symbology and numeric labeling, as well as other map cosmetic functions for generating alphanumeric labeling of polygons.
The problem I see is the arrangement of polygon vertices. In case if 3 the order of point is not essential its triangle but in case of 4 and more you have to sort the points and then push into array.
Here is a helpful question about convex (non-concave) polygon
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With