Working with layers
Last updated
Was this helpful?
Last updated
Was this helpful?
The Felt SDK allows you to add GeoJSON data to your maps from various sources:
Remote URLs
Local files
Programmatically generated GeoJSON data
GeoJSON layers created via the SDK are temporary and session-specific - they're not permanently added to the map and won't be visible to other users.
When creating a GeoJSON layer, you can specify different styles for each geometry type (Point, Line, Polygon) that might be found in the source. Each geometry type will create its own layer. It's important to note that GeoJSON layers added via the SDK have limited capabilities compared to regular Felt layers - they cannot be filtered, nor can statistics be fetched for them.
Use the method to add GeoJSON layers to your map. This method accepts different source types depending on where your GeoJSON data comes from.
To create a layer from a GeoJSON file at a remote URL:
To create a layer from a GeoJSON file on the user's device:
To create a layer from GeoJSON data that you've generated or processed in your application. This approach is useful when you need to dynamically generate GeoJSON data based on user interactions or other app states:
When creating GeoJSON layers, you can specify different styles for each geometry type that might be found in your data. The SDK will create separate layers for each geometry type:
Each style should be a valid FSL (Felt Style Language) style. If you don't specify styles, Felt will apply default styles based on the geometry type.
To remove a GeoJSON layer:
Note that this only works for layers created via the SDK's createLayersFromGeoJson
method, not for layers added through the Felt UI.
For GeoJSON layers created from URLs, you can set automatic refreshing:
At Creation Time: By setting the refreshInterval
parameter when creating the layer. The refreshInterval
parameter is optional and specifies how frequently (in milliseconds) the layer should be automatically refreshed from the URL. Valid values range from 250ms to 5 minutes (300,000ms). If set to null
or omitted, the layer won't refresh automatically.
Manual Refresh: Simply replace the source
property of any layer you have created, using the method to update the source data.