Skip to main content

Overview

MapInterface is the central interface for the Open Mobile Maps SDK. It manages the map’s rendering context, layers, camera, touch handling, and overall lifecycle. The interface provides both factory methods for creating map instances and instance methods for controlling the map. Header Location: shared/public/MapInterface.h:29

Factory Methods

create
static method
Creates a new map instance with custom factories and rendering context.
return
std::shared_ptr<MapInterface>
A non-null shared pointer to the created map instance
createWithOpenGl
static method
Creates a new map instance with default OpenGL rendering.
return
std::shared_ptr<MapInterface>
A non-null shared pointer to the created map instance

Configuration Methods

setCallbackHandler
void
Sets the callback handler for map events.
setCamera
void
Sets the camera for the map.
getCamera
std::shared_ptr<MapCameraInterface>
Returns the current camera instance.
return
std::shared_ptr<MapCameraInterface>
The current map camera
setTouchHandler
void
Sets the touch handler for user interaction.
getTouchHandler
std::shared_ptr<TouchHandlerInterface>
Returns the current touch handler.
return
std::shared_ptr<TouchHandlerInterface>
The current touch handler
setViewportSize
void
Sets the viewport size for rendering.
setBackgroundColor
void
Sets the map background color.

Accessor Methods

getGraphicsObjectFactory
std::shared_ptr<GraphicsObjectFactoryInterface>
Returns the graphics object factory.
return
std::shared_ptr<GraphicsObjectFactoryInterface>
Factory for creating graphics objects
getShaderFactory
std::shared_ptr<ShaderFactoryInterface>
Returns the shader factory.
return
std::shared_ptr<ShaderFactoryInterface>
Factory for creating shader programs
getScheduler
std::shared_ptr<SchedulerInterface>
Returns the scheduler.
return
std::shared_ptr<SchedulerInterface>
Scheduler for asynchronous tasks
getRenderingContext
std::shared_ptr<RenderingContextInterface>
Returns the rendering context.
return
std::shared_ptr<RenderingContextInterface>
The rendering context
getMapConfig
MapConfig
Returns the map configuration.
return
MapConfig
Current map configuration
getCoordinateConverterHelper
std::shared_ptr<CoordinateConversionHelperInterface>
Returns the coordinate conversion helper.
return
std::shared_ptr<CoordinateConversionHelperInterface>
Helper for coordinate conversions
is3d
bool
Checks if the map is in 3D mode.
return
bool
True if 3D rendering is enabled

Layer Management

getLayers
std::vector<std::shared_ptr<LayerInterface>>
Returns all layers in the map.
return
std::vector<std::shared_ptr<LayerInterface>>
Vector of all layers
getLayersIndexed
std::vector<std::shared_ptr<IndexedLayerInterface>>
Returns all indexed layers in the map.
return
std::vector<std::shared_ptr<IndexedLayerInterface>>
Vector of indexed layers
addLayer
void
Adds a layer to the top of the layer stack.
insertLayerAt
void
Inserts a layer at a specific index.
insertLayerAbove
void
Inserts a layer above another layer.
insertLayerBelow
void
Inserts a layer below another layer.
removeLayer
void
Removes a layer from the map.

Performance Monitoring

setPerformanceLoggers
void
Sets performance loggers for monitoring.
getPerformanceLoggers
std::vector<std::shared_ptr<PerformanceLoggerInterface>>
Returns all performance loggers.
return
std::vector<std::shared_ptr<PerformanceLoggerInterface>>
Vector of performance loggers

Rendering Methods

The following rendering methods must be called on the rendering thread.
invalidate
void
Marks the map as needing a redraw.
resetIsInvalidated
void
Resets the invalidation state.
prepare
void
Prepares the map for rendering.
getNeedsCompute
bool
Checks if compute operations are needed.
return
bool
True if compute operations are pending
drawFrame
void
Draws a single frame. Must be called on the rendering thread.
drawOffscreenFrame
void
Draws a frame to an offscreen render target.
compute
void
Executes compute operations. Must be called on the rendering thread.
drawReadyFrame
void
Draws a frame when all layers within bounds are ready.Changes camera bounds, checks all layers for readiness, and updates callbacks. Always draws the frame when state is updated in the ready callbacks.

Lifecycle Methods

resume
void
Resumes the map rendering. Must be called on the rendering thread.
pause
void
Pauses the map rendering. Must be called on the rendering thread.
destroy
void
Destroys the map and releases resources.
forceReload
void
Forces a complete reload of the map.

Usage Example

// Create a map with OpenGL rendering
auto scheduler = /* create scheduler */;
MapConfig config{MapCoordinateSystem::EPSG3857};
auto map = MapInterface::createWithOpenGl(config, scheduler, 2.0f, false);

// Set viewport size
map->setViewportSize(Vec2I{800, 600});

// Add a layer
auto layer = /* create layer */;
map->addLayer(layer);

// Set camera
auto camera = /* create camera */;
map->setCamera(camera);

// Draw frame (on rendering thread)
map->drawFrame();

// Clean up
map->destroy();

See Also

Build docs developers (and LLMs) love