CartoType's graphics acceleration system gives you a smooth, fast, fluid user experience, with no delays when panning or zooming the map. Drawing speeds of up to 30 frames per second are supported.

What can I do with graphics acceleration?

You can do everything you do already (and more: you can use smooth animations for zooming, panning and rotation). The standard CartoType API is available, and you can use the same map data (CTM1 files) and style sheets that the standard version of CartoType uses. And unlike some mapping frameworks, which require you to use the Web Mercator projection, CartoType GL allows you to use any projection.

How it works

CartoType's graphics-accelerated rendering system uses two things to give you that extra speed. Multi-threading uses several processor cores at once to fetch the map data. The Open GL ES graphics language gives access to the GPU (graphics processing unit) on the device. All modern mobile and desktop platforms now support graphics acceleration.

Availability

Graphics-accelerated rendering is available now as an integral part of the CartoType SDK, for iOS, Android, Windows (desktop), .NET for Windows, and Linux. Evaluation SDKs are available for all those platforms. It is also supported on Qt for Windows, Mac OS and Linux. 

How to use graphics acceleration

To use graphics acceleration for rendering, you should first create a framework object (e.g., CFramework on C++, Framework on Android, CartoTypeFramework on iOS, etc.) then create a map renderer object (CMapRenderer on C++, MapRenderer on .NET, MapRenderer on Android, CartoTypeMapRenderer on iOS), passing your framework to it.

On Windows and .NET: pass the handle of the window into which the map is to be drawn to the map renderer's constructor. This is the m_hWnd data member on MFC in Windows, and the Handle property in .NET. You don't need to make any explicit drawing calls: the map is drawn automatically at 25 frames per second by the map renderer object.

On other platforms: call the map renderer's Draw function when you need to redraw the map. You can call it continuously if you like, or call it only when you know the map needs to be redrawn.

On Android there is a higher-level class, MapView: it creates a map renderer and draws the map as needed, and handles touch gestures for panning, rotation and zooming.

In the iOS demo program TestGL there is a CartoTypeViewController class which creates the map renderer, draws the map as needed, and handles touch gestures for panning, rotation and zooming.

Maps

You can use the same maps with graphics-accelerated rendering as with standard CartoType. All projections are supported. Some tile-based systems require the map to use the Web Mercator projection; CartoType imposes no such restriction. When loading multiple maps into a framework to be rendered using graphics acceleration you should load all the maps before creating the map renderer, unless you know that the new maps will not change the overall bounds.

Styles

The graphics-accelerated rendering system supports standard CartoType style sheets. It supports all graphic features except bridge graphics (faint lines beside bridges). 3D buildings have better support than in standard CartoType. OpenStreetMap colors and roof shapes are used.

Perspective

You can set perspective mode in the usual way from the standard API.

Calling arbitrary functions on your framework object

You can call any function in the standard API quite freely during graphics accelerated drawing. For example, you can

  • pan
  • zoom
  • rotate
  • set the map position using degrees of latitude and longitude
  • insert pushpins
  • search for a place
  • calculate and display a route

The only thing you shouldn't do is delete your framework object, in languages such as C++ which allow that.

Android notes

To use CartoType GL on Android your view class should extend CartoType's MapView class. It handles panning, rotation and pinch zooming, and provides overridable functions for handling clicks and long presses. To see how to use it please refer to the sample source code at https://github.com/CartoType/CartoType-Public/tree/master/src/demo/android/CartoTypeMaps/app/src/main/java/com/cartotype/cartotypemaps.

Linux notes

You will to install the library libGLESv2 and link your program to it. There is a very simple demonstration program using the GLFW UI framework. Its source code is at https://github.com/CartoType/CartoType-Public/blob/master/src/demo/unix/unix_gl_demo/unix_gl_demo.cpp.

iOS notes

On iOS you need to add the MetalANGLE framework to your project as well as the CartoType framework. Both frameworks are supplied in .xcframework format as part of the CartoType iOS SDK.

All you need to do is make your ViewController class a subclass of CartoTypeViewController, which handles all rendering for you. It should have an init function taking a CartoTypeFramework object and a bounding rectangle. The sample source code you need is in the public source code repository at https://github.com/CartoType/CartoType-Public/tree/master/src/demo/ios/CartoTypeSwiftDemo.

Windows notes

You will need to link to OpenGLES libraries and/or DLLs. If you are using the Angle OpenGL ES library (recommended) you need to link to angle_common.lib, angle_util.lib, sample_util.lib, libEGL.lib, and libGLESv2.lib, and to ensure that the Angle DLLs are available in the search path (the PATH environment variable) when your executable is run, for example by executing the command 'PATH=C:\angle\build\Release_x64;%PATH%' beforehand.

You should add a data member to your view window to hold a CMapRenderer object:

std::unique_ptr iMapRenderer;

and initialise it in your OnInitialUpdate function like this:

iMapRenderer = std::make_unique<CartoType::CMapRenderer>(*iFramework,m_hWnd);

after you have created your CFramework object (iFramework in this example).

There is no need to draw the map manually. The CMapRenderer object draws the map automatically at 25 frames per second, taking account of any changes you make to the map, such as panning, zooming, creating routes, etc.

The source code for the Windows demonstration program is at https://github.com/CartoType/CartoType-Public/tree/master/src/demo/windows_demo.

C# notes (using the .NET SDK)

You will need to ensure that the OpenGL DLLs, libEGL.dll and libGLESv2.dll, are available in the search path (the PATH environment variable) when your executable is run, for example by executing the command 'PATH=C:\angle\build\Release_x64;%PATH%' beforehand. These DLLs are supplied with the .NET SDK, in the same directories as the .NET CartoType wrapper DLLs (CartoTypeDemo\vs2017\bin\x64\Release and CartoTypeDemo\vs2017\bin\x64\Debug).

You should add a data member to your Form (window) to hold a MapRenderer object:

private CartoType.MapRenderer m_map_renderer;

and initialise it in your Form constructor:

m_map_renderer = new CartoType.MapRenderer(m_framework, Handle);

after you have created your Framework object (m_framework in this example).

There is no need to draw the map manually. The MapRenderer object draws the map automatically at 25 frames per second, taking account of any changes you make to the map, such as panning, zooming, creating routes, etc.

The source code for the .NET C# demonstration program is at https://github.com/CartoType/CartoType-Public/tree/master/src/demo/windows_csharp_demo.

Qt notes (using the C++ SDK)

You create a CMapRenderer object in the same way as for plain Windows, and then set up a timer to update (say) 25 times per second. (There is no need to install OpenGL libraries: they are included with Qt.) You then implement the initializeGL and paintGL functions in your form class:

void MapForm::initializeGL()
    {
    // Protect against calls by the QOpenGLWidget constructor in cases where the map could not be opened.
    if (!m_map_renderer)
        return;

    m_map_renderer->Init();
    }

void MapForm::paintGL()
    {
    // Protect against calls by the QOpenGLWidget constructor in cases where the map could not be opened.
    if (!m_map_renderer)
        return;

    m_map_renderer->Draw();
    }

The best way to understand what is needed, and how you can switch between hardware-accelerated rendering and software rendering, is to look at the source code of the CartoType Maps App: https://github.com/CartoType/CartoType-Public/blob/master/src/apps/Maps/mapform.cpp.

void MapForm::initializeGL()
{
// Protect against calls by the QOpenGLWidget constructor in cases where the map could not be opened.
if (!m_map_renderer)
return;

m_map_renderer->Init();
}

void MapForm::paintGL()
{
// Protect against calls by the QOpenGLWidget constructor in cases where the map could not be opened.
if (!m_map_renderer)
return;

m_map_renderer->Draw();
}