Я разрабатываю приложение с kotlin, в нем я реализую карты Google и его API, или я получаю местоположение и все, но мне нужно, чтобы я отфильтровал определенный c тип места, это будет предопределено в Приложении, и оно будет работать так же, как при выполнении поиска, например, в больницах, и показе ближайших больниц, как бы вы выполняли этот поиск по коду?
class HomeActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarkerClickListener {
private lateinit var fusedLocationClient : FusedLocationProviderClient
private lateinit var lastLocation: Location
companion object {
private const val LOCATION_PERMISSION_REQUEST_CODE = 1
}
private lateinit var map: GoogleMap
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
val mapFragment = supportFragmentManager
.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
override fun onMapReady(googleMap: GoogleMap) {
map = googleMap
map.setOnMarkerClickListener(this)
map.uiSettings.isZoomControlsEnabled = true
setUpMap()
}
private fun setUpMap(){
if(ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION), LOCATION_PERMISSION_REQUEST_CODE)
return
}
map.isMyLocationEnabled = true
map.mapType = GoogleMap.MAP_TYPE_HYBRID
fusedLocationClient.lastLocation.addOnSuccessListener (this){location:Location ->
lastLocation = location
val currentLatLong = LatLng(location.latitude, location.longitude)
map.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLong, 16f))
}
}
override fun onMarkerClick(p0: Marker?): Boolean = false
Это код, который у меня есть, и он контролирует все на карте
Я требую, чтобы вы показывали мне подобные сайты.
Я искал "больницы", и это показывает мне маркерами больницы в округе, мне нужно, чтобы что-то подобное было видно в приложении поиск больниц в Google Maps