就是ob不是类似一个阉割的浏览器吗?
浏览器输入如下内容
// 完全独立的地理位置调试代码 - 高德地图版
(() => {
console.log("🛠️ 地理定位调试工具(高德地图版)");
const showResult = (success, data) => {
const time = new Date().toLocaleTimeString();
const style = success
? "color: green; font-weight: bold"
: "color: red; font-weight: bold";
console.log(`%c[${time}] ${success ? "✅ 成功" : "❌ 失败"}`, style);
if (success) {
console.log("🌐 坐标:", `${data.lat}, ${data.lng}`);
console.log("🗺️ 高德地图:",
`https://uri.amap.com/marker?position=${data.lng},${data.lat}`);
console.log("🧭 高德导航:",
`https://uri.amap.com/navigation?to=${data.lng},${data.lat}`);
} else {
console.log("⚠️ 错误:", data.message);
console.log("💡 解决方案: 请检查:\n 1. 浏览器位置权限\n 2. 设备GPS/WiFi状态\n 3. 网络连接");
}
};
const getLocation = () => {
if (!navigator.geolocation) {
showResult(false, { message: "浏览器不支持地理定位API" });
return;
}
navigator.geolocation.getCurrentPosition(
pos => showResult(true, {
lat: pos.coords.latitude,
lng: pos.coords.longitude,
accuracy: pos.coords.accuracy
}),
err => showResult(false, {
code: err.code,
message: [
"用户拒绝授权",
"无法获取位置信息(GPS/WiFi关闭)",
"请求超时"
][err.code-1] || err.message
}),
{
enableHighAccuracy: true,
timeout: 15000,
maximumAge: 0
}
);
};
// 注册全局函数方便重复调用
window.定位测试 = getLocation;
console.log("🔧 使用方法:");
console.log("1. 输入「定位测试()」开始获取位置");
console.log("2. 首次使用需允许位置权限");
console.log("3. 支持在控制台多次调用");
// 立即执行一次
getLocation();
})();
那么就会提示授权给与地理位置信息
然后,允许以后就能获得自己所在位置坐标
但是ob似乎阉割了这个地理位置的内容,所以没有允许这一步弹出,然后就会超时。
我现在用迂回的方式
用powershell来获取,让ob调用powershell
但是这个过程,调用powershell有时间,就会延迟一会。
最优的肯定是ob原生支持……
还是说我没找到对应插件赋予ob这么个功能?