diff --git a/README.md b/README.md index 0406259..63d1483 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ This Leaflet plugin adds a Vega layer on top of the map, and provides two way si Optionally, provide additional parameters to vegaLayer(): * `vega` - custom instance of Vega library -* `parseConfig` - Options to be passed to the Vega parse method -* `viewConfig` - Options to be passed ot the Vega View constructor +* `parseConfig` - Config to be passed to the Vega parse method +* `parseOptions` - Options to be passed to the Vega parse method +* `viewConfig` - Config to be passed ot the Vega View constructor # Usage (Vega spec) diff --git a/dist/bundle.js b/dist/bundle.js index 6f22506..79f9937 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1,5 +1,5 @@ -/* leaflet-vega - v0.8.6 - Mon Apr 23 2018 00:57:57 GMT+0300 (MSK) - * Copyright (c) 2018 Yuri Astrakhan +/* leaflet-vega - v0.8.7 - Sun Sep 11 2022 11:26:23 GMT-0700 (Pacific Daylight Time) + * Copyright (c) 2022 Yuri Astrakhan * BSD-2-Clause */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('leaflet')) : @@ -112,7 +112,7 @@ var _class = function () { return _class; }(); -var version = "0.8.6"; +var version = "0.8.7"; var asyncToGenerator = function (fn) { return function () { @@ -226,10 +226,13 @@ L.VegaLayer = (L.Layer ? L.Layer : L.Class).extend({ // If Vega spec creates controls (inputs), put them all into this container bindingsContainer: undefined, - // Options to be passed to the Vega`s parse method + // Config to be passed to the Vega`s parse method parseConfig: undefined, - // Options to be passed ot the Vega`s View constructor + // Options to be passed to the Vega`s parse method + parseOptions: undefined, + + // Config to be passed ot the Vega`s View constructor viewConfig: undefined, // If true, graph will be repainted only after the map has finished moving (faster) @@ -322,7 +325,7 @@ L.VegaLayer = (L.Layer ? L.Layer : L.Class).extend({ map._panes.overlayPane.appendChild(_this2._vegaContainer); _options = _this2.options, vega = _options.vega, viewConfig = _options.viewConfig; - dataflow = vega.parse(_this2._spec, _this2.options.parseConfig); + dataflow = vega.parse(_this2._spec, _this2.options.parseConfig, _this2.options.parseOptions); if (viewConfig && viewConfig.loader) { diff --git a/dist/bundle.js.map b/dist/bundle.js.map index 9f2a8b7..bd04f6e 100644 --- a/dist/bundle.js.map +++ b/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"bundle.js","sources":["../node_modules/vega-spec-injector/es/index.js","../src/VegaLayer.js"],"sourcesContent":["function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar _class = function () {\n function _class(onWarning) {\n _classCallCheck(this, _class);\n\n this.onWarning = onWarning || (console ? console.log : function () {});\n }\n\n /**\n * Add values like signals to a vega spec, or ignore if the they are already defined.\n * @param {object} spec vega spec to modify and return\n * @param {string} field name of the vega spec branch, e.g. `signals`\n * @param {[]} values to add\n * @return {object} returns the same spec object as passed in\n */\n\n\n _class.prototype.addToList = function addToList(spec, field, values) {\n var newSigs = new Map(values.map(function (v) {\n return typeof v === \"string\" ? [v, { name: v }] : [v.name, v];\n }));\n\n for (var _iterator = this.findUndefined(spec, field, newSigs.keys()), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {\n var _ref;\n\n if (_isArray) {\n if (_i >= _iterator.length) break;\n _ref = _iterator[_i++];\n } else {\n _i = _iterator.next();\n if (_i.done) break;\n _ref = _i.value;\n }\n\n var sig = _ref;\n\n spec[field].push(newSigs.get(sig));\n }\n\n return spec;\n };\n\n /**\n * Set a spec field, and warn if overriding an existing value in that field\n * @param {object} spec vega spec to modify and return\n * @param {string} field\n * @param {*} value\n * @return {object} returns the same spec object as passed in\n */\n\n\n _class.prototype.overrideField = function overrideField(spec, field, value) {\n if (spec[field] && spec[field] !== value) {\n this.onWarning(\"Overriding \" + field + \": \" + spec[field] + \" \\uD800\\uDCD8 \" + value);\n }\n spec[field] = value;\n return spec;\n };\n\n /**\n * Find all names that are not defined in the spec's section. Creates section if missing.\n * @param {object} spec\n * @param {string} section\n * @param {Iterable.} names\n * @return {Iterable.}\n */\n\n\n _class.prototype.findUndefined = function findUndefined(spec, section, names) {\n if (!spec.hasOwnProperty(section)) {\n spec[section] = [];\n return names;\n } else if (!Array.isArray(spec[section])) {\n throw new Error(\"spec.\" + section + \" must be an array\");\n }\n\n var nameStrings = new Set(names);\n for (var _iterator2 = spec[section], _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {\n var _ref2;\n\n if (_isArray2) {\n if (_i2 >= _iterator2.length) break;\n _ref2 = _iterator2[_i2++];\n } else {\n _i2 = _iterator2.next();\n if (_i2.done) break;\n _ref2 = _i2.value;\n }\n\n var obj = _ref2;\n\n // If obj has a name field, delete that name from the names\n // Set will silently ignore delete() for undefined names\n if (obj.name) nameStrings.delete(obj.name);\n }\n\n return nameStrings;\n };\n\n return _class;\n}();\n\nexport default _class;","import Vsi from 'vega-spec-injector';\n// eslint-disable-next-line import/extensions,import/no-unresolved\nimport L from 'leaflet';\nimport { version } from '../package.json';\n\nL.vega = function vega(spec, options) {\n return new L.VegaLayer(spec, options);\n};\n\nL.VegaLayer = (L.Layer ? L.Layer : L.Class).extend({\n\n options: {\n // FIXME: uses window.vega\n // eslint-disable-next-line no-undef\n vega: window && window.vega,\n\n // If Vega spec creates controls (inputs), put them all into this container\n bindingsContainer: undefined,\n\n // Options to be passed to the Vega`s parse method\n parseConfig: undefined,\n\n // Options to be passed ot the Vega`s View constructor\n viewConfig: undefined,\n\n // If true, graph will be repainted only after the map has finished moving (faster)\n delayRepaint: true,\n\n // optional warning handler: (warning) => { ... }\n onWarning: false,\n\n // optional error handler: (err) => { ...; throw err; }\n onError: false,\n },\n\n initialize(spec, options) {\n L.Util.setOptions(this, options);\n\n // expression parsing in Vega is global,\n // ensure it hasn't been intialized before,\n // and make sure calls to setMapView() only happen\n // when the View instance was created by us\n const { vega } = this.options;\n if (!vega.expressionFunction('setMapView')) {\n vega.expressionFunction(\n 'setMapView',\n function setMapView(...args) {\n const view = this.context.dataflow;\n const handler = view.Leaflet_setMapViewHandler;\n if (!handler) throw new Error('setMapView() is not defined for this graph');\n view.runAfter(() => handler(...args));\n }\n );\n }\n this._ignoreSignals = 0;\n this.disableSignals = () => {\n this._ignoreSignals++;\n };\n this.enableSignals = () => {\n this._ignoreSignals--;\n if (this._ignoreSignals < 0) {\n this._ignoreSignals = 0;\n throw new Error('Too many calls to enableSignals()');\n }\n };\n\n // Inject signals into the spec\n const vsi = new Vsi(options.onWarning);\n\n vsi.overrideField(spec, 'padding', 0);\n vsi.overrideField(spec, 'autosize', 'none');\n vsi.addToList(spec, 'signals', ['zoom', 'latitude', 'longitude']);\n vsi.addToList(spec, 'projections', [this.defaultProjection]);\n\n this._spec = spec;\n },\n\n /**\n * @param {L.Map} map\n * @return {L.VegaLayer}\n */\n addTo(map) {\n map.addLayer(this);\n return this;\n },\n\n onAdd(map) {\n this._onAddAsync(map);\n return this;\n },\n\n async _onAddAsync(map) {\n this.disableSignals();\n\n try {\n this._map = map;\n this._vegaContainer = L.DomUtil.create('div', 'leaflet-vega-container');\n map._panes.overlayPane.appendChild(this._vegaContainer);\n\n const { vega, viewConfig } = this.options;\n\n const dataflow = vega.parse(this._spec, this.options.parseConfig);\n\n if (viewConfig && viewConfig.loader) {\n const oldLoad = viewConfig.loader.load.bind(viewConfig.loader);\n viewConfig.loader.load = (uri, opt) => oldLoad(uri, opt);\n }\n this._view = new vega.View(dataflow, viewConfig);\n\n if (!viewConfig || viewConfig.logLevel === undefined) {\n this._view.logLevel(vega.Warn);\n }\n if (this.options.onWarning) {\n this._view.warn = this.options.onWarning;\n }\n if (this.options.onError) {\n this._view.error = this.options.onError;\n }\n\n this._view\n .padding({\n left: 0, right: 0, top: 0, bottom: 0,\n })\n .initialize(this._vegaContainer, this.options.bindingsContainer)\n .hover();\n\n const onSignal = (sig, value) => this._onSignalChange(sig, value);\n\n this._view\n .addSignalListener('latitude', onSignal)\n .addSignalListener('longitude', onSignal)\n .addSignalListener('zoom', onSignal);\n\n map.on(this.options.delayRepaint ? 'moveend' : 'move', () => this._resetAsync());\n map.on('zoomend', () => this._resetAsync());\n\n /**\n * Given longitude/latitude/zoom or bounding box, position the map to those coordinates\n * The function can be called in one of the following ways:\n * setMapView(latitude, longitude)\n * setMapView(latitude, longitude, zoom)\n * setMapView([longitude, latitude])\n * setMapView([longitude, latitude], zoom)\n * setMapView([[lng1,lat1],[lng2,lat2]])\n */\n this._view.Leaflet_setMapViewHandler = (...args) => {\n function throwError() {\n throw new Error('Unexpected setMapView() parameters. It could be called with a bounding box setMapView([[longitude1,latitude1],[longitude2,latitude2]]), or it could be the center point setMapView([longitude, latitude], optional_zoom), or it can be used as setMapView(latitude, longitude, optional_zoom)');\n }\n\n function checkArray(val) {\n if (!Array.isArray(val) || val.length !== 2 ||\n typeof val[0] !== 'number' || typeof val[1] !== 'number'\n ) {\n throwError();\n }\n return val;\n }\n\n let lng;\n let lat;\n let zoom;\n switch (args.length) {\n default:\n throwError();\n break;\n case 1: {\n const arg = args[0];\n if (Array.isArray(arg) && arg.length === 2 &&\n Array.isArray(arg[0]) && Array.isArray(arg[1])\n ) {\n // called with a bounding box, need to reverse order\n const [lng1, lat1] = checkArray(arg[0]);\n const [lng2, lat2] = checkArray(arg[1]);\n map.fitBounds(L.latLngBounds(L.latLng(lat1, lng1), L.latLng(lat2, lng2)));\n } else {\n // called with a center point and no zoom\n [lng, lat] = checkArray(arg);\n }\n break;\n }\n case 2:\n if (Array.isArray(args[0])) {\n [lng, lat] = checkArray(args[0]);\n // eslint-disable-next-line prefer-destructuring\n zoom = args[1];\n } else {\n [lat, lng] = args;\n }\n break;\n case 3:\n [lat, lng, zoom] = args;\n break;\n }\n\n if (lat !== undefined && lng !== undefined) {\n if (typeof lat !== 'number' || typeof lng !== 'number') {\n throwError();\n }\n if (zoom === undefined) {\n zoom = map.getZoom();\n } else if (typeof zoom !== 'number') {\n throwError();\n }\n map.setView({ lat, lng }, zoom);\n }\n };\n await this._resetAsync(true);\n } catch (err) {\n this._reportError(err);\n } finally {\n this.enableSignals();\n }\n },\n\n onRemove() {\n if (this._view) {\n this._view.finalize();\n this._view = null;\n }\n\n // TODO: once Leaflet 0.7 is fully out of the picture, replace this with L.DomUtil.empty()\n const el = this._vegaContainer;\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n },\n\n _reportError(err) {\n /* eslint-disable no-console */\n if (this.options.onError) {\n this.options.onError(err);\n } else if (console && console.error) {\n console.error(err);\n }\n /* eslint-enable */\n },\n\n _onSignalChange(sig, value) {\n if (this._ignoreSignals) {\n return;\n }\n\n try {\n const map = this._map;\n const center = map.getCenter();\n let zoom = map.getZoom();\n\n switch (sig) {\n case 'latitude':\n center.lat = value;\n break;\n case 'longitude':\n center.lng = value;\n break;\n case 'zoom':\n zoom = value;\n break;\n default:\n return; // ignore\n }\n\n map.setView(center, zoom);\n } catch (err) {\n this._reportError(err);\n }\n },\n\n async _resetAsync(force) {\n if (!this._view) return;\n\n this.disableSignals();\n try {\n const map = this._map;\n const view = this._view;\n const topLeft = map.containerPointToLayerPoint([0, 0]);\n L.DomUtil.setPosition(this._vegaContainer, topLeft);\n\n const size = map.getSize();\n const center = map.getCenter();\n const zoom = map.getZoom();\n\n // Only send changed signals to Vega.\n // Detect if any of the signals have changed before calling run()\n const sendSignal = (sig, value) => {\n if (view.signal(sig) !== value) {\n view.signal(sig, value);\n return 1;\n }\n return 0;\n };\n\n // update if any of the signal's values have changed\n const changed =\n sendSignal('width', size.x) +\n sendSignal('height', size.y) +\n sendSignal('latitude', center.lat) +\n sendSignal('longitude', center.lng) +\n sendSignal('zoom', zoom);\n\n if (changed > 0 || force) {\n await view.runAsync();\n }\n } catch (err) {\n this._reportError(err);\n } finally {\n this.enableSignals();\n }\n },\n\n defaultProjection: {\n name: 'projection',\n type: 'mercator',\n scale: { signal: '256*pow(2,zoom)/2/PI' },\n rotate: [{ signal: '-longitude' }, 0, 0],\n center: [0, { signal: 'latitude' }],\n translate: [{ signal: 'width/2' }, { signal: 'height/2' }],\n fit: false,\n },\n\n});\n\nL.VegaLayer.version = version;\n"],"names":["L","vega","spec","options","VegaLayer","Layer","Class","extend","window","undefined","Util","setOptions","expressionFunction","setMapView","args","view","context","dataflow","handler","Leaflet_setMapViewHandler","Error","runAfter","_ignoreSignals","disableSignals","enableSignals","vsi","Vsi","onWarning","overrideField","addToList","defaultProjection","_spec","map","addLayer","_onAddAsync","_map","_vegaContainer","DomUtil","create","_panes","overlayPane","appendChild","viewConfig","parse","parseConfig","loader","load","bind","uri","opt","oldLoad","_view","View","logLevel","Warn","warn","onError","error","padding","right","top","bottom","initialize","bindingsContainer","hover","onSignal","sig","value","_onSignalChange","addSignalListener","on","delayRepaint","_resetAsync","throwError","checkArray","val","Array","isArray","length","lng","lat","zoom","arg","lng1","lat1","lng2","lat2","fitBounds","latLngBounds","latLng","getZoom","setView","_reportError","finalize","el","firstChild","removeChild","err","console","center","getCenter","force","containerPointToLayerPoint","setPosition","topLeft","getSize","sendSignal","signal","size","x","y","changed","runAsync","version"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,YAAY,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC,EAAE,EAAE;;AAEzJ,IAAI,MAAM,GAAG,YAAY;EACvB,SAAS,MAAM,CAAC,SAAS,EAAE;IACzB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;;IAE9B,IAAI,CAAC,SAAS,GAAG,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,GAAG,GAAG,YAAY,EAAE,CAAC,CAAC;GACxE;;;;;;;;;;;EAWD,MAAM,CAAC,SAAS,CAAC,SAAS,GAAG,SAAS,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IACnE,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,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AD,EAA2B,CAA3B,EAA8B,CAA9B,CAJS;YAKT,CAAC,CAAD,EAAI,EAAEA,QAAQ,UAAV,EAAJ,CALS;eAMN,CAAC,EAAEA,QAAQ,SAAV,EAAD,EAAwB,EAAEA,QAAQ,UAAV,EAAxB,CANM;SAOZ;;;CApTK,CAAd;;AAyTA3G,EAAEI,SAAF,CAAY6G,OAAZ,GAAsBA,OAAtB;;;;"} \ No newline at end of file +{"version":3,"file":"bundle.js","sources":["../node_modules/vega-spec-injector/es/index.js","../src/VegaLayer.js"],"sourcesContent":["function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar _class = function () {\n function _class(onWarning) {\n _classCallCheck(this, _class);\n\n this.onWarning = onWarning || (console ? console.log : function () {});\n }\n\n /**\n * Add values like signals to a vega spec, or ignore if the they are already defined.\n * @param {object} spec vega spec to modify and return\n * @param {string} field name of the vega spec branch, e.g. `signals`\n * @param {[]} values to add\n * @return {object} returns the same spec object as passed in\n */\n\n\n _class.prototype.addToList = function addToList(spec, field, values) {\n var newSigs = new Map(values.map(function (v) {\n return typeof v === \"string\" ? [v, { name: v }] : [v.name, v];\n }));\n\n for (var _iterator = this.findUndefined(spec, field, newSigs.keys()), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {\n var _ref;\n\n if (_isArray) {\n if (_i >= _iterator.length) break;\n _ref = _iterator[_i++];\n } else {\n _i = _iterator.next();\n if (_i.done) break;\n _ref = _i.value;\n }\n\n var sig = _ref;\n\n spec[field].push(newSigs.get(sig));\n }\n\n return spec;\n };\n\n /**\n * Set a spec field, and warn if overriding an existing value in that field\n * @param {object} spec vega spec to modify and return\n * @param {string} field\n * @param {*} value\n * @return {object} returns the same spec object as passed in\n */\n\n\n _class.prototype.overrideField = function overrideField(spec, field, value) {\n if (spec[field] && spec[field] !== value) {\n this.onWarning(\"Overriding \" + field + \": \" + spec[field] + \" \\uD800\\uDCD8 \" + value);\n }\n spec[field] = value;\n return spec;\n };\n\n /**\n * Find all names that are not defined in the spec's section. Creates section if missing.\n * @param {object} spec\n * @param {string} section\n * @param {Iterable.} names\n * @return {Iterable.}\n */\n\n\n _class.prototype.findUndefined = function findUndefined(spec, section, names) {\n if (!spec.hasOwnProperty(section)) {\n spec[section] = [];\n return names;\n } else if (!Array.isArray(spec[section])) {\n throw new Error(\"spec.\" + section + \" must be an array\");\n }\n\n var nameStrings = new Set(names);\n for (var _iterator2 = spec[section], _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {\n var _ref2;\n\n if (_isArray2) {\n if (_i2 >= _iterator2.length) break;\n _ref2 = _iterator2[_i2++];\n } else {\n _i2 = _iterator2.next();\n if (_i2.done) break;\n _ref2 = _i2.value;\n }\n\n var obj = _ref2;\n\n // If obj has a name field, delete that name from the names\n // Set will silently ignore delete() for undefined names\n if (obj.name) nameStrings.delete(obj.name);\n }\n\n return nameStrings;\n };\n\n return _class;\n}();\n\nexport default _class;","import Vsi from 'vega-spec-injector';\n// eslint-disable-next-line import/extensions,import/no-unresolved\nimport L from 'leaflet';\nimport { version } from '../package.json';\n\nL.vega = function vega(spec, options) {\n return new L.VegaLayer(spec, options);\n};\n\nL.VegaLayer = (L.Layer ? L.Layer : L.Class).extend({\n\n options: {\n // FIXME: uses window.vega\n // eslint-disable-next-line no-undef\n vega: window && window.vega,\n\n // If Vega spec creates controls (inputs), put them all into this container\n bindingsContainer: undefined,\n\n // Config to be passed to the Vega`s parse method\n parseConfig: undefined,\n\n // Options to be passed to the Vega`s parse method\n parseOptions: undefined,\n\n // Config to be passed ot the Vega`s View constructor\n viewConfig: undefined,\n\n // If true, graph will be repainted only after the map has finished moving (faster)\n delayRepaint: true,\n\n // optional warning handler: (warning) => { ... }\n onWarning: false,\n\n // optional error handler: (err) => { ...; throw err; }\n onError: false,\n },\n\n initialize(spec, options) {\n L.Util.setOptions(this, options);\n\n // expression parsing in Vega is global,\n // ensure it hasn't been intialized before,\n // and make sure calls to setMapView() only happen\n // when the View instance was created by us\n const { vega } = this.options;\n if (!vega.expressionFunction('setMapView')) {\n vega.expressionFunction(\n 'setMapView',\n function setMapView(...args) {\n const view = this.context.dataflow;\n const handler = view.Leaflet_setMapViewHandler;\n if (!handler) throw new Error('setMapView() is not defined for this graph');\n view.runAfter(() => handler(...args));\n }\n );\n }\n this._ignoreSignals = 0;\n this.disableSignals = () => {\n this._ignoreSignals++;\n };\n this.enableSignals = () => {\n this._ignoreSignals--;\n if (this._ignoreSignals < 0) {\n this._ignoreSignals = 0;\n throw new Error('Too many calls to enableSignals()');\n }\n };\n\n // Inject signals into the spec\n const vsi = new Vsi(options.onWarning);\n\n vsi.overrideField(spec, 'padding', 0);\n vsi.overrideField(spec, 'autosize', 'none');\n vsi.addToList(spec, 'signals', ['zoom', 'latitude', 'longitude']);\n vsi.addToList(spec, 'projections', [this.defaultProjection]);\n\n this._spec = spec;\n },\n\n /**\n * @param {L.Map} map\n * @return {L.VegaLayer}\n */\n addTo(map) {\n map.addLayer(this);\n return this;\n },\n\n onAdd(map) {\n this._onAddAsync(map);\n return this;\n },\n\n async _onAddAsync(map) {\n this.disableSignals();\n\n try {\n this._map = map;\n this._vegaContainer = L.DomUtil.create('div', 'leaflet-vega-container');\n map._panes.overlayPane.appendChild(this._vegaContainer);\n\n const { vega, viewConfig } = this.options;\n\n const dataflow = vega.parse(this._spec, this.options.parseConfig, this.options.parseOptions);\n\n if (viewConfig && viewConfig.loader) {\n const oldLoad = viewConfig.loader.load.bind(viewConfig.loader);\n viewConfig.loader.load = (uri, opt) => oldLoad(uri, opt);\n }\n this._view = new vega.View(dataflow, viewConfig);\n\n if (!viewConfig || viewConfig.logLevel === undefined) {\n this._view.logLevel(vega.Warn);\n }\n if (this.options.onWarning) {\n this._view.warn = this.options.onWarning;\n }\n if (this.options.onError) {\n this._view.error = this.options.onError;\n }\n\n this._view\n .padding({\n left: 0, right: 0, top: 0, bottom: 0,\n })\n .initialize(this._vegaContainer, this.options.bindingsContainer)\n .hover();\n\n const onSignal = (sig, value) => this._onSignalChange(sig, value);\n\n this._view\n .addSignalListener('latitude', onSignal)\n .addSignalListener('longitude', onSignal)\n .addSignalListener('zoom', onSignal);\n\n map.on(this.options.delayRepaint ? 'moveend' : 'move', () => this._resetAsync());\n map.on('zoomend', () => this._resetAsync());\n\n /**\n * Given longitude/latitude/zoom or bounding box, position the map to those coordinates\n * The function can be called in one of the following ways:\n * setMapView(latitude, longitude)\n * setMapView(latitude, longitude, zoom)\n * setMapView([longitude, latitude])\n * setMapView([longitude, latitude], zoom)\n * setMapView([[lng1,lat1],[lng2,lat2]])\n */\n this._view.Leaflet_setMapViewHandler = (...args) => {\n function throwError() {\n throw new Error('Unexpected setMapView() parameters. It could be called with a bounding box setMapView([[longitude1,latitude1],[longitude2,latitude2]]), or it could be the center point setMapView([longitude, latitude], optional_zoom), or it can be used as setMapView(latitude, longitude, optional_zoom)');\n }\n\n function checkArray(val) {\n if (!Array.isArray(val) || val.length !== 2 ||\n typeof val[0] !== 'number' || typeof val[1] !== 'number'\n ) {\n throwError();\n }\n return val;\n }\n\n let lng;\n let lat;\n let zoom;\n switch (args.length) {\n default:\n throwError();\n break;\n case 1: {\n const arg = args[0];\n if (Array.isArray(arg) && arg.length === 2 &&\n Array.isArray(arg[0]) && Array.isArray(arg[1])\n ) {\n // called with a bounding box, need to reverse order\n const [lng1, lat1] = checkArray(arg[0]);\n const [lng2, lat2] = checkArray(arg[1]);\n map.fitBounds(L.latLngBounds(L.latLng(lat1, lng1), L.latLng(lat2, lng2)));\n } else {\n // called with a center point and no zoom\n [lng, lat] = checkArray(arg);\n }\n break;\n }\n case 2:\n if (Array.isArray(args[0])) {\n [lng, lat] = checkArray(args[0]);\n // eslint-disable-next-line prefer-destructuring\n zoom = args[1];\n } else {\n [lat, lng] = args;\n }\n break;\n case 3:\n [lat, lng, zoom] = args;\n break;\n }\n\n if (lat !== undefined && lng !== undefined) {\n if (typeof lat !== 'number' || typeof lng !== 'number') {\n throwError();\n }\n if (zoom === undefined) {\n zoom = map.getZoom();\n } else if (typeof zoom !== 'number') {\n throwError();\n }\n map.setView({ lat, lng }, zoom);\n }\n };\n await this._resetAsync(true);\n } catch (err) {\n this._reportError(err);\n } finally {\n this.enableSignals();\n }\n },\n\n onRemove() {\n if (this._view) {\n this._view.finalize();\n this._view = null;\n }\n\n // TODO: once Leaflet 0.7 is fully out of the picture, replace this with L.DomUtil.empty()\n const el = this._vegaContainer;\n while (el.firstChild) {\n el.removeChild(el.firstChild);\n }\n },\n\n _reportError(err) {\n /* eslint-disable no-console */\n if (this.options.onError) {\n this.options.onError(err);\n } else if (console && console.error) {\n console.error(err);\n }\n /* eslint-enable */\n },\n\n _onSignalChange(sig, value) {\n if (this._ignoreSignals) {\n return;\n }\n\n try {\n const map = this._map;\n const center = map.getCenter();\n let zoom = map.getZoom();\n\n switch (sig) {\n case 'latitude':\n center.lat = value;\n break;\n case 'longitude':\n center.lng = value;\n break;\n case 'zoom':\n zoom = value;\n break;\n default:\n return; // ignore\n }\n\n map.setView(center, zoom);\n } catch (err) {\n this._reportError(err);\n }\n },\n\n async _resetAsync(force) {\n if (!this._view) return;\n\n this.disableSignals();\n try {\n const map = this._map;\n const view = this._view;\n const topLeft = map.containerPointToLayerPoint([0, 0]);\n L.DomUtil.setPosition(this._vegaContainer, topLeft);\n\n const size = map.getSize();\n const center = map.getCenter();\n const zoom = map.getZoom();\n\n // Only send changed signals to Vega.\n // Detect if any of the signals have changed before calling run()\n const sendSignal = (sig, value) => {\n if (view.signal(sig) !== value) {\n view.signal(sig, value);\n return 1;\n }\n return 0;\n };\n\n // update if any of the signal's values have changed\n const changed =\n sendSignal('width', size.x) +\n sendSignal('height', size.y) +\n sendSignal('latitude', center.lat) +\n sendSignal('longitude', center.lng) +\n sendSignal('zoom', zoom);\n\n if (changed > 0 || force) {\n await view.runAsync();\n }\n } catch (err) {\n this._reportError(err);\n } finally {\n this.enableSignals();\n }\n },\n\n defaultProjection: {\n name: 'projection',\n type: 'mercator',\n scale: { signal: '256*pow(2,zoom)/2/PI' },\n rotate: [{ signal: '-longitude' }, 0, 0],\n center: [0, { signal: 'latitude' }],\n translate: [{ signal: 'width/2' }, { signal: 'height/2' }],\n fit: false,\n },\n\n});\n\nL.VegaLayer.version = version;\n"],"names":["L","vega","spec","options","VegaLayer","Layer","Class","extend","window","undefined","Util","setOptions","expressionFunction","setMapView","args","view","context","dataflow","handler","Leaflet_setMapViewHandler","Error","runAfter","_ignoreSignals","disableSignals","enableSignals","vsi","Vsi","onWarning","overrideField","addToList","defaultProjection","_spec","map","addLayer","_onAddAsync","_map","_vegaContainer","DomUtil","create","_panes","overlayPane","appendChild","viewConfig","parse","parseConfig","parseOptions","loader","load","bind","uri","opt","oldLoad","_view","View","logLevel","Warn","warn","onError","error","padding","right","top","bottom","initialize","bindingsContainer","hover","onSignal","sig","value","_onSignalChange","addSignalListener","on","delayRepaint","_resetAsync","throwError","checkArray","val","Array","isArray","length","lng","lat","zoom","arg","lng1","lat1","lng2","lat2","fitBounds","latLngBounds","latLng","getZoom","setView","_reportError","finalize","el","firstChild","removeChild","err","console","center","getCenter","force","containerPointToLayerPoint","setPosition","topLeft","getSize","sendSignal","signal","size","x","y","changed","runAsync","version"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,YAAY,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC,EAAE,EAAE;;AAEzJ,IAAI,MAAM,GAAG,YAAY;EACvB,SAAS,MAAM,CAAC,SAAS,EAAE;IACzB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;;IAE9B,IAAI,CAAC,SAAS,GAAG,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,GAAG,GAAG,YAAY,EAAE,CAAC,CAA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,CAAV,IAAeV,KAhCE;;;;;;qBAiCbvF,KAAKkG,QAAL,EAjCa;;;;;;;;;;qBAoChBpB,YAAL;;;;;qBAEKrE,aAAL;;;;;;;;;;GA5S6C;;;qBAgT9B;UACX,YADW;UAEX,UAFW;WAGV,EAAEoF,QAAQ,sBAAV,EAHU;YAIT,CAAC,EAAEA,QAAQ,YAAV,EAAD,EAA2B,CAA3B,EAA8B,CAA9B,CAJS;YAKT,CAAC,CAAD,EAAI,EAAEA,QAAQ,UAAV,EAAJ,CALS;eAMN,CAAC,EAAEA,QAAQ,SAAV,EAAD,EAAwB,EAAEA,QAAQ,UAAV,EAAxB,CANM;SAOZ;;;CAvTK,CAAd;;AA4TA5G,EAAEI,SAAF,CAAY8G,OAAZ,GAAsBA,OAAtB;;;;"} \ No newline at end of file diff --git a/package.json b/package.json index 4c8ac96..b819511 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leaflet-vega", - "version": "0.8.6", + "version": "0.8.7", "description": "Vega layer for Leaflet", "homepage": "https://github.com/nyurik/leaflet-vega", "author": "Yuri Astrakhan ", diff --git a/src/VegaLayer.js b/src/VegaLayer.js index 348d5d2..5bc78fe 100644 --- a/src/VegaLayer.js +++ b/src/VegaLayer.js @@ -17,10 +17,13 @@ L.VegaLayer = (L.Layer ? L.Layer : L.Class).extend({ // If Vega spec creates controls (inputs), put them all into this container bindingsContainer: undefined, - // Options to be passed to the Vega`s parse method + // Config to be passed to the Vega`s parse method parseConfig: undefined, - // Options to be passed ot the Vega`s View constructor + // Options to be passed to the Vega`s parse method + parseOptions: undefined, + + // Config to be passed ot the Vega`s View constructor viewConfig: undefined, // If true, graph will be repainted only after the map has finished moving (faster) @@ -99,7 +102,7 @@ L.VegaLayer = (L.Layer ? L.Layer : L.Class).extend({ const { vega, viewConfig } = this.options; - const dataflow = vega.parse(this._spec, this.options.parseConfig); + const dataflow = vega.parse(this._spec, this.options.parseConfig, this.options.parseOptions); if (viewConfig && viewConfig.loader) { const oldLoad = viewConfig.loader.load.bind(viewConfig.loader);