diff --git a/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.java b/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.java index df8cd851..797c0372 100644 --- a/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.java +++ b/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.java @@ -6,6 +6,8 @@ import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.bridge.WritableNativeMap; +import com.google.gson.JsonObject; + import org.maplibre.geojson.Feature; import org.maplibre.geojson.FeatureCollection; import org.maplibre.geojson.Geometry; @@ -34,11 +36,19 @@ public static WritableMap fromFeature(Feature feature) { map.putString("type", "Feature"); map.putString("id", feature.id()); - WritableMap geometry = fromGeometry(feature.geometry()); - map.putMap("geometry", geometry); + Geometry geometry = feature.geometry(); + if (geometry == null) { + map.putNull("geometry"); + } else { + map.putMap("geometry", fromGeometry(geometry)); + } - WritableMap properties = ConvertUtils.toWritableMap(feature.properties()); - map.putMap("properties", properties); + JsonObject properties = feature.properties(); + if(properties == null) { + map.putNull("properties"); + } else { + map.putMap("properties", ConvertUtils.toWritableMap(properties)); + } return map; } @@ -140,9 +150,6 @@ public static WritableArray getCoordinates(Polygon polygon) { WritableArray array = Arguments.createArray(); List> points = polygon.coordinates(); - if (points == null) { - return array; - } for (List curPoint : points) { WritableArray innerArray = Arguments.createArray();