mapContext.toScreenLocation({
longitude: marker.longitude,
latitude: marker.latitude,
success(pos) {
console.log("==========", pos);
},
fail(err) {
console.log("===============", err)
},
complete(ei) {
console.log("===============", ei)
}
});

- 发布:2025-05-29 23:41
- 更新:2025-05-29 23:58
- 阅读:47
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 15.5
HBuilderX类型: 正式
HBuilderX版本号: 4.66
第三方开发者工具版本号: 1.06.2503300
基础库版本号: 3.8.6
项目创建方式: HBuilderX
示例代码:
操作步骤:
<map id="map"></map>
const mapContext = uni.createMapContext("map");
mapContext.toScreenLocation({
longitude: marker.longitude,
latitude: marker.latitude,
success(pos) {
console.log("==========", pos);
},
fail(err) {
console.log("===============", err)
},
complete(ei) {
console.log("===============", ei)
}
});
<map id="map"></map>
const mapContext = uni.createMapContext("map");
mapContext.toScreenLocation({
longitude: marker.longitude,
latitude: marker.latitude,
success(pos) {
console.log("==========", pos);
},
fail(err) {
console.log("===============", err)
},
complete(ei) {
console.log("===============", ei)
}
});
预期结果:
正常调用,且有结果返回
正常调用,且有结果返回
实际结果:
无任何反应
无任何反应
bug描述:
在 map 组件结合 createMapContext 使用过程中,调用 toScreenLocation 无效。
1 个回复
c***@sina.com (作者)
已解决
本地开发过程中,因为无法获取到位置权限,所以无法转换
真机测试可以获取到该数据