[android] expose ImageSource coordinates setter (#11262)

This commit is contained in:
Łukasz Paczos
2018-02-22 10:01:48 +01:00
committed by GitHub
parent ebb72b9002
commit fcf5fa6bbb
3 changed files with 20 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

@@ -45,6 +45,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::Object<Source> ImageSource::createJavaPeer(jni::JNIEnv& env) {
@@ -66,7 +71,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

@@ -30,6 +30,8 @@ public:
void setImage(jni::JNIEnv&, jni::Object<Bitmap>);
void setCoordinates(jni::JNIEnv&, jni::Object<LatLngQuad>);
private:
jni::Object<Source> createJavaPeer(jni::JNIEnv&);