Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti farg’ona filiali dasturiy injiniringi va raqamli iqtisodiyot fakulteti dasturiy injinering
} imgSearch.setOnClickListener {
Download 122.69 Kb.
|
MI5
}
imgSearch.setOnClickListener { val fragment = CompleteSearchFragment(object: CompleteSearchFragmentListener{ override fun onClickItem(lat: Double, long: Double) { try{ val cameraPosition = CameraPosition.Builder() .target(LatLng(lat, long)) .zoom(17f) .build() googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) marker?.position = googleMap.cameraPosition.target }catch(e: Exception){ } } }) fragment.cordianates= "${googleMap.cameraPosition.target?.longitude},${googleMap.cameraPosition.target.latitude}" fragment.show(supportFragmentManager, fragment.tag) } } override fun onMapReady(map: GoogleMap?) { googleMap = map ?: return googleMap.setOnCameraMoveListener(this) googleMap.setOnCameraMoveCanceledListener(this) googleMap.setOnCameraIdleListener(this) var latLng = LatLng(40.365618139573535, 71.78346533328295) val icon = BitmapDescriptorFactory.fromBitmap( BitmapFactory.decodeResource( this.resources, R.drawable.location_placeholder ) ) marker = googleMap.addMarker( MarkerOptions() .position(latLng) .title("Tanlangan manzil!") .icon(icon) ) val cameraPosition = CameraPosition.Builder() .target(latLng) .zoom(17f) .build() googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) getMapAddress(latLng) if (isPermissionGiven()) { googleMap.isMyLocationEnabled = true googleMap.uiSettings.isMyLocationButtonEnabled= true googleMap.uiSettings.isZoomControlsEnabled= true getCurrentLocation() } else { givePermission() } } private fun isPermissionGiven(): Boolean { return ActivityCompat.checkSelfPermission( this, android.Manifest.permission.ACCESS_FINE_LOCATION ) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( this, android.Manifest.permission.ACCESS_COARSE_LOCATION ) == PackageManager.PERMISSION_GRANTED } private fun givePermission() { ActivityCompat.requestPermissions( this, arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION), REQUEST_CHECK_SETTINGS ) } Download 122.69 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2025
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling