[core] geojson source - cancel any pending request when setting geojson explicitly
This commit is contained in:
committed by
Ivo van Dongen
parent
6277dca898
commit
b14e83ea40
@@ -51,7 +51,14 @@ optional<std::string> GeoJSONSource::Impl::getURL() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
void GeoJSONSource::Impl::setGeoJSON(const GeoJSON& geoJSON) {
|
||||
req.reset();
|
||||
_setGeoJSON(geoJSON);
|
||||
}
|
||||
|
||||
//Private implementation
|
||||
void GeoJSONSource::Impl::_setGeoJSON(const GeoJSON& geoJSON) {
|
||||
double scale = util::EXTENT / util::tileSize;
|
||||
|
||||
cache.clear();
|
||||
@@ -74,7 +81,7 @@ void GeoJSONSource::Impl::setGeoJSON(const GeoJSON& geoJSON) {
|
||||
geoJSONOrSupercluster =
|
||||
std::make_unique<mapbox::supercluster::Supercluster>(features, clusterOptions);
|
||||
}
|
||||
|
||||
|
||||
for (auto const &item : tiles) {
|
||||
GeoJSONTile* geoJSONTile = static_cast<GeoJSONTile*>(item.second.get());
|
||||
setTileData(*geoJSONTile, geoJSONTile->id);
|
||||
@@ -134,9 +141,9 @@ void GeoJSONSource::Impl::loadDescription(FileSource& fileSource) {
|
||||
geoJSON.error().message.c_str());
|
||||
// Create an empty GeoJSON VT object to make sure we're not infinitely waiting for
|
||||
// tiles to load.
|
||||
setGeoJSON(GeoJSON{ FeatureCollection{} });
|
||||
_setGeoJSON(GeoJSON{ FeatureCollection{} });
|
||||
} else {
|
||||
setGeoJSON(*geoJSON);
|
||||
_setGeoJSON(*geoJSON);
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
|
||||
@@ -29,6 +29,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void _setGeoJSON(const GeoJSON&);
|
||||
|
||||
Range<uint8_t> getZoomRange() final;
|
||||
std::unique_ptr<Tile> createTile(const OverscaledTileID&, const UpdateParameters&) final;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user