Commit dbbb12cb authored by youjie's avatar youjie

no message

parent 6e8f2a18
...@@ -88,6 +88,8 @@ export default { ...@@ -88,6 +88,8 @@ export default {
props: ["dataAll", "ConfigId"], props: ["dataAll", "ConfigId"],
data() { data() {
return { return {
layerIds: [],
sourceIds: [],
setLoading: false, setLoading: false,
imageUrl: "", imageUrl: "",
deviceMarkers: [], deviceMarkers: [],
...@@ -289,12 +291,20 @@ export default { ...@@ -289,12 +291,20 @@ export default {
}); });
this.pois = listCity.join(","); this.pois = listCity.join(",");
this.citys = [...new Set(this.pois.split(","))]; this.citys = [...new Set(this.pois.split(","))];
this.clearCitiesMarkersHandler()
this.citiesData = this.citiesData.filter(x=>this.citys.indexOf(x.name)!=-1)
this.citys = this.citys.filter(x=>this.citiesData.findIndex(y=>y.name==x)==-1)
this.TripMapList.forEach(x => { this.TripMapList.forEach(x => {
if (x.MId) { if (x.MId) {
this.SearchCity(x.MId); this.SearchCity(x.MId);
} }
}); });
this.countriesData.forEach((x, i) => { this.countriesData.forEach((x, i) => {
if(this.map && this.map.getLayer("world-layer-" + x.MId)) {
this.map.removeLayer("world-layer-" + x.MId);
this.map.removeSource("word-source" + x.MId);
}
if (this.map && this.map.getLayer("world-layer-" + x.MId)) { if (this.map && this.map.getLayer("world-layer-" + x.MId)) {
this.map.removeLayer("world-layer-" + x.MId); this.map.removeLayer("world-layer-" + x.MId);
} }
...@@ -451,18 +461,31 @@ export default { ...@@ -451,18 +461,31 @@ export default {
err => {} err => {}
); );
}, },
clearCountryFillRange(){
//删除图层
if (this.layerIds.length) {
this.layerIds.forEach(id => {
this.map.removeLayer(id)
})
this.layerIds = [];
}
//删除数据源
if (this.sourceIds.length) {
this.sourceIds.forEach(id =>{
this.map.removeSource(id)
})
this.sourceIds = [];
}
},
addCountryFillRange() { addCountryFillRange() {
this.countriesData.forEach((x, i) => { this.countriesData.forEach((x, i) => {
if (x.MName == "中国") { if (x.MName == "中国") {
x.MName = "中华人民共和国"; x.MName = "中华人民共和国";
} }
if (this.map.getLayer("world-layer-" + x.MId)) {
this.map.removeLayer("world-layer-" + x.MId);
}
this.map.addLayer({ this.map.addLayer({
id: "world-layer-" + x.MId, id: "world-layer-" + x.MId,
type: "fill", type: "fill",
source: "word-source", source: "word-source" + x.MId,
filter: ["==", "NAME_ZH", x.MName] filter: ["==", "NAME_ZH", x.MName]
}); });
this.map.setPaintProperty("world-layer-" + x.MId, "fill-color", [ this.map.setPaintProperty("world-layer-" + x.MId, "fill-color", [
...@@ -474,6 +497,14 @@ export default { ...@@ -474,6 +497,14 @@ export default {
]); ]);
}); });
}, },
clearCitiesMarkersHandler(){
if(this.deviceMarkers && this.deviceMarkers.length>0){
this.deviceMarkers.forEach(x=>{
x.remove()
})
this.deviceMarkers = []
}
},
addMarker() { addMarker() {
// let markerColor = calculateComplementaryColor("#71adeb"); // let markerColor = calculateComplementaryColor("#71adeb");
this.citiesData.forEach((item, i) => { this.citiesData.forEach((item, i) => {
...@@ -481,6 +512,7 @@ export default { ...@@ -481,6 +512,7 @@ export default {
.setLngLat([item.longitude, item.latitude]) .setLngLat([item.longitude, item.latitude])
.addTo(this.map); .addTo(this.map);
this.addLabel(item, i); this.addLabel(item, i);
this.deviceMarkers.push(marker);
}); });
}, },
addLabel(item, i) { addLabel(item, i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment