Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨建斌
/
dy-wx2
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3430d388
authored
2018-09-08 15:52:17 +0800
by
ex
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
GPS
1 parent
cda75a27
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
33 deletions
js/JSBridge.js
js/controller/mapController.js
js/JSBridge.js
View file @
3430d38
...
...
@@ -15,31 +15,31 @@ function isJson(str) {
return
true
;
}
// console.log(obj.latitude)
function
toJson
(
str
)
{
try
{
if
(
str
.
length
>
2
){
var
result
=
/
\{([\s\S]
*
)\}
/
.
exec
(
str
);
}
var
arr
=
result
[
1
].
split
(
','
)
var
obj
=
{}
arr
.
forEach
(
function
(
value
)
{
var
key
,
val
if
(
isAndroid
){
key
=
value
.
split
(
'='
)[
0
]
val
=
value
.
split
(
'='
)[
1
]
}
else
{
key
=
value
.
split
(
':'
)[
0
]
val
=
value
.
split
(
':'
)[
1
]
}
obj
[
key
]
=
val
*
1
})
return
obj
}
catch
(
e
)
{
return
{}
}
}
//
function toJson(str) {
//
try {
//
if(str.length > 2){
//
var result = /\{([\s\S]*)\}/.exec(str);
//
}
//
var arr = result[1].split(',')
//
var obj = {}
//
arr.forEach(function (value) {
//
var key, val
//
if(isAndroid){
//
key = value.split('=')[0]
//
val = value.split('=')[1]
//
} else {
//
key = value.split(':')[0]
//
val = value.split(':')[1]
//
}
//
//
obj[key] = val*1
//
})
//
return obj
//
//
} catch (e) {
//
return {}
//
}
//
}
// layer.open({
// content: "isAndroid:"+ isAndroid+ ",isiOS:" + isiOS,
// time: 2
...
...
js/controller/mapController.js
View file @
3430d38
...
...
@@ -303,9 +303,19 @@ angular.module('myApp')
},
1000
)
}
else
{
appClient
.
getGPS
(
''
,
function
(
data
,
cb
)
{
var
obj
=
toJson
(
data
)
var
latitude
=
''
var
longitude
=
''
var
result
=
/
\{([\s\S]
*
)\}
/
.
exec
(
str
);
// var obj = toJson(data)
var
arr
=
result
[
1
].
split
(
','
)
if
(
isAndroid
){
latitude
=
result
[
0
].
split
(
'='
)[
1
]
longitude
=
result
[
1
].
split
(
'='
)[
1
]
}
else
{
latitude
=
result
[
0
].
split
(
':'
)[
1
]
longitude
=
result
[
1
].
split
(
':'
)[
1
]
}
// layer.open({
// content: obj.latitude,
// time: 5
...
...
@@ -318,11 +328,11 @@ angular.module('myApp')
// content: JSON.stringify(obj),
// time: 5
// })
onSuccess
(
JSON
.
parse
(
JSON
.
stringify
(
obj
)))
//
onSuccess({
// latitude: obj.
latitude,
// longitude: obj.
longitude
//
})
//
onSuccess(JSON.parse(JSON.stringify(obj)))
onSuccess
({
latitude
:
latitude
,
longitude
:
longitude
})
})
// if(isAndroid){
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment