d197998b by ex

查看Android的GPS

1 parent c5e285ba
...@@ -76,7 +76,7 @@ AppClient.prototype.getGPS = function (jsonStr, callback) { ...@@ -76,7 +76,7 @@ AppClient.prototype.getGPS = function (jsonStr, callback) {
76 var isRes = false 76 var isRes = false
77 if(this.isAndroid) { 77 if(this.isAndroid) {
78 var toNonExponential = function (num) { 78 var toNonExponential = function (num) {
79 var m = num.toExponential().match(/\d(?:\.(\d*))?e([+-]\d+)/); 79 var m = num.toExponential().match(/\d(?:\.(\d*))?E([+-]\d+)/);
80 return num.toFixed(Math.max(0, (m[1] || '').length - m[2])); 80 return num.toFixed(Math.max(0, (m[1] || '').length - m[2]));
81 } 81 }
82 82
...@@ -86,18 +86,13 @@ AppClient.prototype.getGPS = function (jsonStr, callback) { ...@@ -86,18 +86,13 @@ AppClient.prototype.getGPS = function (jsonStr, callback) {
86 var latitude = '' 86 var latitude = ''
87 var longitude = '' 87 var longitude = ''
88 var str = JSON.stringify(data) 88 var str = JSON.stringify(data)
89 try { 89 var result = /\{([\s\S]*)\}/.exec(str);
90 var result = /\{([\s\S]*)\}/.exec(str); 90 var arr = result[1].split(',')
91 var arr = result[1].split(',') 91 latitude = arr[0].split('=')[1]
92 latitude = arr[0].split('=')[1] 92 longitude = arr[1].split('=')[1]
93 longitude = arr[1].split('=')[1] 93 latitude = toNonExponential(latitude)
94 latitude = toNonExponential(latitude) 94 longitude = toNonExponential(longitude)
95 longitude = toNonExponential(longitude) 95
96 } catch (e) {
97 layer.open({
98 content: e
99 })
100 }
101 96
102 layer.open({ 97 layer.open({
103 content: latitude 98 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!