Overlay Patterns on android google map
Patterner is an android library, that draws line patterns on google map programmatically, it supports irregular shaped-polygons.
How to use
Add dependency to the Gradle:
implementation 'com.github.AmosKorir:Patterner-googlemap-patterns:Tag'
Example usage of the MapPatterner
//overlay
val groundOverlay = GMapPattern.getBitmapPolygonGround(
this,
polygonOptions,
500,
500,
R.drawable.example_pattern
)
map.addGroundOverlay(groundOverlay)
getBitmapPolygonGround returns a shaped-bitmap image ovelay of the polygon supplied.
/**
* @param context , this is the view context, it required for creating bitmap
* @param polygonOptions, this provide list of latLongs that forms the polygon
* @param width , Integer width of the required pattern
* @param height , Integer width of the required pattern
* @param drawable image resource ID
* @return Ground Overlay
*/
fun getBitmapPolygonGround(
context: Context,
polygonOptions: PolygonOptions,
width: Int,
height: Int,
drawable: Int
): GroundOverlayOptions
drawPolygonBitmap returns a shaped-bitmap of the polygon supplied.
/**
* @param context , this is the view context, it required for creating bitmap
* @param polygonOptions, this provide list of latLongs that forms the polygon
* @param width , Integer width of the required pattern
* @param height , Integer width of the required pattern
* @param drawable image resource ID
* @return Bitmap
*/
fun drawPolygonBitmap(
context: Context,
polygonOptions: PolygonOptions,
width: Int,
height: Int,
drawable: Int
): Bitmap
To run this example you need to set your map api key in local.properties file
add below line and change the value to your api key
api_map_key="AIzaSyCz75O....."