Commit 2049d682 authored by 宋永孟's avatar 宋永孟

add 优化

parent 02a0e876
...@@ -31,7 +31,7 @@ import kotlinx.android.synthetic.main.activity_select_address.* ...@@ -31,7 +31,7 @@ import kotlinx.android.synthetic.main.activity_select_address.*
* Date: 2021/6/24 2:10 PM * Date: 2021/6/24 2:10 PM
* Describe: * Describe:
*/ */
class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMyLocationChangeListener, AMap.OnMapClickListener, OnPoiSearchListener, AMapLocationListener { class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMyLocationChangeListener, AMap.OnMapClickListener, OnPoiSearchListener{
private lateinit var mapView: MapView private lateinit var mapView: MapView
private var adapter = PoiListAdapter() private var adapter = PoiListAdapter()
private var myLocationStyle: MyLocationStyle? = null private var myLocationStyle: MyLocationStyle? = null
...@@ -39,8 +39,6 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy ...@@ -39,8 +39,6 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
private var markerView: View? = null private var markerView: View? = null
private var currentMarker: Marker? = null private var currentMarker: Marker? = null
private var boundsBuilder: LatLngBounds.Builder? = null private var boundsBuilder: LatLngBounds.Builder? = null
private var mlocationClient = AMapLocationClient(this)
var aMap: AMap? = null var aMap: AMap? = null
override fun createViewBinding(): ActivitySelectAddressBinding { override fun createViewBinding(): ActivitySelectAddressBinding {
...@@ -106,11 +104,6 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy ...@@ -106,11 +104,6 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
aMap!!.myLocationStyle = myLocationStyle aMap!!.myLocationStyle = myLocationStyle
aMap!!.isMyLocationEnabled = true // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false aMap!!.isMyLocationEnabled = true // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
aMap!!.setOnMapClickListener(this) // 设置点击marker事件监听器 aMap!!.setOnMapClickListener(this) // 设置点击marker事件监听器
//设置定位监听
mlocationClient.setLocationListener(this)
mlocationClient.startLocation()
} }
//定位 //定位
...@@ -169,12 +162,6 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy ...@@ -169,12 +162,6 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
"住宿服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|交通设施服务|" + "住宿服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|交通设施服务|" +
"金融保险服务|公司企业|道路附属设施|地名地址信息|公共设施" "金融保险服务|公司企业|道路附属设施|地名地址信息|公共设施"
// keyWord表示搜索字符串,第二个参数表示POI搜索类型,默认为:生活服务、餐饮服务、商务住宅
//共分为以下20种:汽车服务|汽车销售|
//汽车维修|摩托车服务|餐饮服务|购物服务|生活服务|体育休闲服务|医疗保健服务|
//住宿服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|交通设施服务|
//金融保险服务|公司企业|道路附属设施|地名地址信息|公共设施
//cityCode表示POI搜索区域,(这里可以传空字符串,空字符串代表全国在全国范围内进行搜索)
val query: PoiSearch.Query = PoiSearch.Query("", typeRange, "") val query: PoiSearch.Query = PoiSearch.Query("", typeRange, "")
query.pageSize = 10 // 设置每页最多返回多少条poiitem query.pageSize = 10 // 设置每页最多返回多少条poiitem
query.pageNum = 1 //设置查第一页 query.pageNum = 1 //设置查第一页
...@@ -183,10 +170,10 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy ...@@ -183,10 +170,10 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
latLng.longitude), 500) //设置周边搜索的中心点以及区域 latLng.longitude), 500) //设置周边搜索的中心点以及区域
poiSearch.setOnPoiSearchListener(this) //设置数据返回的监听器 poiSearch.setOnPoiSearchListener(this) //设置数据返回的监听器
poiSearch.searchPOIAsyn() poiSearch.searchPOIAsyn()
} }
//poi搜索结束
override fun onPoiSearched(poiResult: PoiResult?, rCode: Int) { override fun onPoiSearched(poiResult: PoiResult?, rCode: Int) {
if (rCode == AMapException.CODE_AMAP_SUCCESS) { if (rCode == AMapException.CODE_AMAP_SUCCESS) {
if (poiResult != null && poiResult.getQuery() != null) { if (poiResult != null && poiResult.getQuery() != null) {
...@@ -206,9 +193,4 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy ...@@ -206,9 +193,4 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
override fun onPoiItemSearched(p0: PoiItem?, p1: Int) { override fun onPoiItemSearched(p0: PoiItem?, p1: Int) {
} }
override fun onLocationChanged(p0: AMapLocation?) {
Log.d("song_test","有数据过来")
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment