var url = "https://iserver.supermap.io/iserver/services/map-world/rest/maps/World";
var markerGroup,markerGroups;
var map;
var Layer;
$(function() {
});
window.goSuperMap = function(row) {
bindFlashMarker(row);
};
window.goSuperMapQuery= function(data) {
var rows = data.rows;
var sttps = ['1','2','3','5'];
rows = rows.filter(ele => ele.lttd != null && ele.lgtd != null);
rows = rows.filter(ele => sttps.indexOf(ele.sttp) > -1 );
bindMarkers(rows);
}
function initSuperMap() {
var China = L.supermap
.tiledMapLayer(
'https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China',
{
noWrap : true
});
var ChinaDark = L.supermap
.tiledMapLayer(
'https://iserver.supermap.io/iserver/services/map-china400/rest/maps/ChinaDark',
{
noWrap : true
});
map = L.map('map', {
center : [ 40, 100 ],
maxZoom : 10,
zoom : 5,
zoomControl : false,
layers : [ China ]
});
var baseMaps = {
"China" : China,
"ChinaDark" : ChinaDark
};
Layer = L.control.layers(baseMaps).addTo(map);
};
function bindFlashMarker(data) {
let lttd = data.lttd;
let lgtd = data.lgtd;
let stnm = data.stnm;
if(lttd == null || lgtd == null){
return;
}
var layer = [];
if(markerGroup){
markerGroup.clearLayers();
}
const oMarker = L.blinkMarker([lttd, lgtd ], {
iconSize: [12, 12],
color: 'green',
diveColor: 'red',
level: '3',
speedTime: 1,
});
oMarker.bindTooltip(data.stnm, {
direction : 'top',
offset : [ 0, -10 ],
permanent : true,
opacity : 0.9
});
const html = "<p>站名:" + stnm+"<br/>经度:" + lgtd + "<br/>纬度:" + lttd + "</p>";
oMarker.bindPopup(html, {
maxHeight : 500,
maxWidth : 500,
className : 'content',
offset : [ 0, 0 ]
}).on('popupopen', function(params) {
console.log(params)
});
layer.push(oMarker);
markerGroup=L.layerGroup(layer);
map.addLayer(markerGroup);
map.flyTo([lttd, lgtd],9);
}
function bindMarkers(result) {
clearAllMarkers();
var layers=[];
for (var i = 0; i < result.length; i++) {
let lttd = result[i].lttd;
let lgtd = result[i].lgtd;
let sttp = result[i].sttp;
let stnm = result[i].stnm;
var marker = new L.marker([ lttd, lgtd ], {
icon : bindIcon(sttp)
})
marker.bindTooltip(stnm, {
direction : 'top',
offset : [ 0, -10 ],
opacity : 0.9
});
const html = "<p>站名:" + stnm+"<br/>经度:" + lgtd + "<br/>纬度:" + lttd + "</p>";
marker.bindPopup(html, {
maxHeight : 500,
maxWidth : 500,
className : 'content',
offset : [ 0, 0 ]
}).on('popupopen', function(params) {
console.log(params)
});
layers.push(marker);
}
markerGroups = L.layerGroup(layers);
map.addLayer(markerGroups);
}
function bindIcon(sttp) {
var imgurl = '';
if (sttp == null || sttp == '') {
} else if (sttp == '1') {
imgurl = "theme/map/zz1.png"
} else if (sttp == '2') {
imgurl = "theme/map/zq1.png"
} else if (sttp == '3') {
imgurl = "theme/map/pp1.png"
} else if (sttp == '5') {
imgurl = "theme/map/dxscz7.jpg"
}
var greenIcon = L.icon({
iconUrl : imgurl,
iconSize : [ 8, 10 ],
popupAnchor : [ 0, 0 ]
});
return greenIcon;
}
function clearAllMarkers(){
if(markerGroup){
markerGroup.clearLayers();
}
if(markerGroups){
markerGroups.clearLayers();
}
}
let markers = [];
let markers_text = [];
var marker_text = new L.marker([45, 90], {
icon: L.divIcon({
html: "xxxx",
className: 'my-div-icon',
iconSize: 30,
iconAnchor: [-16, 40]
})
})
var myIcon = L.icon({
iconSize: [38, 38],
iconUrl: require("@/assets/images/common/menu.png"),
className: "leaflet-pulsing-icon",
color: "rgb(111, 34, 255)"
});
var pulseIcon = L.icon.pulse({
iconSize: [12, 12],
color: '#2f8'
});
var marker = new L.marker([45, 90], {
icon: pulseIcon
});
let stnm = "测试";
const html = "<p>站名:" + stnm + "<br/>经度:" + 40 + "<br/>纬度:" + 50 + "</p>" +
"<el-button type='primary'>主要按钮</el-button>";
marker.bindPopup(html, {
maxHeight: 500,
maxWidth: 500,
className: 'content',
offset: [0, 0]
}).on('popupopen', function (params) {
console.log(params)
});
markers.push(marker);
markers_text.push(marker_text);
L.featureGroup(markers).addTo(map);
L.featureGroup(markers_text).addTo(map);