[core] Generalize Map::{add,remove}CustomLayer

This commit is contained in:
John Firebaugh
2016-04-25 13:14:34 -07:00
parent a43940afb2
commit d7e1ecd19e
10 changed files with 65 additions and 74 deletions

View File

@@ -740,24 +740,17 @@ std::vector<Feature> Map::queryRenderedFeatures(const ScreenBox& box, const opti
#pragma mark - Style API
void Map::addCustomLayer(const std::string& id,
CustomLayerInitializeFunction initialize,
CustomLayerRenderFunction render_,
CustomLayerDeinitializeFunction deinitialize,
void* context_,
const char* before) {
void Map::addLayer(std::unique_ptr<Layer> layer, const optional<std::string>& before) {
impl->view.activate();
impl->style->addLayer(
std::make_unique<CustomLayer>(id, initialize, render_, deinitialize, context_),
before ? std::string(before) : optional<std::string>());
impl->style->addLayer(std::move(layer), before);
impl->updateFlags |= Update::Classes;
impl->asyncUpdate.send();
impl->view.deactivate();
}
void Map::removeCustomLayer(const std::string& id) {
void Map::removeLayer(const std::string& id) {
impl->view.activate();
impl->style->removeLayer(id);