地图pick组件重构(待)

dev
Tuzki 3 years ago
parent 3a7ebb4a06
commit 28387130e0
  1. BIN
      ruoyi-ui/public/bitbug_favicon.ico
  2. BIN
      ruoyi-ui/public/favicon.ico
  3. 4
      ruoyi-ui/public/index.html
  4. BIN
      ruoyi-ui/public/logo.png
  5. 8
      ruoyi-ui/src/api/estate/wholeFlow.js
  6. 28
      ruoyi-ui/src/components/CommonComponents/PublicCoponents/map/RLocation.vue
  7. 73
      ruoyi-ui/src/components/CommonComponents/PublicCoponents/map/RMap.vue
  8. 101
      ruoyi-ui/src/components/CommonComponents/PublicCoponents/map/newMap.vue
  9. 25
      ruoyi-ui/src/views/demo/demo.vue
  10. 2
      ruoyi-ui/src/views/system/management/electronic-patrol/patrol-point/index.vue
  11. 2
      ruoyi-ui/src/views/system/management/operational-data/lineData/lineData/index.vue

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

@ -5,9 +5,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script src="https://webapi.amap.com/maps?v=1.4.15&key=61050e92c9dea01ff1531c78376abe31&plugin=AMap.DistrictSearch"></script>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=61050e92c9dea01ff1531c78376abe31&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.DistrictSearch"></script>
<script src="http://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
<link rel="icon" href="<%= BASE_URL %>bitbug_favicon.ico">
<link rel="icon" href="<%= BASE_URL %>logo.png">
<title><%= webpackConfig.name %></title>
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
<style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -12,7 +12,7 @@ export function listWholeFlow(query) {
// 查询全域客流信息详细
export function getWholeFlow(id) {
return request({
url: '/estate/wholeFlow/' + id,
url: '/estate/whole/flow/' + id,
method: 'get'
})
}
@ -20,7 +20,7 @@ export function getWholeFlow(id) {
// 新增全域客流信息
export function addWholeFlow(data) {
return request({
url: '/estate/wholeFlow',
url: '/estate/whole/flow',
method: 'post',
data: data
})
@ -29,7 +29,7 @@ export function addWholeFlow(data) {
// 修改全域客流信息
export function updateWholeFlow(data) {
return request({
url: '/estate/wholeFlow',
url: '/estate/whole/flow',
method: 'put',
data: data
})
@ -38,7 +38,7 @@ export function updateWholeFlow(data) {
// 删除全域客流信息
export function delWholeFlow(id) {
return request({
url: '/estate/wholeFlow/' + id,
url: '/estate/whole/flow/' + id,
method: 'delete'
})
}

@ -13,16 +13,17 @@
</div>
<el-dialog
:modal="false"
:visible="visible"
title="定位"
width="800px"
:modal="false"
>
<r-map ref="Map" :show-input="showInput" :address="address" :lineType="lineType" :value="tempObj||value"
<r-map ref="Map" :address="address" :lan-lat="lanLat" :lineType="lineType" :show-input="showInput"
:value="tempObj||value"
class="map-container"
@change="handleChange"></r-map>
<span slot="footer" class="dialog-footer">
<el-button @click="resetData"> </el-button>
<!-- <el-button @click="resetData"> </el-button>-->
<el-button @click="handleClose"> </el-button>
<el-button type="primary" @click="handleOk"> </el-button>
</span>
@ -40,6 +41,10 @@ export default {
RMap,
},
props: {
lanLat: {
type: Array,
default: () => []
},
placeholder: {
type: String,
required: false,
@ -95,8 +100,13 @@ export default {
this.address = ""
this.$emit('change', this.tempObj)
// this.$emit('update:address', this.tmp.address)
this.$emit('update:lng', this.tempObj.split(',')[0])
this.$emit('update:lat', this.tempObj.split(',')[1])
if (this.tempObj !== null) {
this.$emit('update:lng', this.tempObj.split(',')[0])
this.$emit('update:lat', this.tempObj.split(',')[1])
} else {
this.$message.error('请先选择点位')
}
// this.$emit('update:regionCode', this.tmp.regionCode)
// this.allowInput = true
this.handleClose()
@ -109,14 +119,12 @@ export default {
}
},
pointChange(info) {
console.log(info, 'pppppp')
},
// handleAddressChange(e) {
// this.$emit('update:address', e.target.value)
// },
resetData() {
this.$refs.Map.myMarker.setMap(null)
this.$refs.Map.myMarker = null
this.$refs.Map.clearMarkers()
},
handleClose() {
this.visible = false
},

@ -11,13 +11,7 @@
</el-col>
</el-row>
<div v-if="isMapReady">
<div id="container" ref="map" class="map" tabindex="0"></div>
</div>
<div v-else>
<!-- 显示等待提示 -->
<p>正在加载地图请稍候...</p>
</div>
<div id="container" class="map" tabindex="0"></div>
</div>
</template>
@ -30,6 +24,10 @@ export default {
name: 'ZMap',
components: {},
props: {
lanLat: {
type:Array,
default:()=>[]
},
value: String,
lineType: {
type: Boolean,
@ -55,6 +53,7 @@ export default {
value: {
immediate: true,
handler(val) {
// debugger
if (val) {
if (this.lineType) {
let splitArr = val.split('@')
@ -98,7 +97,6 @@ export default {
pathArr: [],
pointLnglat: '',
editing: false, //
isMapReady: false, //
}
},
created() {
@ -106,25 +104,20 @@ export default {
},
mounted() {
// self = this
// setTimeout(() => {
self = this
// this.$nextTick(() => {
// this.initAMap()
//
// }, 2000)
// 100 API
const checkMapTimer = setInterval(() => {
if (typeof AMap === 'object') { // API
clearInterval(checkMapTimer); //
this.initAMap(); //
this.isMapReady = true; //
}
}, 100);
// })
setTimeout(()=>{
this.initAMap()
},1500)
},
methods: {
async initAMap(lng = 114.502461, lat = 38.045474) {
// debugger
AMapLoader.reset()
initAMap(lanLat) {
AMapLoader.load({
// key: 'c324f5ff276a2cba35ee8eee55d17b1d', //key
key: '7231218170a7459001b54d9b8c73cee6',
@ -152,7 +145,7 @@ export default {
viewMode: '3D',
zoom: 10,
zooms: [2, 22],
center: [lng, lat],
center: lanLat,
layers: [
new AMap.TileLayer(),
imageLayer
@ -199,11 +192,12 @@ export default {
}
})
.catch((e) => {
console.log(e, 'ooooo')
})
},
makeMarker(pointLnglat) {
console.log(pointLnglat);
this.myMarker = new AMap.Marker({
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
position: pointLnglat,
@ -214,30 +208,8 @@ export default {
this.pointLnglat = pointLnglat[0] + ',' + pointLnglat[1]
},
clearMarkers() {
debugger
this.pointLnglat.split(',').forEach(marker => {
marker.setMap(null); //
});
this.pointLnglat = ''; // markerList
},
setMarker(arr) {
this.myMarker = new AMap.Marker({
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
position: [arr[0], arr[1]],
offset: new AMap.Pixel(-16, -60),
extData: {
patrolPointName: arr[2],
id: arr[3],
}
})
this.map.add(this.myMarker)
},
//
search(addr) {
// debugger
this.$nextTick(() => {
let _this = this
window.AMap.plugin('AMap.PlaceSearch', function () {
@ -293,6 +265,7 @@ export default {
}
if (this.myPolyline) {
this.myPolyline.destroy()
this.myPolyline.close()
}
@ -356,9 +329,8 @@ export default {
this.endEdit()
}
},
// destroyed() {
// this.map.destroy()
// },
destroyed() {
},
model: {
prop: 'value',
event: 'change',
@ -421,3 +393,4 @@ export default {
}
</style>

@ -0,0 +1,101 @@
<template>
<div>
<div ref="mapContainer" style="height: 100%;"></div>
<el-button @click="cleanMap">清除</el-button>
</div>
</template>
<script>
import {debounce} from "@/utils";
export default {
name: 'Map',
props: {
mapCenter: {
type: Array,
default: () => []
},
pointArr: {
type: Array,
default: () => []
},
clean: {
type: Boolean,
default: true,
},
},
data() {
return {
defaultPoint: [114.56, 38.03],
map: null,
markers: [],
selectedMarker: null, //
arr: []
}
},
mounted() {
this.initMap(this.mapCenter)
},
watch: {
pointArr: {
immediate: true,
deep: true,
handler(val) {
// this.markers = val
}
}
},
methods: {
initMap(center) {
const map = new window.AMap.Map(this.$refs.mapContainer, {
center: center,
zoom: 13
})
this.map = map
this.addMarker(this.pointArr)
this.initEvents()
this.map.setFitView()
},
addMarker(position) { //
debugger
if (position !== undefined && position.length <= 2 || Array.isArray(position)===false && Object.keys(position).length > 0) {
if (this.selectedMarker && this.clean === true) {
this.selectedMarker.setMap(null)
} //
const marker = new window.AMap.Marker({
position
})
marker.setMap(this.map)
this.markers.push(marker)
this.selectedMarker = marker //
} else {
position.forEach(item => {
const marker = new window.AMap.Marker({
position: [item[0], item[1]]
})
marker.setMap(this.map)
// this.selectedMarker = marker
this.markers.push(marker)
})
}
},
initEvents() { //
this.map.on('click', (e) => {
console.log(typeof (e.lnglat), '][][')
this.addMarker(e.lnglat)
this.$emit('markerAdded', e.lnglat)
})
},
cleanMap() {
console.log(this.markers, '000');
this.map.remove(this.markers)
// this.addMarker(this.defaultPoint)
this.map.setZoom(11)
this.map.setFitView()
}
}
}
</script>

@ -1,10 +1,12 @@
<template>
<div>
<r-location v-model="model.lonLat" :isLine="false" :lat.sync="lat" :lng.sync="lng" :type="'button'"
placeholder="请选择点或路段" @change="getLngLat"/>
<el-input class="test" v-model="model.lonLat" placeholder="请输入内容">
<template slot="prepend">经纬度</template>
</el-input>
<new-map :clean="true" :map-center="[114.41,38.04]" :point-arr="pointArr" style="width: 50vh;height: 50vh" @markerAdded="handleMarkerAdded" />
{{markers }}
<!-- <r-location v-model="model.lonLat" :isLine="false" :lat.sync="lat" :lng.sync="lng" :type="'button'"-->
<!-- placeholder="请选择点或路段" @change="getLngLat"/>-->
<!-- <el-input class="test" v-model="model.lonLat" placeholder="请输入内容">-->
<!-- <template slot="prepend">经纬度</template>-->
<!-- </el-input>-->
<!-- <div>-->
<!-- <file-upload :file-type="['mp3']"></file-upload>-->
@ -35,6 +37,7 @@ import ImgUpload from '@/components/ImageUpload/index'
import Edit from '@/components/Editor/index'
import treeBox from "@/components/CommonComponents/PublicCoponents/editTree/TreeBox";
import transfer from "@/components/CommonComponents/PublicCoponents/transfel/transfer";
import NewMap from "@/components/CommonComponents/PublicCoponents/map/newMap";
let dayjs = require('dayjs')
let calendar = require('dayjs/plugin/calendar')
@ -43,11 +46,13 @@ let now = dayjs()
export default {
name: "demo",
components: {
RLocation, FileUpload, ImgUpload, Edit, treeBox,transfer
RLocation, FileUpload, ImgUpload, Edit, treeBox,transfer,NewMap
},
data() {
return {
pointArr:[[114.56,38.03],[116.405467, 39.907761], [116.415467, 39.907761], [116.415467, 39.917761], [116.425467, 39.907761],
[116.385467, 39.907761]],
model: {},
lng: '',
lat: '',
@ -59,7 +64,8 @@ export default {
{ key: "2", label: "选项二" },
{ key: "3", label: "选项三" }
],
selected: []
selected: [],
markers: []
}
},
mounted() {
@ -74,6 +80,11 @@ export default {
console.log(nowMonth, month, '0-----')
},
methods: {
handleMarkerAdded(lnglat) {
console.log('Marker added:', lnglat)
this.markers.push(lnglat)
console.log(this.markers)
},
getLngLat(val) {
console.log(val, '[[[[[[[')
},

@ -120,7 +120,7 @@
<div class="m-longitude-box">
<el-input v-model="form.longitude" placeholder="请输入经度"/>
<el-input v-model="form.dimension" placeholder="请输入纬度"/>
<r-location :isButton="true" :isLine="false" :lat.sync="form.dimension" :lng.sync="form.longitude"
<r-location :lan-lat="[114.48,38.06]" :isButton="true" :isLine="false" :lat.sync="form.dimension" :lng.sync="form.longitude"
placeholder="请选择点或路段"/>
</div>
</el-form-item>

@ -176,7 +176,7 @@
<el-input disabled="" v-model="form.operateLineTheme" placeholder="请输入线路主题" />
</el-form-item>
<el-form-item label="线路点位" prop="linePoint">
<r-location :show-input="false" @arrChange="getPointList" :arrLength.sync="nums" v-model="form.linePoint"></r-location>
<r-location :lan-lat="[114.48,38.06]" :show-input="false" @arrChange="getPointList" :arrLength.sync="nums" v-model="form.linePoint"></r-location>
<span>已选{{nums}}</span>
</el-form-item>
<el-form-item label="封面图" prop="coverPicture">

Loading…
Cancel
Save