优化成 3秒 更新一次位置
This commit is contained in:
parent
c40e75725b
commit
d3ce652209
|
|
@ -561,40 +561,11 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建定位标记图标
|
* 创建定位标记图标(使用 real_postion.png)
|
||||||
*/
|
*/
|
||||||
createLocationIcon() {
|
createLocationIcon() {
|
||||||
// 创建一个带方向的箭头图标
|
// 直接使用静态图片作为定位图标
|
||||||
// 使用 Canvas 绘制一个圆形标记和方向箭头
|
this.locationIconUrl = './image/real_postion.png';
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
canvas.width = 40;
|
|
||||||
canvas.height = 40;
|
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
|
|
||||||
// 绘制圆形背景
|
|
||||||
ctx.fillStyle = '#3388ff';
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(20, 20, 15, 0, Math.PI * 2);
|
|
||||||
ctx.fill();
|
|
||||||
|
|
||||||
// 绘制白色边框
|
|
||||||
ctx.strokeStyle = '#ffffff';
|
|
||||||
ctx.lineWidth = 3;
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(20, 20, 15, 0, Math.PI * 2);
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
// 绘制方向箭头(默认向上)
|
|
||||||
ctx.fillStyle = '#ffffff';
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(20, 5);
|
|
||||||
ctx.lineTo(15, 15);
|
|
||||||
ctx.lineTo(25, 15);
|
|
||||||
ctx.closePath();
|
|
||||||
ctx.fill();
|
|
||||||
|
|
||||||
// 转换为图片URL
|
|
||||||
this.locationIconUrl = canvas.toDataURL();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -844,7 +815,7 @@
|
||||||
enableHighAccuracy: true, // 使用GPS精确定位
|
enableHighAccuracy: true, // 使用GPS精确定位
|
||||||
timeout: 15000 // 15秒超时(给GPS足够时间)
|
timeout: 15000 // 15秒超时(给GPS足够时间)
|
||||||
});
|
});
|
||||||
}, 5000); // 每5秒更新一次位置
|
}, 3000); // 每5秒更新一次位置
|
||||||
|
|
||||||
// 保存geolocation实例,以便后续使用
|
// 保存geolocation实例,以便后续使用
|
||||||
this.baiduGeolocation = geolocation;
|
this.baiduGeolocation = geolocation;
|
||||||
|
|
@ -928,7 +899,7 @@
|
||||||
console.error('uni-app GPS定位更新失败:', err);
|
console.error('uni-app GPS定位更新失败:', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 5000); // 每5秒更新一次
|
}, 3000); // 每3秒更新一次
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1001,7 +972,7 @@
|
||||||
console.error('uni-app定位更新失败:', err);
|
console.error('uni-app定位更新失败:', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 5000); // 每5秒更新一次位置
|
}, 3000); // 每3秒更新一次位置
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue