Some services, such as HERE Maps, require you to display attributions when using their data on the map. LuciadCPillar keeps track of the attributions from all layers that provide attribution data, and exposes an API to retrieve these attributions.

Retrieving the attributions on a map
The attributions on a map are exposed through MapAttributions
. You can get attributions from all layers, or request the attributions of a specific layer. Layers that aren’t visible aren’t
included.
const MapAttributions& mapAttributions = map->getAttributions(); const std::vector<DataAttribution>& allDataAttributions = mapAttributions.getAllAttributions(); std::optional<DataAttribution> attributionForOneLayer = mapAttributions.getAttribution(layerId);
To receive events when any of these attributions change, register an IMapObserver
on the map and filter on the attributions property:
map->addObserver(IMapObserver::create([](const MapEvent& event) { if (event.getChangedProperty() != Map::propertyAttributions()) { return; } // Do something with the attributions, e.g. format and show on the UI std::stringstream ss; const MapAttributions& mapAttributions = event.getMap()->getAttributions(); const auto& attributions = mapAttributions.getAllAttributions(); for (auto it = attributions.rbegin(); it != attributions.rend(); it++) { const auto& attribution = *it; for (const auto& attributionString : attribution.getAttributionStrings()) { ss << attributionString << "\n"; } } std::cout << "New attributions:\n" << ss.str(); }));
Providing attribution data
For a RasterLayer
with a multi-level tiled raster model or quad tree raster model, you can provide your own attribution based on the currently
displayed tiles using an IMultilevelTiledAttributionProvider
.
QuadTreeRasterModel
.
std::shared_ptr<IMultilevelTiledAttributionProvider> myAttributionProvider = IMultilevelTiledAttributionProvider::create( [](const std::vector<MultilevelTileInfo>& /*tiles*/, const CancellationToken& /*cancellationToken*/) { // Search through the tiles and return the appropriate attribution strings std::vector<std::string> strings{"Attribution 1", "Attribution 2"}; return DataAttribution{strings}; }); auto model = QuadTreeRasterModelBuilder::newBuilder() .attributionProvider(myAttributionProvider) ... .build();