|
|
@ -1,20 +1,91 @@ |
|
|
|
<template> |
|
|
|
<div class="home"> |
|
|
|
<h1>This is an home page</h1> |
|
|
|
<svg-icon iconClass="atm" @click="$router.push({path:'/path3'})"/> |
|
|
|
<input id="search"/> |
|
|
|
<div style="width:700px;height:600px;border:1px solid #ddd;" ref="map"/> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { defineComponent } from 'vue' |
|
|
|
import { defineComponent, onMounted, shallowRef } from 'vue' |
|
|
|
import AMapLoader from "@amap/amap-jsapi-loader" |
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
name:"home", |
|
|
|
created(){ |
|
|
|
console.log('-----------home--------created----------') |
|
|
|
}, |
|
|
|
setup() { |
|
|
|
console.log("---------home------------------------") |
|
|
|
var map; |
|
|
|
|
|
|
|
var _data={ |
|
|
|
map:shallowRef(null), |
|
|
|
} |
|
|
|
|
|
|
|
onMounted(()=>{ |
|
|
|
window._AMapSecurityConfig={ |
|
|
|
securityJsCode:"3eceddef3eafbf06e01107c78db2c264", |
|
|
|
} |
|
|
|
AMapLoader.load({key:"3b999eeef15d7b6ca6a3fd0c9531160d",version:"2.0",plugins:["AMap.PolygonEditor,AMap.AutoComplete"]}).then(AMap=>{ |
|
|
|
map=new AMap.Map(_data.map.value,{ |
|
|
|
viewMode:"3D", |
|
|
|
zoom:16, |
|
|
|
zooms:[13,16.75], |
|
|
|
center:[103.144875, 25.482653], |
|
|
|
layers:[ |
|
|
|
// 卫星 |
|
|
|
new AMap.TileLayer.Satellite(), |
|
|
|
// 路网 |
|
|
|
new AMap.TileLayer.RoadNet() |
|
|
|
], |
|
|
|
}) |
|
|
|
window.m=map |
|
|
|
//多边形 |
|
|
|
var polygon=new AMap.Polygon({ |
|
|
|
path:[ |
|
|
|
[103.154206, 25.482612], |
|
|
|
[103.154297, 25.482324], |
|
|
|
[103.154146, 25.481694], |
|
|
|
[103.15457, 25.481461], |
|
|
|
[103.154813, 25.482379], |
|
|
|
[103.154555, 25.482448] |
|
|
|
], |
|
|
|
strokeColor: "#FF33FF", |
|
|
|
strokeWeight: 1, |
|
|
|
strokeOpacity: 0.7, |
|
|
|
fillOpacity: 0.2, |
|
|
|
fillColor: '#1791fc', |
|
|
|
zIndex: 50, |
|
|
|
}) |
|
|
|
var polygon1=new AMap.Polygon({ |
|
|
|
path:[ |
|
|
|
[103.145047, 25.483922], |
|
|
|
[103.149596, 25.483689], |
|
|
|
[103.145798, 25.480222], |
|
|
|
], |
|
|
|
strokeColor: "#FF33FF", |
|
|
|
strokeWeight: 3, |
|
|
|
strokeOpacity: 0.7, |
|
|
|
fillOpacity: 0.2, |
|
|
|
fillColor: '#1791fc', |
|
|
|
zIndex: 60, |
|
|
|
}) |
|
|
|
map.add([polygon,polygon1]) |
|
|
|
var polyEditor=new AMap.PolygonEditor(map) |
|
|
|
polyEditor.on("end",res=>{ |
|
|
|
console.log("---------end-------------") |
|
|
|
}) |
|
|
|
// polyEditor.open() |
|
|
|
|
|
|
|
var auto = new AMap.AutoComplete({ |
|
|
|
input:"search", |
|
|
|
}); |
|
|
|
setTimeout(()=>{ |
|
|
|
auto.search('北京',(a,b)=>{ |
|
|
|
console.log(a,"-------aaaaaa----------") |
|
|
|
console.log(b,"----------bbbbbbb---------") |
|
|
|
}) |
|
|
|
},1000) |
|
|
|
}) |
|
|
|
}) |
|
|
|
return _data; |
|
|
|
}, |
|
|
|
}) |
|
|
|
</script> |
|
|
|