Commit 7888e0a0 authored by youjie's avatar youjie

no message

parent 15d32ee4
...@@ -309,6 +309,7 @@ export default { ...@@ -309,6 +309,7 @@ export default {
this.TripMapList.forEach(x => { this.TripMapList.forEach(x => {
let obj = { let obj = {
MName: x.MName, MName: x.MName,
name: x.MName,
MId: x.MId, MId: x.MId,
ColorStr: x.ColorStr, ColorStr: x.ColorStr,
Lng: x.Lng, Lng: x.Lng,
...@@ -410,8 +411,8 @@ export default { ...@@ -410,8 +411,8 @@ export default {
bounds.extend([city.longitude, city.latitude]); bounds.extend([city.longitude, city.latitude]);
}); });
this.map.fitBounds(bounds,{ this.map.fitBounds(bounds,{
padding: 150, // 可选:在地图边界周围添加一些内边距 padding: 150, // 可选:在地图边界周围添加一些内边距
}); });
// this.map.setCenter(bounds.getCenter()); // this.map.setCenter(bounds.getCenter());
this.addMarker(); //标记 this.addMarker(); //标记
this.createLineHandler(); //连线 this.createLineHandler(); //连线
...@@ -429,12 +430,12 @@ export default { ...@@ -429,12 +430,12 @@ export default {
} }
}); });
}); });
this.countriesData.forEach(y => { // this.countriesData.forEach(y => {
if (x.MName == y.name) { // if (x.MName == y.name) {
x.Lng = y.Lng; // x.Lng = y.Lng;
x.Lat = y.Lat; // x.Lat = y.Lat;
} // }
}); // });
}); });
this.dataAll.TripMapList = JSON.parse(JSON.stringify(this.TripMapList)); this.dataAll.TripMapList = JSON.parse(JSON.stringify(this.TripMapList));
}, },
...@@ -625,8 +626,8 @@ export default { ...@@ -625,8 +626,8 @@ export default {
addCountryFillRange() { addCountryFillRange() {
let that = this let that = this
this.countriesData.forEach((x, i) => { this.countriesData.forEach((x, i) => {
if (x.MName == "中国") x.MName = "中华人民共和国"; if (x.MName == "中国") x.name = "中华人民共和国";
if (x.MName == "韩国") x.MName = "大韩民国"; if (x.MName == "韩国") x.name = "大韩民国";
x.CityListAll.forEach(y=>{ x.CityListAll.forEach(y=>{
}) })
...@@ -653,7 +654,7 @@ export default { ...@@ -653,7 +654,7 @@ export default {
id: "world-layer-" + x.MId, id: "world-layer-" + x.MId,
type: "fill", type: "fill",
source: source, source: source,
filter: ["==", "NAME_ZH", x.MName] filter: ["==", "NAME_ZH", x.name]
}); });
if(x.MId!=651&&x.MId!=891) { if(x.MId!=651&&x.MId!=891) {
that.ClearSource("mapLayer-" + x.MId,1) that.ClearSource("mapLayer-" + x.MId,1)
...@@ -661,7 +662,7 @@ export default { ...@@ -661,7 +662,7 @@ export default {
this.map.setPaintProperty("world-layer-" + x.MId, "fill-color",[ this.map.setPaintProperty("world-layer-" + x.MId, "fill-color",[
"match", "match",
["get", "NAME_ZH"], ["get", "NAME_ZH"],
x.MName, x.name,
x.ColorStr, // 选定的国家颜色 x.ColorStr, // 选定的国家颜色
["rgba", 0, 122, 255, 0] ["rgba", 0, 122, 255, 0]
]); ]);
...@@ -671,7 +672,7 @@ export default { ...@@ -671,7 +672,7 @@ export default {
id: "mapLayer-"+ x.MId, id: "mapLayer-"+ x.MId,
type: "fill", type: "fill",
source: source, source: source,
filter: ["==", "NAME_ZH", x.MName], filter: ["==", "NAME_ZH", x.name],
}); });
this.map.addLayer({ this.map.addLayer({
id: "mapLayerId-"+ x.MId, id: "mapLayerId-"+ x.MId,
...@@ -890,24 +891,21 @@ export default { ...@@ -890,24 +891,21 @@ export default {
} }
}, },
async addCountriesMaker() { async addCountriesMaker() {
console.log(this.countriesData,'-----------1111')
let that = this; let that = this;
await Promise.all( await Promise.all(
this.countriesData.map(async (x, i) => { this.countriesData.map(async (x, i) => {
let result; let result;
if (x.Lng && x.Lat) { if (x.Lng && x.Lat) {
// console.log(x.Lng, "====");
result = [x.Lng, x.Lat]; result = [x.Lng, x.Lat];
} else { } else {
// console.log(x.Lng, "22222===="); result = await this.getCountryCoordinates(x.name);
result = await this.getCountryCoordinates(x.MName);
} }
if (result && result.length == 2) { if (result && result.length == 2) {
let el = document.createElement("div"); let el = document.createElement("div");
el.style.fontSize = "30px"; el.style.fontSize = "30px";
el.style.fontWeight = "bold"; el.style.fontWeight = "bold";
el.style.color = "rgba(0,0,0,0.4)"; el.style.color = "rgba(0,0,0,0.4)";
el.innerHTML = x.MName; el.innerHTML = x.name;
var marker = new mapboxgl.Marker(el, { var marker = new mapboxgl.Marker(el, {
offset: [0, 0], offset: [0, 0],
draggable: true draggable: true
...@@ -916,11 +914,9 @@ export default { ...@@ -916,11 +914,9 @@ export default {
marker.addTo(this.map); marker.addTo(this.map);
marker.on("dragend", function() { marker.on("dragend", function() {
let currentMarkerLngLat = marker.getLngLat(); let currentMarkerLngLat = marker.getLngLat();
x.Lng = currentMarkerLngLat.lng; let TripMapList = that.TripMapList.filter(y=> y.MName==x.MName)
x.Lat = currentMarkerLngLat.lat; TripMapList[0].Lng = currentMarkerLngLat.lng;
console.log(x.MName,'=====') TripMapList[0].Lat = currentMarkerLngLat.lat;
let TripMapList = that.TripMapList.filter(y=>y.MName==x.MName)
console.log(TripMapList,'--------')
}); });
this.countriesMarkers.push(marker); this.countriesMarkers.push(marker);
} }
......
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