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

Runtime Styling API - mutable GeoJsonSource #5906

Closed

Description

@sddamico

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.

Activity

  1. sddamico commented on Aug 8, 2016

    @sddamico
    Author

    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.

  2. added
    Android
    on Aug 8, 2016
  3. ivovandongen commented on Aug 11, 2016

    @ivovandongen
    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

  4. changed the title [-]Android Local Styling API, GeoJsonSource additions[/-] [+]Runtime Styling API - mutable GeoJsonSource[/+] on Aug 11, 2016
  5. sddamico commented on Aug 16, 2016

    @sddamico
    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.

  6. ivovandongen commented on Aug 17, 2016

    @ivovandongen
    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 .

  7. self-assigned this
    on Aug 17, 2016
  8. added this to the android-v4.2.0 milestone on Aug 17, 2016
  9. added 3 commits that reference this issue on Aug 17, 2016
  10. sddamico commented on Aug 17, 2016

    @sddamico
    Author

    Awesome, thanks!

  11. 1ec5 commented on Aug 25, 2016

    @1ec5
    Contributor

    Tracking the iOS/macOS equivalent in #6159.

  12. added 2 commits that reference this issue on Sep 5, 2016
  13. ivovandongen commented on Sep 5, 2016

    @ivovandongen
    Contributor

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

  14. jfirebaugh commented on Sep 12, 2016

    @jfirebaugh
    Contributor

    #setData(Object jsonObject)

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

  15. ivovandongen commented on Sep 13, 2016

    @ivovandongen
    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.

  16. jfirebaugh commented on Sep 13, 2016

    @jfirebaugh
    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.

  17. added 2 commits that reference this issue on Sep 13, 2016
  18. added 2 commits that reference this issue on Sep 15, 2016
  19. tobrun commented on Sep 20, 2016

    @tobrun
    Member

    Core integration has landed with 7df9a21

  20. added
    GL JS parity
    on Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AndroidGL JS parityruntime styling

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions