This commit is contained in:
luozhun 2024-11-07 17:17:05 +08:00
parent b79bacc424
commit 18f6bd715a
1 changed files with 0 additions and 37 deletions

View File

@ -1,41 +1,4 @@
<template> <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> </template>
<script lang="ts" setup> <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> </script>