我正在使用ans
值来绘制多边形。但它不绘制任何多边形。如果我直接投入ans
价值,那么它的工作。
我的问题是如何ans
在 L.polygon 方法中使用值
var a = g_cord.split(":"); //g_cord= 28.40106, 77.31231: 28.40129, 77.31231: 28.40129, 77.31269: 28.40106, 77.31269
var ans="";
for(var k=0;k<a.length;k++){
ans="["+a[k]+"]," +ans;
}
alert(ans); //[ 28.40106, 77.31269 ],[ 28.40129, 77.31269],[ 28.40129, 77.31231],[ 28.40106, 77.31231],
window['polygon'+id] = new L.polygon([ans],{color:"#738DEA",weight:4});
window['polygon'+id].bindPopup(""+g_name);
map.fitBounds(window['polygon'+id].getBounds());
document.getElementById("_"+id).checked = true;
group.addLayer(window['polygon'+id]);