updateGeoJSONSourceFeatures method
Update existing features in a GeoJSON style source.
The update operation will be scheduled and applied on a GeoJSON serialization queue.
In order to capture events when actual data is drawn on the map please refer to Events API
and listen to onSourceDataLoaded
(optionally pass the dataId
parameter to filter the events)
or onMapLoadingError
with type = metadata
if data parsing error has occurred.
Partially updating a GeoJSON source is not compatible with using shared cache and generated IDs.
It is important to ensure that every feature in the GeoJSON style source, as well as the newly added
feature, has a unique ID (or a unique promote ID if in use). Failure to provide unique IDs will result
in a map-loading-error
.
- Note: The method allows the user to provide a data ID, which will be returned as the
dataId
parameter in thesource-data-loaded
event. However, it's important to note that multiple partial updates can be queued for the same GeoJSON source when ongoing source parsing is taking place. In these cases, the partial updates will be applied to the source in batches. Only the data ID provided in the most recent call within each batch will be included in thesource-data-loaded
event. If no data ID is provided in the most recent call, the data ID in thesource-data-loaded
event will be null.
@param sourceId A style source identifier. @param dataId An arbitrary string used to track the given GeoJSON data. @param features The GeoJSON features to be updated in the source.
@return A string describing an error if the operation was not successful, empty otherwise.
Implementation
Future<void> updateGeoJSONSourceFeatures(
String sourceId, String dataId, List<Feature> features) async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.mapbox_maps_flutter.StyleManager.updateGeoJSONSourceFeatures$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
.send(<Object?>[sourceId, dataId, features]) as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}