From 22b4ef1f4b0ea053068d45bd2b4cffd7f935a250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Thu, 12 Apr 2018 10:42:14 +0200 Subject: Update layer immediately when changing its max/min zoom level (#11399) * [android][core] update layer immediately when changing it's max/min zoom * [core] node bindings for layer zoom range --- platform/node/src/node_map.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'platform/node/src/node_map.cpp') diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 0fe69e8ac9..9b76f0f542 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -74,6 +74,7 @@ void NodeMap::Init(v8::Local target) { Nan::SetPrototypeMethod(tpl, "removeLayer", RemoveLayer); Nan::SetPrototypeMethod(tpl, "addImage", AddImage); Nan::SetPrototypeMethod(tpl, "removeImage", RemoveImage); + Nan::SetPrototypeMethod(tpl, "setLayerZoomRange", SetLayerZoomRange); Nan::SetPrototypeMethod(tpl, "setLayoutProperty", SetLayoutProperty); Nan::SetPrototypeMethod(tpl, "setPaintProperty", SetPaintProperty); Nan::SetPrototypeMethod(tpl, "setFilter", SetFilter); @@ -740,6 +741,33 @@ void NodeMap::RemoveImage(const Nan::FunctionCallbackInfo& info) { nodeMap->map->getStyle().removeImage(*Nan::Utf8String(info[0])); } + +void NodeMap::SetLayerZoomRange(const Nan::FunctionCallbackInfo& info) { + using namespace mbgl::style; + + auto nodeMap = Nan::ObjectWrap::Unwrap(info.Holder()); + if (!nodeMap->map) return Nan::ThrowError(releasedMessage()); + + if (info.Length() != 3) { + return Nan::ThrowTypeError("Three arguments required"); + } + + if (!info[0]->IsString()) { + return Nan::ThrowTypeError("First argument must be a string"); + } + + if (!info[1]->IsNumber() || !info[2]->IsNumber()) { + return Nan::ThrowTypeError("Second and third arguments must be numbers"); + } + + mbgl::style::Layer* layer = nodeMap->map->getStyle().getLayer(*Nan::Utf8String(info[0])); + if (!layer) { + return Nan::ThrowTypeError("layer not found"); + } + + layer->setMinZoom(info[1]->NumberValue()); + layer->setMaxZoom(info[2]->NumberValue()); +} void NodeMap::SetLayoutProperty(const Nan::FunctionCallbackInfo& info) { using namespace mbgl::style; -- cgit v1.2.1