Add padding support to MapSnapshotter Android (#3882)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
@@ -126,6 +126,10 @@ open class MapSnapshotter(context: Context, options: Options) {
|
||||
var region: LatLngBounds? = null
|
||||
private set
|
||||
|
||||
// only works when using region to specify the camera
|
||||
var regionPadding: IntArray = intArrayOf(0, 0, 0, 0)
|
||||
private set
|
||||
|
||||
/**
|
||||
* @return the camera position
|
||||
*/
|
||||
@@ -204,6 +208,16 @@ open class MapSnapshotter(context: Context, options: Options) {
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* @param padding of the padding of the region.
|
||||
* This is applied before the region, if region is null, it will not work
|
||||
* @return the mutated [Options]
|
||||
*/
|
||||
fun withPadding(left:Int, top:Int, right:Int, bottom:Int): Options {
|
||||
this.regionPadding = intArrayOf(left, top, right, bottom)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pixelRatio the pixel ratio to use (default: 1)
|
||||
* @return the mutated [Options]
|
||||
@@ -349,7 +363,11 @@ open class MapSnapshotter(context: Context, options: Options) {
|
||||
options.cameraPosition,
|
||||
options.showLogo,
|
||||
options.showAttribution,
|
||||
options.localIdeographFontFamily
|
||||
options.localIdeographFontFamily,
|
||||
options.regionPadding[0] / options.pixelRatio,
|
||||
options.regionPadding[1] / options.pixelRatio,
|
||||
options.regionPadding[2] / options.pixelRatio,
|
||||
options.regionPadding[3] / options.pixelRatio
|
||||
)
|
||||
}
|
||||
|
||||
@@ -394,6 +412,14 @@ open class MapSnapshotter(context: Context, options: Options) {
|
||||
@Keep
|
||||
external fun setRegion(region: LatLngBounds?)
|
||||
|
||||
/**
|
||||
* Updates the snapshotter padding with a new [IntArray]
|
||||
*
|
||||
* @param left, top, right, bottom
|
||||
*/
|
||||
@Keep
|
||||
external fun setPadding(left:Int, top:Int, right:Int, bottom:Int)
|
||||
|
||||
/**
|
||||
* Updates the snapshotter with a new style url
|
||||
*
|
||||
@@ -746,7 +772,11 @@ open class MapSnapshotter(context: Context, options: Options) {
|
||||
position: CameraPosition?,
|
||||
showLogo: Boolean,
|
||||
showAttribution: Boolean,
|
||||
localIdeographFontFamily: String?
|
||||
localIdeographFontFamily: String?,
|
||||
paddingLeft: Float,
|
||||
paddingTop: Float,
|
||||
paddingRight: Float,
|
||||
paddingBottom: Float
|
||||
)
|
||||
|
||||
@Keep
|
||||
|
||||
Reference in New Issue
Block a user