|
|
|
|
@ -22,7 +22,7 @@ |
|
|
|
|
</view> |
|
|
|
|
<view class="btn-location right-btn" @click="location"> |
|
|
|
|
<image src="/static/dw.png" class="img-location" /> |
|
|
|
|
<view>{{locationing?'定位中':'定位'}}</view> |
|
|
|
|
<view>{{locationing?'定位中':'定位'}}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="btn-mjcl right-btn" @click="showJwdPopup"> |
|
|
|
|
<image src="/static/jwd.png" class="img-jwd" /> |
|
|
|
|
@ -276,7 +276,11 @@ |
|
|
|
|
console.log(resp) |
|
|
|
|
if (resp.data.data) { |
|
|
|
|
const item = resp.data.data; |
|
|
|
|
this.layerItems = item?.layerItems.map(layerItem => { |
|
|
|
|
const defaultShowIndexs = []; |
|
|
|
|
this.layerItems = item?.layerItems.map((layerItem, i) => { |
|
|
|
|
if (layerItem.visible) { |
|
|
|
|
defaultShowIndexs.push(i); |
|
|
|
|
} |
|
|
|
|
return { |
|
|
|
|
text: layerItem.title, |
|
|
|
|
value: layerItem.layerName, |
|
|
|
|
@ -287,7 +291,10 @@ |
|
|
|
|
layerWorkspace: layerItem.layerWorkspace || item.layerWorkspace, |
|
|
|
|
...layerItem |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
if (defaultShowIndexs.length > 0) { |
|
|
|
|
this.currentLayers = defaultShowIndexs; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
@ -391,8 +398,10 @@ |
|
|
|
|
success: (res) => { |
|
|
|
|
console.log(res); |
|
|
|
|
this.locationing = false; |
|
|
|
|
const coords = helper.gcj02towgs84(res.longitude, res.latitude) |
|
|
|
|
console.log(coords, [res.longitude, res.latitude]) |
|
|
|
|
this.mapData = { |
|
|
|
|
center: [res.longitude, res.latitude, Math.random()] |
|
|
|
|
center: [...coords, Math.random()] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail: () => { |
|
|
|
|
@ -537,7 +546,7 @@ |
|
|
|
|
import { |
|
|
|
|
WMTS as WMTSGrid |
|
|
|
|
} from 'ol/tilegrid' |
|
|
|
|
let map, vectorLayer; |
|
|
|
|
let map, vectorLayer, locationVectorLayer; |
|
|
|
|
export default { |
|
|
|
|
name: 'c-ol-map', |
|
|
|
|
data() { |
|
|
|
|
@ -579,8 +588,8 @@ |
|
|
|
|
// }) |
|
|
|
|
// }) |
|
|
|
|
]) |
|
|
|
|
vectorLayer.getSource().clear(); |
|
|
|
|
vectorLayer.getSource().addFeature(pFeature); |
|
|
|
|
locationVectorLayer.getSource().clear(); |
|
|
|
|
locationVectorLayer.getSource().addFeature(pFeature); |
|
|
|
|
map.getView().fit(point, { |
|
|
|
|
maxZoom: 16 |
|
|
|
|
}); |
|
|
|
|
@ -636,13 +645,30 @@ |
|
|
|
|
businessName: opt.layerName, |
|
|
|
|
businessIndex: opt.layerIndex, |
|
|
|
|
zIndex: opt.zIndex, |
|
|
|
|
source |
|
|
|
|
source, |
|
|
|
|
extent: opt.extent || undefined |
|
|
|
|
}); |
|
|
|
|
} else if (opt.layerType === 'xyz') { |
|
|
|
|
layer = new TileLayer({ |
|
|
|
|
source: new XYZ({ |
|
|
|
|
maxZoom: opt.maxZoom || 18, |
|
|
|
|
url: opt.url, |
|
|
|
|
// url: 'http://t{0-5}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=cef191b507ff5cb698811cd8a9b11ca0', |
|
|
|
|
projection: opt.projection || 'EPSG:3857', |
|
|
|
|
crossOrigin: '*', |
|
|
|
|
}), |
|
|
|
|
zIndex: opt.zIndex, |
|
|
|
|
extent: opt.extent || undefined, |
|
|
|
|
businessId: 'business-layer', |
|
|
|
|
businessName: opt.layerName, |
|
|
|
|
businessIndex: opt.layerIndex, |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
layer = new Image({ |
|
|
|
|
businessId: 'business-layer', |
|
|
|
|
businessName: opt.layerName, |
|
|
|
|
businessIndex: opt.layerIndex, |
|
|
|
|
extent: opt.extent || undefined, |
|
|
|
|
source: new ImageWMS({ |
|
|
|
|
ratio: 1, |
|
|
|
|
url: `${opt.geoserverUrl}/geoserver/${opt.layerWorkspace}/wms`, |
|
|
|
|
@ -775,21 +801,22 @@ |
|
|
|
|
if (map) { |
|
|
|
|
map.removeLayer(map.getAllLayers().find(l => l.get('id') === 'draw-layer')); |
|
|
|
|
vectorLayer.getSource().clear(); |
|
|
|
|
locationVectorLayer.getSource().clear(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 初始化天地图 |
|
|
|
|
initMap() { |
|
|
|
|
let that = this |
|
|
|
|
//天地图影像 |
|
|
|
|
var tdt = new TileLayer({ |
|
|
|
|
source: new XYZ({ |
|
|
|
|
maxZoom: 16, |
|
|
|
|
url: "https://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}", |
|
|
|
|
// url: 'http://t{0-5}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=cef191b507ff5cb698811cd8a9b11ca0', |
|
|
|
|
projection: 'EPSG:3857', |
|
|
|
|
crossOrigin: '*', |
|
|
|
|
}), |
|
|
|
|
}) |
|
|
|
|
// var tdt = new TileLayer({ |
|
|
|
|
// source: new XYZ({ |
|
|
|
|
// maxZoom: 16, |
|
|
|
|
// url: "https://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}", |
|
|
|
|
// // url: 'http://t{0-5}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=cef191b507ff5cb698811cd8a9b11ca0', |
|
|
|
|
// projection: 'EPSG:3857', |
|
|
|
|
// crossOrigin: '*', |
|
|
|
|
// }), |
|
|
|
|
// }) |
|
|
|
|
//天地图标注 |
|
|
|
|
// var tdtLabel = new TileLayer({ |
|
|
|
|
// source: new XYZ({ |
|
|
|
|
@ -801,7 +828,7 @@ |
|
|
|
|
map = new Map({ |
|
|
|
|
controls: [], |
|
|
|
|
target: 'map', |
|
|
|
|
layers: [tdt], |
|
|
|
|
layers: [], |
|
|
|
|
view: new View({ |
|
|
|
|
projection: 'EPSG:4326', |
|
|
|
|
center: [102.45438, 32.53223], |
|
|
|
|
@ -817,9 +844,15 @@ |
|
|
|
|
zIndex: 999 |
|
|
|
|
}) |
|
|
|
|
map.addLayer(vectorLayer); |
|
|
|
|
locationVectorLayer = new VectorLayer({ |
|
|
|
|
id: 'l-v-layer', |
|
|
|
|
source: new VectorSource(), |
|
|
|
|
zIndex: 1000 |
|
|
|
|
}) |
|
|
|
|
map.addLayer(locationVectorLayer); |
|
|
|
|
map.on('singleclick', evt => { |
|
|
|
|
vectorLayer.getSource().clear(); |
|
|
|
|
console.log('evt', evt) |
|
|
|
|
console.log('evt', evt, map.getView().calculateExtent()) |
|
|
|
|
this.showByWkt(evt.coordinate); |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|