|
@@ -2,6 +2,7 @@
|
|
|
<div class="MapViewer" ref="map"></div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+import publicFun from "@/utils/publicFunction.js";
|
|
|
export default {
|
|
|
name: "Map",
|
|
|
data() {
|
|
@@ -43,19 +44,17 @@ export default {
|
|
|
for (let item in this.$store.state.selectSelectDataMap.singlePolygon) {
|
|
|
this.$store.state.selectSelectDataMap.singlePolygon[item].forEach(item => {
|
|
|
let geometry = item.geometry;
|
|
|
- // let uniqueId = item.uniqueId;
|
|
|
- let coordinates = "";
|
|
|
// 经纬度等上海2000转为经纬度坐标后再重新修改
|
|
|
let coord = JSON.parse(geometry).geometry.coordinates[0];
|
|
|
- coordinates = coord.map(v => {
|
|
|
- return [v[1], v[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.4
|
|
|
+ fillOpacity: 0
|
|
|
}).addTo(this.map);
|
|
|
this.polygon.push(polygon);
|
|
|
});
|
|
@@ -80,24 +79,21 @@ export default {
|
|
|
crs: crs,
|
|
|
zoom: 1,
|
|
|
minZoom: 0,
|
|
|
- maxZoom: 6,
|
|
|
+ maxZoom: 7,
|
|
|
attributionControl: false,
|
|
|
zoomControl: false
|
|
|
- }).setView(L.latLng(31.46921085801776, 121.00402922590389), 6);
|
|
|
+ }).setView(L.latLng(31.14785322514787, 121.50195320451814), 3);
|
|
|
|
|
|
//添加默认图层
|
|
|
var layer = L.esri
|
|
|
.tiledMapLayer({
|
|
|
- url:
|
|
|
- // "http://aimap.pudong.sh:5236/maps/rest/services/basemap-shanghai-gem-blue-sh2000/mapserver/"
|
|
|
- // systemConfig.mapService + "?servertype=Street_Purplish_Blue&token=" + systemConfig.token
|
|
|
- this.mapUrl
|
|
|
+ tileSize: 512,
|
|
|
+ url: this.mapUrl
|
|
|
})
|
|
|
.addTo(this.map);
|
|
|
this.layers = layer;
|
|
|
},
|
|
|
setView: function (coord, zoom) {
|
|
|
- console.log("setView", coord, zoom);
|
|
|
let center = L.latLng(coord[0], coord[1]);
|
|
|
this.map.setView(center, zoom);
|
|
|
},
|
|
@@ -105,14 +101,11 @@ export default {
|
|
|
changeMapSize() {
|
|
|
this.$nextTick(() => {
|
|
|
if (this.map) {
|
|
|
- // this.layers.setUrl(this.mapUrl);
|
|
|
this.map.removeLayer(this.layers);
|
|
|
var layer = L.esri
|
|
|
.tiledMapLayer({
|
|
|
- url:
|
|
|
- // "http://aimap.pudong.sh:5236/maps/rest/services/basemap-shanghai-gem-blue-sh2000/mapserver/"
|
|
|
- // systemConfig.mapService + "?servertype=Street_Purplish_Blue&token=" + systemConfig.token
|
|
|
- this.mapUrl
|
|
|
+ tileSize: 512,
|
|
|
+ url: this.mapUrl
|
|
|
})
|
|
|
.addTo(this.map);
|
|
|
this.layers = layer;
|