[core] reload geojson source on url change
This commit is contained in:
committed by
Ivo van Dongen
parent
5527887c4b
commit
ab63a9494f
@@ -20,6 +20,9 @@ public:
|
||||
virtual void onSourceAttributionChanged(Source&, const std::string&) {}
|
||||
virtual void onSourceError(Source&, std::exception_ptr) {}
|
||||
|
||||
//Source description needs to be reloaded
|
||||
virtual void onSourceDescriptionChanged(Source&) {}
|
||||
|
||||
virtual void onTileChanged(Source&, const OverscaledTileID&) {}
|
||||
virtual void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) {}
|
||||
};
|
||||
|
||||
@@ -38,6 +38,12 @@ GeoJSONSource::Impl::~Impl() = default;
|
||||
|
||||
void GeoJSONSource::Impl::setURL(std::string url_) {
|
||||
url = std::move(url_);
|
||||
|
||||
//Signal that the source description needs a reload
|
||||
if (loaded) {
|
||||
loaded = false;
|
||||
observer->onSourceDescriptionChanged(base);
|
||||
}
|
||||
}
|
||||
|
||||
optional<std::string> GeoJSONSource::Impl::getURL() {
|
||||
@@ -132,6 +138,7 @@ void GeoJSONSource::Impl::loadDescription(FileSource& fileSource) {
|
||||
|
||||
loaded = true;
|
||||
observer->onSourceLoaded(base);
|
||||
req.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -491,6 +491,13 @@ void Style::onSourceError(Source& source, std::exception_ptr error) {
|
||||
observer->onResourceError(error);
|
||||
}
|
||||
|
||||
void Style::onSourceDescriptionChanged(Source& source) {
|
||||
observer->onSourceDescriptionChanged(source);
|
||||
if (!source.baseImpl->loaded) {
|
||||
source.baseImpl->loadDescription(fileSource);
|
||||
}
|
||||
}
|
||||
|
||||
void Style::onTileChanged(Source& source, const OverscaledTileID& tileID) {
|
||||
observer->onTileChanged(source, tileID);
|
||||
observer->onUpdate(Update::Repaint);
|
||||
|
||||
@@ -134,6 +134,7 @@ private:
|
||||
void onSourceLoaded(Source&) override;
|
||||
void onSourceAttributionChanged(Source&, const std::string&) override;
|
||||
void onSourceError(Source&, std::exception_ptr) override;
|
||||
void onSourceDescriptionChanged(Source&) override;
|
||||
void onTileChanged(Source&, const OverscaledTileID&) override;
|
||||
void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user