How to specify the size of the icon on the Marker in Google Maps V2 Android

前端 未结 5 657
温柔的废话
温柔的废话 2020-12-08 13:32

In may app i use Map from Google Maps V2 and in this map i am trying to add markers each Marker with an icon, but the marker is taking the size of the icon which is making t

5条回答
  •  再見小時候
    2020-12-08 14:19

    Kotlin version I used 0- 9 answer and used it with kotlin

    fun generateHomeMarker(context: Context): MarkerOptions {
        return MarkerOptions()
            .icon(BitmapDescriptorFactory.fromBitmap(generateSmallIcon(context)))
    }
    
    fun generateSmallIcon(context: Context): Bitmap {
        val height = 100
        val width = 100
        val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.logo)
        return Bitmap.createScaledBitmap(bitmap, width, height, false)
    }
    

提交回复
热议问题