importLandmarks method
Asynchronously imports landmarks into this store from a file path.
The import supports formats defined by LandmarkFileFormat and can attach a map
image to the imported landmarks. A ProgressListener is returned to monitor
progress. The onComplete callback receives a GemError describing final status.
Parameters
filePath: Path to the file containing landmark data (KML, GeoJSON, etc.).format: The LandmarkFileFormat describing the file contents.image: An Img used as the landmark image for imported items (or default when omitted).onComplete: Optional callback invoked with a GemError when the import finishes. Possible values include:- GemError.success — import completed successfully.
- GemError.inUse — an import is already in progress.
- GemError.notFound — file could not be opened or category id invalid.
- GemError.cancel — operation was cancelled.
- GemError.invalidInput — provided data could not be parsed.
onProgressUpdated: Optional progress callback (0-100).categoryId: Optional category id to assign to imported landmarks. Use uncategorizedLandmarkCategId to import without a category.
Returns
- ProgressListener?: A progress listener if the import started, otherwise null.
See also:
- importLandmarksWithDataBuffer — imports landmarks from a data buffer.
Implementation
ProgressListener? importLandmarks({
required String filePath,
required LandmarkFileFormat format,
required Img image,
final void Function(GemError error)? onComplete,
final void Function(int progress)? onProgressUpdated,
int categoryId = uncategorizedLandmarkCategId,
}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
if (onComplete != null) {
progressListener.registerOnCompleteWithData(
(final int err, final String hint, final Map<dynamic, dynamic> json) =>
onComplete(GemErrorExtension.fromCode(err)),
);
}
if (onProgressUpdated != null) {
progressListener.registerOnProgress(onProgressUpdated);
}
GemKitPlatform.instance.registerEventHandler(
progressListener.id,
progressListener,
);
final OperationResult resultString = objectMethod(
pointerId,
'LandmarkStore',
'importLandmarks',
args: <String, dynamic>{
'path': filePath,
'fileFormat': format.id,
'image': image.pointerId,
'categoryId': categoryId,
'listener': progressListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode);
return null;
}
return progressListener;
}