//获取当前设备位置信息
plus.geolocation.getCurrentPosition(function(p) {
var rpPlace = document.getElementById("rpPlace");
//alert('Geolocation\nLatitude:' + p.coords.latitude + '\nLongitude:' + p.coords.longitude + '\nAltitude:' + p.coords.altitude);
console.log("坐标类型:" + p.coordsType + "\n");
console.log('Geolocation\nLatitude:' + p.coords.latitude + '\nLongitude:' + p.coords.longitude + '\nAltitude:' + p.coords.altitude);
rpPlace.value = p.coords.longitude + ',' + p.coords.latitude + ',' + p.coords.altitude;
}, function(e) {
//alert('Geolocation error: ' + e.message);
console.log('Geolocation error: ' + e.message);
},{coordsType:'wgs84'});
这段代码执行后,结果如下
坐标类型:gcj02
为什么 设置'wgs84'不起作用。
2, 当设置为选项为 {provider: 'system'}时,
报错: No location providers available。
3, 最奇怪的是,同样一段代码我之前发布的应用,得到的坐标,与新版本的Hbuider发布的应用,得到的坐标居然不一样。旧版的好像是GPS坐标, 而新版是gcj02的坐标系。
1 个回复
飞行的鱼 (作者)
plus.geolocation.getCurrentPosition()方法,为什么 调用时,一定要有网络才能用呢?
我就想得到GPS的坐标,不想调用baidu或高德地图,难道不行吗?