QML Places APIOverviewThe Places API allows users to discover places of interest and view details about them, such as address and contact information. Some places may have additional content associated with them, such as images and reviews. The Places API also facilitates management of places and categories, allowing users to save and remove them. Quickstart TutorialPlugin InitializationA Plugin is an abstraction for a backend. One Plugin might access places from a REST server while another may access places from a local database. The following instantiates a Plugin element by providing a name of "nokia". The Plugin name identifies which backend to choose from. Note that different Plugin backends may have different nuances and behaviours, refer to the Plugin References for these details. See also the overview for the C++ API which introduces aspects of the API in greater detail. SearchingSearching is accomplished via the PlaceSearchModel. To instantiate a PlaceSearchModel we provide a Plugin and some search parameters such as a search center and search text. The model can be used with a ListView and delegate to display the results. A search operation is started by invoking the PlaceSearchModel::execute() method. The PlaceSearchModel can also be used in conjuction with a MapItemView to display markers on a map. The MapItemView's model is set to the search model, and for the delegate we use a MapQuickItem to display and position a given marker image. A marker is shown for every place that was found by the search model. The search model may also be used to specify whether corrections are returned. See the documentation for PlaceSearchModel for details. Fetching DetailsIn order to save bandwidth, sometimes a backend will only return places which are partially populated with details. This can be checked with the Place::detailsFetched property which indicates whether all availalable details have been fetched or not. If not, the Place::getDetails() method can be invoked to fetch the missing details. Saving and Removing PlacesSome backends may support saving and removing places. This can be done by calling the Place::save() and Place::remove() functions, respectively. Note that in order to save a Place, a Plugin must be assigned to specify which backend we are saving to. Learn MoreThe above quickstart tutorial only exhibits a subset of Places functionality. Refer to the Places Elements shown below for richer content such as recommendations, images, reviews etc, as well as more indepth descriptions and explanations. See also the QML Places Example for a more comprehensive demonstration on how to use the API. Places ElementsData Elements
Models
|