|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="map-container">
|
|
|
|
|
<div id="map"></div>
|
|
|
|
|
<div id="container"></div>
|
|
|
|
|
<el-dialog
|
|
|
|
|
v-if="isShowDialog"
|
|
|
|
|
title=""
|
|
|
|
@ -69,17 +69,30 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import mapboxgl from 'mapbox-gl'
|
|
|
|
|
import 'mapbox-gl/dist/mapbox-gl.css'
|
|
|
|
|
import { reportList, reportInfo } from '@/api/zongzhi/manage'
|
|
|
|
|
// import mapboxgl from 'mapbox-gl'
|
|
|
|
|
// import 'mapbox-gl/dist/mapbox-gl.css'
|
|
|
|
|
// import VueAMap from '@vuemap/vue-amap';
|
|
|
|
|
// import '@vuemap/vue-amap/dist/style.css'
|
|
|
|
|
import location from '@/assets/ecosphere/point.png'
|
|
|
|
|
// import { reportList, reportInfo } from '@/api/zongzhi/manage'
|
|
|
|
|
import {
|
|
|
|
|
listJbmap,
|
|
|
|
|
getJbmap,
|
|
|
|
|
} from "@/api/netManage/index.js";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
// VueAMap.initAMapApiLoader({
|
|
|
|
|
// key: 'b3c7a7ce466721c3be1d4ea539f82421', // 高德key
|
|
|
|
|
// securityJsCode: 'ec84db9c5dfc3d304ca9219e764ffeb8', // 安全密钥
|
|
|
|
|
// });
|
|
|
|
|
return {
|
|
|
|
|
isShowDialog: false,
|
|
|
|
|
center: [121.136909, 31.463778],
|
|
|
|
|
zoom: 14.5,
|
|
|
|
|
zooms:[14,18],
|
|
|
|
|
// markerOffset: [-35,-123],
|
|
|
|
|
// markers: [],
|
|
|
|
|
// 展示的内容
|
|
|
|
|
currentMsg: {
|
|
|
|
|
jbdx: '电子科技有限公司',
|
|
|
|
@ -95,81 +108,165 @@ export default {
|
|
|
|
|
{ id: 3, lng: 121.05452, lat: 31.515175, title: '太仓星兴亮机械设备有限公司' },
|
|
|
|
|
{ id: 4, lng: 121.127801, lat: 31.472566, title: '兴和电子有限公司' },
|
|
|
|
|
{ id: 5, lng: 121.142345, lat: 31.477655, title: '太仓裕盛体育用品有限公司' }
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
layers:{
|
|
|
|
|
layer:null,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async mounted() {
|
|
|
|
|
// let data = await reportList();
|
|
|
|
|
listJbmap({isStatus:1,pageNum:1,pageSize:50}).then(data=>{
|
|
|
|
|
let arr = []
|
|
|
|
|
data.rows.map((item)=>{
|
|
|
|
|
let obj = {}
|
|
|
|
|
obj.id = item.id
|
|
|
|
|
obj.lng = item.longitude
|
|
|
|
|
obj.lat = item.latitude
|
|
|
|
|
obj.title = item.jbObj
|
|
|
|
|
arr.push(obj)
|
|
|
|
|
mounted() {
|
|
|
|
|
var layer = new AMap.createDefaultLayer({
|
|
|
|
|
zooms:[14,18], //可见级别
|
|
|
|
|
visible:true, //是否可见
|
|
|
|
|
opacity:1, //透明度
|
|
|
|
|
zIndex:10, //叠加层级
|
|
|
|
|
mapStyle: 'amap://styles/d02b66b0a7f190d5a1556a3f59c86518',
|
|
|
|
|
})
|
|
|
|
|
this.pointList = arr
|
|
|
|
|
const _this = this
|
|
|
|
|
mapboxgl.accessToken = 'pk.eyJ1Ijoic2hhcmVhbGV4IiwiYSI6ImNsaXNhZmRjbTFhbnczZmxib3h1OW05YXYifQ.PhlKv60ar3K359d8x2yBPw'
|
|
|
|
|
const map = new mapboxgl.Map({
|
|
|
|
|
container: 'map', // 地图容器的id或元素
|
|
|
|
|
style: 'mapbox://styles/sharealex/cl3ntpire000314ookb5o81oo', // 地图样式
|
|
|
|
|
center: [121.136909, 31.463778], // 中心点经纬度
|
|
|
|
|
zoom: 14.5,
|
|
|
|
|
pitch: 50
|
|
|
|
|
var map = new AMap.Map('container',{
|
|
|
|
|
zoom: 16, //设置地图显示的缩放级别
|
|
|
|
|
zooms: this.zooms,
|
|
|
|
|
center: this.center,//设置地图中心点坐标
|
|
|
|
|
mapStyle: 'amap://styles/d02b66b0a7f190d5a1556a3f59c86518', //设置地图的显示样式
|
|
|
|
|
layers: [
|
|
|
|
|
// 高德默认标准图层
|
|
|
|
|
// new AMap.TileLayer.Satellite(),
|
|
|
|
|
layer,
|
|
|
|
|
// 楼块图层
|
|
|
|
|
new AMap.Buildings({
|
|
|
|
|
zooms: [14, 18],
|
|
|
|
|
zIndex: 11,
|
|
|
|
|
wallColor: 'rgba(24,79,129,1)',
|
|
|
|
|
roofColor: 'rgba(24,79,129,1)',
|
|
|
|
|
// heightFactor: 2//2倍于默认高度,3D下有效
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
resizeEnable: true,
|
|
|
|
|
rotateEnable:false,
|
|
|
|
|
pitchEnable:false,
|
|
|
|
|
pitch: 55,
|
|
|
|
|
rotation: 25,
|
|
|
|
|
viewMode: '3D', //设置地图模式
|
|
|
|
|
lang:'zh_cn', //设置地图语言类型
|
|
|
|
|
buildingAnimation:true,
|
|
|
|
|
// expandZoomRange:true,
|
|
|
|
|
});
|
|
|
|
|
this.layers.layer = new AMap.OverlayGroup(); // 点位
|
|
|
|
|
map.add(this.layers.layer);
|
|
|
|
|
this.map = map;
|
|
|
|
|
this.init(this.map);
|
|
|
|
|
// let data = await reportList();
|
|
|
|
|
// listJbmap({isStatus:1,pageNum:1,pageSize:50}).then(data=>{
|
|
|
|
|
// let arr = []
|
|
|
|
|
// data.rows.map((item)=>{
|
|
|
|
|
// let obj = {}
|
|
|
|
|
// obj.id = item.id
|
|
|
|
|
// obj.lng = item.longitude
|
|
|
|
|
// obj.lat = item.latitude
|
|
|
|
|
// obj.title = item.jbObj
|
|
|
|
|
// arr.push(obj)
|
|
|
|
|
// })
|
|
|
|
|
// this.pointList = arr
|
|
|
|
|
// const _this = this
|
|
|
|
|
// mapboxgl.accessToken = 'pk.eyJ1Ijoic2hhcmVhbGV4IiwiYSI6ImNsaXNhZmRjbTFhbnczZmxib3h1OW05YXYifQ.PhlKv60ar3K359d8x2yBPw'
|
|
|
|
|
// const map = new mapboxgl.Map({
|
|
|
|
|
// container: 'map', // 地图容器的id或元素
|
|
|
|
|
// style: 'mapbox://styles/sharealex/cl3ntpire000314ookb5o81oo', // 地图样式
|
|
|
|
|
// center: [121.136909, 31.463778], // 中心点经纬度
|
|
|
|
|
// zoom: 14.5,
|
|
|
|
|
// pitch: 50
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// // 地图加载完毕
|
|
|
|
|
// map.on('load', function() {
|
|
|
|
|
// // 地图点位
|
|
|
|
|
// _this.pointList.forEach(item => {
|
|
|
|
|
// const el = document.createElement('div')
|
|
|
|
|
// el.className = 'map-marker'
|
|
|
|
|
// el.innerHTML = `
|
|
|
|
|
// <img class="marker-img" src= "${require('@/assets/ecosphere/point.png')}" />
|
|
|
|
|
// <div class="marker-text">${item.title}</div>
|
|
|
|
|
// `
|
|
|
|
|
// new mapboxgl.Marker(el)
|
|
|
|
|
// .setLngLat([item.lng, item.lat])
|
|
|
|
|
// .addTo(map)
|
|
|
|
|
// el.addEventListener('click', () => {
|
|
|
|
|
// // 点击事件里去修改内容
|
|
|
|
|
// // reportInfo(item.id).then(res=>{
|
|
|
|
|
// getJbmap(item.id).then(res=>{
|
|
|
|
|
// let { jbObj, number, jbTime, address, content } = res.data
|
|
|
|
|
// _this.currentMsg.jbdx = jbObj
|
|
|
|
|
// _this.currentMsg.szbh = number
|
|
|
|
|
// _this.currentMsg.jbsj = jbTime
|
|
|
|
|
// _this.currentMsg.dz = address
|
|
|
|
|
// _this.currentMsg.jbnr = content
|
|
|
|
|
// _this.isShowDialog = true
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// map.addLayer({
|
|
|
|
|
// id: 'lou-extrusion',
|
|
|
|
|
// type: 'fill-extrusion',
|
|
|
|
|
// source: {
|
|
|
|
|
// type: 'geojson',
|
|
|
|
|
// data: require('@/utils/mapGeojson/1.json')
|
|
|
|
|
// },
|
|
|
|
|
// paint: {
|
|
|
|
|
// // 设置填充颜色
|
|
|
|
|
// 'fill-extrusion-color': '#2998F8',
|
|
|
|
|
// // 从属性中获得高度,这里用的是height字段
|
|
|
|
|
// 'fill-extrusion-height': ['get', 'height'],
|
|
|
|
|
// 'fill-extrusion-base': 0,
|
|
|
|
|
// // 透明度设置
|
|
|
|
|
// 'fill-extrusion-opacity': 0.7
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// this.map = map
|
|
|
|
|
// })
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
init(map){
|
|
|
|
|
|
|
|
|
|
// 地图加载完毕
|
|
|
|
|
map.on('load', function() {
|
|
|
|
|
// 地图点位
|
|
|
|
|
_this.pointList.forEach(item => {
|
|
|
|
|
const el = document.createElement('div')
|
|
|
|
|
el.className = 'map-marker'
|
|
|
|
|
el.innerHTML = `
|
|
|
|
|
<img class="marker-img" src= "${require('@/assets/ecosphere/point.png')}" />
|
|
|
|
|
<div class="marker-text">${item.title}</div>
|
|
|
|
|
`
|
|
|
|
|
new mapboxgl.Marker(el)
|
|
|
|
|
.setLngLat([item.lng, item.lat])
|
|
|
|
|
.addTo(map)
|
|
|
|
|
el.addEventListener('click', () => {
|
|
|
|
|
// 点击事件里去修改内容
|
|
|
|
|
// reportInfo(item.id).then(res=>{
|
|
|
|
|
listJbmap({isStatus:1,pageNum:1,pageSize:50}).then(data=>{
|
|
|
|
|
// let arr = [];
|
|
|
|
|
map.clearMap();
|
|
|
|
|
data.rows.map((item)=>{
|
|
|
|
|
// let obj = {}
|
|
|
|
|
// obj.id = item.id;
|
|
|
|
|
// obj.imgSrc = location;
|
|
|
|
|
// obj.lng = item.longitude
|
|
|
|
|
// obj.lat = item.latitude
|
|
|
|
|
// obj.title = item.jbObj
|
|
|
|
|
var marker = new AMap.Marker({
|
|
|
|
|
position: new AMap.LngLat(item.longitude, item.latitude), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
// <span style="color: #fff; font-size: 25px;width:${item.jbObj.length * 26}px">${item.jbObj}</span>
|
|
|
|
|
content: `<div class="amap-markers" data-projectid="${item.id}">
|
|
|
|
|
<img src="${location}" />
|
|
|
|
|
<div style="color: #fff; font-size: 25px;width:${item.jbObj.length * 26}px">${item.jbObj}</div>
|
|
|
|
|
</div>`,
|
|
|
|
|
offset:new AMap.Pixel(-(item.jbObj.length * 10), -30),
|
|
|
|
|
});
|
|
|
|
|
marker.on('click', (e)=>{
|
|
|
|
|
getJbmap(item.id).then(res=>{
|
|
|
|
|
let { jbObj, number, jbTime, address, content } = res.data
|
|
|
|
|
_this.currentMsg.jbdx = jbObj
|
|
|
|
|
_this.currentMsg.szbh = number
|
|
|
|
|
_this.currentMsg.jbsj = jbTime
|
|
|
|
|
_this.currentMsg.dz = address
|
|
|
|
|
_this.currentMsg.jbnr = content
|
|
|
|
|
_this.isShowDialog = true
|
|
|
|
|
})
|
|
|
|
|
this.currentMsg.jbdx = jbObj
|
|
|
|
|
this.currentMsg.szbh = number
|
|
|
|
|
this.currentMsg.jbsj = jbTime
|
|
|
|
|
this.currentMsg.dz = address
|
|
|
|
|
this.currentMsg.jbnr = content
|
|
|
|
|
this.isShowDialog = true
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
map.addLayer({
|
|
|
|
|
id: 'lou-extrusion',
|
|
|
|
|
type: 'fill-extrusion',
|
|
|
|
|
source: {
|
|
|
|
|
type: 'geojson',
|
|
|
|
|
data: require('@/utils/mapGeojson/1.json')
|
|
|
|
|
},
|
|
|
|
|
paint: {
|
|
|
|
|
// 设置填充颜色
|
|
|
|
|
'fill-extrusion-color': '#2998F8',
|
|
|
|
|
// 从属性中获得高度,这里用的是height字段
|
|
|
|
|
'fill-extrusion-height': ['get', 'height'],
|
|
|
|
|
'fill-extrusion-base': 0,
|
|
|
|
|
// 透明度设置
|
|
|
|
|
'fill-extrusion-opacity': 0.7
|
|
|
|
|
}
|
|
|
|
|
map.add(marker);
|
|
|
|
|
// arr.push(obj)
|
|
|
|
|
})
|
|
|
|
|
// this.pointList = arr;
|
|
|
|
|
})
|
|
|
|
|
this.map = map
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
methods: {}
|
|
|
|
|
aaaa(){
|
|
|
|
|
console.log(1111111);
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
@ -177,11 +274,12 @@ export default {
|
|
|
|
|
.map-container{
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: $ScreenHeight;
|
|
|
|
|
#map{
|
|
|
|
|
#container{
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.screen-dialog {
|
|
|
|
|
left: 30%;
|
|
|
|
|
right: 30%;
|
|
|
|
|