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:
@@ -25,7 +25,11 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
|
||||
const jni::Object<CameraPosition>& position,
|
||||
jni::jboolean _showLogo,
|
||||
jni::jboolean _showAttribution,
|
||||
const jni::String& _localIdeographFontFamily)
|
||||
const jni::String& _localIdeographFontFamily,
|
||||
jni::jfloat paddingLeft,
|
||||
jni::jfloat paddingTop,
|
||||
jni::jfloat paddingRight,
|
||||
jni::jfloat paddingBottom)
|
||||
: javaPeer(_env, _obj),
|
||||
pixelRatio(_pixelRatio) {
|
||||
// Get a reference to the JavaVM for callbacks
|
||||
@@ -57,6 +61,10 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
|
||||
}
|
||||
|
||||
if (region) {
|
||||
snapshotter->setPadding({static_cast<double>(paddingTop),
|
||||
static_cast<double>(paddingLeft),
|
||||
static_cast<double>(paddingBottom),
|
||||
static_cast<double>(paddingRight)});
|
||||
snapshotter->setRegion(LatLngBounds::getLatLngBounds(_env, region));
|
||||
}
|
||||
|
||||
@@ -138,6 +146,11 @@ void MapSnapshotter::setRegion(JNIEnv& env, const jni::Object<LatLngBounds>& reg
|
||||
snapshotter->setRegion(LatLngBounds::getLatLngBounds(env, region));
|
||||
}
|
||||
|
||||
void MapSnapshotter::setPadding(JNIEnv&, jni::jint left, jni::jint top, jni::jint right, jni::jint bottom) {
|
||||
snapshotter->setPadding(
|
||||
{static_cast<double>(top), static_cast<double>(left), static_cast<double>(bottom), static_cast<double>(right)});
|
||||
}
|
||||
|
||||
// Private methods //
|
||||
|
||||
void MapSnapshotter::activateFilesource(JNIEnv& env) {
|
||||
@@ -330,7 +343,11 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) {
|
||||
const jni::Object<CameraPosition>&,
|
||||
jni::jboolean,
|
||||
jni::jboolean,
|
||||
const jni::String&>,
|
||||
const jni::String&,
|
||||
jni::jfloat,
|
||||
jni::jfloat,
|
||||
jni::jfloat,
|
||||
jni::jfloat>,
|
||||
"nativeInitialize",
|
||||
"finalize",
|
||||
METHOD(&MapSnapshotter::setStyleUrl, "setStyleUrl"),
|
||||
@@ -345,6 +362,7 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&MapSnapshotter::setSize, "setSize"),
|
||||
METHOD(&MapSnapshotter::setCameraPosition, "setCameraPosition"),
|
||||
METHOD(&MapSnapshotter::setRegion, "setRegion"),
|
||||
METHOD(&MapSnapshotter::setPadding, "setPadding"),
|
||||
METHOD(&MapSnapshotter::start, "nativeStart"),
|
||||
METHOD(&MapSnapshotter::cancel, "nativeCancel"));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,11 @@ public:
|
||||
const jni::Object<CameraPosition>& position,
|
||||
jni::jboolean showLogo,
|
||||
jni::jboolean _showAttribution,
|
||||
const jni::String& localIdeographFontFamily);
|
||||
const jni::String& localIdeographFontFamily,
|
||||
jni::jfloat paddingLeft,
|
||||
jni::jfloat paddingTop,
|
||||
jni::jfloat paddingRight,
|
||||
jni::jfloat paddingBottom);
|
||||
|
||||
virtual ~MapSnapshotter() override;
|
||||
|
||||
@@ -49,6 +53,8 @@ public:
|
||||
|
||||
void setRegion(JNIEnv&, const jni::Object<LatLngBounds>& region);
|
||||
|
||||
void setPadding(JNIEnv&, jni::jint left, jni::jint top, jni::jint right, jni::jint bottom);
|
||||
|
||||
void start(JNIEnv&);
|
||||
|
||||
void cancel(JNIEnv&);
|
||||
|
||||
Reference in New Issue
Block a user