日期:2014-05-16 浏览次数:20381 次
function secRing(gridid) {
alert("测试");
map.clearOverlays(); //清除地图覆盖物
var secRing = [];
var Json = [];
$.ajax({
url: 'TreeView.ashx', //后台处理程序
type: 'get', //数据发送方式
dataType: 'json', //接受数据格式
data: 'action=getGridpoints&id=' + gridid, //要传递的数据
success: function (result) {
secRing = result;
alert(secRing.length);
for (var i = 0; i < secRing.length; i++) {
alert(secRing[i].x +','+ secRing[i].y);
var temp = new BMap.Point(secRing[i].x , secRing[i].y);
i + 3;
Json.push(temp);
}
},
error: function () { alert("err1"); }
});
//创建多边形
var secRingPolygon = new BMap.Polygon(Json, { strokeColor: "#ff0000", strokeWeight: 2, strokeOpacity: 0.5 });
map.addOverlay(secRingPolygon); //添加多边形到地图上
secRingPolygon.addEventListener("mouseover", function () {
secRingPolygon.setStrokeColor("red");
});
secRingPolygon.addEventListener("mouseout", function () {
secRingPolygon.setStrokeColor("blue");
});
map.setViewport(secRingPolygon.getPath()); //调整视野
}