I am trying to draw polygon in my map but fail. I have set latlng from my database. I already read the tutorial in here https://developers.google.com/maps/documentation/javascript/examples/polygon-simple
I am using vb.net on query.
here is my code :
function showpolygon(){
var data1 = "<%= vpolygon %>";
var ndata1 = data1.split("|");
var len1 = ndata1.length;
var nnama, nlat, nlong, gmbrpolygon;
var arraypoly = [];
var arraypoly1 = [];
var n =0;
var polygons = [];
alert ("<%= vpolygon %>");
for (var i = 0; i < len1; i++)
{
ndata11 = ndata1[i].split("~");
nlat = parseFloat (ndata11[1]);
nlong = parseFloat(ndata11[2]);
arraypoly = new google.maps.LatLng(nlat,nlong);
//alert(polygons);
arraypoly1.push(arraypoly);
}
polygons.push(arraypoly1);
gmbrpolygon = new google.maps.Polygon({
paths: arraypoly1,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35
});
gmbrpolygon.setMap(map);
}
I am trying to using a mvc array but an error occurs.
edit :<%= vpolygon %> contain : name~lat~long~numberof|
polygon[n] = { location: new google.maps.LatLng(nlat,nlong)};
var polygons = new google.maps.MVCArray(polygon);
the error when i am using mvc array is parameter 0: [object][object] and Cannot set property '0' of undefined
and with this code nothing error in console javascript, but the polygon doesn't appear.