searchLandmarkDetails static method
Get details for the given landmark list.
The main purpose of this method is to populate the details for a landmark provided by selecting a landmark from the upper zoom level of the map. Other types of landmarks (such as the ones provided by search) are already up-to-date. Does not work with user created landmarks.
Parameters
- IN results The landmark list for which the landmarks details are searched.
- IN onCompleteCallback Will be invoked when the search operation is completed, providing the error code.
If the landmarks in list already have the details populated, the function will return GemError.upToDate.
- GemError.success if the search was successfully completed
- GemError.invalidated if the landmark provided is invalid (ex: user created landmark)
- GemError.upToDate if the landmark already has all the details.
Returns
- Associated TaskHandler for this operation if the search can be started otherwise null.
Throws
- An exception if it fails.
Implementation
static TaskHandler? searchLandmarkDetails(
final List<Landmark> results,
final void Function(GemError err) onCompleteCallback,
) {
final EventDrivenProgressListener progListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);
progListener.registerOnCompleteWithDataCallback((
final int err,
final String hint,
final Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progListener.id);
if (err == GemError.success.code || err == GemError.reducedResult.code) {
onCompleteCallback(GemErrorExtension.fromCode(err));
} else {
onCompleteCallback(GemErrorExtension.fromCode(err));
}
});
final LandmarkList resultsList = LandmarkList();
for (final Landmark result in results) {
resultsList.add(result);
}
final String resultString = GemKitPlatform.instance.callObjectMethod(
jsonEncode(<String, Object>{
'id': 0,
'class': 'SearchService',
'method': 'searchLandmarkDetails',
'args': <String, dynamic>{
'results': resultsList.pointerId,
'listener': progListener.id,
},
}),
);
final dynamic decodedVal = jsonDecode(resultString);
final GemError errorCode = GemErrorExtension.fromCode(decodedVal['result']);
if (errorCode != GemError.success) {
onCompleteCallback(errorCode);
return null;
}
return TaskHandlerImpl(progListener.id);
}