MFW Map

The MfwMap plugin allows users to display maps based on data, either online or offline. User can draw a variety of objects on the map, interact with them, and style them according to their preferences.

Basic usage scenarios:

  • connecting the map to the application
  • interaction with the map using gestures
  • adding objects to the map

Build status:

  1. master - pipeline status
  2. dev - pipeline status

Build documentation

Instructions for building documentation for MfwMap using qdoc can be found here.

Terms of Use and Participation

The source code of the project is provided under the license, that allows it to be used in third-party applications.

The contributor agreement documents the rights granted by contributors to the Open Mobile Platform.

Code of conduct is a current set of rules of the Open Mobile Platform which informs you how we expect the members of the community will interact while contributing and communicating.

For information about contributors see AUTHORS.

Project Structure

  • include/MfwMap directory contains the include header files MfwMap.
  • plugin directory contains the C++ source code of the plugin.
  • rpm directory contains the rpm-package build settings.
  • test directory contains unit tests.
  • vendors directory contains the MapLibre GL Native submodule.
  • CMakeLists.txt file describes the project structure for the CMake build system.

Connecting the map component

Cloning a repository

In the root of the project, add the repository as a submodule:

git init
mkdir plugins
cd plugins/
git submodule add https://gitlab.com/omprussia/libraries/mfw-map.git && cd MfwMap &&
git submodule update --init --recursive

Setting up the .spec file

In the .spec file in the rpm folder after the lines:

%install
%make_install

should to add the lines:

%define __requires_exclude ^(libMfwMap.*).*$
%define __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$

Integration into CMake

CMakeList.txt starting with project(ru.auroraos.projectName CXX) it should look like this:

cmake_minimum_required(VERSION 3.5)

find_package (Qt5 COMPONENTS Core Network Qml Positioning Gui Quick LinguistTools REQUIRED)

include(FindPkgConfig)
pkg_search_module(AURORA auroraapp REQUIRED)
pkg_search_module(AURORA auroraapp_i18n REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(short_name untitled3)

file(GLOB TsFiles "translations/*.ts")
qt5_add_translation(QmFiles ${TsFiles})
add_subdirectory("plugins/MfwMap" MfwMap EXCLUDE_FROM_ALL)
include_directories("plugins/MfwMap/include/MfwMap")
set(SOURCES
    src/main.cpp
)

set(CMAKE_SKIP_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/lib")

add_executable(${PROJECT_NAME} ${SOURCES} ${QmFiles})
target_compile_definitions(${PROJECT_NAME} PRIVATE
    $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
)
add_dependencies(${PROJECT_NAME}
    MfwMap
)
target_include_directories(${PROJECT_NAME} PRIVATE
    $<BUILD_INTERFACE:
    ${CMAKE_SOURCE_DIR}/plugins/MfwMap/include/MfwMap
    ${CMAKE_BINARY_DIR}/plugins/MfwMap/include/MfwMap
    ${AURORA_INCLUDE_DIRS}
>)
target_link_directories(
    ${PROJECT_NAME}
    PRIVATE
    ${CMAKE_SOURCE_DIR}/plugins/MfwMap/
    ${CMAKE_BINARY_DIR}/plugins/MfwMap/
)
target_link_libraries(${PROJECT_NAME}
    Qt5::Quick
    Qt5::Positioning
    ${AURORA_LDFLAGS}
    MfwMap
)
install(TARGETS MfwMap
    DESTINATION ${CMAKE_INSTALL_RPATH}
)
install(TARGETS ${PROJECT_NAME}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY qml
    DESTINATION share/${PROJECT_NAME}
)

foreach(_file IN LISTS QmFiles)
    get_filename_component(_filename "${_file}" NAME)
    string(REPLACE "${short_name}" "${PROJECT_NAME}" _full_filename "${_filename}")
    install(FILES ${_file} DESTINATION share/${PROJECT_NAME}/translations RENAME ${_full_filename})
endforeach()

set(IconSize 86x86 108x108 128x128 172x172)
foreach(_size IN LISTS IconSize)
    install(FILES icons/${_size}/${PROJECT_NAME}.png DESTINATION share/icons/hicolor/${_size}/apps)
endforeach()

install(FILES ${PROJECT_NAME}.desktop
    DESTINATION share/applications
)

# Get the other files reachable from the project tree in Qt Creator
file(GLOB_RECURSE IconFiles "icons" "*.png")
set(RESOURCE_FILES ${IconFiles})

file(GLOB_RECURSE QmlFiles "qml/*.qml")

add_custom_target(distfiles
    SOURCES
        ${PROJECT_NAME}.desktop
        rpm/${PROJECT_NAME}.spec
        rpm/${PROJECT_NAME}.changes.in
        rpm/${PROJECT_NAME}.changes.run.in
        ${QmlFiles}
        ${TsFiles}
        ${IconFiles})

file(WRITE "${CMAKE_BINARY_DIR}/QtCreatorDeployment.txt"
    "${CMAKE_INSTALL_PREFIX}
${CMAKE_BINARY_DIR}/${PROJECT_NAME}:bin
")

Registration of the module in main.cpp

In main.cpp you need to add the code:


#include <auroraapp.h>
#include <QtQuick>
#include <MfwMap/MfwMap>

int main(int argc, char *argv[])
{
    qmlRegisterType<MfwMap>("MfwMap", 1, 0, "MfwMap");
    //generated code
}

Importing a module into the QML of a registered component.

Add a component to the page, for example in AboutPage.qml:

//other imports
import MfwMap 1.0

Page {

    MfwMap {
        width: parent.width
        height: parent.height

        accessToken: "pk.eyJ1Ijoic2xhdmFjaGVybmlrb2ZmIiwiYSI6ImNsZDBlemo0ejAxdnUzd3Fxc242Y2g2dHAifQ.YptKmH0xY8nfDfZnhdPiFg"
        styleUrl: "mapbox://styles/mapbox/streets-v10"
    }
}

Configuring the MfwMap component

Basic state of the component

  1. Data source
  • 1.1 Online.
    MfwMap {
        id: map
        zoomLevel: 17.0
        center: QtPositioning.coordinate(55.752121, 37.617664) // Moscow
        styleUrl: "https://api.maptiler.com/maps/streets/style.json?key=rIkhrE0BML0xS89iIyfG"
    }
  • 1.2. Offline. Specify the path to .json with styles.
    MfwOfflineMap {
        styleOfflinePath: "path/to/file"
        center: QtPositioning.coordinate(55.752121, 37.617664) // Moscow
        zoomLevel: 17.0
    }
    1. Specifying the center of the map
    1. Map zoom.