|
@@ -1,25 +1,30 @@
|
|
|
<style lang='scss' scoped>
|
|
|
-.mapContent {
|
|
|
- position: relative;
|
|
|
- height: 95%;
|
|
|
- transition: 0.5s;
|
|
|
- .center-add {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- bottom: 0;
|
|
|
- left: 0;
|
|
|
- right: 0;
|
|
|
- margin: auto;
|
|
|
- z-index: 999;
|
|
|
- width: 30px;
|
|
|
- height: 30px;
|
|
|
+ .mapContent {
|
|
|
+ position: relative;
|
|
|
+ height: 95%;
|
|
|
+ transition: 0.5s;
|
|
|
+
|
|
|
+ .center-add {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ margin: auto;
|
|
|
+ z-index: 999;
|
|
|
+ width: 30px;
|
|
|
+ height: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #mapContainer {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-#mapContainer {
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
-}
|
|
|
+ .amap-info-close {
|
|
|
+ display: none !important;
|
|
|
+ }
|
|
|
</style>
|
|
|
|
|
|
<template>
|
|
@@ -29,132 +34,140 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { regionData, CodeToText, TextToCode } from 'element-china-area-data'
|
|
|
-import image from '../../../public/img/ic_locationmarker.jpg'
|
|
|
-export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- clickData: {},
|
|
|
- map: null,
|
|
|
- marker: null,
|
|
|
- provinces: [],
|
|
|
- province: '',
|
|
|
- districts: [],
|
|
|
- district: '',
|
|
|
- citys: [],
|
|
|
- city: '',
|
|
|
- polygons: [],
|
|
|
- selectedOptions1: [],
|
|
|
- areacode: '',
|
|
|
- address: '',
|
|
|
- objPoint: [],
|
|
|
- markers: [],
|
|
|
- zoomEnable: true,
|
|
|
- dragEnable: true,
|
|
|
- status: true,
|
|
|
- center: ''
|
|
|
- }
|
|
|
- },
|
|
|
- props: [
|
|
|
- 'flagVisible',
|
|
|
- 'position',
|
|
|
- 'selectedOptions',
|
|
|
- 'isShowaddress',
|
|
|
- 'type'
|
|
|
- ],
|
|
|
- computed: {},
|
|
|
- watch: {},
|
|
|
- async created() {
|
|
|
- // 已载入高德地图API,则直接初始化地图
|
|
|
- if (window.AMap && window.AMapUI) {
|
|
|
- this.initMap()
|
|
|
- // 未载入高德地图API,则先载入API再初始化
|
|
|
- } else {
|
|
|
- // await remoteLoad(`http://webapi.amap.com/maps?v=1.3&key=${MapKey}`)
|
|
|
- // await remoteLoad('http://webapi.amap.com/ui/1.0/main.js')
|
|
|
- // this.initMap()
|
|
|
- }
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- // console.log(this)
|
|
|
- setTimeout(() => {
|
|
|
- var that = this
|
|
|
- this.map = new AMap.Map('mapContainer', {
|
|
|
- resizeEnable: true,
|
|
|
- zoom: 5,
|
|
|
- center:[103.809074,36.051121],
|
|
|
- zoomEnable: this.zoomEnable,
|
|
|
- dragEnable: this.dragEnable
|
|
|
- })
|
|
|
- this.loadmap()
|
|
|
- }, 500)
|
|
|
- },
|
|
|
- methods: {
|
|
|
- loadmap(val) {
|
|
|
- let that = this
|
|
|
- AMap.plugin(['AMap.DistrictSearch', 'AMap.Polygon'], function() {
|
|
|
- var geolocation = new AMap.Geolocation({
|
|
|
- // 是否使用高精度定位,默认:true
|
|
|
- enableHighAccuracy: true, // 设置定位超时时间,默认:无穷大
|
|
|
- timeout: 10000, // 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
|
- buttonOffset: new AMap.Pixel(10, 20), // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
|
- zoomToAccuracy: true, // 定位按钮的排放位置, RB表示右下
|
|
|
- buttonPosition: 'RB'
|
|
|
+ import {
|
|
|
+ regionData,
|
|
|
+ CodeToText,
|
|
|
+ TextToCode
|
|
|
+ } from 'element-china-area-data'
|
|
|
+ import image from '../../../public/img/ic_locationmarker.jpg'
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ map: null,
|
|
|
+ marker: null,
|
|
|
+ markers: [],
|
|
|
+ zoomEnable: true,
|
|
|
+ dragEnable: true,
|
|
|
+ status: true,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ props: [
|
|
|
+ 'listData'
|
|
|
+ ],
|
|
|
+ computed: {},
|
|
|
+ watch: {
|
|
|
+ listData: function(val1, val2) {
|
|
|
+ debugger
|
|
|
+ this.listData = val1
|
|
|
+ var that = this
|
|
|
+ this.map = new AMap.Map('mapContainer', {
|
|
|
+ resizeEnable: true,
|
|
|
+ zoom: 5,
|
|
|
+ center: [103.809074, 36.051121],
|
|
|
+ zoomEnable: this.zoomEnable,
|
|
|
+ dragEnable: this.dragEnable
|
|
|
})
|
|
|
- geolocation.getCurrentPosition()
|
|
|
- AMap.event.addListener(geolocation, 'complete', e => {
|
|
|
- console.log(e) // 定位成功之后做的事 // 定位成功之后再定位处添加一个marker
|
|
|
- that.markers = [
|
|
|
- [122.26399, 40.583527],
|
|
|
- [122.527662, 40.581441],
|
|
|
- [122.26811, 40.18498]
|
|
|
- ]
|
|
|
- var infoWindow = new AMap.InfoWindow({
|
|
|
- offset: new AMap.Pixel(0, -30)
|
|
|
+ this.loadmap()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ // 已载入高德地图API,则直接初始化地图
|
|
|
+ if (window.AMap && window.AMapUI) {
|
|
|
+ this.initMap()
|
|
|
+ // 未载入高德地图API,则先载入API再初始化
|
|
|
+ } else {
|
|
|
+ // await remoteLoad(`http://webapi.amap.com/maps?v=1.3&key=${MapKey}`)
|
|
|
+ // await remoteLoad('http://webapi.amap.com/ui/1.0/main.js')
|
|
|
+ // this.initMap()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {},
|
|
|
+ methods: {
|
|
|
+ makeMarkersList() {
|
|
|
+ let _list = this.listData
|
|
|
+ for (let i = 0; i < _list.length; i++) {
|
|
|
+ _list[i].marker = []
|
|
|
+ _list[i].marker.push(_list[i].warehousePositioning.split(',')[1])
|
|
|
+ _list[i].marker.push(_list[i].warehousePositioning.split(',')[0])
|
|
|
+ }
|
|
|
+ },
|
|
|
+ loadmap(val) {
|
|
|
+ let that = this
|
|
|
+ //构造markersList
|
|
|
+ this.makeMarkersList()
|
|
|
+ AMap.plugin(['AMap.DistrictSearch', 'AMap.Polygon'], function() {
|
|
|
+ var geolocation = new AMap.Geolocation({
|
|
|
+ // 是否使用高精度定位,默认:true
|
|
|
+ enableHighAccuracy: true, // 设置定位超时时间,默认:无穷大
|
|
|
+ timeout: 10000, // 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
|
+ buttonOffset: new AMap.Pixel(10, 20), // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
|
+ zoomToAccuracy: true, // 定位按钮的排放位置, RB表示右下
|
|
|
+ buttonPosition: 'RB'
|
|
|
})
|
|
|
- function infoOpen(e) {
|
|
|
- infoWindow.setContent(e.target.content)
|
|
|
- infoWindow.open(that.map, e.target.getPosition())
|
|
|
- }
|
|
|
- function infoClose(e) {
|
|
|
- infoWindow.close(that.map, e.target.getPosition())
|
|
|
- }
|
|
|
- function toGetList(e) {
|
|
|
- that.$parent.getList(e,1)
|
|
|
- }
|
|
|
-
|
|
|
- for (let i = 0; i < that.markers.length; i++) {
|
|
|
- var marker = new AMap.Marker({
|
|
|
- position: that.markers[i], // (e.position)--->定位点的点坐标, position ---> marker的定位点坐标,也就是marker最终显示在那个点上,
|
|
|
- icon: '', // marker的图标,可以自定义,不写默认使用高德自带的
|
|
|
- map: that.map // map ---> 要显示该marker的地图对象
|
|
|
+ geolocation.getCurrentPosition()
|
|
|
+ AMap.event.addListener(geolocation, 'complete', e => {
|
|
|
+ console.log(e) // 定位成功之后做的事 // 定位成功之后再定位处添加一个marker
|
|
|
+ var infoWindow = new AMap.InfoWindow({
|
|
|
+ offset: new AMap.Pixel(0, -30)
|
|
|
})
|
|
|
- // marker.setMap(that.map);
|
|
|
- // 设置鼠标划过点标记显示的文字提示
|
|
|
- // marker.setTitle('我是marker的title');
|
|
|
- marker.content = '<h4>我是第' + (i + 1) + '个</h4>'
|
|
|
- marker.on('mouseover', infoOpen)
|
|
|
- marker.on('mouseout', infoClose)
|
|
|
- marker.on('click',toGetList)
|
|
|
- // 设置label标签
|
|
|
- // label默认蓝框白底左上角显示,样式className为:amap-marker-label
|
|
|
- // marker.setLabel({
|
|
|
- // offset: new AMap.Pixel(20, 20), //设置文本标注偏移量
|
|
|
- // content: "<div class='info'>我是 marker 的 label 标签</div>", //设置文本标注内容
|
|
|
- // direction: 'right' //设置文本标注方位
|
|
|
- // });
|
|
|
- }
|
|
|
- // var marker = new AMap.Marker({
|
|
|
- // position: e.position, // (e.position)--->定位点的点坐标, position ---> marker的定位点坐标,也就是marker最终显示在那个点上,
|
|
|
- // icon: '', // marker的图标,可以自定义,不写默认使用高德自带的
|
|
|
- // map: that.map // map ---> 要显示该marker的地图对象
|
|
|
- // })
|
|
|
- })
|
|
|
- AMap.event.addListener(geolocation, 'error', e => {
|
|
|
- console.log(e) // 定位失败做的事
|
|
|
+
|
|
|
+ function infoOpen(e) {
|
|
|
+ infoWindow.setContent(e.target.content)
|
|
|
+ infoWindow.open(that.map, e.target.getPosition())
|
|
|
+ }
|
|
|
+
|
|
|
+ function infoClose(e) {
|
|
|
+ infoWindow.close(that.map, e.target.getPosition())
|
|
|
+ }
|
|
|
+
|
|
|
+ function toGetList(e) {debugger
|
|
|
+ // console.log(e.target.getExtData())
|
|
|
+
|
|
|
+ that.$parent.getList(e.target.getExtData().id, 1)
|
|
|
+ }
|
|
|
+ for (let i = 0; i < that.listData.length; i++) {
|
|
|
+ var marker = new AMap.Marker({
|
|
|
+ map: that.map,
|
|
|
+ position: that.listData[i]
|
|
|
+ .marker, // marker最终显示在那个点上,
|
|
|
+ icon: new AMap.Icon({
|
|
|
+ image: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/home_pic.png",
|
|
|
+ size: new AMap.Size(20, 20), //图标大小
|
|
|
+ imageSize: new AMap.Size(20, 20),
|
|
|
+ }),
|
|
|
+ })
|
|
|
+
|
|
|
+ marker.setExtData({'id':that.listData[i].warehouseName})
|
|
|
+ let _cwList = '<div class="cw-wrap">'
|
|
|
+ for (let k = 0; k < that.listData[i].tradeWarehouseReceiptAppls.length; k++) {
|
|
|
+ let _k = that.listData[i].tradeWarehouseReceiptAppls[k]
|
|
|
+ _cwList += '<div style="display:flex">' +
|
|
|
+ '<div style="margin:10px 20px">' + _k.warehouseNo + '仓位</div>' +
|
|
|
+ '<div style="margin:10px 20px">' + _k.goodsName + '</div>' +
|
|
|
+ '<div style="margin:10px 20px">' + _k.weight + '</div>' +
|
|
|
+ '</div>'
|
|
|
+ }
|
|
|
+ _cwList = _cwList + '</div>'
|
|
|
+ console.log('地图仓位数据',_cwList)
|
|
|
+ marker.content = '<div style="display:flex;justify-content: center">' + that.listData[i]
|
|
|
+ .warehouseName + '</div>' + _cwList + '</div>'
|
|
|
+ marker.on('mouseover', infoOpen)
|
|
|
+ marker.on('mouseout', infoClose)
|
|
|
+ marker.on('click', toGetList)
|
|
|
+ // 设置label标签
|
|
|
+ // label默认蓝框白底左上角显示,样式className为:amap-marker-label
|
|
|
+ // marker.setLabel({
|
|
|
+ // offset: new AMap.Pixel(20, 20), //设置文本标注偏移量
|
|
|
+ // content: "<div class='info'>我是 marker 的 label 标签</div>", //设置文本标注内容
|
|
|
+ // direction: 'right' //设置文本标注方位
|
|
|
+ // });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ AMap.event.addListener(geolocation, 'error', e => {
|
|
|
+ console.log(e) // 定位失败
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
</script>
|