summaryrefslogtreecommitdiff
path: root/platform/node
diff options
context:
space:
mode:
authorTom MacWright <tom@macwright.org>2015-10-28 15:48:55 -0400
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-10-29 16:55:30 -0700
commit26cb45ed46f327d3c84d68feeb1c16680e6e9b30 (patch)
tree72cf934ead12cfd6b1896f80d0345ec3385fd3f0 /platform/node
parent7821dccae5d20b697eee2b1ec8b8749878392286 (diff)
downloadqtlocation-mapboxgl-26cb45ed46f327d3c84d68feeb1c16680e6e9b30.tar.gz
Document node-mapbox-gl-native with JSDoc
Diffstat (limited to 'platform/node')
-rw-r--r--platform/node/src/node_map.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index 76e14e3b94..e36f9bc222 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -56,6 +56,45 @@ NAN_MODULE_INIT(NodeMap::Init) {
sharedDisplay();
}
+/**
+ * A request object, given to the `request` handler of a map, is an
+ * encapsulation of a URL and type of a resource that the map asks you to load.
+ *
+ * The `kind` property is one of
+ *
+ * "Unknown": 0,
+ * "Style": 1,
+ * "Source": 2,
+ * "Tile": 3,
+ * "Glyphs": 4,
+ * "SpriteImage": 5,
+ * "SpriteJSON": 6
+ *
+ * @typedef
+ * @name Request
+ * @property {string} url
+ * @property {number} kind
+ */
+
+/**
+ * Mapbox GL object: this object loads stylesheets and renders them into
+ * images.
+ *
+ * @class
+ * @name Map
+ * @param {Object} options
+ * @param {Function} options.request a method used to request resources
+ * over the internet
+ * @param {Function} [options.cancel]
+ * @param {number} options.ratio pixel ratio
+ * @example
+ * var map = new mbgl.Map({ request: function() {} });
+ * map.load(require('./test/fixtures/style.json'));
+ * map.render({}, function(err, image) {
+ * if (err) throw err;
+ * fs.writeFileSync('image.png', image);
+ * });
+ */
NAN_METHOD(NodeMap::New) {
if (!info.IsConstructCall()) {
return Nan::ThrowTypeError("Use the new operator to create new Map objects");
@@ -103,6 +142,21 @@ const std::string StringifyStyle(v8::Local<v8::Value> styleHandle) {
return *Nan::Utf8String(Nan::MakeCallback(JSON, "stringify", 1, &styleHandle));
}
+/**
+ * Load a stylesheet
+ *
+ * @function
+ * @name load
+ * @param {string|Object} stylesheet either an object or a JSON representation
+ * @returns {undefined} loads stylesheet into map
+ * @throws {Error} if stylesheet is missing or invalid
+ * @example
+ * // providing an object
+ * map.load(require('./test/fixtures/style.json'));
+ *
+ * // providing a string
+ * map.load(fs.readFileSync('./test/fixtures/style.json', 'utf8'));
+ */
NAN_METHOD(NodeMap::Load) {
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
@@ -176,6 +230,22 @@ std::unique_ptr<NodeMap::RenderOptions> NodeMap::ParseOptions(v8::Local<v8::Obje
return options;
}
+/**
+ * Render an image from the currently-loaded style
+ *
+ * @name render
+ * @param {Object} options
+ * @param {number} [options.zoom=0]
+ * @param {number} [options.width=512]
+ * @param {number} [options.height=512]
+ * @param {Array<number>} [options.center=[0,0]] latitude, longitude center
+ * of the map
+ * @param {number} [options.bearing=0] rotation
+ * @param {Array<string>} [options.classes=[]] GL Style Classes
+ * @param {Function} callback
+ * @returns {undefined} calls callback
+ * @throws {Error} if stylesheet is not loaded or if map is already rendering
+ */
NAN_METHOD(NodeMap::Render) {
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
@@ -302,6 +372,11 @@ void NodeMap::renderFinished() {
}
}
+/**
+ * Clean up any resources used by a map instance.options
+ * @name release
+ * @returns {undefined}
+ */
NAN_METHOD(NodeMap::Release) {
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());