Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_fiveworld
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_fiveworld
Commits
e9c9204e
Commit
e9c9204e
authored
Aug 05, 2021
by
fengruiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户不给定位权限默认定位到北京天安门
parent
6090d3b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
35 deletions
+42
-35
zsmap.js
app/src/main/assets/web/zsmap.js
+16
-16
GoogleMapFragment.kt
...java/com/mints/street/main/googlemap/GoogleMapFragment.kt
+5
-1
HomeFragment.kt
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
+21
-18
No files found.
app/src/main/assets/web/zsmap.js
View file @
e9c9204e
...
@@ -76,7 +76,7 @@ var vm = new Vue({
...
@@ -76,7 +76,7 @@ var vm = new Vue({
point
=
B_MAP
.
getCenter
();
point
=
B_MAP
.
getCenter
();
}
}
console
.
log
(
this
.
NOWUSEBAIDU
,
point
)
console
.
log
(
this
.
NOWUSEBAIDU
,
point
)
getLocation
(
point
,
function
(
res
)
{
getLocation
(
point
,
function
(
res
)
{
if
(
res
.
c
)
{
if
(
res
.
c
)
{
...
@@ -107,9 +107,13 @@ var vm = new Vue({
...
@@ -107,9 +107,13 @@ var vm = new Vue({
}
}
},
},
initZsMap
:
function
(
pointStr
)
{
initZsMap
:
function
(
pointStr
)
{
console
.
log
(
"
>>>>>>"
,
pointStr
)
console
.
log
(
">>>>>>>>
>>>>>>"
,
pointStr
)
var
th
=
this
;
var
th
=
this
;
var
inMsg
=
JSON
.
parse
(
pointStr
)
var
inMsg
=
JSON
.
parse
(
pointStr
)
if
(
inMsg
.
lat
==
0
||
inMsg
.
lng
==
0
||
inMsg
.
lat
==
'0'
||
inMsg
.
lng
==
'0'
)
{
inMsg
=
{
"lat"
:
39.90960456049752
,
"lng"
:
116.3972282409668
,
"inner"
:
0
};
}
var
point
=
{
lat
:
parseFloat
(
inMsg
.
lat
),
lng
:
parseFloat
(
inMsg
.
lng
)};
var
point
=
{
lat
:
parseFloat
(
inMsg
.
lat
),
lng
:
parseFloat
(
inMsg
.
lng
)};
if
(
inMsg
.
inner
==
null
)
{
if
(
inMsg
.
inner
==
null
)
{
getLocation
(
point
,
function
(
res
)
{
getLocation
(
point
,
function
(
res
)
{
...
@@ -211,13 +215,12 @@ var vm = new Vue({
...
@@ -211,13 +215,12 @@ var vm = new Vue({
},
},
B_initmap
:
function
(
point
,
zoomLevel
)
{
B_initmap
:
function
(
point
,
zoomLevel
)
{
this
.
NOWUSEBAIDU
=
true
;
this
.
NOWUSEBAIDU
=
true
;
console
.
log
(
"initB==>"
,
point
,
zoomLevel
)
// setTimeout(function () {
// setTimeout(function () {
if
(
zoomLevel
==
undefined
||
zoomLevel
==
null
)
if
(
zoomLevel
==
undefined
||
zoomLevel
==
null
)
zoomLevel
=
6
;
zoomLevel
=
6
;
var
th
=
vm
;
var
th
=
vm
;
if
(
th
.
B_MAPINITED
==
false
)
{
if
(
th
.
B_MAPINITED
==
false
)
{
console
.
log
(
">>>>>>>initB==>"
,
point
,
zoomLevel
)
th
.
B_MAPINITED
=
true
;
th
.
B_MAPINITED
=
true
;
// 百度地图API功能
// 百度地图API功能
// $("#map").hide();
// $("#map").hide();
...
@@ -248,14 +251,12 @@ var vm = new Vue({
...
@@ -248,14 +251,12 @@ var vm = new Vue({
}
else
{
}
else
{
B_MAP
.
centerAndZoom
(
new
BMap
.
Point
(
point
.
lng
,
point
.
lat
),
zoomLevel
);
// 初始化地图,设置中心点坐标和地图级别
B_MAP
.
centerAndZoom
(
new
BMap
.
Point
(
point
.
lng
,
point
.
lat
),
zoomLevel
);
// 初始化地图,设置中心点坐标和地图级别
setTimeout
(
function
(){
setTimeout
(
function
(){
B_MAP
.
centerAndZoom
(
new
BMap
.
Point
(
point
.
lng
,
point
.
lat
),
zoomLevel
);
// 初始化地图,设置中心点坐标和地图级别
B_MAP
.
centerAndZoom
(
new
BMap
.
Point
(
point
.
lng
,
point
.
lat
),
zoomLevel
);
// 初始化地图,设置中心点坐标和地图级别
},
500
)
},
500
)
console
.
log
(
">>>>>>>"
,
point
,
B_MAP
.
getCenter
())
//console.log(">>>>>>>", point, B_MAP.getCenter())
console
.
log
(
">>>>>>>cB==>"
,
B_MAP
.
getCenter
().
lat
,
B_MAP
.
getCenter
().
lng
,
zoomLevel
)
}
}
// },500)
// },500)
},
},
...
@@ -293,11 +294,11 @@ var vm = new Vue({
...
@@ -293,11 +294,11 @@ var vm = new Vue({
G_MAP
.
setCenter
(
point
)
G_MAP
.
setCenter
(
point
)
}
}
//
if (!this.NOWUSEBAIDU && this.B_MAPINITED) {
if
(
!
this
.
NOWUSEBAIDU
&&
this
.
B_MAPINITED
)
{
//
var bpoint = toBPoint(point)
var
bpoint
=
toBPoint
(
point
)
//
console.log("同步百度中心")
console
.
log
(
"同步百度中心"
)
//
B_MAP.setCenter(bpoint)
B_MAP
.
setCenter
(
bpoint
)
//
}
}
}
}
}
}
})
})
...
@@ -306,7 +307,6 @@ var vm = new Vue({
...
@@ -306,7 +307,6 @@ var vm = new Vue({
window
.
onload
=
function
()
{
window
.
onload
=
function
()
{
// console.log("window.load_+++++++++++=")170.89184781519282,-9.108152184807182
// console.log("window.load_+++++++++++=")170.89184781519282,-9.108152184807182
allIsOk
();
allIsOk
();
//vm.initZsMap('{"lat": 39.30336768549658, "lng": 350.8918478151928}')
}
}
...
...
app/src/main/java/com/mints/street/main/googlemap/GoogleMapFragment.kt
View file @
e9c9204e
...
@@ -47,9 +47,13 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
...
@@ -47,9 +47,13 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
private
var
gps
=
GPS
(
39.915121
,
116.403947
,
0
)
private
var
gps
=
GPS
(
39.915121
,
116.403947
,
0
)
inner
class
MyLocationListener
:
BDLocationListener
{
inner
class
MyLocationListener
:
BDLocationListener
{
override
fun
onReceiveLocation
(
location
:
BDLocation
?)
{
override
fun
onReceiveLocation
(
location
:
BDLocation
?)
{
//4.9E-324 4.9E-324
if
(
location
?.
latitude
==
4.9E-324
||
location
?.
longitude
==
4.9E-324
){
return
}
gps
.
lat
=
location
?.
latitude
?:
39.915121
gps
.
lat
=
location
?.
latitude
?:
39.915121
gps
.
lng
=
location
?.
longitude
?:
116.403947
gps
.
lng
=
location
?.
longitude
?:
116.403947
KLog
.
e
(
"onReceiveLocation"
,
"${location?.latitude} --- ${location?.longitude}"
)
}
}
}
}
...
...
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
View file @
e9c9204e
...
@@ -261,40 +261,43 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
...
@@ -261,40 +261,43 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
var
positioningBean
:
PositioningBean
?
=
null
var
positioningBean
:
PositioningBean
?
=
null
inner
class
MyLocationListener
:
BDLocationListener
{
inner
class
MyLocationListener
:
BDLocationListener
{
override
fun
onReceiveLocation
(
location
:
BDLocation
)
{
override
fun
onReceiveLocation
(
location
:
BDLocation
?)
{
if
(
location
?.
latitude
==
4.9E-324
||
location
?.
longitude
==
4.9E-324
){
return
}
if
(
sp
==
null
)
{
if
(
sp
==
null
)
{
sp
=
SPUtils
.
getInstance
(
SPUtils
.
POSITIONING_MAP
)
sp
=
SPUtils
.
getInstance
(
SPUtils
.
POSITIONING_MAP
)
}
}
if
(
positioningBean
==
null
)
{
if
(
positioningBean
==
null
)
{
positioningBean
=
PositioningBean
()
positioningBean
=
PositioningBean
()
}
}
positioningBean
?.
latitude
=
location
.
latitude
positioningBean
?.
latitude
=
location
?
.
latitude
positioningBean
?.
longitude
=
location
.
longitude
positioningBean
?.
longitude
=
location
?
.
longitude
positioningBean
?.
countryCode
=
location
.
countryCode
positioningBean
?.
countryCode
=
location
?
.
countryCode
positioningBean
?.
country
=
location
.
country
positioningBean
?.
country
=
location
?
.
country
positioningBean
?.
province
=
location
.
province
positioningBean
?.
province
=
location
?
.
province
positioningBean
?.
city
=
location
.
city
positioningBean
?.
city
=
location
?
.
city
positioningBean
?.
district
=
location
.
district
positioningBean
?.
district
=
location
?
.
district
positioningBean
?.
town
=
location
.
town
positioningBean
?.
town
=
location
?
.
town
positioningBean
?.
street
=
location
.
street
positioningBean
?.
street
=
location
?
.
street
positioningBean
?.
addrStr
=
location
.
addrStr
positioningBean
?.
addrStr
=
location
?
.
addrStr
sp
?.
encode
(
SPUtils
.
POSITIONING_MAP
,
Gson
().
toJson
(
positioningBean
).
toString
())
sp
?.
encode
(
SPUtils
.
POSITIONING_MAP
,
Gson
().
toJson
(
positioningBean
).
toString
())
// MapView 销毁后不在处理新接收的位置
// MapView 销毁后不在处理新接收的位置
mBaiduMap
?.
apply
{
mBaiduMap
?.
apply
{
mCurrentLat
=
location
.
latitude
mCurrentLat
=
location
?.
latitude
?:
0.0
mCurrentLon
=
location
.
longitude
mCurrentLon
=
location
?.
longitude
?:
0.0
mCurrentAccracy
=
location
.
radius
mCurrentAccracy
=
location
?.
radius
?:
0f
myLocationData
=
MyLocationData
.
Builder
()
myLocationData
=
MyLocationData
.
Builder
()
.
accuracy
(
location
.
radius
)
// 设置定位数据的精度信息,单位:米
.
accuracy
(
location
?.
radius
?:
0f
)
// 设置定位数据的精度信息,单位:米
.
direction
(
mCurrentDirection
.
toFloat
())
// 此处设置开发者获取到的方向信息,顺时针0-360
.
direction
(
mCurrentDirection
.
toFloat
())
// 此处设置开发者获取到的方向信息,顺时针0-360
.
latitude
(
location
.
latitude
)
.
latitude
(
location
?.
latitude
?:
0.0
)
.
longitude
(
location
.
longitude
)
.
longitude
(
location
?.
longitude
?:
0.0
)
.
build
()
.
build
()
this
.
setMyLocationData
(
myLocationData
)
this
.
setMyLocationData
(
myLocationData
)
if
(
isFirstLoc
)
{
if
(
isFirstLoc
)
{
isFirstLoc
=
false
isFirstLoc
=
false
val
ll
=
LatLng
(
location
.
latitude
,
location
.
longitude
)
val
ll
=
LatLng
(
location
?.
latitude
?:
0.0
,
location
?.
longitude
?:
0.0
)
val
builder
=
MapStatus
.
Builder
()
val
builder
=
MapStatus
.
Builder
()
builder
.
target
(
ll
).
zoom
(
18.0f
)
builder
.
target
(
ll
).
zoom
(
18.0f
)
this
.
animateMapStatus
(
MapStatusUpdateFactory
.
newMapStatus
(
builder
.
build
()))
this
.
animateMapStatus
(
MapStatusUpdateFactory
.
newMapStatus
(
builder
.
build
()))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment