Hi all,
I would like to animate a line in the Android SDK like this example for Mapbox for web:
I see in the documentation that with “dynamic map sources” I can add a geojson to the map. My idea is then to update the geojson every 0.2 sec or so to animate a walked route in an app.
However, I already get stuck by adding a geojson to the map. I added the following code and I don’t see anything. Anybody knows how to do this? Thanks!
String geoJsonData = “{\n” +
" “type”: “FeatureCollection”,\n" +
" “features”: [\n" +
" {\n" +
" “id”: “GeoJSON Polygon”,\n" +
" “type”: “Feature”,\n" +
" “properties”: {" +
" “line-color”: “rgba(26, 203, 207, 1)”,\n" +
" “line-width”: 6},\n" +
" “geometry”: {\n" +
" “type”: “Polygon”,\n" +
" “coordinates”: [\n" +
" [\n" +
" [48.893478, 2.334595],\n" +
" [48.893479, 2.334597],\n" +
" [48.893482, 2.334599],\n" +
" [48.893485, 2.334600],\n" +
" [48.893489, 2.334605],\n" +
" [48.893491, 2.334608],\n" +
" [48.893495, 2.334610],\n" +
" [48.893499, 2.334612],\n" +
" [48.893500, 2.334616],\n" +
" [48.893504, 2.334619],\n" +
" [48.893508, 2.334620],\n" +
" [48.893509, 2.334622],\n" +
" [48.893512, 2.334623],\n" +
" [48.893516, 2.334626],\n" +
" [48.893518, 2.334628],\n" +
" [48.893520, 2.334630],\n" +
" [48.893522, 2.334632],\n" +
" [48.893528, 2.334633],\n" +
" [48.893529, 2.334635],\n" +
" [48.893530, 2.334637],\n" +
" [48.893534, 2.334639]\n" +
" ]\n" +
" ]\n" +
" }\n" +
" }\n" +
" ]\n" +
“}”;
//tag::add_geo_json_source[]
//GEOJSON_SOURCE_ID = unique_source_id
//GeoJsonData = JSON representing source data
GeoJsonSource source = SourceFactory.createGeoJsonSource(GEOJSON_SOURCE_ID);
source.setGeoJson(geoJsonData);
map.getStyleSettings().addSource(source);