ol-mapbox-style
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -272,8 +272,16 @@ (function(_g){(function(f){var r=(typeof require==='function'?require:function(name){return {"_":null,"openlayers":ol}[name];});if (typeof exports==='object'&&typeof module!=='undefined'){module.exports=f(r)}else if(typeof define==='function'&&define.amd){define(["_","openlayers"],f.bind(_g,r))}else{f(r)}})(function(require,define,module,exports){var _m=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
* @param {string} source `source` key from the Mapbox GL style object. | ||
* @param {Array<number>} resolutions Resolutions for mapping resolution to | ||
* zoom level. For tile layers, this can be | ||
* `layer.getSource().getTileGrid().getResolutions()`. | ||
* @param {Function} onChange Callback which will be called when the style is | ||
* ready to use for rendering, and every time a new resource (e.g. icon sprite | ||
* or font) is ready to be applied. | ||
* @param {Array<number>|undefined} [resolutions=[156543.03392804097, | ||
* 78271.51696402048, 39135.75848201024, 19567.87924100512, 9783.93962050256, | ||
* 4891.96981025128, 2445.98490512564, 1222.99245256282, 611.49622628141, | ||
* 305.748113140705, 152.8740565703525, 76.43702828517625, 38.21851414258813, | ||
* 19.109257071294063, 9.554628535647032, 4.777314267823516, 2.388657133911758, | ||
* 1.194328566955879, 0.5971642834779395, 0.29858214173896974, | ||
* 0.14929107086948487, 0.07464553543474244]] | ||
* Resolutions for mapping resolution to zoom level. For tile layers, this can | ||
* be `layer.getSource().getTileGrid().getResolutions()`. | ||
* @param {Function} [onChange=function() {}] Callback which will be called when | ||
* the style is ready to use for rendering, and every time a new resource (e.g. | ||
* icon sprite or font) is ready to be applied. When the `glStyle` has no | ||
* `sprite` and only standard fonts, the style will be ready to use immediately, | ||
* and the callback can be omitted. | ||
* @return {ol.style.StyleFunction} Style function for use in | ||
@@ -283,2 +291,9 @@ * `ol.layer.Vector` or `ol.layer.VectorTile`. | ||
function getStyleFunction(glStyle, source, resolutions, onChange) { | ||
if (!resolutions) { | ||
resolutions = []; | ||
for (var res = 156543.03392804097; resolutions.length < 22; res /= 2) { | ||
resolutions.push(res); | ||
} | ||
} | ||
onChange = onChange || function() {}; | ||
if (typeof glStyle == 'object') { | ||
@@ -427,3 +442,4 @@ // We do not want to modify the original, so we deep-clone it | ||
} | ||
} else if (type == 'LineString') { | ||
} | ||
if (type != 'Point') { | ||
if (!('line-pattern' in paint) && 'line-color' in paint) { | ||
@@ -430,0 +446,0 @@ color = colorWithOpacity( |
30
index.js
@@ -271,8 +271,16 @@ /* | ||
* @param {string} source `source` key from the Mapbox GL style object. | ||
* @param {Array<number>} resolutions Resolutions for mapping resolution to | ||
* zoom level. For tile layers, this can be | ||
* `layer.getSource().getTileGrid().getResolutions()`. | ||
* @param {Function} onChange Callback which will be called when the style is | ||
* ready to use for rendering, and every time a new resource (e.g. icon sprite | ||
* or font) is ready to be applied. | ||
* @param {Array<number>|undefined} [resolutions=[156543.03392804097, | ||
* 78271.51696402048, 39135.75848201024, 19567.87924100512, 9783.93962050256, | ||
* 4891.96981025128, 2445.98490512564, 1222.99245256282, 611.49622628141, | ||
* 305.748113140705, 152.8740565703525, 76.43702828517625, 38.21851414258813, | ||
* 19.109257071294063, 9.554628535647032, 4.777314267823516, 2.388657133911758, | ||
* 1.194328566955879, 0.5971642834779395, 0.29858214173896974, | ||
* 0.14929107086948487, 0.07464553543474244]] | ||
* Resolutions for mapping resolution to zoom level. For tile layers, this can | ||
* be `layer.getSource().getTileGrid().getResolutions()`. | ||
* @param {Function} [onChange=function() {}] Callback which will be called when | ||
* the style is ready to use for rendering, and every time a new resource (e.g. | ||
* icon sprite or font) is ready to be applied. When the `glStyle` has no | ||
* `sprite` and only standard fonts, the style will be ready to use immediately, | ||
* and the callback can be omitted. | ||
* @return {ol.style.StyleFunction} Style function for use in | ||
@@ -282,2 +290,9 @@ * `ol.layer.Vector` or `ol.layer.VectorTile`. | ||
function getStyleFunction(glStyle, source, resolutions, onChange) { | ||
if (!resolutions) { | ||
resolutions = []; | ||
for (var res = 156543.03392804097; resolutions.length < 22; res /= 2) { | ||
resolutions.push(res); | ||
} | ||
} | ||
onChange = onChange || function() {}; | ||
if (typeof glStyle == 'object') { | ||
@@ -426,3 +441,4 @@ // We do not want to modify the original, so we deep-clone it | ||
} | ||
} else if (type == 'LineString') { | ||
} | ||
if (type != 'Point') { | ||
if (!('line-pattern' in paint) && 'line-color' in paint) { | ||
@@ -429,0 +445,0 @@ color = colorWithOpacity( |
{ | ||
"name": "ol-mapbox-style", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Use Mapbox style objects with OpenLayers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -55,8 +55,16 @@ # ol-mapbox-style | ||
- `source` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `source` key from the Mapbox GL style object. | ||
- `resolutions` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** Resolutions for mapping resolution to | ||
zoom level. For tile layers, this can be | ||
`layer.getSource().getTileGrid().getResolutions()`. | ||
- `onChange` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Callback which will be called when the style is | ||
ready to use for rendering, and every time a new resource (e.g. icon sprite | ||
or font) is ready to be applied. | ||
- `resolutions` **\[([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)> | [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined))]** Resolutions for mapping resolution to zoom level. For tile layers, this can | ||
be `layer.getSource().getTileGrid().getResolutions()`. (optional, default `[156543.03392804097, | ||
78271.51696402048,39135.75848201024,19567.87924100512,9783.93962050256, | ||
4891.96981025128,2445.98490512564,1222.99245256282,611.49622628141, | ||
305.748113140705,152.8740565703525,76.43702828517625,38.21851414258813, | ||
19.109257071294063,9.554628535647032,4.777314267823516,2.388657133911758, | ||
1.194328566955879,0.5971642834779395,0.29858214173896974, | ||
0.14929107086948487]`) | ||
- `onChange` **\[[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)]** Callback which will be called when | ||
the style is ready to use for rendering, and every time a new resource (e.g. | ||
icon sprite or font) is ready to be applied. When the `glStyle` has no | ||
`sprite` and only standard fonts, the style will be ready to use | ||
immediately, and the callback can be omitted. (optional, default | ||
`function(){}`) | ||
@@ -63,0 +71,0 @@ Returns **ol.style.StyleFunction** Style function for use in |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77200
1988
95