MapmyIndia Scalebar Plugin can be used to add a scale bar on map view to determine distance based on zoom level.
Initalize ScaleBarPlugin in onMapReady()
Add below dependency in app level build.gradle file
implementation 'com.mapmyindia.sdk:scalebar-plugin:0.2.0'
ScaleBarPlugin scaleBarPlugin = new ScaleBarPlugin(mapView, mapmyIndiaMap);
ScaleBarOptions scaleBarOptions = new ScaleBarOptions(this)
.setTextColor(android.R.color.black)
.setTextSize(40f)
.setBarHeight(5f)
scaleBarPlugin.create(scaleBarOptions);
val scaleBarPlugin = ScaleBarPlugin(mapView, mapmyIndiaMap!!)
val scalebarOptions = ScaleBarOptions(this)
.setTextColor(android.R.color.black)
.setTextSize(40f)
.setBarHeight(5f)
scaleBarPlugin.create(scalebarOptions)
You can use ScaleBarOptions
to set the following properties:
setPrimaryColor(Integer)
: To set primary color of scalebarsetSecondaryColor(Integer)
: To set secondary color of scalebarsetTextColor(Integer)
: To set the text color of text in scalebarsetTextSize(float)
: To set the text size in scalebarsetBarHeight(float)
: To set the height of scalebarsetBorderWidth(float)
: To set border width of scalebarsetRefreshInterval(Integer)
: To set refresh interval of scalebarsetMarginTop(Integer)
: To set top margin of scalebarsetMarginLeft(Integer)
: To set left margin of scalebarsetTextBarMargin(float)
: To set margin between text and scalebarsetMaxWidthRatio(float)
: To set width ratio of scalebarsetShowTextBorder(Boolean)
: To show text border or notsetMetricUnit(Boolean)
: To use metric unitsetTextBorderWidth(float)
: To set border width of text