百度地图开放平台
/ 方向图层
更新时间:2026/09/15 14:58

指南针图层

可通过调用CompassLayer类方法或者属性进行定位位置、显示隐藏等控制,通过点击图标可重置地图方向。

JavaScript
MapComponent({ onReady: async (err, mapController) => {
if (!err) {
// 获取地图的控制器类,用来操作地图
this.mapController= mapController;
this.compass = this.mapController.getLayerByTag(SysEnum.LayerTag.COMPASS) as CompassLayer;
this.compass.x = 64;
this.compass.y = 64;
}
}, mapOptions: new MapOptions(null)}).width('100%').height('100%')

本篇文章对您是否有帮助?

使用中遇到问题?查看常见问题提交工单