16c212e0 by ex

查看Android的GPS

1 parent 5e6fc261
...@@ -75,10 +75,13 @@ AppClient.prototype.getGPS = function (jsonStr, callback) { ...@@ -75,10 +75,13 @@ AppClient.prototype.getGPS = function (jsonStr, callback) {
75 }; 75 };
76 var isRes = false 76 var isRes = false
77 if(this.isAndroid) { 77 if(this.isAndroid) {
78 var toNonExponential = function (num) {
79 var m = num.toExponential().match(/\d(?:\.(\d*))?e([+-]\d+)/);
80 return num.toFixed(Math.max(0, (m[1] || '').length - m[2]));
81 }
82
78 var cb = function(data, responseCallback){ 83 var cb = function(data, responseCallback){
79 layer.open({ 84
80 content: JSON.stringify(data)
81 })
82 isRes = true 85 isRes = true
83 var latitude = '' 86 var latitude = ''
84 var longitude = '' 87 var longitude = ''
...@@ -87,7 +90,12 @@ AppClient.prototype.getGPS = function (jsonStr, callback) { ...@@ -87,7 +90,12 @@ AppClient.prototype.getGPS = function (jsonStr, callback) {
87 var arr = result[1].split(',') 90 var arr = result[1].split(',')
88 latitude = arr[0].split('=')[1] 91 latitude = arr[0].split('=')[1]
89 longitude = arr[1].split('=')[1] 92 longitude = arr[1].split('=')[1]
90 callback(latitude, longitude, responseCallback) 93 latitude = toNonExponential(latitude)
94 longitude = toNonExponential(longitude)
95 layer.open({
96 content: latitude + ',' + longitude
97 })
98 callback(toNonExponential(latitude), toNonExponential(longitude), responseCallback)
91 } 99 }
92 window.WebViewJavascriptBridge.callHandler('getGPS', jsonStr, function (data, responseCallback) { 100 window.WebViewJavascriptBridge.callHandler('getGPS', jsonStr, function (data, responseCallback) {
93 cb(data, responseCallback) 101 cb(data, responseCallback)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!