html5 - JavaScript获取到的位置有错
伊谢尔伦
伊谢尔伦 2017-04-11 10:50:00
[JavaScript讨论组]
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(2)
怪我咯

请看 html5 关于 Geolocation API 规范的描述:

The API itself is agnostic of the underlying location information sources. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. No guarantee is given that the API returns the device's actual location.

来源

这已经指明了这个API返回位置的源信息来自于GPS、IP、RFID、WiFi、蓝牙MAC地址、GSM/CDMA,甚至户输入。并不保证得到结果是设置所在的实际位置。因此,如果源信息设备能提供GPS信号则返回的结果就准确,如果测试模拟的设备根本获取不到GPS信息,那么只能通过其他允许的信号源了,就这里而言很可能是IP地址。精度当然差很多

黄舟

navigator.geolocation得到的坐标是按wgs84标准来的,高德的坐标系貌似是按gcj02标准来的,你需要转换下才能判断是否是准确的。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号