|
@@ -1,21 +1,31 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
|
|
+ <div class="input-card content-window-card" ref="infoBox" v-if="infoBoxData" v-show="infoBoxData">
|
|
|
|
+ <div style="padding:7px 0px 0px 0px;">
|
|
|
|
+ <h4>{{infoBoxData.properties.name}}</h4>
|
|
|
|
+ <p class="input-item">完成率: {{ infoBoxData.baseItem.完成率 }}%</p>
|
|
|
|
+ <p class="input-item">移栽面积 {{ infoBoxData.baseItem.面积 }}平方米 移栽数量 {{ infoBoxData.baseItem.已种植 }}</p>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<div id="container" class="g-bg1"></div>
|
|
<div id="container" class="g-bg1"></div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import AMapLoader from '@amap/amap-jsapi-loader'
|
|
import AMapLoader from '@amap/amap-jsapi-loader'
|
|
-import mapOfTongren from '../page1/mapOfTongren.json'
|
|
|
|
|
|
+import mapOfTongren from '@/http/mapOfTongren.json'
|
|
|
|
+
|
|
window.map = {}
|
|
window.map = {}
|
|
|
|
|
|
export default {
|
|
export default {
|
|
components: {},
|
|
components: {},
|
|
data() {
|
|
data() {
|
|
- return {}
|
|
|
|
|
|
+ return {
|
|
|
|
+ infoBoxData: undefined,
|
|
|
|
+ }
|
|
},
|
|
},
|
|
computed: {},
|
|
computed: {},
|
|
- async created() {},
|
|
|
|
|
|
+ async created() { },
|
|
mounted() {
|
|
mounted() {
|
|
this.initAMap()
|
|
this.initAMap()
|
|
},
|
|
},
|
|
@@ -24,7 +34,18 @@ export default {
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
async initAMap() {
|
|
async initAMap() {
|
|
- const json = mapOfTongren
|
|
|
|
|
|
+ const vm = this
|
|
|
|
+ let infoWindow
|
|
|
|
+ //在指定位置打开信息窗体
|
|
|
|
+ function openInfo() {
|
|
|
|
+ const item = vm.infoBoxData
|
|
|
|
+ const { center } = item.properties
|
|
|
|
+ infoWindow = new AMap.InfoWindow({
|
|
|
|
+ content: vm.$refs.infoBox,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ infoWindow.open(map, center || map.getCenter());
|
|
|
|
+ }
|
|
window._AMapSecurityConfig = {
|
|
window._AMapSecurityConfig = {
|
|
securityJsCode: `a2017cdc059be6c03b430a3185098003`,
|
|
securityJsCode: `a2017cdc059be6c03b430a3185098003`,
|
|
}
|
|
}
|
|
@@ -33,10 +54,8 @@ export default {
|
|
version: `2.0`, // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
version: `2.0`, // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
plugins: [`AMap.Scale`], // 需要使用的的插件列表,如比例尺'AMap.Scale',支持添加多个如:['...','...']
|
|
plugins: [`AMap.Scale`], // 需要使用的的插件列表,如比例尺'AMap.Scale',支持添加多个如:['...','...']
|
|
})
|
|
})
|
|
- .then((AMap) => {
|
|
|
|
- let content = []
|
|
|
|
|
|
+ .then(async (AMap) => {
|
|
function addPolygon(data) {
|
|
function addPolygon(data) {
|
|
- const { name, center } = data.properties
|
|
|
|
const path = data.geometry.coordinates
|
|
const path = data.geometry.coordinates
|
|
let polygon = new AMap.Polygon({
|
|
let polygon = new AMap.Polygon({
|
|
path: path,
|
|
path: path,
|
|
@@ -51,14 +70,10 @@ export default {
|
|
lineCap: `round`,
|
|
lineCap: `round`,
|
|
})
|
|
})
|
|
polygon.on(`mouseover`, (e) => {
|
|
polygon.on(`mouseover`, (e) => {
|
|
- console.log(`mouseover`)
|
|
|
|
// 如果缩放过大还变色, 万一人家是想看放大后的详细地点, 变色后反而不方便
|
|
// 如果缩放过大还变色, 万一人家是想看放大后的详细地点, 变色后反而不方便
|
|
if (window.map.getZoom() <= 11) {
|
|
if (window.map.getZoom() <= 11) {
|
|
- content = [`<div class='info_box_contant'>222</div>`]
|
|
|
|
- infoWindow._originOpts.content = content.join(`</br>`)
|
|
|
|
- console.log(infoWindow._originOpts, `2222222222`)
|
|
|
|
- // infoWindow.open(window.map, [e.lnglat.lng, e.lnglat.lat]) // 后面的参数指的是经纬度,在此显示窗口
|
|
|
|
- infoWindow.open(window.map, center) // 后面的参数指的是经纬度,在此显示窗口
|
|
|
|
|
|
+ vm.infoBoxData = data
|
|
|
|
+ openInfo()
|
|
polygon.setOptions({
|
|
polygon.setOptions({
|
|
fillOpacity: 0.7,
|
|
fillOpacity: 0.7,
|
|
fillColor: `#7bccc4`,
|
|
fillColor: `#7bccc4`,
|
|
@@ -73,15 +88,9 @@ export default {
|
|
fillOpacity: 0,
|
|
fillOpacity: 0,
|
|
fillColor: `#ccebc5`,
|
|
fillColor: `#ccebc5`,
|
|
})
|
|
})
|
|
- infoWindow.close()
|
|
|
|
})
|
|
})
|
|
window.map.add(polygon)
|
|
window.map.add(polygon)
|
|
}
|
|
}
|
|
- const infoWindow = new AMap.InfoWindow({
|
|
|
|
- isCustom: true, // 使用自定义窗体
|
|
|
|
- content: content.join(`<br>`),
|
|
|
|
- offset: new AMap.Pixel(0, -25),
|
|
|
|
- })
|
|
|
|
window.map = new AMap.Map(`container`, {
|
|
window.map = new AMap.Map(`container`, {
|
|
// resizeEnable: true,
|
|
// resizeEnable: true,
|
|
// 设置地图容器id
|
|
// 设置地图容器id
|
|
@@ -123,10 +132,20 @@ export default {
|
|
// zooms: [16, 20],
|
|
// zooms: [16, 20],
|
|
})
|
|
})
|
|
window.map.setFeatures([`point`]) // 单一种类要素显示
|
|
window.map.setFeatures([`point`]) // 单一种类要素显示
|
|
- let list = json.features.map((item) => item)
|
|
|
|
|
|
+ const baseList = await this.$http.get(`/api/base`)
|
|
|
|
+ let list = mapOfTongren.features.map((item) => {
|
|
|
|
+ const baseItem = baseList.find((baseItem) => String(baseItem.区域编码) === String(item.properties.adcode)) || {}
|
|
|
|
+ item.baseItem = baseItem
|
|
|
|
+ return item
|
|
|
|
+ })
|
|
list.forEach((item) => {
|
|
list.forEach((item) => {
|
|
addPolygon(item)
|
|
addPolygon(item)
|
|
})
|
|
})
|
|
|
|
+ const item = list[0]
|
|
|
|
+ this.infoBoxData = item
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ openInfo()
|
|
|
|
+ })
|
|
})
|
|
})
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
console.log(e)
|
|
console.log(e)
|
|
@@ -142,6 +161,29 @@ export default {
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
+<style label="less">
|
|
|
|
+.custom-input-card {
|
|
|
|
+ width: 18rem;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.custom-input-card .btn:last-child {
|
|
|
|
+ margin-left: 1rem;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.content-window-card {
|
|
|
|
+ color: #000;
|
|
|
|
+ position: relative;
|
|
|
|
+ width: 23rem;
|
|
|
|
+ padding: 0.75rem 0 0 1.25rem;
|
|
|
|
+ box-shadow: none;
|
|
|
|
+ bottom: 0;
|
|
|
|
+ left: 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.content-window-card p {
|
|
|
|
+ height: 2rem;
|
|
|
|
+}
|
|
|
|
+</style>
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
#container {
|
|
#container {
|
|
position: absolute;
|
|
position: absolute;
|