for (var i = 0; i < list.length; i++) {
let bdPoint = transformPoints(list[i].lat,list[i].lon)
let point = new BMapGL.Point(bdPoint.lng,bdPoint.lat)
let name = list[i].carNumber
let type = list[i].type
// 'static/imgs/shouye/car.png'
let src = list[i].type == 1 ? 'static/imgs/shouye/person1.png' :'static/imgs/shouye/person1.png'
let icon = new BMapGL.Icon(src, new BMapGL.Size(40, 40), {
// imageSize: new BMapGL.Size(30, 30)
});
let marker = new BMapGL.Marker(point,{ icon: icon })
if (type == 1) {
marker.type = 'car'
}else if (type == 2) {
marker.type = 'person'
}
if (name) {
var opts = { offset: new BMapGL.Size(0,-40)};
let label = new BMapGL.Label(name, opts);
label.setStyle({
color: "#333",
backgroundColor: "#fff",
borderRadius: "10px",
padding: "0 10px",
fontSize: "12px",
lineHeight: "20px",
border :"0",
transform:'translateX(-50%)'
});
marker.setLabel(label)
}
let item = list[i]
// 给marker添加点击事件
marker.addEventListener('click', () => {
// var myGeo = new BMapGL.Geocoder();
// // 根据坐标得到地址描述
// myGeo.getLocation(point, (result)=>{
// if (result){
// var addComp = result.content.address_detail;
// let address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.street_number + addComp.town
// item.address = address
// }
this.$ownerInstance.callMethod('onDeviceShow', item)
// });
this.getMapCenter([point])
});
marker.info = list[i]
if (list[i].markerType == 'currentDeviceMarker') {
this.currentDeviceMarker = marker
}
this.map.addOverlay(marker)
}
- 发布:2023-09-27 11:34
- 更新:2024-01-03 11:47
- 阅读:468
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 11
HBuilderX类型: 正式
HBuilderX版本号: 3.8.7
手机系统: iOS
手机系统版本号: iOS 16
手机厂商: 苹果
手机机型: iphone14pro
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
for (var i = 0; i < list.length; i++) {
let bdPoint = transformPoints(list[i].lat,list[i].lon)
let point = new BMapGL.Point(bdPoint.lng,bdPoint.lat)
let name = list[i].carNumber
let type = list[i].type
// 'static/imgs/shouye/car.png'
let src = list[i].type == 1 ? 'static/imgs/shouye/person1.png' :'static/imgs/shouye/person1.png'
let icon = new BMapGL.Icon(src, new BMapGL.Size(40, 40), {
// imageSize: new BMapGL.Size(30, 30)
});
let marker = new BMapGL.Marker(point,{ icon: icon })
if (type == 1) {
marker.type = 'car'
}else if (type == 2) {
marker.type = 'person'
}
if (name) {
var opts = { offset: new BMapGL.Size(0,-40)};
let label = new BMapGL.Label(name, opts);
label.setStyle({
color: "#333",
backgroundColor: "#fff",
borderRadius: "10px",
padding: "0 10px",
fontSize: "12px",
lineHeight: "20px",
border :"0",
transform:'translateX(-50%)'
});
marker.setLabel(label)
}
let item = list[i]
// 给marker添加点击事件
marker.addEventListener('click', () => {
// var myGeo = new BMapGL.Geocoder();
// // 根据坐标得到地址描述
// myGeo.getLocation(point, (result)=>{
// if (result){
// var addComp = result.content.address_detail;
// let address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.street_number + addComp.town
// item.address = address
// }
this.$ownerInstance.callMethod('onDeviceShow', item)
// });
this.getMapCenter([point])
});
marker.info = list[i]
if (list[i].markerType == 'currentDeviceMarker') {
this.currentDeviceMarker = marker
}
this.map.addOverlay(marker)
}
for (var i = 0; i < list.length; i++) {
let bdPoint = transformPoints(list[i].lat,list[i].lon)
let point = new BMapGL.Point(bdPoint.lng,bdPoint.lat)
let name = list[i].carNumber
let type = list[i].type
// 'static/imgs/shouye/car.png'
let src = list[i].type == 1 ? 'static/imgs/shouye/person1.png' :'static/imgs/shouye/person1.png'
let icon = new BMapGL.Icon(src, new BMapGL.Size(40, 40), {
// imageSize: new BMapGL.Size(30, 30)
});
let marker = new BMapGL.Marker(point,{ icon: icon })
if (type == 1) {
marker.type = 'car'
}else if (type == 2) {
marker.type = 'person'
}
if (name) {
var opts = { offset: new BMapGL.Size(0,-40)};
let label = new BMapGL.Label(name, opts);
label.setStyle({
color: "#333",
backgroundColor: "#fff",
borderRadius: "10px",
padding: "0 10px",
fontSize: "12px",
lineHeight: "20px",
border :"0",
transform:'translateX(-50%)'
});
marker.setLabel(label)
}
let item = list[i]
// 给marker添加点击事件
marker.addEventListener('click', () => {
// var myGeo = new BMapGL.Geocoder();
// // 根据坐标得到地址描述
// myGeo.getLocation(point, (result)=>{
// if (result){
// var addComp = result.content.address_detail;
// let address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.street_number + addComp.town
// item.address = address
// }
this.$ownerInstance.callMethod('onDeviceShow', item)
// });
this.getMapCenter([point])
});
marker.info = list[i]
if (list[i].markerType == 'currentDeviceMarker') {
this.currentDeviceMarker = marker
}
this.map.addOverlay(marker)
}
预期结果:
ios可以正常显示marker
ios可以正常显示marker
实际结果:
无法显示
无法显示
bug描述:
app端通过renderjs渲染百度地图 使用本地图片作为marker 安卓显示正常 ios 不显示
Diligent_UI - 【插件开发】【专治疑难杂症】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=193663(微信搜索飘逸科技UI小程序直接体验)】【骗子请绕道】问题咨询请加QQ群:120594820,代表作灵感实用工具小程序
在IOS真机看看有没有什么问题,或者把图片换成网络地址试试
意念开发创始人 (作者)
网络地址也是无法展示 从百度下载的图片可以 上传到自己服务器的图片 就不行 真机运行也无法展示
2023-09-27 14:30
3***@qq.com
回复 意念开发创始人: 哥们解决了吗?我们用的天地图,网络地址可以加载,本地出不来。H5是ok的,app不行
2023-11-28 14:16
HRK_01
回复 3***@qq.com: ios与安卓端都会复现该问题吗
2024-01-18 11:22