Bruno Abinader, Software Engineer, Mapbox

Customizable vector maps with the Mapbox Qt SDK

Published Tuesday October 4th, 2016
13 Comments on Customizable vector maps with the Mapbox Qt SDK
Posted in Biz Circuit & Dev Loop, Contributors, Embedded, Yocto

Mapbox is a mapping platform that makes it easy to integrate location into any mobile and online application. We are pleased to showcase the Mapbox Qt SDK as a target platform for our open source vector maps rendering engine. Our Qt SDK is a key component in Mapbox Drive, the first lane guidance map designed for car companies to control the in-car experience. The Qt SDK also brings high quality, OpenGL accelerated and customizable maps to Qt native and QtQuick.

QML: Properties QML: Runtime style
QMLProperties QMLRuntimeStyle

The combination of Qt and Yocto is perfect for bringing our maps to a whole series of embedded devices, ranging from professional NVIDIA and i.MX6 based boards to the popular Raspberry Pi 3.

As part of our Mapbox Qt SDK, we expose Mapbox GL to Qt in two separate APIs:

  • QMapboxGL – implements a C++03x-conformant API that has been tested from Qt 4.7 onwards (Travis CI currently builds it using both Qt 4 and Qt 5).
  • QQuickMapboxGL – implements a Qt Quick (QML) item that can be added to a scene. Because QQuickFramebufferObjecthas been added in Qt version 5.2, we support this API from this version onwards. The QML item interface matches the Qt Map QML type almost entirely, making it easy to exchange from the upstream solution.

QMapboxGL and QQuickMapboxGL solve different problems. The former is backwards-compatible with previous versions of Qt and is easily integrated into pure C++ environments. The latter takes advantage of Qt Quick’s modern user interface technology, and is the perfect tool for adding navigation maps on embedded platforms. So far we have been testing our code on Linux and macOS desktops, as well as on Linux based embedded devices.

Mapbox is on a joint effort with the Qt Company to make the Mapbox Qt SDK also available through the official Qt Location module – we are aligning APIs to make sure Mapbox-specific features like runtime styles are available.

QQuickMapboxGL API matches Qt’s Map QML Type, as you can see from the example below:

import QtPositioning 5.0 
import QtQuick 2.0 
import QtQuick.Controls 1.0 

import QQuickMapboxGL 1.0 

ApplicationWindow {
    width: 640 
    height: 480 
    visible: true

    QQuickMapboxGL {
        anchors.fill: parent

        parameters: [
            MapParameter {
                property var type: "style"
                property var url: "mapbox://styles/mapbox/streets-v9"
            },
        ]

        center: QtPositioning.coordinate(60.170448, 24.942046) // Helsinki
        zoomLevel: 14
    }   
}

Mapbox Qt SDK is currently in beta stage. We’re continuously adding new features and improving documentation is one of our immediate goals. Your patches and ideas are always welcome!

We also invite you to join us next month at Qt World Summit 2016 and contribute to Mapbox on GitHub.

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Biz Circuit & Dev Loop, Contributors, Embedded, Yocto

13 comments

Bernhard says:

Wow, that looks really great!
Are there also plans to bring that to mobile platforms (Android in particular)?

Thanks,
Bernhard

Mike says:

Really cool! See the GitHub link at the bottom for a similar Android (and iOS) SDK. Looks like they’ve been around for a while.

Bruno Abinader Bruno Abinader says:

Thank you! As Mike said, we have our own native SDKs for Android and iOS – though nothing really stops you from compiling and running the Mapbox Qt SDK in both Android and iOS.

Benoit says:

Vector maps for Qt, finally! And looking really good… I am also wondering if it can be used for mobile apps. It would be also great to have access to the internal OpenGL API when using QQuickMapboxGL in order to be able to create map items (and of course example would be great!). And even better: do you have plans to integrate it with QtLocation?

Bruno Abinader Bruno Abinader says:

Hi Benoit! As previously replied, currently mobile apps are officially supported via our native SDKs. Though access to the internal OpenGL API is not yet possible, we expose an API in QMapboxGL for custom layers that allows foreign OpenGL code sharing the same context. Integration with QtLocation is on its way – we plan to provide our rendering engine as part of the Qt framework, and provide the vector tiles implementation as a plugin for the Map QML Type.

Bernhard says:

Hi Bruno,

is there already a time frame when it will be integrated into QtLocation? Really looking forward to use it ๐Ÿ˜‰

Benoit says:

Thanks for the answer. Sounds great, a plugin for QtLocation would be the ideal solution!

DavidB says:

A couple of things:

1) The Demo(s) you have picture are not part of the Qt Examples provided by the git repository (I am using the master branch). Can you tell me where to find them.

2) The SDK compiles with Qt 5.6, but does not compile for me with Qt 5.7 on the Mac anyway. The first error being:

In file included from ../../../src/mbgl/actor/mailbox.cpp:2:
../../../src/mbgl/actor/message.hpp:30:22: error: no type named ‘index_sequence’ in namespace ‘std’
void invoke(std::index_sequence) {

Must be some flag changed in the qmakespec. Any ideas from the Qt trolls.

And could you please explain if it is possible to cache maps locally, if so how does one do this.

Thanks for making this great SDK available.

-David

ekke ekke says:

Integration with QtLocation and support of HighDpi and working inside a QtQuickControls2 App for Android and iOS would be cool ๐Ÿ˜‰

Mitch Mitch says:

Do you plan on renaming the types exposed to QML to better align with how Qt has named QML counterparts to C++ types? For example, QQuickMapboxGL would be MapboxGL.

Thiago Marcos P. Santos says:

Thanks for the suggestion. We renamed it already, our Map item is called MapboxMap:
https://github.com/mapbox/mapbox-gl-native/blob/8d221cafe/platform/qt/qmlapp/main.qml#L16

Bojan says:

What is the source of the data? Google maps?

Jeremy Stratman says:

Bojan, the bulk of the data making up standard Mapbox maps is a highly curated extract from OpenStreetMap, updated every few minutes. Other data sources make up some components of the Streets layer as well as Terrain and Satellite layers. Custom maps can be created from any data source you have rights to use, however (www.mapbox.com/mapbox-studio).
– Jeremy, Mapbox

Commenting closed.

Get started today with Qt Download now