|
这是我获取位置的代码如下:
- Model.prototype.getLocation = function() {
- var gpsDtd = $.Deferred();
- if (this.wxApi) {
- this.wxApi.exec().done(function(wx) {
- wx.getLocation({
- type : "gcj02",
- success : function(data) {
- gpsDtd.resolve({
- longitude : data.longitude,
- latitude : data.latitude,
- radius : data.radius
- });
- },
- cancel : function(res) {
- alert("您拒绝授权位置信息,禁止继续操作!");
- justep.Shell.showPage("servicesheet");
- gpsDtd.resolve({
- longitude : 0,
- latitude : 0
- });
- }
- });
- }).fail(function() {
- alert("您拒绝授权位置信息,禁止继续操作!");
- justep.Shell.showPage("servicesheet");
- gpsDtd.resolve({
- longitude : 0,
- latitude : 0
- });
- });
- } else if (navigator.geolocation) {
- var success = function(data) {
- // data.longtitude 经度
- // data.latitude 纬度
- // data.address 文字描述的地址信息
- // data.hasRadius 是否有定位精度半径
- // data.radius 定位精度半径
- // data.type 定位方式
- // data.coorType
- gpsDtd.resolve({
- coorType : data.coorType,
- address : data.address,
- longitude : data.coords.longitude,
- latitude : data.coords.latitude,
- radius : data.coords.radius
- });
- };
- var fail = function(e) {
- alert("您拒绝授权位置信息,禁止继续操作!");
- justep.Shell.showPage("servicesheet");
- gpsDtd.resolve({
- longitude : 0,
- latitude : 0
- });
- };
- /**
- * 如果在室内 enableHighAccuracy: true 反而误差更大 如果在室外 enableHighAccuracy:
- * true 相对准确
- */
- navigator.geolocation.getCurrentPosition(success, fail);
- /*
- * var gpsWatchID = navigator.geolocation.watchPosition(success,
- * fail,{ timeout: 30*1000, maximumAge: 30000, enableHighAccuracy:
- * true});
- */
- } else {
- alert("您拒绝授权位置信息,禁止继续操作!");
- justep.Shell.showPage("servicesheet");
- gpsDtd.resolve({
- longitude : 0,
- latitude : 0
- });
- }
- return gpsDtd.promise();
- };
复制代码 问题就出在 这个 radius ,
同样的代码,我在 android 手机上(安卓版本4.4)就可以成功获取到地址,但是在ios的手机上(版本 iOS10)却获取不到,这是为什么呢?
|
|