离线地图城市列表

[!TIP|labelVisibility:hidden|iconVisibility:hidden] getOfflineMapCityList(resultCallback)

参数说明

参数 类型 必填 说明
resultCallback Function 回调函数

resultCallback函数会返回一个对象,其属性包含以下一项或多项:

  • success(Boolean)
    • true -- 获取成功
    • false-- 获取失败
  • data(对象数组 ObjectArray) -- 数据对象数组,数组中的对象属性包含以下两项:
    • name(String)-- 城市名称
    • code(String)-- 城市编码
  • message(String) -- 成功或者失败的相关信息

示例代码

<template>
  <div class="wrapper">
    <hcm-amap class="map" ref="map"
              :zoomLevel="map.zoomLevel"
              :showScale="map.showScale"
              :center="map.center"
              :showPositioning="map.showPositioning"
              :showUserLocation="true">
    </hcm-amap>
    <text class="close" @click="close">关闭</text>
  </div>
</template>

<script>
const modal = weex.requireModule('modal')
const amap = weex.requireModule('amap')
const offline = weex.requireModule('amap-offline')

export default {
  data () {
    return {
      map: {
        zoomLevel: 16,
        showScale: false,
        showPositioning: true,
        showUserLocation: false,
        center: {
          latitude: 30.238753,
          longitude: 120.145336
        }
      }
    }
  },
  mounted () {
    offline.getOfflineMapCityList(function (res) {
      modal.toast({
        message: JSON.stringify(res)
      })
    })
  },
  methods: {
    close () {
      amap.close()
    }
  }
}
</script>
<style scoped>
.wrapper {
  flex: 1;
}
.map {
  flex: 1;
}
.close {
  position: absolute;
  top: 40px;
  right: 30px;
  width: 88px;
  height: 88px;
  background-color: white;
  text-align: center;
  line-height: 88px;
  font-size: 30px;
  border-radius: 44px;
}
</style>

results matching ""

    No results matching ""