0

In MapBox-GL-JS you can easily draw figures on a map with the addLayer() method by passing it a JSON object that adheres to the Mapbox style specification. This is super convenient and easy.

For example see the map.addLayer() call here:

How to add a GeoJSON line

I am now working with the Mapbox GL Native (Android SDK) and I have been scouring the documentation and examples for a similar method but have come up empty. All the examples show how to programmatically interact with the style but nothing where I can just pass it a style JSON object and have it render the whole thing.

I must be missing something simple.

Is there an analogous method available in Mapbox GL Native?

Yermo Lamers
  • 1,911
  • 14
  • 25

1 Answers1

1

https://docs.mapbox.com/android/maps/examples/draw-a-geojson-line/ is the analogous Android SDK example.

I believe you can't just pass it a JSON object (like addLayer, per the Mapbox Style Spec) since Android/iOS aren't programmed in JavaScript, so have no concept of a JSON object. Hence why you need to construct a native object like your JSON in the native language, like in the linked example.

AndrewHarvey
  • 2,867
  • 11
  • 21