| | |
| | | |
| | | |
| | | object AMapKit { |
| | | |
| | | fun initLocation(context: Context, lisener: AMapLocationListener) { //初始化定位 |
| | | var mlocationClient = AMapLocationClient(context) |
| | | //初始化定位参数 |
| | |
| | | } |
| | | |
| | | fun moveCamera(aMap: AMap, start: LatLng?, end: LatLng?) { |
| | | var bounds: LatLngBounds? = null |
| | | if (start!!.latitude < end!!.latitude) |
| | | bounds = LatLngBounds(start, end) |
| | | else |
| | | bounds = LatLngBounds(end, start) |
| | | var bounds: LatLngBounds = getLatLngBounds(start!!,end!!) |
| | | val mCameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 150) |
| | | aMap.animateCamera(mCameraUpdate, object : AMap.CancelableCallback { |
| | | override fun onFinish() { |
| | |
| | | sysErr("onCancel") |
| | | } |
| | | }) |
| | | } |
| | | |
| | | fun getLatLngBounds(start: LatLng, end: LatLng): LatLngBounds { |
| | | val b = LatLngBounds.builder() |
| | | b.include(LatLng(start.latitude, start.longitude)) |
| | | b.include(LatLng(end.latitude, end.longitude)) |
| | | return b.build() |
| | | } |
| | | |
| | | fun moveCamera(aMap: AMap, start: LatLng?, end: LatLng?, padd: Int) { |
| | |
| | | } |
| | | |
| | | fun drawCricle(context: Context, aMap: AMap, latLng: LatLng,bg:Double): Circle? { |
| | | return aMap.addCircle(CircleOptions(). |
| | | center(latLng). |
| | | radius(bg). |
| | | fillColor(ContextCompat.getColor(context, R.color.l_transparent_10)). |
| | | strokeColor( Color.RED). |
| | | strokeWidth(1f)); |
| | | return aMap.addCircle( |
| | | CircleOptions().center(latLng).radius(bg) |
| | | .fillColor(ContextCompat.getColor(context, R.color.l_transparent_10)) |
| | | .strokeColor(Color.RED).strokeWidth(1f) |
| | | ); |
| | | } |
| | | |
| | | |
| | |
| | | /*** |
| | | * 逆地址编码 |
| | | */ |
| | | fun getAddressReg(context: Context,lat:Double,lon:Double,function:(RegeocodeAddress)->Unit) { |
| | | fun getAddressReg( |
| | | context: Context, |
| | | lat: Double, |
| | | lon: Double, |
| | | function: (RegeocodeAddress) -> Unit |
| | | ) { |
| | | var geocoderSearch = GeocodeSearch(context); |
| | | // 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系 |
| | | var query = RegeocodeQuery(LatLonPoint(lat,lon), 500f,GeocodeSearch.AMAP); |