-
-
Save AlexPrestonSB/2cb4d2b79b339dd3cc1f0b34c90518d4 to your computer and use it in GitHub Desktop.
Shows the implementation for your CustomViewHolderClass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val mapView = view.map_gchat_me | |
/** Initialises the MapView by calling its lifecycle methods */ | |
init { | |
with(mapView) { | |
// Initialise the MapView | |
onCreate(null) | |
// Set the map ready callback to receive the GoogleMap object | |
getMapAsync(this@MyLocationHolder) | |
} | |
} | |
fun bindView(context: Context, message: UserMessage, isNewDay: Boolean) { | |
this.context = context | |
val cords = message.message.split(",") | |
longitude = cords[0].toDouble() | |
latitude = cords[1].toDouble() | |
latLng = LatLng(latitude, longitude) | |
setLocation() | |
} | |
override fun onMapReady(googleMap: GoogleMap?) { | |
MapsInitializer.initialize(context.applicationContext) | |
map = googleMap ?: return | |
setLocation() | |
} | |
private fun setLocation() { | |
if (!::map.isInitialized) return | |
with(map) { | |
moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 11f)) | |
addMarker(MarkerOptions().position(latLng)) | |
mapType = GoogleMap.MAP_TYPE_NORMAL | |
} | |
mapView.onResume() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment