HarmonyOS 鸿蒙Next地图不显示

发布于 1周前 作者 yibo5220 来自 鸿蒙OS

HarmonyOS 鸿蒙Next地图不显示

在AppGallery Connect 创建了应用,打开了地图服务开关               cke_1724.png            

然后配置了证书,添加了公钥签名
 

项目module.json5文件添加了client_id  和 网络权限

cke_34007.png

项目运行也是添加了证书文件
cke_64292.png

代码如下:

import { MapComponent, mapCommon, map } from ‘@kit.MapKit’;
import { AsyncCallback } from ‘@kit.BasicServicesKit’;

@Entry
@Component
struct BasicMapDemo {
private mapOptions?: mapCommon.MapOptions;
private callback?: AsyncCallback<map.MapComponentController>;
private mapController?: map.MapComponentController;

aboutToAppear(): void {
// 地图初始化参数,设置地图中心点坐标及层级
let target: mapCommon.LatLng = {
latitude: 39.9181,
longitude: 116.3970193
};
let cameraPosition: mapCommon.CameraPosition = {
target: target,
zoom: 15
};
this.mapOptions = {
position: cameraPosition
};

// 地图初始化的回调
this.callback = async (err, mapController) => {
if (!err) {
this.mapController = mapController;
// 初始化marker(标记)参数
let markerOptions: mapCommon.MarkerOptions = {
position: {
latitude: 39.9181,
longitude: 116.3970193
}
};
// 新建一个默认的marker图标
await this.mapController?.addMarker(markerOptions);
}
}
}

build() {
Stack() {
// 调用MapComponent组件初始化地图
MapComponent({ mapOptions: this.mapOptions, mapCallback: this.callback }).width(‘100%’).height(‘100%’);
}.height(‘100%’)
}
}

运行起项目,但是没有显示地图,请问除了上面已经配置的还有啥需要申请的吗?有知道的大佬帮忙看下
cke_63518.png

3 回复
mapController前面加个[@state](/user/state)看看

看看这个图片中的 公钥指纹

image.png

HarmonyOS 鸿蒙Next地图不显示的问题可能由多种原因引起,包括未配置SHA256指纹证书、网络问题、定位权限未开启或地图服务未正确设置等。请检查这些设置是否正确,并确保系统时间已更新以反映最新配置。同时,确保module.json5文件中的clientid配置正确,且签名证书指纹与AGC配置一致。如果问题依旧无法解决,请加我微信,我的微信是itying888,以便进一步探讨解决方案。

回到顶部