Last active
October 31, 2022 04:54
-
-
Save byansanur/33d15f8c096a1d719afa212390cc2e3c to your computer and use it in GitHub Desktop.
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
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