This commit is contained in:
parent
b79bacc424
commit
18f6bd715a
|
@ -1,41 +1,4 @@
|
|||
<template>
|
||||
<MapContainer ref="mapRef" style="width: 800px;height: 800px" :init-callback="callback"/>
|
||||
<div id="myPageTop">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label>请输入关键字:</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input id="tipinput"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import MapContainer from "@/components/aMap/MapContainer.vue";
|
||||
import {ref} from "vue";
|
||||
import {ComponentExposed} from "vue-component-type-helpers";
|
||||
|
||||
const mapRef = ref<ComponentExposed<typeof MapContainer>>(null)
|
||||
//输入提示
|
||||
|
||||
const callback = () => {
|
||||
AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], () => {
|
||||
var auto = new AMap.AutoComplete({
|
||||
input: "tipinput"
|
||||
});
|
||||
var placeSearch = new AMap.PlaceSearch({
|
||||
map: mapRef.value.mapInstance
|
||||
}); //构造地点查询类
|
||||
auto.on("select", select);//注册监听,当选中某条记录时会触发
|
||||
function select(e) {
|
||||
placeSearch.setCity(e.poi.adcode);
|
||||
placeSearch.search(e.poi.name); //关键字查询查询
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue