Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Expose ImageSource coordinates setter #11262

Merged
merged 1 commit into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ public String getUrl() {
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);
Expand All @@ -132,6 +141,8 @@ public String getUrl() {

protected native void nativeSetImage(Bitmap bitmap);

protected native void nativeSetCoordinates(LatLngQuad latLngQuad);

@Override
protected native void finalize() throws Throwable;
}
8 changes: 7 additions & 1 deletion platform/android/src/style/sources/image_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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")
);
}

Expand Down
2 changes: 2 additions & 0 deletions platform/android/src/style/sources/image_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ImageSource : public Source {

void setImage(jni::JNIEnv&, jni::Object<Bitmap>);

void setCoordinates(jni::JNIEnv&, jni::Object<LatLngQuad>);

private:
jni::Object<Source> createJavaPeer(jni::JNIEnv&);

Expand Down