鸿蒙花瓣地图,动态更改option的market,不生效,这个是为什么?该怎么改?而且iconPath用的本地图片也不生效
this.nearbylists = this.nearbylists.map((item, index) => ({
// ...item,
// id: Number(item.id),
// title: item.join_type == 6 || item.join_type == 8 ?
// item.NearbyStoreDetail.car_name : item.organization_name,
// address: item.province + item.city + item.district + item.address,
longitude: Number(item.lnt),
latitude: Number(item.lat),
// height: 30,
iconPath:'/static/location.png',
// width: 30,
// callout: {
// content: ${item.join_type == 6 || item.join_type == 8 ? item.NearbyStoreDetail.car_name : item.organization_name}\n距离您${item.distance}km,
// bgColor: '#ffffff',
// color: '#D81616',
// display: index === 0 ? 'ALWAYS' : 'BYCLICK',
// padding: 5,
// borderRadius: 5,
// fontSize: 14,
// borderWidth: 1,
// borderColor: '#D81616',
// textAlign: 'center'
// }
}));
this.ismarkers = this.nearbylists;
// #ifdef APP-HARMONY
this.options.markers=this.ismarkers
console.log('ismarkers',this.options)
// #endif
if (this.ismarkers.length > 0) {
this.clickedId = this.ismarkers[0].id;
}
1 个回复
Ask小助手 - Ask社区AI助手
在鸿蒙平台使用uni-app的花瓣地图时,动态更新markers和本地图片路径不生效主要有以下原因及解决方案:
动态更新markers不生效
uni-app的map组件在鸿蒙平台不支持直接修改
options.markers触发视图更新。这是因为鸿蒙平台的地图实现机制与App不同,需要通过mapContext API操作。解决方案:
需要先通过
uni.createMapContext获取地图上下文实例,再调用updateMarkers方法更新标记点。本地图片路径不生效
鸿蒙平台对资源路径有特殊要求,
/static/location.png这种绝对路径无法识别。解决方案:
'../../static/location.png'(根据页面层级调整)'@app/ets/resources/base/media/location.png'src/main/ets/resources/base/media/目录,通过资源ID引用其他注意事项
参考文档:uni-app鸿蒙地图组件文档
要回复问题请先登录或注册
公告
更多>相关问题