Skip to content

Instantly share code, notes, and snippets.

@byansanur
Last active October 31, 2022 04:54
Show Gist options
  • Save byansanur/33d15f8c096a1d719afa212390cc2e3c to your computer and use it in GitHub Desktop.
Save byansanur/33d15f8c096a1d719afa212390cc2e3c to your computer and use it in GitHub Desktop.
for (story in it.data?.listStory!!) {
val latLon = LatLng(story.lat!!, story.lon!!)
Glide.with(requireContext())
.asBitmap()
.load(story.photoUrl)
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
val scale = requireContext().resources.displayMetrics.density
val pixels = (50 * scale + 0.5f).toInt()
val bitmap = Bitmap.createScaledBitmap(resource, pixels, pixels, true)
gMap.addMarker(MarkerOptions()
.position(latLon)
.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
.anchor(0.5f, 1F)
)?.tag = story
}
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment