|
@@ -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,28 +36,34 @@ 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(item => {
|
|
|
- let geometry = item.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: "#FF0000",
|
|
|
- weight: 3,
|
|
|
- fillColor: "#FF0000",
|
|
|
- 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(
|
|
|
+ (item) => {
|
|
|
+ let geometry = item.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: "#FF0000",
|
|
|
+ weight: 3,
|
|
|
+ fillColor: "#FF0000",
|
|
|
+ opacity: 1,
|
|
|
+ fillOpacity: 0,
|
|
|
+ }).addTo(this.map);
|
|
|
+ this.polygon.push(polygon);
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -68,29 +74,29 @@ 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
|
|
|
+ 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, {
|
|
|
crs: crs,
|
|
|
zoom: 1,
|
|
|
minZoom: 0,
|
|
|
- maxZoom: 7,
|
|
|
+ maxZoom: 14,
|
|
|
attributionControl: false,
|
|
|
- zoomControl: false
|
|
|
+ zoomControl: false,
|
|
|
}).setView(map2DViewer.map.getCenter(), map2DViewer.map.getZoom());
|
|
|
|
|
|
//添加默认图层
|
|
|
- var layer = L.esri
|
|
|
- .tiledMapLayer({
|
|
|
- tileSize: 512,
|
|
|
- url: this.mapUrl
|
|
|
- })
|
|
|
- .addTo(this.map);
|
|
|
+ let layer = this.$store.state.mapMethodsCollection
|
|
|
+ .get("RENDER")
|
|
|
+ .addTiledMapLayer(this.mapUrl);
|
|
|
this.layers = layer;
|
|
|
},
|
|
|
setView: function (coord, zoom) {
|
|
@@ -104,17 +110,15 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
if (this.map) {
|
|
|
this.map.removeLayer(this.layers);
|
|
|
- var layer = L.esri
|
|
|
- .tiledMapLayer({
|
|
|
- tileSize: 512,
|
|
|
- url: this.mapUrl
|
|
|
- })
|
|
|
+ let layer = this.$store.state.mapMethodsCollection
|
|
|
+ .get("RENDER")
|
|
|
+ .addTiledMapLayer(this.mapUrl)
|
|
|
.addTo(this.map);
|
|
|
this.layers = layer;
|
|
|
this.map.invalidateSize(true);
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
centerZoom: {
|
|
@@ -123,7 +127,7 @@ export default {
|
|
|
this.setView(newValue.center, newValue.zoom);
|
|
|
}
|
|
|
},
|
|
|
- deep: true
|
|
|
+ deep: true,
|
|
|
},
|
|
|
centerZoomInit: {
|
|
|
handler(newValue, oldValue) {
|
|
@@ -132,9 +136,9 @@ export default {
|
|
|
this.map.setView(center, newValue.zoom);
|
|
|
}
|
|
|
},
|
|
|
- deep: true
|
|
|
- }
|
|
|
- }
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
<style scoped>
|