HarmonyOS 地图相关问题

1.地图是否支持禁止拖动

2.是否支持动态切换某个marker图片的方法,还是只能重新add

3.marker是否支持网络图

HarmonyOS
2024-08-14 16:02:48
1131浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

问题一:draggable 为false

问题二:支持动态切换marker图片Marker接口支持更新和查询标记,继承BaseOverlay。在调用map.MapComponentController类的addMarker方法时会返回该类型的实例。

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/map-map-V5#section166747193469

demo:

import { MapComponent, mapCommon, map } from '@kit.MapKit'; 
import { AsyncCallback } from '@kit.BasicServicesKit'; 
 
@Entry 
@Component 
struct Index { 
  private mapOptions?: mapCommon.MapOptions; 
  private mapController?: map.MapComponentController; 
  private callback?: AsyncCallback<map.MapComponentController>; 
  private marker?: map.Marker; 
 
  aboutToAppear(): void { 
    // 地图初始化参数 
    this.mapOptions = { 
      position: { 
        target: { 
          latitude: 31.984410259206815, 
          longitude: 118.76625379397866 
        }, 
        zoom: 15 
      } 
    }; 
    this.callback = async (err, mapController) => { 
      if (!err) { 
        this.mapController = mapController; 
        // Marker初始化参数 
        let markerOptions: mapCommon.MarkerOptions = { 
          position: { 
            latitude: 31.984410259206815, 
            longitude: 118.76625379397866 
          }, 
          rotation: 0, 
          visible: true, 
          zIndex: 0, 
          alpha: 1, 
          anchorU: 0.5, 
          anchorV: 1, 
          clickable: true, 
          draggable: true, 
          flat: false 
        }; 
        // 创建Marker 
        this.marker = await this.mapController.addMarker(markerOptions); 
      } 
    }; 
  } 
 
  build() { 
    Stack() { 
      Column() { 
        MapComponent({ mapOptions: this.mapOptions, mapCallback: this.callback }); 
        Button("修改marker图片").onClick(() => { 
          this.marker?.setIcon('app_icon.png'); 
        }) 
      }.width('100%') 
    }.height('100%') 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.

问题三:支持设置base64编码格式图片,toDataURL格式(即data:image/png;base64,<图片的Base64字节编码值>)https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/map-map-V5#section182051718143214

分享
微博
QQ
微信
回复
2024-08-14 23:15:03


相关问题
HarmonyOS 地图和位置服务相关资料
819浏览 • 1回复 待解决
HarmonyOS地图使用问题
989浏览 • 1回复 待解决
HarmonyOS 地图呈现问题
869浏览 • 1回复 待解决
HarmonyOS 地图城市显示问题
615浏览 • 1回复 待解决
HarmonyOS 地图服务的使用问题
727浏览 • 1回复 待解决
HarmonyOS 有关地图轨迹的问题
584浏览 • 1回复 待解决
HarmonyOS KVStore 相关问题
1038浏览 • 1回复 待解决
HarmonyOS Worker相关问题
918浏览 • 1回复 待解决
HarmonyOS Lib相关问题
719浏览 • 1回复 待解决
HarmonyOS string相关问题
946浏览 • 1回复 待解决
HarmonyOS BindSheet相关问题
1435浏览 • 1回复 待解决
HarmonyOS 证书相关问题
1059浏览 • 1回复 待解决
HarmonyOS AccountKit相关问题
1242浏览 • 1回复 待解决
HarmonyOS 线程相关问题
1335浏览 • 1回复 待解决
HarmonyOS Grid相关问题
1271浏览 • 1回复 待解决
HarmonyOS 混淆相关问题
793浏览 • 1回复 待解决
HarmonyOS RelativeContainer相关问题
736浏览 • 1回复 待解决
HarmonyOS PushExtensionAbility相关问题
840浏览 • 1回复 待解决
HarmonyOS CardRecognition相关问题
940浏览 • 1回复 待解决
HarmonyOS ApplicationContext相关问题
1032浏览 • 1回复 待解决
HarmonyOS 打包相关问题
956浏览 • 1回复 待解决
HarmonyOS @Event相关问题
933浏览 • 1回复 待解决
适配HarmonyOS相关问题
991浏览 • 1回复 待解决
HarmonyOS RN相关问题
1416浏览 • 1回复 待解决