| | |
| | | import com.amap.api.navi.model.AMapCalcRouteResult |
| | | import com.amap.api.navi.model.AMapNaviPath |
| | | import com.amap.api.navi.model.NaviPoi |
| | | import com.amap.api.services.core.AMapException |
| | | import com.amap.api.services.core.LatLonPoint |
| | | import com.amap.api.services.district.DistrictSearch |
| | | import com.amap.api.services.district.DistrictSearchQuery |
| | |
| | | } |
| | | |
| | | /*** |
| | | * 周边检索地址 |
| | | * 逆地理编码(坐标转地址) |
| | | * @param lat |
| | | * @param lng |
| | | */ |
| | |
| | | context: Context, |
| | | lat: Double, |
| | | lng: Double, |
| | | var1: PoiSearch.OnPoiSearchListener |
| | | block: (lat: Double, lng: Double, regeocodeAddress: RegeocodeAddress) -> Unit |
| | | ) { |
| | | val query = PoiSearch.Query("", "", "") |
| | | // val query = PoiSearch.Query("", ctgr, "") |
| | | // query.pageSize = 10 // 设置每页最多返回多少条poiitem |
| | | // query.pageNum = 1 //设置查询页码 |
| | | val poiSearch = PoiSearch(context, query) |
| | | poiSearch.setOnPoiSearchListener(var1) |
| | | poiSearch.bound = PoiSearch.SearchBound(LatLonPoint(lat, lng), 5000) //设置周边搜索的中心点以及半径 |
| | | poiSearch.searchPOIAsyn() |
| | | val geocodeSearch = GeocodeSearch(context) |
| | | geocodeSearch.setOnGeocodeSearchListener(object : GeocodeSearch.OnGeocodeSearchListener { |
| | | override fun onRegeocodeSearched(result: RegeocodeResult?, rCode: Int) { |
| | | if (rCode == AMapException.CODE_AMAP_SUCCESS) { |
| | | if (result?.regeocodeAddress?.formatAddress != null) { |
| | | block.invoke(lat, lng, result.regeocodeAddress) |
| | | } |
| | | } |
| | | } |
| | | |
| | | override fun onGeocodeSearched(p0: GeocodeResult?, p1: Int) { |
| | | |
| | | } |
| | | }) |
| | | // 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系 |
| | | val query = RegeocodeQuery(LatLonPoint(lat, lng), 50f, GeocodeSearch.AMAP) |
| | | geocodeSearch.getFromLocationAsyn(query); |
| | | } |
| | | |
| | | /*** |
| New file |
| | |
| | | package com.fangxinxing.xxfxx.bean |
| | | |
| | | import android.os.Parcelable |
| | | import kotlinx.android.parcel.Parcelize |
| | | |
| | | //目的地信息 |
| | | @Parcelize |
| | | data class DestinationInfo( |
| | | var lat: Double, |
| | | var lng: Double, |
| | | var province: String, |
| | | var city: String, |
| | | var cityCode: String, |
| | | var district: String, |
| | | var address: String, |
| | | var adCode: String, |
| | | ) : Parcelable { |
| | | |
| | | } |
| | |
| | | import androidx.core.content.ContextCompat |
| | | import androidx.recyclerview.widget.LinearLayoutManager |
| | | import cn.sinata.xldutils.utils.DensityUtil |
| | | import com.amap.api.services.core.PoiItem |
| | | import com.fangxinxing.xxfxx.R |
| | | import com.fangxinxing.xxfxx.bean.AllCarBean |
| | | import com.fangxinxing.xxfxx.bean.DestinationInfo |
| | | import com.fangxinxing.xxfxx.ui.adapter.ColorOnlyAdapter |
| | | import com.fangxinxing.xxfxx.ui.adapter.ServerModeAdapter |
| | | import com.fangxinxing.xxfxx.ui.adapter.ServerOnlyAdapter |
| | |
| | | //获取设置乘客目的地弹窗 |
| | | fun getSetPassengerDestinationDialog( |
| | | context: Context, |
| | | item: PoiItem, |
| | | item: DestinationInfo, |
| | | clickSure: () -> Unit |
| | | ): Dialog { |
| | | val dialog = getDialog(context, R.layout.dialog_set_passenger_destination) |
| | | val view = getView(dialog) |
| | | view.tv_address.text = item.provinceName + item.cityName + item.adName + item.title |
| | | view.tv_address.text = item.address |
| | | view.iv_dialog_close.setOnClickListener { dialog.dismiss() } |
| | | view.tv_dialog_cancel.setOnClickListener { dialog.dismiss() } |
| | | view.tv_dialog_confirm.setOnClickListener { |
| | |
| | | import com.fangxinxing.xxfxx.base.MyBaseActivity |
| | | import com.fangxinxing.xxfxx.base.gaode.AMapKit |
| | | import com.fangxinxing.xxfxx.bean.AddressInfo |
| | | import com.fangxinxing.xxfxx.bean.DestinationInfo |
| | | import com.fangxinxing.xxfxx.utils.clickDelay |
| | | import kotlinx.android.synthetic.main.activity_set_destination.iv_reset_map |
| | | import kotlinx.android.synthetic.main.activity_set_destination.map_view |
| | |
| | | intent.getStringExtra("title") |
| | | } |
| | | var marker: Marker? = null |
| | | |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | | map_view.onCreate(savedInstanceState) |
| | |
| | | AMapKit.searchAddress( |
| | | this, |
| | | position.latitude, |
| | | position.longitude, |
| | | object : PoiSearch.OnPoiSearchListener { |
| | | override fun onPoiItemSearched(p0: PoiItem?, p1: Int) { |
| | | |
| | | } |
| | | |
| | | override fun onPoiSearched(p0: PoiResult?, p1: Int) { |
| | | if (isDestroy || isFinishing) { |
| | | return |
| | | } |
| | | if (p0?.pois!!.size > 0) { |
| | | setData(p0.pois.first()) |
| | | } |
| | | } |
| | | }) |
| | | position.longitude |
| | | ) { lat, lng, regeocodeAddress -> |
| | | setData( |
| | | DestinationInfo( |
| | | lat, |
| | | lng, |
| | | regeocodeAddress.province, |
| | | regeocodeAddress.city, |
| | | regeocodeAddress.cityCode, |
| | | regeocodeAddress.district, |
| | | regeocodeAddress.formatAddress, |
| | | regeocodeAddress.adCode, |
| | | ) |
| | | ) |
| | | } |
| | | } |
| | | |
| | | //设置数据 |
| | | private fun setData(item: PoiItem) { |
| | | tv_site.text = item.adName |
| | | tv_site_detail.text = item.title |
| | | tv_city_name.text = item.cityName |
| | | private fun setData(item: DestinationInfo) { |
| | | tv_site.text = item.district |
| | | tv_site_detail.text = item.address |
| | | tv_city_name.text = item.city |
| | | marker?.`object` = item |
| | | } |
| | | |
| | |
| | | startActivity<SearchAddressActivity>("cityName" to tv_city_name.text.toString()) |
| | | } |
| | | tv_sure.clickDelay { |
| | | (marker?.`object` as? PoiItem)?.also { |
| | | (marker?.`object` as? DestinationInfo)?.also { |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.SELECT_ADDRESS, gson.toJson(it))) |
| | | } |
| | | finish() |
| | |
| | | import com.amap.api.maps.model.Marker |
| | | import com.amap.api.maps.model.MarkerOptions |
| | | import com.amap.api.maps.model.Polyline |
| | | import com.amap.api.services.core.PoiItem |
| | | import com.fangxinxing.xxfxx.R |
| | | import com.fangxinxing.xxfxx.base.BaseEvent |
| | | import com.fangxinxing.xxfxx.base.MyApplication |
| | |
| | | import com.fangxinxing.xxfxx.base.gaode.AMapKit.getTimeType |
| | | import com.fangxinxing.xxfxx.base.gaode.AMapKit.initMap |
| | | import com.fangxinxing.xxfxx.base.gaode.AMapKit.moveCamera |
| | | import com.fangxinxing.xxfxx.bean.DestinationInfo |
| | | import com.fangxinxing.xxfxx.bean.OrderBean |
| | | import com.fangxinxing.xxfxx.bean.OrderSimpleData |
| | | import com.fangxinxing.xxfxx.bean.PassengersLocationInfo |
| | |
| | | } |
| | | |
| | | //显示设置乘客目的地弹窗 |
| | | private fun showSetPassengerDestinationDialog(item: PoiItem) { |
| | | private fun showSetPassengerDestinationDialog(item: DestinationInfo) { |
| | | DialogUtil.getSetPassengerDestinationDialog(this, item) { |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["endLat"] = item.latLonPoint.latitude |
| | | map["endLon"] = item.latLonPoint.longitude |
| | | map["endAddress"] = item.provinceName + item.cityName + item.adName + item.title |
| | | map["endLat"] = item.lat |
| | | map["endLon"] = item.lng |
| | | map["endAddress"] = item.address |
| | | callNet(Api.setDestination, map) { |
| | | callOrder() |
| | | } |
| | |
| | | } |
| | | |
| | | BaseEvent.SELECT_ADDRESS -> { |
| | | val info = gson.fromJson(event.msg, PoiItem::class.java) |
| | | val info = gson.fromJson(event.msg, DestinationInfo::class.java) |
| | | showSetPassengerDestinationDialog(info) |
| | | } |
| | | } |