HarmonyOS 集成地图sdk实现poi搜索?

如何通过选择定位可以获取周边的地点信息?

阅读 556
1 个回答

示例参考如下:

searchInBounds() {
  const bdsearch: PoiSearch = new PoiSearch();
  const bound = '坐标';
  bdsearch.searchInBounds(this.keyword, bound, (results: Array<result>) => {
    console.log('lbs' + JSON.stringify(results))
    for (let i = 0; i < results.length; i++) {
      let location: LatLng = new LatLng(results[i].location.lat, results[i].location.lng);
      let image: ImageEntity = new ImageEntity('rawfile://xxx.png', 50, 81);
      let marker: Marker = new Marker({
        position: location,
        icon: image,
        yOffset: 0,
        isFlat: false,
        isDraggable: true,
        rotate: 0,
        alpha: 0.9,
        scaleX: 2,
        scaleY: 2,
        isTop: true
      });
      this.mapController?.addOverlay(marker);
    }
  }, {});
}

文档链接:https://lbsyun.baidu.com/faq/api?title=harmonynextsdk/guide/search/poi