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

Manage Geojson sources (Android Bug, all-SDK opportunity) #8096

Closed
nitrag opened this issue Feb 17, 2017 · 2 comments
Closed

Manage Geojson sources (Android Bug, all-SDK opportunity) #8096

nitrag opened this issue Feb 17, 2017 · 2 comments
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity runtime styling

Comments

@nitrag
Copy link
Contributor

nitrag commented Feb 17, 2017

Please find a better name for this title!

This is an Android issue but I have a proposal for all platforms for the best long-term solution.

In Android we start with an empty GeoJsonSource (Why is this not a ShapeSource like iOS?) As the user pans the map, API requests fetch new GeoJSON to add to this source.

In Android, we are running into an issue where we have manage a JSONObject which API responses get merged to. Eventually we will get a TransactiontooLargeException triggered during a screen rotation onResume() "where it pulls the parcel from onSaveInstance()"

In iOS, we don't have to manage a global object because it is possible to extract the shape source's data live, modify it, and set it to the new object, then memory is then released.

For parity in Android we need a getGeoJSON function.

Or, the better yet, it would be best if all platforms had anappendGeoJSON()/appendShape function

Android

//current
...
newGeoJSONData = Utils.mergeGeoJSON(oldGeoJSONdata, APIresponse);
String geoJSONString = String.valueOf(newGeoJSONData);
myDataSource.setGeoJson(geoJSONString);

//proposed
...
String geoJSONString = String.valueOf(newGeoJSONData);
myDataSource.appendGeoJson(geoJSONString);

iOS

//current
...
if let newData = mergeGeoJSONfeatures(old: self.campsiteData?.shape?.geoJSONData(usingEncoding: String.Encoding.utf8.rawValue), new: APIresponse) {
    if let shape = try? MGLShape(data: newData, encoding: String.Encoding.utf8.rawValue) {
        DispatchQueue.main.async {
            self.campsiteData?.shape = shape
        }
    }
}
//proposed
if let newShapes = try? MGLShape(data: APIresponse, encoding: String.Encoding.utf8.rawValue) {
    DispatchQueue.main.async {
        self.campsiteData?.appendShapes = newShapes
    }
}

It would be best managed at the C++/SDK level for best performance and memory management.

@1ec5 1ec5 added Android Mapbox Maps SDK for Android runtime styling labels Feb 22, 2017
@1ec5
Copy link
Contributor

1ec5 commented Feb 22, 2017

Or, the better yet, it would be best if all platforms had anappendGeoJSON()/appendShape function

Tracking for iOS and macOS in #7458.

It would be best managed at the C++/SDK level for best performance and memory management.

Tracking in #7376.

@stale stale bot added the archived Archived because of inactivity label Nov 12, 2018
@stale
Copy link

stale bot commented Nov 25, 2018

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Nov 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity runtime styling
Projects
None yet
Development

No branches or pull requests

2 participants