[android] expose ImageSource coordinates setter (#11262)

This commit is contained in:
Łukasz Paczos
2018-02-22 10:01:48 +01:00
committed by Tobrun
parent 7623ed99bc
commit 0fe1219bfd
3 changed files with 19 additions and 1 deletions

View File

@@ -124,6 +124,15 @@ public class ImageSource extends Source {
return nativeGetUrl();
}
/**
* Updates the latitude and longitude of the four corners of the image
*
* @param latLngQuad latitude and longitude of the four corners of the image
*/
public void setCoordinates(LatLngQuad latLngQuad) {
nativeSetCoordinates(latLngQuad);
}
protected native void initialize(String layerId, LatLngQuad payload);
protected native void nativeSetUrl(String url);
@@ -132,6 +141,8 @@ public class ImageSource extends Source {
protected native void nativeSetImage(Bitmap bitmap);
protected native void nativeSetCoordinates(LatLngQuad latLngQuad);
@Override
protected native void finalize() throws Throwable;
}

View File

@@ -43,6 +43,11 @@ namespace android {
source.as<mbgl::style::ImageSource>()->setImage(Bitmap::GetImage(env, bitmap));
}
void ImageSource::setCoordinates(jni::JNIEnv& env, jni::Object<LatLngQuad> coordinatesObject) {
source.as<mbgl::style::ImageSource>()->setCoordinates(
LatLngQuad::getLatLngArray(env, coordinatesObject));
}
jni::Class<ImageSource> ImageSource::javaClass;
jni::jobject* ImageSource::createJavaPeer(jni::JNIEnv& env) {
@@ -64,7 +69,8 @@ namespace android {
"finalize",
METHOD(&ImageSource::setURL, "nativeSetUrl"),
METHOD(&ImageSource::getURL, "nativeGetUrl"),
METHOD(&ImageSource::setImage, "nativeSetImage")
METHOD(&ImageSource::setImage, "nativeSetImage"),
METHOD(&ImageSource::setCoordinates, "nativeSetCoordinates")
);
}

View File

@@ -29,6 +29,7 @@ public:
jni::String getURL(jni::JNIEnv&);
void setImage(jni::JNIEnv&, jni::Object<Bitmap>);
void setCoordinates(jni::JNIEnv&, jni::Object<LatLngQuad>);
jni::jobject* createJavaPeer(jni::JNIEnv&);