Location Wikipedia
Landmarks can include Wikipedia data such as title, image title, URL, description, page summary, language, and more. To demonstrate how to retrieve Wikipedia information, we introduce the ExternalInfo
class, which handles Wikipedia data.
ExternalInfo class
This class provides Wikipedia information for a landmark. An ExternalInfo
object is obtained using the static method getExternalInfo
of the ExternalInfo
class.
final completer = Completer<ExternalInfo?>();
ExternalInfo.getExternalInfo(
landmark,
onWikiDataAvailable: (externalInfo) => completer.complete(externalInfo),
);
final externalInfo = await completer.future;
The method returns an ExternalInfo
object, which should not be accessed before the onWikiDataAvailable
callback completes.
The onWikiDataAvailable
callback might return null
if no Wikipedia info is available for the given lmk
. To check this before calling getExternalInfo
, use the following code:
final ExternalInfo pExternalInfo = ExternalInfo();
final bool hasExternalInfo = pExternalInfo.hasWikiInfo(landmark);
Wikipedia data
Wikipedia information can be accessed using methods provided by the ExternalInfo
object. The following table explains each method:
Method | Return Type | Description |
---|---|---|
getWikiImageDescription | String | Get Wikipedia image description directly, without notifier. |
getWikiImagesCount | int | Get the count of the images on the Wikipedia page. |
getWikiImageTitle | String | Get Wikipedia image title directly, without notifier. |
getWikiImageUrl | String | Get Wikipedia image URL directly, without notifier. |
getWikiPageDescription | String | Get Wikipedia page summary (text). |
getWikiPageLanguage | String | Get Wikipedia page language. |
getWikiPageTitle | String | Get Wikipedia page title. |
getWikiPageUrl | String | Get Wikipedia page URL. |
hasWikiInfo | bool | Checks if the landmark has Wikipedia info. |
Wikipedia data is provided in the language specified in SDKSettings
. Learn more about setting the SDK language here.