|
@@ -9,7 +9,7 @@ export default {
|
|
|
return {
|
|
|
map: "",
|
|
|
layers: "",
|
|
|
- polygon: [],
|
|
|
+ polygon: []
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
@@ -17,14 +17,14 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
this.mapInit();
|
|
|
let that = this;
|
|
|
- this.map.on("move", (e) => {
|
|
|
+ this.map.on("move", e => {
|
|
|
if (that.index == that.mouseIndex) {
|
|
|
let center = that.map.getCenter();
|
|
|
let zoom = that.map.getZoom();
|
|
|
this.$emit("changeCenterZoom", {
|
|
|
center: [center.lat, center.lng],
|
|
|
zoom: zoom,
|
|
|
- index: that.index,
|
|
|
+ index: that.index
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -36,41 +36,35 @@ export default {
|
|
|
addSinglePolygon(state) {
|
|
|
this.$nextTick(() => {
|
|
|
if (!state && this.polygon) {
|
|
|
- this.polygon.forEach((item) => {
|
|
|
+ this.polygon.forEach(item => {
|
|
|
this.map.removeLayer(item);
|
|
|
});
|
|
|
this.addSinglePolygon(true);
|
|
|
- } else if (
|
|
|
- this.$store.state.selectSelectDataMap &&
|
|
|
- this.$store.state.selectSelectDataMap.singlePolygon
|
|
|
- ) {
|
|
|
- for (let item in this.$store.state.selectSelectDataMap
|
|
|
- .singlePolygon) {
|
|
|
- this.$store.state.selectSelectDataMap.singlePolygon[item].forEach(
|
|
|
- (v) => {
|
|
|
- // 叠置分析后的图层
|
|
|
- if (v.uniqueId.indexOf("overlay") > -1) {
|
|
|
- let geometry = JSON.parse(v.geometry);
|
|
|
- this.readGeojson(geometry, v.color);
|
|
|
- } else {
|
|
|
- // 常规图层
|
|
|
- let geometry = v.geometry;
|
|
|
- // 经纬度等上海2000转为经纬度坐标后再重新修改
|
|
|
- let coord = JSON.parse(geometry).geometry.coordinates[0];
|
|
|
- let correctCoord = publicFun.latLngsCorrection(coord);
|
|
|
- let coordinates = publicFun.latLngsToReverse(correctCoord);
|
|
|
- console.log(coord, correctCoord, coordinates);
|
|
|
- let polygon = L.polygon(coordinates, {
|
|
|
- color: v.color,
|
|
|
- weight: 3,
|
|
|
- fillColor: v.color,
|
|
|
- opacity: 1,
|
|
|
- fillOpacity: 0,
|
|
|
- }).addTo(this.map);
|
|
|
- this.polygon.push(polygon);
|
|
|
- }
|
|
|
+ } else if (this.$store.state.selectSelectDataMap && this.$store.state.selectSelectDataMap.singlePolygon) {
|
|
|
+ for (let item in this.$store.state.selectSelectDataMap.singlePolygon) {
|
|
|
+ this.$store.state.selectSelectDataMap.singlePolygon[item].forEach(v => {
|
|
|
+ console.log("map>:v", v);
|
|
|
+ // 叠置分析后的图层
|
|
|
+ if (v.uniqueId.indexOf("overlay") > -1) {
|
|
|
+ let geometry = JSON.parse(v.geometry);
|
|
|
+ this.readGeojson(geometry, v.color);
|
|
|
+ } else {
|
|
|
+ // 常规图层
|
|
|
+ let geometry = v.geometry;
|
|
|
+ // 经纬度等上海2000转为经纬度坐标后再重新修改
|
|
|
+ let coord = JSON.parse(geometry).geometry.coordinates[0];
|
|
|
+ let correctCoord = publicFun.latLngsCorrection(coord);
|
|
|
+ let coordinates = publicFun.latLngsToReverse(correctCoord);
|
|
|
+ let polygon = L.polygon(coordinates, {
|
|
|
+ color: v.color,
|
|
|
+ weight: 3,
|
|
|
+ fillColor: v.color,
|
|
|
+ opacity: 1,
|
|
|
+ fillOpacity: 0
|
|
|
+ }).addTo(this.map);
|
|
|
+ this.polygon.push(polygon);
|
|
|
}
|
|
|
- );
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -83,7 +77,7 @@ export default {
|
|
|
let geojsonData = L.geoJSON(states, {
|
|
|
style: function (feature) {
|
|
|
return { color: color };
|
|
|
- },
|
|
|
+ }
|
|
|
}).addTo(this.map);
|
|
|
this.polygon.push(geojsonData);
|
|
|
},
|
|
@@ -93,14 +87,12 @@ export default {
|
|
|
"+proj=tmerc +lat_0=0 +lon_0=121.2751921 +k=1 +x_0=0 +y_0=-3457147.81 +ellps=krass +units=m +no_defs",
|
|
|
{
|
|
|
resolutions: [
|
|
|
- 132.2919312505292, 52.91677250021167, 26.458386250105836,
|
|
|
- 13.229193125052918, 5.291677250021167, 2.6458386250105836,
|
|
|
- 1.3229193125052918, 0.5291677250021167, 0.26458386250105836,
|
|
|
- 0.13229193125052918, 0.0529167725002, 0.0264583862501,
|
|
|
- 0.0132291931251, 0.00529167725, 0.002645838625, 0.0013229193125,
|
|
|
+ 132.2919312505292, 52.91677250021167, 26.458386250105836, 13.229193125052918, 5.291677250021167, 2.6458386250105836,
|
|
|
+ 1.3229193125052918, 0.5291677250021167, 0.26458386250105836, 0.13229193125052918, 0.0529167725002, 0.0264583862501,
|
|
|
+ 0.0132291931251, 0.00529167725, 0.002645838625, 0.0013229193125
|
|
|
],
|
|
|
origin: [-66000, 75000],
|
|
|
- bounds: L.bounds([-65000, -76000], [75000, 72000]),
|
|
|
+ bounds: L.bounds([-65000, -76000], [75000, 72000])
|
|
|
}
|
|
|
);
|
|
|
this.map = L.map(this.$refs.map, {
|
|
@@ -109,13 +101,11 @@ export default {
|
|
|
minZoom: 0,
|
|
|
maxZoom: 14,
|
|
|
attributionControl: false,
|
|
|
- zoomControl: false,
|
|
|
+ zoomControl: false
|
|
|
}).setView(map2DViewer.map.getCenter(), map2DViewer.map.getZoom());
|
|
|
|
|
|
//添加默认图层
|
|
|
- let layer = this.$store.state.mapMethodsCollection
|
|
|
- .get("RENDER")
|
|
|
- .addTiledMapLayer(this.mapUrl);
|
|
|
+ let layer = this.$store.state.mapMethodsCollection.get("RENDER").addTiledMapLayer(this.mapUrl);
|
|
|
this.layers = layer;
|
|
|
},
|
|
|
setView: function (coord, zoom) {
|
|
@@ -129,15 +119,12 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
if (this.map) {
|
|
|
this.map.removeLayer(this.layers);
|
|
|
- let layer = this.$store.state.mapMethodsCollection
|
|
|
- .get("RENDER")
|
|
|
- .addTiledMapLayer(this.mapUrl)
|
|
|
- .addTo(this.map);
|
|
|
+ let layer = this.$store.state.mapMethodsCollection.get("RENDER").addTiledMapLayer(this.mapUrl).addTo(this.map);
|
|
|
this.layers = layer;
|
|
|
this.map.invalidateSize(true);
|
|
|
}
|
|
|
});
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
centerZoom: {
|
|
@@ -146,7 +133,7 @@ export default {
|
|
|
this.setView(newValue.center, newValue.zoom);
|
|
|
}
|
|
|
},
|
|
|
- deep: true,
|
|
|
+ deep: true
|
|
|
},
|
|
|
centerZoomInit: {
|
|
|
handler(newValue, oldValue) {
|
|
@@ -155,9 +142,9 @@ export default {
|
|
|
this.map.setView(center, newValue.zoom);
|
|
|
}
|
|
|
},
|
|
|
- deep: true,
|
|
|
- },
|
|
|
- },
|
|
|
+ deep: true
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
<style scoped>
|