Map Perspective¶
Control the map perspective.

Use case¶
Change the map perspective to a more suitable perspective.
How to use the sample¶
First, get an API key token, see the Getting Started guide.
Download the Maps & Navigation SDK for C++ archive file for Linux or WindowsWhen you open the sample, you’ll be viewing the scene from above in 2D. The map view perspective will then switch to 3D.
How it works¶
Create an instance of
Environment
and set your API key token:
1Environment& env = Environment::GetInstance();
2
3//
4// Project API token available at:
5// https://developer.magiclane.com/api/projects
6//
7std::string projectApiToken = ""; //YOUR_TOKEN
The SDK is initialized with your API key token string and the log file path, where to write the application logs. Note that
logFilePath
is not initialized by default, which means that no logs are written. The logFilePath is initialized with the first command line argument, if any.
1std::string logFilePath;
2if ( argc > 1 )
3 logFilePath = std::string(argv[1]);
4
5env.InitSDK( projectApiToken, logFilePath.c_str() );
Create a
MapViewListener
,OpenGLContext
andMapView
.
1{
2 MapViewListenerImpl listener;
3 auto oglContext = env.ProduceOpenGLContext("mapPerspective");
4 gem::StrongPointer<gem::MapView> mapView = gem::MapView::produce(oglContext, &listener);
In 2D mode, the view is looking vertically straight down toward the map. In 3D mode, the view is looking toward the map at an angle about the horizontal screen axis, such that the horizon may appear in the view. Instruct the
MapView
to change its perspective to 3D, using a 2 second (2000 millisecond) animation. Wait for the map to load up to 15 seconds, then wait until the user closes the map window.
1 mapView->preferences().setMapViewPerspective(gem::MVP_3D, gem::Animation(gem::AnimationLinear, gem::ProgressListener(), 2000));
2 auto ret = WAIT_UNTIL(std::bind(&MapViewListenerImpl::IsFinished, &listener), 15000);
3 WAIT_UNTIL_WINDOW_CLOSE();
4}
5env.ReleaseSDK();