d197998b by ex

查看Android的GPS

1 parent c5e285ba
......@@ -76,7 +76,7 @@ AppClient.prototype.getGPS = function (jsonStr, callback) {
var isRes = false
if(this.isAndroid) {
var toNonExponential = function (num) {
var m = num.toExponential().match(/\d(?:\.(\d*))?e([+-]\d+)/);
var m = num.toExponential().match(/\d(?:\.(\d*))?E([+-]\d+)/);
return num.toFixed(Math.max(0, (m[1] || '').length - m[2]));
}
......@@ -86,18 +86,13 @@ AppClient.prototype.getGPS = function (jsonStr, callback) {
var latitude = ''
var longitude = ''
var str = JSON.stringify(data)
try {
var result = /\{([\s\S]*)\}/.exec(str);
var arr = result[1].split(',')
latitude = arr[0].split('=')[1]
longitude = arr[1].split('=')[1]
latitude = toNonExponential(latitude)
longitude = toNonExponential(longitude)
} catch (e) {
layer.open({
content: e
})
}
var result = /\{([\s\S]*)\}/.exec(str);
var arr = result[1].split(',')
latitude = arr[0].split('=')[1]
longitude = arr[1].split('=')[1]
latitude = toNonExponential(latitude)
longitude = toNonExponential(longitude)
layer.open({
content: latitude
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!