summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorŁukasz Paczos <lukasz.paczos@mapbox.com>2018-04-12 10:42:14 +0200
committerGitHub <noreply@github.com>2018-04-12 10:42:14 +0200
commit22b4ef1f4b0ea053068d45bd2b4cffd7f935a250 (patch)
tree641cecffdddb3ed086e6b03d118311d939d94aa3 /platform
parentaaba667cc3afaddd21c63d396e9d98ab59b52c65 (diff)
downloadqtlocation-mapboxgl-22b4ef1f4b0ea053068d45bd2b4cffd7f935a250.tar.gz
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
Diffstat (limited to 'platform')
-rw-r--r--platform/node/src/node_map.cpp28
-rw-r--r--platform/node/src/node_map.hpp1
-rw-r--r--platform/node/test/js/map.test.js1
3 files changed, 30 insertions, 0 deletions
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<v8::Object> 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<v8::Value>& info) {
nodeMap->map->getStyle().removeImage(*Nan::Utf8String(info[0]));
}
+
+void NodeMap::SetLayerZoomRange(const Nan::FunctionCallbackInfo<v8::Value>& info) {
+ using namespace mbgl::style;
+
+ auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(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<v8::Value>& info) {
using namespace mbgl::style;
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp
index efa6f6cee0..7fe23ad86a 100644
--- a/platform/node/src/node_map.hpp
+++ b/platform/node/src/node_map.hpp
@@ -50,6 +50,7 @@ public:
static void RemoveLayer(const Nan::FunctionCallbackInfo<v8::Value>&);
static void AddImage(const Nan::FunctionCallbackInfo<v8::Value>&);
static void RemoveImage(const Nan::FunctionCallbackInfo<v8::Value>&);
+ static void SetLayerZoomRange(const Nan::FunctionCallbackInfo<v8::Value>&);
static void SetLayoutProperty(const Nan::FunctionCallbackInfo<v8::Value>&);
static void SetPaintProperty(const Nan::FunctionCallbackInfo<v8::Value>&);
static void SetFilter(const Nan::FunctionCallbackInfo<v8::Value>&);
diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js
index 81c15f9c1b..ce22816ef2 100644
--- a/platform/node/test/js/map.test.js
+++ b/platform/node/test/js/map.test.js
@@ -114,6 +114,7 @@ test('Map', function(t) {
'removeLayer',
'addImage',
'removeImage',
+ 'setLayerZoomRange',
'setLayoutProperty',
'setPaintProperty',
'setFilter',