flat: 修改地图

This commit is contained in:
Apcallover
2024-05-16 15:16:11 +08:00
parent 5d82ff12d4
commit f97bd0f232
3 changed files with 29 additions and 6 deletions

View File

@@ -44,6 +44,7 @@
FeatureService, FeatureService,
GetFeaturesByGeometryParameters GetFeaturesByGeometryParameters
} from '@supermap/iclient-ol'; } from '@supermap/iclient-ol';
const geoJSONParser = new GeoJSON();
let mypoint = require('@/static/img/mypoint.png'); let mypoint = require('@/static/img/mypoint.png');
export default { export default {
name: "uMapView", name: "uMapView",
@@ -197,7 +198,6 @@
scale: item.id === 1 ? [0.15, 0.15] : [0.1, 0.1] scale: item.id === 1 ? [0.15, 0.15] : [0.1, 0.1]
} }
})) }))
this.careateFeature(features) this.careateFeature(features)
}, },
@@ -228,6 +228,7 @@
POP: 1, POP: 1,
CAPITAL: 'test' CAPITAL: 'test'
}); });
this.addPointsSource.clear()
// 将特征添加到矢量图层 // 将特征添加到矢量图层
this.addPointsSource.addFeature(pointFeature); this.addPointsSource.addFeature(pointFeature);
// 确保更新地图视图以显示新的标点 // 确保更新地图视图以显示新的标点
@@ -243,14 +244,22 @@
careateFeature(result) { careateFeature(result) {
if (this.vectorSourceIcon) { if (this.vectorSourceIcon) {
this.vectorSourceIcon.clear() this.vectorSourceIcon.clear()
const geojsonObject = {
type: 'FeatureCollection',
features: result,
};
this.vectorSourceIcon.addFeatures(geoJSONParser.readFeatures(geojsonObject))
this.vectorSourceIcon.changed()
return
} }
const geojsonObject = { const geojsonObject = {
type: 'FeatureCollection', type: 'FeatureCollection',
features: result, features: result,
}; };
// 创建一个图层作为点位 // 创建一个图层作为点位
this.vectorSourceIcon = new SourceVector({ this.vectorSourceIcon = new SourceVector({
features: new GeoJSON().readFeatures(geojsonObject) features: geoJSONParser.readFeatures(geojsonObject)
}); });
this.vectorLayerIcon = new LayerVector({ this.vectorLayerIcon = new LayerVector({
source: this.vectorSourceIcon, source: this.vectorSourceIcon,
@@ -280,6 +289,7 @@
} }
}); });
this.map.addLayer(this.vectorLayerIcon); this.map.addLayer(this.vectorLayerIcon);
// 添加事件
this.selectInteraction = new Select({ this.selectInteraction = new Select({
layers: [this.vectorLayerIcon] layers: [this.vectorLayerIcon]
}); });

View File

@@ -6,7 +6,14 @@ module.exports = {
showTitle: false, showTitle: false,
// map 1、黑色模块 2、白色模块 // map 1、黑色模块 2、白色模块
// supperMap: 'http://10.165.0.44:1205/proxy/rest/maps/f346b6c59dc64d5793713cf384fab78d/33cbaa14370449a08588f1074ecfec67', // supperMap: 'http://10.165.0.44:1205/proxy/rest/maps/f346b6c59dc64d5793713cf384fab78d/33cbaa14370449a08588f1074ecfec67',
supperMap: 'http://10.165.0.44:1205/proxy/rest/maps/c02c6f51f3ab4190bffd5e3e54cf5ac4/111013e9067749488d44841208771768', // supperMap: 'http://10.165.0.44:1205/proxy/rest/maps/c02c6f51f3ab4190bffd5e3e54cf5ac4/111013e9067749488d44841208771768',
supperMap: (() => {
if (process.env.NODE_ENV === 'development') {
return 'http://10.165.0.44:1205/proxy/rest/maps/c02c6f51f3ab4190bffd5e3e54cf5ac4/111013e9067749488d44841208771768'
} else {
return 'map/proxy/rest/maps/c02c6f51f3ab4190bffd5e3e54cf5ac4/111013e9067749488d44841208771768'
}
})(),
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称
@@ -38,6 +45,7 @@ module.exports = {
} else { } else {
return { return {
'{oss_file_url}': 'https://dy12333.org.cn/api', '{oss_file_url}': 'https://dy12333.org.cn/api',
"http://10.165.0.173:8000": "https://dy12333.org.cn/api",
"http://10.165.0.77:8000": "https://dy12333.org.cn/api" "http://10.165.0.77:8000": "https://dy12333.org.cn/api"
} }
} }

View File

@@ -4,7 +4,7 @@
<view class="top-search"> <view class="top-search">
<view class="top-input"> <view class="top-input">
<input class="put" type="text" placeholder-class="put-pla" v-model="searchValue" <input class="put" type="text" placeholder-class="put-pla" v-model="searchValue"
placeholder="搜索地点或者附近岗位"> placeholder="搜索附近岗位或任务">
<button class="input-btn" @tap="search">搜索</button> <button class="input-btn" @tap="search">搜索</button>
</view> </view>
</view> </view>
@@ -118,6 +118,7 @@
// this.longitude = myPoint.longitude // this.longitude = myPoint.longitude
// _this.getList(_this.longitude, _this.latitude).then((covers) => { // _this.getList(_this.longitude, _this.latitude).then((covers) => {
// _this.$api.msg('成功获得周边信息') // _this.$api.msg('成功获得周边信息')
// console.log(covers)
// _this.$refs.uMap.addFeature(covers) // _this.$refs.uMap.addFeature(covers)
// }) // })
// }) // })
@@ -142,6 +143,7 @@
} }
}, },
search() { search() {
const _this = this
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
success: function(res) { success: function(res) {
@@ -152,6 +154,7 @@
_this.latitude = latitude _this.latitude = latitude
_this.longitude = longitude _this.longitude = longitude
_this.getList(longitude, latitude).then((covers) => { _this.getList(longitude, latitude).then((covers) => {
_this.$api.msg('成功获得周边信息')
_this.$refs.uMap.addFeature(covers) _this.$refs.uMap.addFeature(covers)
}) })
}, },
@@ -160,8 +163,10 @@
}, },
complete: function(e) {} complete: function(e) {}
}) })
// this.getList(this.longitude, this.longitude).then((covers) => { // this.getList(this.longitude, this.latitude).then((covers) => {
// this.covers = covers // this.$api.msg('成功获得周边信息')
// console.log(covers)
// this.$refs.uMap.addFeature(covers)
// }) // })
}, },
clickmark(cover) { clickmark(cover) {