我需要在地图中获取多边形的区域.我找了一个例子new google.maps.geometry.spherical.computeArea,但我不能让它工作,我不知道为什么.
function dibuV(area){
var i;
var a = new Array();
for(i=0; i<area.length; i++){
var uno = area[i].split(",");
a[i] = new google.maps.LatLng(uno[0],uno[1]);
}
poligon = new google.maps.Polygon({
paths: a,
strokeColor: "#22B14C",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#22B14C",
fillOpacity: 0.35
})
poligon.setMap(map);//until here is ok
var z = new google.maps.geometry.spherical.computeArea(poligon.getPath());
alert(z); //this is not working
}
Run Code Online (Sandbox Code Playgroud)