// Load the scene at the given absolute file path asynchronously
void loadSceneAsync(const char* _scenePath, bool _useScenePosition = false,
- std::function<void(void*)> _platformCallback = {}, void *_cbData = nullptr);
+ std::function<void(void*)> _platformCallback = {}, void *_cbData = nullptr,
+ const std::vector<SceneUpdate>& sceneUpdates = {});
// Load the scene at the given absolute file path synchronously
- void loadScene(const char* _scenePath, bool _useScenePosition = false);
+ void loadScene(const char* _scenePath, bool _useScenePosition = false,
+ const std::vector<SceneUpdate>& sceneUpdates = {});
// Request an update to the scene configuration; the path is a series of yaml keys
// separated by a '.' and the value is a string of yaml to replace the current value
// at the given path in the scene
void queueSceneUpdate(const char* _path, const char* _value);
+ void queueSceneUpdate(std::vector<SceneUpdate> sceneUpdates);
// Apply all previously requested scene updates
void applySceneUpdates();
return;
}
+ std::vector<Tangram::SceneUpdate> sceneUpdates;
maps_view_type_e map_type;
maps_view_get_type(view, &map_type);
tangram_view_type newViewType = (tangram_view_type)convert_maps_view_type_to_tangram_view_type(map_type);
- // Loading a new tangram scene resets the map states/caches.
+ // If Scene is being reloaded then reset all the scene preferences to their defaults (building/transit/language/providerKey)
if (newViewType != m_viewType) {
- const char* newSceneFile = NORMAL_SCENE_FILE_PATH;
- switch(newViewType) {
- case TANGRAM_VIEW_TERRAIN:
- newSceneFile = TERRAIN_SCENE_FILE_PATH;
- break;
- case TANGRAM_VIEW_NORMAL:
- newSceneFile = NORMAL_SCENE_FILE_PATH;
- break;
- default:
- return;
- }
- m_viewType = newViewType;
- m_map->loadSceneAsync(newSceneFile, false, sceneLoadedCb, (void*)view);
+ m_buildingsEnabled = true;
+ m_publicTransitEnabled = false;
+ m_language = "eng";
m_isProviderKeySet = false;
-
- // When the scene is changed, update the 'sdk-point-overlay' style to remove it's texture;
- // this allows us to use this style for markers with custom bitmaps.
- m_map->queueSceneUpdate("styles.sdk-point-overlay.texture", "null");
}
bool buildings_enabled = false;
if (buildings_enabled != m_buildingsEnabled) {
m_buildingsEnabled = buildings_enabled;
if (m_buildingsEnabled) {
- m_map->queueSceneUpdate("global.building_extrude", "true");
+ sceneUpdates.push_back( {"global.building_extrude", "true"} );
} else {
- m_map->queueSceneUpdate("global.building_extrude", "false");
+ sceneUpdates.push_back( {"global.building_extrude", "false"} );
}
}
if (public_transit_enabled != m_publicTransitEnabled) {
m_publicTransitEnabled = public_transit_enabled;
if (m_publicTransitEnabled) {
- m_map->queueSceneUpdate("global.sdk_transit_overlay", "true");
+ sceneUpdates.push_back( {"global.sdk_transit_overlay", "true"} );
} else {
- m_map->queueSceneUpdate("global.sdk_transit_overlay", "false");
+ sceneUpdates.push_back( {"global.sdk_transit_overlay", "false"} );
}
}
char* language = nullptr;
maps_view_get_language(view, &language);
- if (std::string(language) != m_language) {
+ if (m_language != language) {
m_language = language;
- m_map->queueSceneUpdate("global.ux_language", m_language.c_str());
+ sceneUpdates.push_back( {"global.ux_language", m_language.c_str()} );
}
free(language);
// set provider key for vector tiles
if (m_providerKey.size() > 0 && !m_isProviderKeySet) {
MAPS_LOGD("Queueing API key update: %s", m_providerKey.c_str());
- m_map->queueSceneUpdate("sources.mapzen.url_params.api_key", m_providerKey.c_str());
+ sceneUpdates.push_back( {"sources.mapzen.url_params.api_key", m_providerKey.c_str()} );
m_isProviderKeySet = true;
}
- // bool traffic_enabled = false;
- // maps_view_get_traffic_enabled(view, &traffic_enabled);
- m_map->applySceneUpdates();
+ // Loading a new tangram scene resets the map states/caches.
+ if (newViewType != m_viewType) {
+ // When the scene is changed, update the 'sdk-point-overlay' style to remove it's texture;
+ // this allows us to use this style for markers with custom bitmaps.
+ sceneUpdates.push_back( {"styles.sdk-point-overlay.texture", "null"} );
+
+ const char* newSceneFile = NORMAL_SCENE_FILE_PATH;
+ switch(newViewType) {
+ case TANGRAM_VIEW_TERRAIN:
+ newSceneFile = TERRAIN_SCENE_FILE_PATH;
+ break;
+ case TANGRAM_VIEW_NORMAL:
+ newSceneFile = NORMAL_SCENE_FILE_PATH;
+ break;
+ default:
+ return;
+ }
+ m_viewType = newViewType;
+ m_map->loadSceneAsync(newSceneFile, false, sceneLoadedCb, (void*)view, sceneUpdates);
+ } else {
+ // bool traffic_enabled = false;
+ // maps_view_get_traffic_enabled(view, &traffic_enabled);
+ if (sceneUpdates.empty()) { return; }
+ m_map->queueSceneUpdate(sceneUpdates);
+ m_map->applySceneUpdates();
+ }
}
void TangramView::sceneLoadedCb(void *data) {