Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Runtime Styling API - mutable GeoJsonSource #5906

Closed
sddamico opened this issue Aug 8, 2016 · 11 comments
Closed

Runtime Styling API - mutable GeoJsonSource #5906

sddamico opened this issue Aug 8, 2016 · 11 comments
Assignees
Labels
Android Mapbox Maps SDK for Android GL JS parity For feature parity with Mapbox GL JS runtime styling

Comments

@sddamico
Copy link

sddamico commented Aug 8, 2016

This is really a feature request for two methods:

  1. MapboxMap#getSource(String sourceId)
  2. GeoJsonSource#setData(String rawJson) or, better, #setData(Object jsonObject) so that the caller doesn't need to serialize to String every time.

Intended use here is the ability to dynamically update GeoJson sources. Specifically, this includes things like adding/removing Features from FeatureCollections, etc. and, also, being able to modify the data in sources that are pre-defined in the map style.

Currently, I'm needing to removeSource() and then addSource() when I want to update source data.

@sddamico
Copy link
Author

sddamico commented Aug 8, 2016

Tangentially, adding a first-party GeoJson implementation might be useful. I've started adapting https://github.com/filosganga/geogson by removing the guava dependency in my own project, but I can see others finding use for it.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Aug 8, 2016
@ivovandongen
Copy link
Contributor

@sddamico Thanks for the report.

The api around sources is immutable on purpose ATM as the underlying resources are immutable. Adding a getter + setData() would still need to do add and remove the source.

Concerning the gson support. Currently we're bringing in GSon specifically for GeoJson in #5869 from https://github.com/mapbox/mapbox-java. I like your idea and I added a ticket for it: #5941

@ivovandongen ivovandongen changed the title Android Local Styling API, GeoJsonSource additions Runtime Styling API - mutable GeoJsonSource Aug 11, 2016
@sddamico
Copy link
Author

Great! Thanks @ivovandongen.

Interesting choice on the immutable sources, I was observing the js api and the geojson source there has a setData(). What was the reasoning there?

Somehow I missed the GeoJSON implementation in mapbox-java, I'll be moving my project over to that shortly.

@ivovandongen
Copy link
Contributor

@sddamico Digging further into this, I see now that it should be possible to add a getter for the source and setters for the data/url. Seems like I missed that in the initial implementation.

Somehow I missed the GeoJSON implementation in mapbox-java, I'll be moving my project over to that shortly.

The dependency on mapbox-java is new since #6012 .

@sddamico
Copy link
Author

Awesome, thanks!

@1ec5
Copy link
Contributor

1ec5 commented Aug 25, 2016

Tracking the iOS/macOS equivalent in #6159.

@ivovandongen
Copy link
Contributor

ivovandongen commented Sep 5, 2016

We need to wait on #5701 #6264 for this as the changes in the source are not reflected on the map at this time.

@jfirebaugh
Copy link
Contributor

#setData(Object jsonObject)

Agreed that this signature would be ideal; it requires #5623.

@ivovandongen
Copy link
Contributor

@jfirebaugh For java, Object parameters make less sense. I've added a setter for GeoJson types to accomplish the same thing here.

Besides untyped parameters not being common in java, it would require some nasty reflection from jni as there is no way to access an Object as a map like in some other languages.

@jfirebaugh
Copy link
Contributor

Sorry, I should have been more clear. My point was, ideally neither the API nor implementation require a round trip through stringified JSON. The function signature you linked to looks good, but I want to avoid the features.toJson() in the implementation.

@tobrun
Copy link
Member

tobrun commented Sep 20, 2016

Core integration has landed with 7df9a21

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android GL JS parity For feature parity with Mapbox GL JS runtime styling
Projects
None yet
Development

No branches or pull requests

5 participants