fix: query CoreOnly weather layer presence
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
OpenAI Codex
2026-09-08 19:16:53 +08:00
parent 2d2375cd53
commit 2ea9339e41
14 changed files with 404 additions and 30 deletions

View File

@@ -1113,6 +1113,10 @@ jni::Local<jni::Object<Layer>> NativeMapView::getLayer(JNIEnv& env, const jni::S
return LayerManagerAndroid::get()->createJavaLayerPeer(env, *coreLayer);
}
jni::jboolean NativeMapView::hasStyleLayer(JNIEnv& env, const jni::String& layerId) {
return map->getStyle().getLayer(jni::Make<std::string>(env, layerId)) != nullptr;
}
jni::jboolean NativeMapView::setStyleLayerFloatProperty(JNIEnv& env,
const jni::String& layerId,
const jni::String& propertyName,
@@ -1496,6 +1500,10 @@ jni::Local<jni::Object<Source>> NativeMapView::getSource(JNIEnv& env, const jni:
return jni::NewLocal(env, Source::peerForCoreSource(env, *coreSource, *rendererFrontend, *map));
}
jni::jboolean NativeMapView::hasStyleSource(JNIEnv& env, const jni::String& sourceId) {
return map->getStyle().getSource(jni::Make<std::string>(env, sourceId)) != nullptr;
}
void NativeMapView::addSource(JNIEnv& env, const jni::Object<Source>& obj, jlong sourcePtr) {
assert(sourcePtr != 0);
@@ -1728,6 +1736,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
METHOD(&NativeMapView::getLight, "nativeGetLight"),
METHOD(&NativeMapView::getLayers, "nativeGetLayers"),
METHOD(&NativeMapView::getLayer, "nativeGetLayer"),
METHOD(&NativeMapView::hasStyleLayer, "nativeHasStyleLayer"),
METHOD(&NativeMapView::setStyleLayerFloatProperty, "nativeSetStyleLayerFloatProperty"),
METHOD(&NativeMapView::setStyleLayerVisibility, "nativeSetStyleLayerVisibility"),
METHOD(&NativeMapView::setRasterParticleColors, "nativeSetRasterParticleColors"),
@@ -1750,6 +1759,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
METHOD(&NativeMapView::removeLayer, "nativeRemoveLayer"),
METHOD(&NativeMapView::getSources, "nativeGetSources"),
METHOD(&NativeMapView::getSource, "nativeGetSource"),
METHOD(&NativeMapView::hasStyleSource, "nativeHasStyleSource"),
METHOD(&NativeMapView::addSource, "nativeAddSource"),
METHOD(&NativeMapView::removeSource, "nativeRemoveSource"),
METHOD(&NativeMapView::addImage, "nativeAddImage"),

View File

@@ -281,6 +281,7 @@ public:
jni::Local<jni::Array<jni::Object<Layer>>> getLayers(JNIEnv&);
jni::Local<jni::Object<Layer>> getLayer(JNIEnv&, const jni::String&);
jni::jboolean hasStyleLayer(JNIEnv&, const jni::String&);
jni::jboolean setStyleLayerFloatProperty(JNIEnv&, const jni::String&, const jni::String&, jni::jfloat);
jni::jboolean setStyleLayerVisibility(JNIEnv&, const jni::String&, jni::jboolean);
jni::jboolean setRasterParticleColors(JNIEnv&, const jni::String&, const jni::Array<jni::jfloat>&, const jni::Array<jni::jfloat>&);
@@ -313,6 +314,7 @@ public:
jni::Local<jni::Array<jni::Object<Source>>> getSources(JNIEnv&);
jni::Local<jni::Object<Source>> getSource(JNIEnv&, const jni::String&);
jni::jboolean hasStyleSource(JNIEnv&, const jni::String&);
void addSource(JNIEnv&, const jni::Object<Source>&, jlong nativePtr);

View File

@@ -179,6 +179,24 @@ public final class MapLibreMap {
}
}
/**
* Returns whether the fully loaded Core style contains {@code layerId}.
*
* This intentionally queries Core by id instead of materialising a Java {@link
* org.maplibre.android.style.layers.Layer} peer. It therefore also supports layer types that
* are registered Core-only.
*/
public boolean hasStyleLayer(@NonNull String layerId) {
return nativeMapView.hasStyleLayer(layerId);
}
/**
* Returns whether the fully loaded Core style contains {@code sourceId}.
*/
public boolean hasStyleSource(@NonNull String sourceId) {
return nativeMapView.hasStyleSource(sourceId);
}
/**
* Replaces this map's style-scoped weather facade. The caller must have already verified the
* configured source and layers in the currently loaded style.

View File

@@ -139,6 +139,8 @@ interface NativeMap {
Layer getLayer(String layerId);
boolean hasStyleLayer(@NonNull String layerId);
boolean setStyleLayerFloatProperty(String layerId, String propertyName, float value);
boolean setStyleLayerVisibility(String layerId, boolean visible);
@@ -182,6 +184,8 @@ interface NativeMap {
Source getSource(@NonNull String sourceId);
boolean hasStyleSource(@NonNull String sourceId);
boolean removeSource(@NonNull String sourceId);
boolean removeSource(@NonNull Source source);

View File

@@ -950,6 +950,11 @@ final class NativeMapView implements NativeMap {
return nativeGetLayer(layerId);
}
@Override
public boolean hasStyleLayer(@NonNull String layerId) {
return !checkState("hasStyleLayer") && nativeHasStyleLayer(layerId);
}
@Override
public boolean setStyleLayerFloatProperty(String layerId, String propertyName, float value) {
return !checkState("setStyleLayerFloatProperty")
@@ -1116,6 +1121,11 @@ final class NativeMapView implements NativeMap {
return nativeGetSource(sourceId);
}
@Override
public boolean hasStyleSource(@NonNull String sourceId) {
return !checkState("hasStyleSource") && nativeHasStyleSource(sourceId);
}
@Override
public void addSource(@NonNull Source source) {
if (checkState("addSource")) {
@@ -1758,6 +1768,9 @@ final class NativeMapView implements NativeMap {
@Keep
private native Layer nativeGetLayer(String layerId);
@Keep
private native boolean nativeHasStyleLayer(String layerId);
@Keep
private native boolean nativeSetStyleLayerFloatProperty(String layerId, String propertyName, float value);
@@ -1811,6 +1824,9 @@ final class NativeMapView implements NativeMap {
@Keep
private native Source nativeGetSource(String sourceId);
@Keep
private native boolean nativeHasStyleSource(String sourceId);
@Keep
private native void nativeAddSource(Source source, long sourcePtr) throws CannotAddSourceException;

View File

@@ -1 +1 @@
13.4.1-step060d
13.4.1-step060e