// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example places_map
    \title Places Map (QML)
    \ingroup qtlocation-examples
    \examplecategory {Positioning & Location}
    \brief The Places Map example demonstrates how to search for and display a list of places
           on a map using a MapItemView.
    \image places_map.png

    The example displays a map of the current location or, if no position is
    available, it uses Oslo/Norway. Subsequently a search for places
    matching the term "food" is performed and each result shown on the map.

    \include examples-run.qdocinc

    \section1 Local Search

    To write the QML application that will show places on a map, we start by
    making the following import declarations.

    \snippet places_map/places_map.qml Imports

    Instantiate a \l Plugin instance.  The \l Plugin is effectively the backend
    from where places are sourced from. Depending on the chosen plugin
    some manadatory parameters may be needed. In this case the
    \l {Qt Location Open Street Map Plugin}{OSM plugin} is selected which does not have any mandatory
    parameters.

    \snippet places_map/places_map.qml Initialize Plugin

    Next we instantiate a \l PlaceSearchModel which we can use to specify
    search parameters and perform a places search operation.  For illustrative
    purposes, \l {PlaceSearchModel::update} {update()} is invoked once
    construction of the model is complete.  Typically \l
    {PlaceSearchModel::update} {update()} would be invoked in response to a
    user action such as a button click.

    \snippet places_map/places_map.qml PlaceSearchModel

    The map is displayed by using the \l MapView type and inside we declare the \l
    MapItemView and supply the search model and a delegate.  An inline delegate
    has been used and we have assumed that every search result is of \l {Search
    Result Types} {type} \c PlaceSerachesult.  Consequently it is assumed that
    we always have access to the \e place \l {PlaceSearchModel Roles} {role},
    other search result types may not have a \e place \l {PlaceSearchModel
    Roles} {role}.

    \snippet places_map/places_map.qml Places MapItemView

    Finally, a \c PositionSource is used to reset the map to the curent
    location and find "food" places in the new area. The position information
    is updated every 2 minutes and if the new position is more than 500 meters
    away from the last food search area the place search is retriggered.

    \snippet places_map/places_map.qml Current Location
*/
