[core] [android] Fix InfoWindow topOffsetPixels adjustment when switching styles
Fixes #2599 Make getTopOffsetPixelsForAnnotationSymbol private Also implements MapChangeWillStartLoadingMap, MapChangeDidFinishLoadingMap Paritally implements #630
This commit is contained in:
@@ -74,6 +74,10 @@ void Map::renderSync() {
|
||||
} else if (renderState != RenderState::fully) {
|
||||
renderState = RenderState::fully;
|
||||
view.notifyMapChange(MapChangeDidFinishRenderingMapFullyRendered);
|
||||
if (data->loading) {
|
||||
data->loading = false;
|
||||
view.notifyMapChange(MapChangeDidFinishLoadingMap);
|
||||
}
|
||||
}
|
||||
|
||||
// Triggers an asynchronous update, that eventually triggers a view
|
||||
@@ -93,10 +97,12 @@ void Map::update(Update flags) {
|
||||
#pragma mark - Style
|
||||
|
||||
void Map::setStyleURL(const std::string &url) {
|
||||
view.notifyMapChange(MapChangeWillStartLoadingMap);
|
||||
context->invoke(&MapContext::setStyleURL, url);
|
||||
}
|
||||
|
||||
void Map::setStyleJSON(const std::string& json, const std::string& base) {
|
||||
view.notifyMapChange(MapChangeWillStartLoadingMap);
|
||||
context->invoke(&MapContext::setStyleJSON, json, base);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,10 +92,6 @@ void MapContext::triggerUpdate(const TransformState& state, const Update flags)
|
||||
}
|
||||
|
||||
void MapContext::setStyleURL(const std::string& url) {
|
||||
if (styleURL == url) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileSource* fs = util::ThreadContext::getFileSource();
|
||||
|
||||
if (styleRequest) {
|
||||
@@ -120,15 +116,12 @@ void MapContext::setStyleURL(const std::string& url) {
|
||||
loadStyleJSON(res.data, base);
|
||||
} else {
|
||||
Log::Error(Event::Setup, "loading style failed: %s", res.message.c_str());
|
||||
data.loading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MapContext::setStyleJSON(const std::string& json, const std::string& base) {
|
||||
if (styleJSON == json) {
|
||||
return;
|
||||
}
|
||||
|
||||
styleURL.clear();
|
||||
styleJSON = json;
|
||||
|
||||
@@ -146,6 +139,10 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base)
|
||||
// force style cascade, causing all pending transitions to complete.
|
||||
style->cascade();
|
||||
|
||||
// set loading here so we don't get a false loaded event as soon as map is
|
||||
// created but before a style is loaded
|
||||
data.loading = true;
|
||||
|
||||
updateFlags |= Update::DefaultTransition | Update::Classes | Update::Zoom | Update::Annotations;
|
||||
asyncUpdate->send();
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ public:
|
||||
bool paused = false;
|
||||
std::mutex mutexPause;
|
||||
std::condition_variable condPause;
|
||||
bool loading = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user