fix: route WeatherColor opacity through typed API
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
OpenAI Codex
2026-09-08 22:14:33 +08:00
parent 3f9f2456d6
commit c91af16825
14 changed files with 100 additions and 11 deletions

View File

@@ -1176,6 +1176,17 @@ jni::jboolean NativeMapView::setStyleLayerFloatProperty(JNIEnv& env,
return true;
}
jni::jboolean NativeMapView::setWeatherColorOpacity(JNIEnv& env,
const jni::String& layerId,
const jni::jfloat opacity) {
if (!std::isfinite(opacity)) return false;
auto* layer = dynamic_cast<mbgl::style::WeatherColorLayer*>(
map->getStyle().getLayer(jni::Make<std::string>(env, layerId)));
if (!layer) return false;
layer->setOpacity(opacity);
return true;
}
jni::jboolean NativeMapView::setStyleLayerVisibility(JNIEnv& env, const jni::String& layerId, const jni::jboolean visible) {
auto* layer = map->getStyle().getLayer(jni::Make<std::string>(env, layerId));
if (!layer) return false;
@@ -1738,6 +1749,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
METHOD(&NativeMapView::getLayer, "nativeGetLayer"),
METHOD(&NativeMapView::hasStyleLayer, "nativeHasStyleLayer"),
METHOD(&NativeMapView::setStyleLayerFloatProperty, "nativeSetStyleLayerFloatProperty"),
METHOD(&NativeMapView::setWeatherColorOpacity, "nativeSetWeatherColorOpacity"),
METHOD(&NativeMapView::setStyleLayerVisibility, "nativeSetStyleLayerVisibility"),
METHOD(&NativeMapView::setRasterParticleColors, "nativeSetRasterParticleColors"),
METHOD(&NativeMapView::setRasterParticleColor, "nativeSetRasterParticleColor"),

View File

@@ -283,6 +283,7 @@ public:
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 setWeatherColorOpacity(JNIEnv&, 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>&);
jni::jboolean setRasterParticleColor(JNIEnv&, const jni::String&, const jni::Array<jni::jfloat>&);

View File

@@ -342,6 +342,11 @@ public final class MapLibreMap {
return nativeMapView.setStyleLayerFloatProperty(layerId, propertyName, value);
}
/** Updates the opacity of an existing Core-owned WeatherColor layer without a Java Layer peer. */
public boolean setWeatherColorOpacity(String layerId, float opacity) {
return nativeMapView.setWeatherColorOpacity(layerId, opacity);
}
/** Low-frequency style visibility used by the typed WeatherRuntime facade. */
public boolean setStyleLayerVisibility(String layerId, boolean visible) {
return nativeMapView.setStyleLayerVisibility(layerId, visible);

View File

@@ -143,6 +143,8 @@ interface NativeMap {
boolean setStyleLayerFloatProperty(String layerId, String propertyName, float value);
boolean setWeatherColorOpacity(String layerId, float opacity);
boolean setStyleLayerVisibility(String layerId, boolean visible);
boolean setRasterParticleColors(String layerId, float[] particleColor, float[] trailColor);

View File

@@ -961,6 +961,11 @@ final class NativeMapView implements NativeMap {
&& nativeSetStyleLayerFloatProperty(layerId, propertyName, value);
}
@Override
public boolean setWeatherColorOpacity(String layerId, float opacity) {
return !checkState("setWeatherColorOpacity") && nativeSetWeatherColorOpacity(layerId, opacity);
}
public boolean setStyleLayerVisibility(String layerId, boolean visible) {
return !checkState("setStyleLayerVisibility") && nativeSetStyleLayerVisibility(layerId, visible);
}
@@ -1774,6 +1779,8 @@ final class NativeMapView implements NativeMap {
@Keep
private native boolean nativeSetStyleLayerFloatProperty(String layerId, String propertyName, float value);
@Keep private native boolean nativeSetWeatherColorOpacity(String layerId, float opacity);
@Keep private native boolean nativeSetStyleLayerVisibility(String layerId, boolean visible);
@Keep private native boolean nativeSetRasterParticleColors(String layerId, float[] particleColor, float[] trailColor);
@Keep private native boolean nativeSetRasterParticleColor(String layerId, float[] particleColor);

View File

@@ -101,7 +101,7 @@ public final class WeatherRuntime {
public CommandResult setForecastTime(long timestampMs) { requireEnabled(); return result(timestampMs >= 0 && map.seekRasterArraySourceTimelineToTimestamp(config.sourceId, timestampMs)); }
public CommandResult setPlaybackState(@NonNull PlaybackState playback) { requireEnabled(); CommandResult result = result(map.controlRasterArraySourceTimeline(config.sourceId, playback == PlaybackState.PLAY ? 0 : 1, 0f)); if (result == CommandResult.ACCEPTED) { playbackState = playback; cancelCadenceWake(); scheduleCadenceWake(); } return result; }
public CommandResult setPlaybackSpeed(@NonNull PlaybackSpeed speed) { requireEnabled(); return result(map.controlRasterArraySourceTimeline(config.sourceId, 2, speed.value)); }
public CommandResult setWeatherColorOpacity(float opacity) { return disposed ? CommandResult.REJECTED : result(Float.isFinite(opacity) && map.setStyleLayerFloatProperty(config.weatherColorLayerId, "weather-color-opacity", opacity)); }
public CommandResult setWeatherColorOpacity(float opacity) { return disposed ? CommandResult.REJECTED : result(Float.isFinite(opacity) && map.setWeatherColorOpacity(config.weatherColorLayerId, opacity)); }
public CommandResult setParticleCount(int count) { return setParticleFloat("raster-particle-particle-count", count); }
public CommandResult setParticleLineWidth(float width) { return setParticleFloat("raster-particle-line-width", width); }
public CommandResult setParticleLength(float length) { return setParticleFloat("raster-particle-particle-length", length); }

View File

@@ -1 +1 @@
13.4.1-step060e
13.4.1-step060f