天地图上添加删除坐标点

  • Post author:
  • Post category:其他


1,在js中

var sign = 1;

var map, control, zoom = 12;

jQuery(document).ready(function () {


//初始化地图对象

map = new TMap(“mapDiv”);

var p = new TLngLat(CenterCo.split(‘|’)[0], CenterCo.split(‘|’)[1]);//地图的中心点

//    //设置显示地图的中心点和级别

map.centerAndZoom(p, zoom);

//创建缩放平移控件对象

control = new TNavigationControl(config);

//添加缩放平移控件

map.addControl(control);

map.enableHandleMouseScroll();

AddPoint();//添加坐标点

})

var listMap;

function AddPoint() {


sign = 1;

map.clearOverLays();

$.ajax({


url: “../Map/GetMapPoint”,

type: “post”,

dataType: “json”,

data:{Where:””},

async: false, //是否异步

success: function (data) {


if (data.success == “false”) {


if (data.Msg != “”)

alert(data.Msg);

else

alert(“加载设备位置信息出错”);

}

else {


if (data.Msg != “”) {


var dataObj = eval(“(” + data.Msg + “)”); //

$.each(dataObj.data, function (idx, item) {


var newPoint = new TLngLat(item.Y, item.X);

addMarker(item.Y, item.X, 0, sign.toString() + “.png”, item.WellLidName, item.Address, item.Type, item.DeviceState, item.Monitor, item.WellType);

sign++;

})

//                    var newPoint = new BMap.Point(116.409, 39.919);

//                    addMarker(newPoint, 0, “1.png”);

}

}

}

});

}

var LayerC = “”;

var LayerO = “”;

function addMarker(Y, X, index, imageName, welllidName, address,type,DeviceState,Monitor, WellType) {


var point = new TLngLat(Y, X);

var marker1;

var icon = new TIcon(“../images/OrangeLoc.gif”, new TSize(25, 35), { anchor: new TPixel(9, 27) });

marker1.setZIndex(999999999999999999999);//设置显示的顺序

marker1 = new TMarker(point, { icon: icon });

marker1.Type = 1000;

//移入事件

var listener = TEvent.bind(marker1, “mouseover”, marker1, function () {


//  alert(“鼠标进入事件”);

var infoWin = marker1.openInfoWinHtml(address);//地址

});

//移出事件

var mapc = TEvent.bind(marker1, “mouseout”, marker1, function () {

//alert(“鼠标离开”);

var infoWin = marker1.openInfoWinHtml(address);

map.removeOverLay(infoWin);

});

map.addOverLay(marker1);

}

//删除覆盖物

function removeMarkets(){

var lays = map.getOverlays();//获取地图上所有的覆盖物

var s = 0;

for (var i =lays.length-1 ; i >= 0; i–) { //倒序删除避免长度发生变化

if (lays[i].Type = 1000) {   //根据地图上覆盖物的类型删除

map.removeOverLay(lays[i]); //从地图上移除。

//        s++;

}

}

}




版权声明:本文为u010606363原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。