[core] map snapshotter - add attributions to snapshotter callback

This commit is contained in:
Ivo van Dongen
2017-10-27 20:05:45 +03:00
committed by Ivo van Dongen
parent 3cdb249c70
commit 2c0c516354
2 changed files with 14 additions and 1 deletions

View File

@@ -76,10 +76,21 @@ void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback)
return transform.latLngToScreenCoordinate(unwrappedLatLng);
}};
// Collect all source attributions
std::vector<std::string> attributions;
for (auto source : map.getStyle().getSources()) {
auto attribution = source->getAttribution();
if (attribution) {
attributions.push_back(*attribution);
}
}
// Invoke callback
callback.invoke(
&MapSnapshotter::Callback::operator(),
error,
error ? PremultipliedImage() : frontend.readStillImage(),
std::move(attributions),
std::move(pointForFn)
);
});

View File

@@ -8,6 +8,7 @@
#include <exception>
#include <memory>
#include <string>
#include <vector>
#include <functional>
namespace mbgl {
@@ -48,7 +49,8 @@ public:
LatLngBounds getRegion() const;
using PointForFn = std::function<ScreenCoordinate (const LatLng&)>;
using Callback = std::function<void (std::exception_ptr, PremultipliedImage, PointForFn)>;
using Attributions = std::vector<std::string>;
using Callback = std::function<void (std::exception_ptr, PremultipliedImage, Attributions, PointForFn)>;
void snapshot(ActorRef<Callback>);
private: