当前位置: 首页 > 工具软件 > vue-amap > 使用案例 >

vue-amap 搜索

安奇
2023-12-01
<template>
  <div>

    <el-amap-search-box class="search-box"
                        :search-option="searchOption"
                        :on-search-result="onSearchResult"></el-amap-search-box>

    <el-amap vid="amapDemo"
             :amap-manager="amapManager"
             :center="center"
             :zoom="zoom"
             :events="mapEvents"
             class="amap-demo">
    </el-amap>
  </div>
</template>
methods: {
    onSearchResult(pois) {
      if (pois.length > 0) {
        this.longitude = pois[0].lng // 经度
        this.latitude = pois[0].lat// 纬度
        this.center = [this.longitude, this.latitude]
        this.zoom = 18
      }
    },
 }
 类似资料: