Skip to content

feat: add geometry field to RenderedFeature#485

Draft
idompolo wants to merge 3 commits intojosxha:mainfrom
idompolo:feat/rendered-feature-geometry
Draft

feat: add geometry field to RenderedFeature#485
idompolo wants to merge 3 commits intojosxha:mainfrom
idompolo:feat/rendered-feature-geometry

Conversation

@idompolo
Copy link

@idompolo idompolo commented Feb 24, 2026

Summary

  • RenderedFeature currently only exposes id and properties, discarding the geometry from native queryRenderedFeatures results
  • This makes it impossible to get geographic coordinates of queried features (e.g., finding the nearest POI to camera center)
  • Adds an optional geometry field (Map<String, Object?>?) to RenderedFeature and populates it on all platforms

Changes

Platform File Approach
Interface queried_layer.dart Add geometry field to RenderedFeature
Android map_state.dart Gson.toJson(feature.geometry()) → JSON parse
iOS extensions.dart MLNFeature.coordinate{type: Point, coordinates: [lon, lat]}
Web map_geojson_feature.dart + map_state.dart Pass through JS geometry object via dartify()

Use case

final features = controller.featuresInRect(rect, layerIds: ['my-layer']);
for (final f in features) {
  final geom = f.geometry; // {type: Point, coordinates: [lon, lat]}
  if (geom != null) {
    final coords = geom['coordinates'] as List;
    final lon = (coords[0] as num).toDouble();
    final lat = (coords[1] as num).toDouble();
    // Now you can use the exact coordinates
  }
}

Test plan

  • Verified on Android with custom vector tile source (featuresInRect + featuresAtPoint)
  • iOS verification needed
  • Web verification needed
  • Backward compatible — geometry is optional, existing code unaffected

Currently, `RenderedFeature` only exposes `id` and `properties`, discarding
the geometry returned by the native `queryRenderedFeatures` API. This makes
it impossible to get the geographic coordinates of queried features without
workarounds like screen-to-geo coordinate conversion.

This commit adds an optional `geometry` field to `RenderedFeature` and
populates it on all platforms:

- **Android**: Extract geometry via `Gson.toJson(feature.geometry())`
- **iOS**: Use `MLNFeature.coordinate` to build a Point geometry
- **Web**: Pass through the JS GeoJSON `geometry` object

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
idompolo and others added 2 commits February 24, 2026 21:01
Add StyleController.setFilter(layerId, filter) to dynamically
update or clear filter expressions on existing style layers.

- platform_interface: abstract setFilter method
- Android: getLayer + setFilter via JNI Expression
- iOS: layerWithIdentifier + MLNVectorStyleLayer.predicate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.10%. Comparing base (1a0b042) to head (8f35325).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@josxha
Copy link
Owner

josxha commented Feb 28, 2026

@idompolo thanks for considering to contribute. I think that adding the geometry field is a good addition but according to the CI the changes have build errors.

@josxha josxha marked this pull request as draft February 28, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants