Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
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
bp
ShenghuoquanBusiness
Commits
2253f122
Commit
2253f122
authored
Jul 10, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复高德地图so库异常问题,并动态配置amap_key
parent
e40cef0d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
45 deletions
+87
-45
build.gradle
CommonLib/Common/build.gradle
+4
-2
AndroidManifest.xml
CommonLib/Common/src/main/AndroidManifest.xml
+11
-0
SelectAddressActivity.kt
...henghuoquan/newscontent/ui/store/SelectAddressActivity.kt
+31
-35
build.gradle
app/build.gradle
+2
-2
proguard-rules.pro
app/proguard-rules.pro
+29
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-4
config.gradle
config/config.gradle
+9
-2
No files found.
CommonLib/Common/build.gradle
View file @
2253f122
...
...
@@ -39,6 +39,7 @@ android {
manifestPlaceholders
=
[
app_name
:
"商家版测试"
,
file_provider:
rootProject
.
ext
.
android
.
applicationId
+
".debug.fileprovider"
,
amap_key
:
rootProject
.
ext
.
amap
.
amap_debug_key
,
]
}
release
{
...
...
@@ -48,6 +49,7 @@ android {
manifestPlaceholders
=
[
app_name
:
"生活圈商家版"
,
file_provider:
rootProject
.
ext
.
android
.
applicationId
+
".fileprovider"
,
amap_key
:
rootProject
.
ext
.
amap
.
amap_release_key
,
]
}
}
...
...
@@ -73,8 +75,8 @@ android {
}
dependencies
{
// 注意高德地图jar引入需要
使用compile,implementation不生效
compile
fileTree
(
include:
'*.jar'
,
dir:
'libs'
)
// 注意高德地图jar引入需要
其他组件可以使用,故而api
api
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
,
'*.aar'
]
)
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// kotlin实现MVVM框架之使用DataBinding之unresolved reference: BR解决办法
kapt
"com.android.databinding:compiler:4.0.1"
...
...
CommonLib/Common/src/main/AndroidManifest.xml
View file @
2253f122
...
...
@@ -16,5 +16,16 @@
<!--允许程序访问CellID或WiFi热点来获取粗略的位置-->
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<application>
<!--高德地图配置 start -->
<meta-data
android:name=
"com.amap.api.v2.apikey"
android:value=
"${amap_key}"
/>
<service
android:name=
"com.amap.api.location.APSService"
/>
<!--高德地图配置 end -->
</application>
</manifest>
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/store/SelectAddressActivity.kt
View file @
2253f122
...
...
@@ -3,7 +3,6 @@ package com.yidian.shenghuoquan.newscontent.ui.store
import
android.content.Intent
import
android.location.Location
import
android.os.Bundle
import
android.util.Log
import
android.view.View
import
android.widget.AdapterView
import
com.amap.api.maps.AMap
...
...
@@ -20,24 +19,25 @@ import com.yidian.common.PoiListAdapter
import
com.yidian.common.base.BaseActivity
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.databinding.ActivitySelectAddressBinding
import
timber.log.Timber
/**
* Author: sym
* Date: 2021/6/24 2:10 PM
* Describe:
* 选择门店地址
*/
class
SelectAddressActivity
:
BaseActivity
<
ActivitySelectAddressBinding
>(),
OnMyLocationChangeListener
,
AMap
.
OnMapClickListener
,
OnPoiSearchListener
{
class
SelectAddressActivity
:
BaseActivity
<
ActivitySelectAddressBinding
>(),
OnMyLocationChangeListener
,
AMap
.
OnMapClickListener
,
OnPoiSearchListener
{
private
lateinit
var
mapView
:
MapView
private
var
adapter
=
PoiListAdapter
()
private
var
resultIntent
=
Intent
()
private
lateinit
var
data
:
List
<
PoiItem
>
private
var
myLocationStyle
:
MyLocationStyle
?
=
null
var
bitmapDescriptor
:
BitmapDescriptor
?
=
null
private
var
bitmapDescriptor
:
BitmapDescriptor
?
=
null
private
var
markerView
:
View
?
=
null
private
var
currentMarker
:
Marker
?
=
null
private
var
boundsBuilder
:
LatLngBounds
.
Builder
?
=
null
var
aMap
:
AMap
?
=
null
private
var
aMap
:
AMap
?
=
null
override
fun
createViewBinding
():
ActivitySelectAddressBinding
{
return
ActivitySelectAddressBinding
.
inflate
(
layoutInflater
)
...
...
@@ -73,8 +73,8 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
}
//设置SDK 自带定位消息监听
aMap
!!
.
setOnMyLocationChangeListener
(
this
)
aMap
!!
.
myLocationStyle
=
myLocationStyle
!!
.
myLocationType
(
MyLocationStyle
.
LOCATION_TYPE_LOCATE
)
aMap
?
.
setOnMyLocationChangeListener
(
this
)
aMap
?.
myLocationStyle
=
myLocationStyle
?
.
myLocationType
(
MyLocationStyle
.
LOCATION_TYPE_LOCATE
)
viewBind
.
selectAddBackBtn
.
setOnClickListener
{
finish
()
}
...
...
@@ -109,38 +109,30 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
private
fun
setUpMap
()
{
// 如果要设置定位的默认状态,可以在此处进行设置
myLocationStyle
=
MyLocationStyle
()
aMap
!!
.
myLocationStyle
=
myLocationStyle
aMap
!!
.
isMyLocationEnabled
=
true
// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
aMap
!!
.
setOnMapClickListener
(
this
)
// 设置点击marker事件监听器
aMap
?
.
myLocationStyle
=
myLocationStyle
aMap
?
.
isMyLocationEnabled
=
true
// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
aMap
?
.
setOnMapClickListener
(
this
)
// 设置点击marker事件监听器
}
//定位
override
fun
onMyLocationChange
(
location
:
Location
?)
{
// 定位回调监听
if
(
location
!=
null
)
{
Log
.
e
(
"amap"
,
"onMyLocationChange 定位成功, lat: "
+
location
.
latitude
+
" lon: "
+
location
.
longitude
)
Timber
.
tag
(
"amap"
).
e
(
"onMyLocationChange 定位成功, lat: "
+
location
.
latitude
+
" lon: "
+
location
.
longitude
)
val
bundle
:
Bundle
=
location
.
extras
if
(
bundle
!=
null
)
{
val
errorCode
=
bundle
.
getInt
(
MyLocationStyle
.
ERROR_CODE
)
val
errorInfo
=
bundle
.
getString
(
MyLocationStyle
.
ERROR_INFO
)
// 定位类型,可能为GPS WIFI等,具体可以参考官网的定位SDK介绍
val
locationType
=
bundle
.
getInt
(
MyLocationStyle
.
LOCATION_TYPE
)
aMap
!!
.
isMyLocationEnabled
=
false
// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
aMap
?
.
isMyLocationEnabled
=
false
// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
updataCurrentMarker
(
LatLng
(
location
.
latitude
,
location
.
longitude
))
updataCurrentMarker
(
LatLng
(
location
.
latitude
,
location
.
longitude
))
/*
errorCode
errorInfo
locationType
*/
Log
.
e
(
"amap"
,
"定位信息, code: $errorCode errorInfo: $errorInfo locationType: $locationType"
)
}
else
{
Log
.
e
(
"amap"
,
"定位信息, bundle is null "
)
}
Timber
.
tag
(
"amap"
).
e
(
"定位信息, code: $errorCode errorInfo: $errorInfo locationType: $locationType"
)
}
else
{
Log
.
e
(
"amap"
,
"定位失败"
)
Timber
.
tag
(
"amap"
).
e
(
"定位失败"
)
}
}
...
...
@@ -156,15 +148,15 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
markerOption
.
icon
(
bitmapDescriptor
)
markerOption
.
anchor
(
0F
,
1F
)
currentMarker
?.
remove
()
currentMarker
=
aMap
!!
.
addMarker
(
markerOption
)
currentMarker
!!
.
setObject
(
latLng
)
currentMarker
=
aMap
?
.
addMarker
(
markerOption
)
currentMarker
?
.
setObject
(
latLng
)
boundsBuilder
?.
include
(
latLng
)
queryPoi
()
}
//poi搜索
private
fun
queryPoi
()
{
val
latLng
=
currentMarker
!!
.
getObject
()
as
LatLng
val
latLng
=
currentMarker
?
.
getObject
()
as
LatLng
val
typeRange
=
"汽车服务|汽车销售|"
+
"汽车维修|摩托车服务|餐饮服务|购物服务|生活服务|体育休闲服务|医疗保健服务|"
+
"住宿服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|交通设施服务|"
+
...
...
@@ -174,8 +166,12 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
query
.
pageSize
=
1000
// 设置每页最多返回多少条poiitem,一次加载全部
query
.
pageNum
=
1
//设置查第一页
val
poiSearch
=
PoiSearch
(
this
,
query
)
poiSearch
.
bound
=
PoiSearch
.
SearchBound
(
LatLonPoint
(
latLng
.
latitude
,
latLng
.
longitude
),
500
)
//设置周边搜索的中心点以及区域
poiSearch
.
bound
=
PoiSearch
.
SearchBound
(
LatLonPoint
(
latLng
.
latitude
,
latLng
.
longitude
),
500
)
//设置周边搜索的中心点以及区域
poiSearch
.
setOnPoiSearchListener
(
this
)
//设置数据返回的监听器
poiSearch
.
searchPOIAsyn
()
...
...
@@ -186,7 +182,7 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
if
(
rCode
==
AMapException
.
CODE_AMAP_SUCCESS
)
{
if
(
poiResult
?.
query
!=
null
)
{
val
poiItems
:
List
<
PoiItem
>
=
poiResult
.
pois
// 取得第一页的poiitem数据,页数从数字0开始
if
(
poiItems
!=
null
&&
poiItems
.
isNotEmpty
())
{
if
(
poiItems
.
isNotEmpty
())
{
data
=
poiItems
adapter
.
setData
(
poiItems
)
}
...
...
app/build.gradle
View file @
2253f122
...
...
@@ -35,7 +35,7 @@ android {
}
buildTypes
{
debug
{
//
applicationIdSuffix ".debug"
applicationIdSuffix
".debug"
buildConfigField
(
"String"
,
"API_URL"
,
rootProject
.
ext
.
buildParams
.
debug
.
API_URL
)
buildConfigField
(
"String"
,
"PROVIDER_NAME"
,
'\"'
+
rootProject
.
ext
.
android
.
applicationId
+
".debug.fileprovider"
+
'\"'
)
manifestPlaceholders
=
[
...
...
@@ -101,7 +101,7 @@ android {
}
dependencies
{
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
,
'*.aar'
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// kotlin实现MVVM框架之使用DataBinding之unresolved reference: BR解决办法
kapt
"com.android.databinding:compiler:4.0.1"
...
...
app/proguard-rules.pro
View file @
2253f122
...
...
@@ -368,3 +368,32 @@ public static final int *;
-keep class com.yalantis.ucrop
*
* { *; }
-keep interface com.yalantis.ucrop
*
* { *; }
#高德地图
#3D 地图 V5.0.0之前:
-keep class com.amap.api.maps.
*
*{*;}
-keep class com.autonavi.amap.mapcore.*{*;}
-keep class com.amap.api.trace.
*
*{*;}
#3D 地图 V5.0.0之后:
-keep class com.amap.api.maps.
*
*{*;}
-keep class com.autonavi.
*
*{*;}
-keep class com.amap.api.trace.
*
*{*;}
#定位
-keep class com.amap.api.location.
*
*{*;}
-keep class com.amap.api.fence.
*
*{*;}
-keep class com.loc.
*
*{*;}
-keep class com.autonavi.aps.amapapi.model.
*
*{*;}
#搜索
-keep class com.amap.api.services.
*
*{*;}
#2D地图
-keep class com.amap.api.maps2d.
*
*{*;}
-keep class com.amap.api.mapcore2d.
*
*{*;}
#导航
-keep class com.amap.api.navi.
*
*{*;}
-keep class com.autonavi.
*
*{*;}
app/src/main/AndroidManifest.xml
View file @
2253f122
...
...
@@ -44,9 +44,7 @@
tools:replace=
"android:allowBackup,android:label"
tools:targetApi=
"n"
>
<meta-data
android:name=
"com.amap.api.v2.apikey"
android:value=
"0b8dd2229f4568b508e51865e402e04a"
/>
<!-- 以下为友盟分享基本配置信息 start-->
<provider
android:name=
"androidx.core.content.FileProvider"
...
...
@@ -243,7 +241,6 @@
</intent-filter>
</service>
<service
android:name=
"com.amap.api.location.APSService"
/>
<service
android:name=
"com.umeng.message.UmengDownloadResourceService"
...
...
config/config.gradle
View file @
2253f122
...
...
@@ -11,13 +11,20 @@ ext {
isApplication
:
false
,
isAppUpgradeOnline:
'true'
// 上线前需要开启版本升级线上环境 true
]
// 高德地图的key
amap
=
[
amap_debug_key
:
'0b8dd2229f4568b508e51865e402e04a'
,
amap_release_key:
'9dc8e3fe44680c65de8dbfd808742b10'
,
]
buildParams
=
[
debug
:
[
API_URL:
'"http://bp-dev.go2yd.com"'
,
API_URL
:
'"http://bp-dev.go2yd.com"'
,
AMAP_KEY:
'"0b8dd2229f4568b508e51865e402e04a"'
,
],
release:
[
API_URL:
'"http://bp-test.go2yd.com"'
,
API_URL
:
'"http://bp-test.go2yd.com"'
,
// API_URL: '"https://bp.go2yd.com"',
AMAP_KEY:
'"9dc8e3fe44680c65de8dbfd808742b10"'
,
]
]
}
...
...
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