百度地图API怎样给数据库中循环出来的标注添加窗口,判断点击了哪个标注,显示不同的内容
$.ajax({url:"/MapMonitoring/GetMapMonitoringList",dataType:"json",type:"post",success...
$.ajax({
url: "/MapMonitoring/GetMapMonitoringList",
dataType: "json",
type: "post",
success: function (data) {
for (var i = 0; i < data.length; i++) {
var Elevtric = data[i].Elevtric;//电流
var Voltage = data[i].Voltage;//电压
var point = new BMap.Point(data[i].Longitude, data[i].Latitude);
if (data[i].Status == "开") {
var iconSelf = new BMap.Icon('/Content/Images/bluewater.png', new BMap.Size(50, 50));
}
else if (data[i].Status == "关") {
var iconSelf = new BMap.Icon('/Content/Images/orangewater.png', new BMap.Size(50, 50));
}
else {
var iconSelf = new BMap.Icon('/Content/Images/redwater.png', new BMap.Size(50, 50));
}
var marker = new BMap.Marker(point, { icon: iconSelf }); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
marker.enableDragging(); //设置可拖拽
}
} 展开
url: "/MapMonitoring/GetMapMonitoringList",
dataType: "json",
type: "post",
success: function (data) {
for (var i = 0; i < data.length; i++) {
var Elevtric = data[i].Elevtric;//电流
var Voltage = data[i].Voltage;//电压
var point = new BMap.Point(data[i].Longitude, data[i].Latitude);
if (data[i].Status == "开") {
var iconSelf = new BMap.Icon('/Content/Images/bluewater.png', new BMap.Size(50, 50));
}
else if (data[i].Status == "关") {
var iconSelf = new BMap.Icon('/Content/Images/orangewater.png', new BMap.Size(50, 50));
}
else {
var iconSelf = new BMap.Icon('/Content/Images/redwater.png', new BMap.Size(50, 50));
}
var marker = new BMap.Marker(point, { icon: iconSelf }); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
marker.enableDragging(); //设置可拖拽
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询