New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ol-ext

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ol-ext - npm Package Compare versions

Comparing version 3.1.5 to 3.1.6

geom/sphere.js

191

control/Bar.js
/* Copyright (c) 2016 Jean-Marc VIGLINO,
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
*/

@@ -16,34 +16,34 @@

* @param {Object=} options Control options.
* @param {String} options.className class of the control
* @param {bool} options.group is a group, default false
* @param {bool} options.toggleOne only one toggle control is active at a time, default false
* @param {bool} options.autoDeactivate used with subbar to deactivate all control when top level control deactivate, default false
* @param {Array<_ol_control_>} options.controls a list of control to add to the bar
* @param {String} options.className class of the control
* @param {bool} options.group is a group, default false
* @param {bool} options.toggleOne only one toggle control is active at a time, default false
* @param {bool} options.autoDeactivate used with subbar to deactivate all control when top level control deactivate, default false
* @param {Array<_ol_control_>} options.controls a list of control to add to the bar
*/
var ol_control_Bar = function(options) {
if (!options) options={};
var element = document.createElement("div");
var element = document.createElement("div");
element.classList.add('ol-unselectable', 'ol-control', 'ol-bar');
if (options.className) {
var classes = options.className.split(' ').filter(function(className) {
return className.length > 0;
});
element.classList.add.apply(element.classList, classes)
}
if (options.group) element.classList.add('ol-group');
if (options.className) {
var classes = options.className.split(' ').filter(function(className) {
return className.length > 0;
});
element.classList.add.apply(element.classList, classes)
}
if (options.group) element.classList.add('ol-group');
ol_control_Control.call(this, {
ol_control_Control.call(this, {
element: element,
target: options.target
});
target: options.target
});
this.set('toggleOne', options.toggleOne);
this.set('autoDeactivate', options.autoDeactivate);
this.set('toggleOne', options.toggleOne);
this.set('autoDeactivate', options.autoDeactivate);
this.controls_ = [];
if (options.controls instanceof Array) {
this.controls_ = [];
if (options.controls instanceof Array) {
for (var i=0; i<options.controls.length; i++) {
this.addControl(options.controls[i]);
}
}
}
}
};

@@ -53,12 +53,12 @@ ol_ext_inherits(ol_control_Bar, ol_control_Control);

/** Set the control visibility
* @param {boolean} b
*/
* @param {boolean} b
*/
ol_control_Bar.prototype.setVisible = function (val) {
if (val) this.element.style.display = '';
else this.element.style.display = 'none';
if (val) this.element.style.display = '';
else this.element.style.display = 'none';
}
/** Get the control visibility
* @return {boolean} b
*/
* @return {boolean} b
*/
ol_control_Bar.prototype.getVisible = function () {

@@ -76,12 +76,12 @@ return this.element.style.display != 'none';

for (var i=0; i<this.controls_.length; i++) {
for (var i=0; i<this.controls_.length; i++) {
var c = this.controls_[i];
// map.addControl(c);
c.setMap(map);
}
// map.addControl(c);
c.setMap(map);
}
};
/** Get controls in the panel
* @param {Array<_ol_control_>}
*/
* @param {Array<_ol_control_>}
*/
ol_control_Bar.prototype.getControls = function () {

@@ -92,39 +92,40 @@ return this.controls_;

/** Set tool bar position
* @param {top|left|bottom|right} pos
*/
* @param {top|left|bottom|right} pos
*/
ol_control_Bar.prototype.setPosition = function (pos) {
this.element.classList.remove('ol-left', 'ol-top', 'ol-bottom', 'ol-right');
pos=pos.split ('-');
for (var i=0; i<pos.length; i++) {
pos=pos.split ('-');
for (var i=0; i<pos.length; i++) {
switch (pos[i]) {
case 'top':
case 'left':
case 'bottom':
case 'right':
this.element.classList.add("ol-"+pos[i]);
break;
default: break;
}
}
case 'left':
case 'bottom':
case 'right':
this.element.classList.add("ol-"+pos[i]);
break;
default: break;
}
}
};
/** Add a control to the bar
* @param {_ol_control_} c control to add
*/
* @param {_ol_control_} c control to add
*/
ol_control_Bar.prototype.addControl = function (c) {
this.controls_.push(c);
c.setTarget(this.element);
if (this.getMap()) {
c.setTarget(this.element);
if (this.getMap()) {
this.getMap().addControl(c);
}
// Activate and toogleOne
c.on ('change:active', this.onActivateControl_.bind(this));
if (c.getActive && c.getActive()) {
c.dispatchEvent({ type:'change:active', key:'active', oldValue:false, active:true });
}
}
// Activate and toogleOne
c.on ('change:active', this.onActivateControl_.bind(this));
if (c.getActive && c.getActive()) {
// c.dispatchEvent({ type:'change:active', key:'active', oldValue:false, active:true });
this.onActivateControl_({ target: c, active: c.getActive() });
}
};
/** Deativate all controls in a bar
* @param {_ol_control_} except a control
*/
* @param {_ol_control_} except a control
*/
ol_control_Bar.prototype.deactivateControls = function (except) {

@@ -134,4 +135,4 @@ for (var i=0; i<this.controls_.length; i++) {

this.controls_[i].setActive(false);
}
}
}
}
};

@@ -142,49 +143,49 @@

var active = [];
for (var i=0, c; c=this.controls_[i]; i++) {
for (var i=0, c; c=this.controls_[i]; i++) {
if (c.getActive && c.getActive()) active.push(c);
}
return active;
}
return active;
}
/** Auto activate/deactivate controls in the bar
* @param {boolean} b activate/deactivate
*/
* @param {boolean} b activate/deactivate
*/
ol_control_Bar.prototype.setActive = function (b) {
if (!b && this.get("autoDeactivate")) {
this.deactivateControls();
}
if (b) {
}
if (b) {
var ctrls = this.getControls();
for (var i=0, sb; (sb = ctrls[i]); i++) {
for (var i=0, sb; (sb = ctrls[i]); i++) {
if (sb.get("autoActivate")) sb.setActive(true);
}
}
}
}
}
/** Post-process an activated/deactivated control
* @param {ol.event} e :an object with a target {_ol_control_} and active flag {bool}
*/
* @param {ol.event} e :an object with a target {_ol_control_} and active flag {bool}
*/
ol_control_Bar.prototype.onActivateControl_ = function (e) {
if (this.get('toggleOne')) {
if (this.get('toggleOne')) {
if (e.active) {
var n;
var ctrl = e.target;
for (n=0; n<this.controls_.length; n++) {
var ctrl = e.target;
for (n=0; n<this.controls_.length; n++) {
if (this.controls_[n]===ctrl) break;
}
// Not here!
if (n==this.controls_.length) return;
this.deactivateControls (this.controls_[n]);
} else {
}
// Not here!
if (n==this.controls_.length) return;
this.deactivateControls (this.controls_[n]);
} else {
// No one active > test auto activate
if (!this.getActiveControls().length) {
if (!this.getActiveControls().length) {
for (var i=0, c; c=this.controls_[i]; i++) {
if (c.get("autoActivate")) {
c.setActive(true);
break;
}
}
}
}
}
break;
}
}
}
}
}
};

@@ -197,10 +198,10 @@

ol_control_Bar.prototype.getControlsByName = function(name) {
var controls = this.getControls();
return controls.filter(
function(control) {
return (control.get('name') === name);
}
);
var controls = this.getControls();
return controls.filter(
function(control) {
return (control.get('name') === name);
}
);
};
export default ol_control_Bar

@@ -274,3 +274,3 @@ /* Copyright (c) 2017 Jean-Marc VIGLINO,

ctx.textBaseline = 'middle';
for (i=0; i<size[0]; i++) {
for (i=0; i<size[1]; i++) {
y = p0[1]+i*dy+dy/2;

@@ -296,3 +296,2 @@ ctx.textAlign = 'right';

ctx.restore();

@@ -299,0 +298,0 @@ };

@@ -298,3 +298,2 @@ /* Copyright (c) 2015 Jean-Marc VIGLINO,

ol_control_LayerSwitcher.prototype.viewChange = function() {
var map = this.getMap();
this.panel_.querySelectorAll('li').forEach( function(li) {

@@ -305,20 +304,2 @@ var l = this._getLayerForLI(li);

else li.classList.add('ol-layer-hidden');
/*
var res = map.getView().getResolution();
if (l.getMaxResolution()<=res || l.getMinResolution()>=res) {
li.classList.add('ol-layer-hidden');
} else {
var ex0 = l.getExtent();
if (ex0) {
var ex = map.getView().calculateExtent(map.getSize());
if (!ol_extent_intersects(ex, ex0)) {
li.classList.add('ol-layer-hidden');
} else {
li.classList.remove('ol-layer-hidden');
}
} else {
li.classList.remove('ol-layer-hidden');
}
}
*/
}

@@ -325,0 +306,0 @@ }.bind(this));

@@ -293,6 +293,6 @@ /* Copyright (c) 2017 Jean-Marc VIGLINO,

* @param {any} f the feature, as passed in the autocomplete
* @api
* @api * @param {boolean} reverse true if reverse geocode
*/
ol_control_Search.prototype.select = function (f) {
this.dispatchEvent({ type:"select", search:f });
ol_control_Search.prototype.select = function (f, reverse) {
this.dispatchEvent({ type:"select", search:f, reverse: !!reverse });
};

@@ -303,5 +303,6 @@

* @param {*} f
* @param {boolean} reverse true if reverse geocode
* @private
*/
ol_control_Search.prototype._handleSelect = function (f) {
ol_control_Search.prototype._handleSelect = function (f, reverse) {
if (!f) return;

@@ -332,3 +333,3 @@ // Save input in history

// Select feature
this.select(f);
this.select(f, reverse);
//this.drawList_();

@@ -335,0 +336,0 @@ };

/* Copyright (c) 2017 Jean-Marc VIGLINO,
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
*/

@@ -16,22 +16,22 @@ import ol_ext_inherits from '../util/ext'

* @param {Object=} Control options.
* @param {string} options.className control class name
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder, default "Search..."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 500.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
* @param {string} options.className control class name
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder, default "Search..."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 500.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
*
* @param {string|undefined} options.url Url to BAN api, default "https://api-adresse.data.gouv.fr/search/"
* @param {boolean} options.position Search, with priority to geo position, default false
* @param {function} options.getTitle a function that takes a feature and return the text to display in the menu, default return label attribute
* @param {string|undefined} options.url Url to BAN api, default "https://api-adresse.data.gouv.fr/search/"
* @param {boolean} options.position Search, with priority to geo position, default false
* @param {function} options.getTitle a function that takes a feature and return the text to display in the menu, default return label attribute
* @see {@link https://adresse.data.gouv.fr/api/}
*/
var ol_control_SearchBAN = function(options)
{ options = options || {};
options.typing = options.typing || 500;
options.url = options.url || 'https://api-adresse.data.gouv.fr/search/';
options.className = options.className || 'BAN';
options.copy = '<a href="https://adresse.data.gouv.fr/" target="new">&copy; BAN-data.gouv.fr</a>';
ol_control_SearchPhoton.call(this, options);
var ol_control_SearchBAN = function(options) {
options = options || {};
options.typing = options.typing || 500;
options.url = options.url || 'https://api-adresse.data.gouv.fr/search/';
options.className = options.className || 'BAN';
options.copy = '<a href="https://adresse.data.gouv.fr/" target="new">&copy; BAN-data.gouv.fr</a>';
ol_control_SearchPhoton.call(this, options);
};

@@ -41,24 +41,24 @@ ol_ext_inherits(ol_control_SearchBAN, ol_control_SearchPhoton);

/** Returns the text to be displayed in the menu
* @param {ol.Feature} f the feature
* @return {string} the text to be displayed in the index
* @api
* @param {ol.Feature} f the feature
* @return {string} the text to be displayed in the index
* @api
*/
ol_control_SearchBAN.prototype.getTitle = function (f) {
var p = f.properties;
return (p.label);
var p = f.properties;
return (p.label);
};
/** A ligne has been clicked in the menu > dispatch event
* @param {any} f the feature, as passed in the autocomplete
* @api
* @param {any} f the feature, as passed in the autocomplete
* @api
*/
ol_control_SearchBAN.prototype.select = function (f){
var c = f.geometry.coordinates;
// Add coordinate to the event
try {
c = ol_proj_transform (f.geometry.coordinates, 'EPSG:4326', this.getMap().getView().getProjection());
} catch(e) { /* ok */ }
this.dispatchEvent({ type:"select", search:f, coordinate: c });
var c = f.geometry.coordinates;
// Add coordinate to the event
try {
c = ol_proj_transform (f.geometry.coordinates, 'EPSG:4326', this.getMap().getView().getProjection());
} catch(e) { /* ok */ }
this.dispatchEvent({ type:"select", search:f, coordinate: c });
};
export default ol_control_SearchBAN
export default ol_control_SearchBAN

@@ -7,3 +7,3 @@ /* Copyright (c) 2017 Jean-Marc VIGLINO,

import {transform as ol_proj_transform} from 'ol/proj'
import ol_control_SearchJSON from "./SearchJSON";
import ol_control_SearchJSON from './SearchJSON';

@@ -39,2 +39,5 @@ /**

this.set('type', options.type || 'StreetAddress,PositionOfInterest');
// Authentication
// this._auth = options.authentication;
};

@@ -63,36 +66,43 @@ ol_ext_inherits(ol_control_SearchGeoportail, ol_control_SearchJSON);

+' </Request>'
+'</XLS>'
var url = this.get('url').replace('ols/apis/completion','geoportail/ols')+"?xls="+encodeURIComponent(request);
this.ajax (url, function(resp) {
var xml = resp.response;
if (xml) {
xml = xml.replace(/\n|\r/g,'');
var p = (xml.replace(/.*<gml:pos>(.*)<\/gml:pos>.*/, "$1")).split(' ');
var f = {};
if (!Number(p[1]) && !Number(p[0])) {
f = { x: lonlat[0], y: lonlat[1], fulltext: String(lonlat) }
} else {
f.x = lonlat[0];
f.y = lonlat[1];
f.city = (xml.replace(/.*<Place type="Municipality">([^<]*)<\/Place>.*/, "$1"));
f.insee = (xml.replace(/.*<Place type="INSEE">([^<]*)<\/Place>.*/, "$1"));
f.zipcode = (xml.replace(/.*<PostalCode>([^<]*)<\/PostalCode>.*/, "$1"));
if (/<Street>/.test(xml)) {
f.kind = '';
f.country = 'StreetAddress';
f.street = (xml.replace(/.*<Street>([^<]*)<\/Street>.*/, "$1"));
var number = (xml.replace(/.*<Building number="([^"]*).*/, "$1"));
f.fulltext = number+' '+f.street+', '+f.zipcode+' '+f.city;
+'</XLS>';
this.ajax (this.get('url').replace('ols/apis/completion','geoportail/ols'),
{ xls: request },
function(xml) {
if (xml) {
xml = xml.replace(/\n|\r/g,'');
var p = (xml.replace(/.*<gml:pos>(.*)<\/gml:pos>.*/, "$1")).split(' ');
var f = {};
if (!Number(p[1]) && !Number(p[0])) {
f = { x: lonlat[0], y: lonlat[1], fulltext: String(lonlat) }
} else {
f.kind = (xml.replace(/.*<Place type="Nature">([^<]*)<\/Place>.*/, "$1"));
f.country = 'PositionOfInterest';
f.street = '';
f.fulltext = f.zipcode+' '+f.city;
f.x = lonlat[0];
f.y = lonlat[1];
f.city = (xml.replace(/.*<Place type="Municipality">([^<]*)<\/Place>.*/, "$1"));
f.insee = (xml.replace(/.*<Place type="INSEE">([^<]*)<\/Place>.*/, "$1"));
f.zipcode = (xml.replace(/.*<PostalCode>([^<]*)<\/PostalCode>.*/, "$1"));
if (/<Street>/.test(xml)) {
f.kind = '';
f.country = 'StreetAddress';
f.street = (xml.replace(/.*<Street>([^<]*)<\/Street>.*/, "$1"));
var number = (xml.replace(/.*<Building number="([^"]*).*/, "$1"));
f.fulltext = number+' '+f.street+', '+f.zipcode+' '+f.city;
} else {
f.kind = (xml.replace(/.*<Place type="Nature">([^<]*)<\/Place>.*/, "$1"));
f.country = 'PositionOfInterest';
f.street = '';
f.fulltext = f.zipcode+' '+f.city;
}
}
if (cback) {
cback.call(this, [f]);
} else {
this._handleSelect(f, true);
// this.setInput('', true);
// this.drawList_();
}
}
if (cback) cback.call(this, [f]);
else this._handleSelect(f);
}
});
}.bind(this),
{ dataType: 'XML' }
);
};

@@ -182,21 +192,24 @@

var url = this.get('url').replace('ols/apis/completion','geoportail/ols')+"?xls="+encodeURIComponent(request);
// Search
this.ajax (this.get('url').replace('ols/apis/completion','geoportail/ols'),
{ 'xls': request },
function(xml) {
if (xml) {
xml = xml.replace(/\n|\r/g,'');
var p = (xml.replace(/.*<gml:pos>(.*)<\/gml:pos>.*/, "$1")).split(' ');
f.x = Number(p[1]);
f.y = Number(p[0]);
f.kind = (xml.replace(/.*<Place type="Nature">([^<]*)<\/Place>.*/, "$1"));
f.insee = (xml.replace(/.*<Place type="INSEE">([^<]*)<\/Place>.*/, "$1"));
if (f.x || f.y) {
if (cback) cback.call(this, [f]);
else this._handleSelect(f);
}
}
}.bind(this),
{ dataType: 'XML' }
);
this.ajax (url, function(resp) {
var xml = resp.response;
if (xml) {
xml = xml.replace(/\n|\r/g,'');
var p = (xml.replace(/.*<gml:pos>(.*)<\/gml:pos>.*/, "$1")).split(' ');
f.x = Number(p[1]);
f.y = Number(p[0]);
f.kind = (xml.replace(/.*<Place type="Nature">([^<]*)<\/Place>.*/, "$1"));
f.insee = (xml.replace(/.*<Place type="INSEE">([^<]*)<\/Place>.*/, "$1"));
if (f.x || f.y) {
if (cback) cback.call(this, [f]);
else this._handleSelect(f);
}
}
});
};
export default ol_control_SearchGeoportail
export default ol_control_SearchGeoportail

@@ -197,3 +197,3 @@ /* Copyright (c) 2017 Jean-Marc VIGLINO,

*/
ol_control_SearchGeoportailParcelle.prototype.searchParcelle = function(search, success, error) {
ol_control_SearchGeoportailParcelle.prototype.searchParcelle = function(search, success /*, error */) {
// Request

@@ -211,26 +211,29 @@ var request = '<?xml version="1.0" encoding="UTF-8"?>'

+'</XLS>'
var url = this.get('url').replace('ols/apis/completion','geoportail/ols?xls=')+encodeURIComponent(request);
// Geocode
this.ajax(url, function(resp) {
// XML to JSON
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(resp.response,"text/xml");
var parcelles = xmlDoc.getElementsByTagName('GeocodedAddress');
var jsonResp = []
for (var i=0, parc; parc= parcelles[i]; i++) {
var node = parc.getElementsByTagName('gml:pos')[0] || parc.getElementsByTagName('pos')[0];
var p = node.childNodes[0].nodeValue.split(' ');
var att = parc.getElementsByTagName('Place');
var json = {
lon: Number(p[1]),
lat: Number(p[0])
};
for (var k=0, a; a=att[k]; k++) {
json[a.attributes.type.value] = a.childNodes[0].nodeValue;
this.ajax(
this.get('url').replace('ols/apis/completion','geoportail/ols'),
{ xls: request },
function(xml) {
// XML to JSON
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xml,"text/xml");
var parcelles = xmlDoc.getElementsByTagName('GeocodedAddress');
var jsonResp = []
for (var i=0, parc; parc= parcelles[i]; i++) {
var node = parc.getElementsByTagName('gml:pos')[0] || parc.getElementsByTagName('pos')[0];
var p = node.childNodes[0].nodeValue.split(' ');
var att = parc.getElementsByTagName('Place');
var json = {
lon: Number(p[1]),
lat: Number(p[0])
};
for (var k=0, a; a=att[k]; k++) {
json[a.attributes.type.value] = a.childNodes[0].nodeValue;
}
jsonResp.push(json);
}
jsonResp.push(json);
}
success(jsonResp);
},
error);
success(jsonResp);
},
{ dataType: 'XML' }
);
};

@@ -237,0 +240,0 @@

@@ -49,5 +49,4 @@ /* Copyright (c) 2017 Jean-Marc VIGLINO,

this._ajax.on('success', function (resp) {
this.element.classList.remove('searching');
if (resp.status >= 200 && resp.status < 400) {
if (typeof(this._callback) === 'function') this._callback(this.handleResponse(resp.response));
if (typeof(this._callback) === 'function') this._callback(resp.response);
} else {

@@ -58,7 +57,12 @@ console.log('AJAX ERROR', arguments);

this._ajax.on('error', function() {
this.element.classList.remove('searching');
console.log('AJAX ERROR', arguments);
}.bind(this));
// Handle searchin
this._ajax.on('loadstart', function() {
this.element.classList.add('searching');
}.bind(this));
this._ajax.on('loadend', function() {
this.element.classList.remove('searching');
}.bind(this));
// Overwrite handleResponse

@@ -69,12 +73,24 @@ if (typeof(options.handleResponse)==='function') this.handleResponse = options.handleResponse;

/** Send ajax request
* @param {string} url
* @param {*} data
* @param {function} cback a callback function that takes an array of {name, feature} to display in the autocomplete field
*/
ol_control_SearchJSON.prototype.ajax = function (url, data, cback, options) {
options = options || {};
this._callback = cback;
this._ajax.set('dataType', options.dataType || 'JSON');
this._ajax.send(url, data, options);
};
/** Autocomplete function (ajax request to the server)
* @param {string} s search string
* @param {function} cback a callback function that takes an array of {name, feature} to display in the autocomplete field
*/
* @param {string} s search string
* @param {function} cback a callback function that takes an array of {name, feature} to display in the autocomplete field
*/
ol_control_SearchJSON.prototype.autocomplete = function (s, cback) {
var data = this.requestData(s);
var url = encodeURI(this.get('url'));
this._callback = cback;
this.element.classList.add('searching');
this._ajax.send(url, data);
this.ajax(url, data, function(resp) {
if (typeof(cback) === 'function') cback(this.handleResponse(resp));
});
};

@@ -81,0 +97,0 @@

/* Copyright (c) 2017 Jean-Marc VIGLINO,
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
*/

@@ -16,24 +16,24 @@ import ol_ext_inherits from '../util/ext'

* @param {Object=} Control options.
* @param {string} options.className control class name
* @param {boolean | undefined} options.polygon To get output geometry of results (in geojson format), default false.
* @param {viewbox | undefined} options.viewbox The preferred area to find search results. Any two corner points of the box are accepted in any order as long as they span a real box, default none.
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder, default "Search..."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 500.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
* @param {string} options.className control class name
* @param {boolean | undefined} options.polygon To get output geometry of results (in geojson format), default false.
* @param {viewbox | undefined} options.viewbox The preferred area to find search results. Any two corner points of the box are accepted in any order as long as they span a real box, default none.
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder, default "Search..."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 500.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
*
* @param {string|undefined} options.url URL to Nominatim API, default "https://nominatim.openstreetmap.org/search"
* @param {string|undefined} options.url URL to Nominatim API, default "https://nominatim.openstreetmap.org/search"
* @see {@link https://wiki.openstreetmap.org/wiki/Nominatim}
*/
var ol_control_SearchNominatim = function(options)
{ options = options || {};
options.className = options.className || 'nominatim';
options.typing = options.typing || 500;
options.url = options.url || 'https://nominatim.openstreetmap.org/search';
options.copy = '<a href="http://www.openstreetmap.org/copyright" target="new">&copy; OpenStreetMap contributors</a>';
ol_control_SearchJSON.call(this, options);
this.set('polygon', options.polygon);
this.set('viewbox', options.viewbox);
var ol_control_SearchNominatim = function(options) {
options = options || {};
options.className = options.className || 'nominatim';
options.typing = options.typing || 500;
options.url = options.url || 'https://nominatim.openstreetmap.org/search';
options.copy = '<a href="http://www.openstreetmap.org/copyright" target="new">&copy; OpenStreetMap contributors</a>';
ol_control_SearchJSON.call(this, options);
this.set('polygon', options.polygon);
this.set('viewbox', options.viewbox);
};

@@ -44,9 +44,12 @@ ol_ext_inherits(ol_control_SearchNominatim, ol_control_SearchJSON);

* @param {ol.Feature} f the feature
* @return {string} the text to be displayed in the index
* @api
*/
* @return {string} the text to be displayed in the index
* @api
*/
ol_control_SearchNominatim.prototype.getTitle = function (f) {
var title = f.display_name+"<i>"+f.class+" - "+f.type+"</i>";
if (f.icon) title = "<img src='"+f.icon+"' />" + title;
return (title);
var info = [];
if (f.class) info.push(f.class);
if (f.type) info.push(f.type);
var title = f.display_name+(info.length ? "<i>"+info.join(' - ')+"</i>" : '');
if (f.icon) title = "<img src='"+f.icon+"' />" + title;
return (title);
};

@@ -60,11 +63,11 @@

ol_control_SearchNominatim.prototype.requestData = function (s) {
var data = {
format: "json",
addressdetails: 1,
q: s,
polygon_geojson: this.get('polygon') ? 1:0,
limit: this.get('maxItems')
};
if (this.get('viewbox')) data.viewbox = this.get('viewbox');
return data;
var data = {
format: "json",
addressdetails: 1,
q: s,
polygon_geojson: this.get('polygon') ? 1:0,
limit: this.get('maxItems')
};
if (this.get('viewbox')) data.viewbox = this.get('viewbox');
return data;
};

@@ -74,13 +77,33 @@

* @param {any} f the feature, as passed in the autocomplete
* @api
*/
* @api
*/
ol_control_SearchNominatim.prototype.select = function (f){
var c = [Number(f.lon), Number(f.lat)];
// Add coordinate to the event
try {
c = ol_proj_transform (c, 'EPSG:4326', this.getMap().getView().getProjection());
} catch(e) { /* ok */}
this.dispatchEvent({ type:"select", search:f, coordinate: c });
var c = [Number(f.lon), Number(f.lat)];
// Add coordinate to the event
try {
c = ol_proj_transform (c, 'EPSG:4326', this.getMap().getView().getProjection());
} catch(e) { /* ok */}
this.dispatchEvent({ type:"select", search:f, coordinate: c });
};
/** Reverse geocode
* @param {ol.coordinate} coord
* @api
*/
ol_control_SearchNominatim.prototype.reverseGeocode = function (coord, cback) {
var lonlat = ol_proj_transform (coord, this.getMap().getView().getProjection(), 'EPSG:4326');
this.ajax(
this.get('url').replace('search', 'reverse'),
{ lon: lonlat[0], lat: lonlat[1], format: 'json' },
function(resp) {
if (cback) {
cback.call(this, [resp]);
} else {
this._handleSelect(resp, true);
//this.setInput('', true);
}
}.bind(this)
);
};
export default ol_control_SearchNominatim
/* Copyright (c) 2017 Jean-Marc VIGLINO,
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
*/

@@ -17,24 +17,24 @@ import ol_ext_inherits from '../util/ext'

* @param {Object=} Control options.
* @param {string} options.className control class name
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder, default "Search..."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 1000.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
* @param {string} options.className control class name
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder, default "Search..."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 1000.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
* @param {function | undefined} options.handleResponse Handle server response to pass the features array to the list
*
* @param {string|undefined} options.url Url to photon api, default "http://photon.komoot.de/api/"
* @param {string|undefined} options.lang Force preferred language, default none
* @param {boolean} options.position Search, with priority to geo position, default false
* @param {function} options.getTitle a function that takes a feature and return the name to display in the index, default return street + name + contry
* @param {string|undefined} options.url Url to photon api, default "http://photon.komoot.de/api/"
* @param {string|undefined} options.lang Force preferred language, default none
* @param {boolean} options.position Search, with priority to geo position, default false
* @param {function} options.getTitle a function that takes a feature and return the name to display in the index, default return street + name + contry
*/
var ol_control_SearchPhoton = function(options)
{ options = options || {};
options.className = options.className || 'photon';
options.url = options.url || 'http://photon.komoot.de/api/';
options.copy = '<a href="http://www.openstreetmap.org/copyright" target="new">&copy; OpenStreetMap contributors</a>';
ol_control_SearchJSON.call(this, options);
this.set('lang', options.lang);
this.set('position', options.position);
var ol_control_SearchPhoton = function(options) {
options = options || {};
options.className = options.className || 'photon';
options.url = options.url || 'http://photon.komoot.de/api/';
options.copy = '<a href="http://www.openstreetmap.org/copyright" target="new">&copy; OpenStreetMap contributors</a>';
ol_control_SearchJSON.call(this, options);
this.set('lang', options.lang);
this.set('position', options.position);
};

@@ -48,11 +48,11 @@ ol_ext_inherits(ol_control_SearchPhoton, ol_control_SearchJSON);

*/
ol_control_SearchPhoton.prototype.getTitle = function (f)
{ var p = f.properties;
return (p.housenumber||"")
+ " "+(p.street || p.name || "")
+ "<i>"
+ " "+(p.postcode||"")
+ " "+(p.city||"")
+ " ("+p.country
+ ")</i>";
ol_control_SearchPhoton.prototype.getTitle = function (f) {
var p = f.properties;
return (p.housenumber||"")
+ " "+(p.street || p.name || "")
+ "<i>"
+ " "+(p.postcode||"")
+ " "+(p.city||"")
+ " ("+p.country
+ ")</i>";
};

@@ -65,18 +65,18 @@

*/
ol_control_SearchPhoton.prototype.requestData = function (s)
{ var data =
{ q: s,
lang: this.get('lang'),
limit: this.get('maxItems')
}
// Handle position proirity
if (this.get('position'))
{ var view = this.getMap().getView();
var pt = new ol_geom_Point(view.getCenter());
pt = (pt.transform (view.getProjection(), "EPSG:4326")).getCoordinates();
ol_control_SearchPhoton.prototype.requestData = function (s) {
var data = {
q: s,
lang: this.get('lang'),
limit: this.get('maxItems')
}
// Handle position proirity
if (this.get('position')) {
var view = this.getMap().getView();
var pt = new ol_geom_Point(view.getCenter());
pt = (pt.transform (view.getProjection(), "EPSG:4326")).getCoordinates();
data.lon = pt[0];
data.lat = pt[1];
}
return data;
data.lon = pt[0];
data.lat = pt[1];
}
return data;
};

@@ -90,3 +90,3 @@

ol_control_SearchPhoton.prototype.handleResponse = function (response) {
return response.features;
return response.features;
};

@@ -101,5 +101,5 @@

ol_control_SearchPhoton.prototype.equalFeatures = function (f1, f2) {
return (this.getTitle(f1) === this.getTitle(f2)
&& f1.geometry.coordinates[0] === f2.geometry.coordinates[0]
&& f1.geometry.coordinates[1] === f2.geometry.coordinates[1]);
return (this.getTitle(f1) === this.getTitle(f2)
&& f1.geometry.coordinates[0] === f2.geometry.coordinates[0]
&& f1.geometry.coordinates[1] === f2.geometry.coordinates[1]);
};

@@ -111,12 +111,40 @@

*/
ol_control_SearchPhoton.prototype.select = function (f)
{ var c = f.geometry.coordinates;
// Add coordinate to the event
try {
c = ol_proj_transform (f.geometry.coordinates, 'EPSG:4326', this.getMap().getView().getProjection());
} catch(e) { /* ok */ }
this.dispatchEvent({ type:"select", search:f, coordinate: c });
ol_control_SearchPhoton.prototype.select = function (f) {
var c = f.geometry.coordinates;
// Add coordinate to the event
try {
c = ol_proj_transform (f.geometry.coordinates, 'EPSG:4326', this.getMap().getView().getProjection());
} catch(e) { /* ok */ }
this.dispatchEvent({ type:"select", search:f, coordinate: c });
};
/** */
/** Get data for reverse geocode
* @param {ol.coordinate} coord
*/
ol_control_SearchPhoton.prototype.reverseData = function (coord) {
var lonlat = ol_proj_transform (coord, this.getMap().getView().getProjection(), 'EPSG:4326');
return { lon: lonlat[0], lat: lonlat[1] };
};
/** Reverse geocode
* @param {ol.coordinate} coord
* @api
*/
ol_control_SearchPhoton.prototype.reverseGeocode = function (coord, cback) {
this.ajax(
this.get('url').replace('/api/', '/reverse/').replace('/search/', '/reverse/'),
this.reverseData(coord),
function(resp) {
if (resp.features) resp = resp.features;
if (!(resp instanceof Array)) resp = [resp];
if (cback) {
cback.call(this, resp);
} else {
this._handleSelect(resp[0], true);
// this.setInput('', true);
}
}.bind(this)
);
};
export default ol_control_SearchPhoton
/* Copyright (c) 2016 Jean-Marc VIGLINO,
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
*/

@@ -17,42 +17,43 @@

* @param {Object=} options Control options.
* @param {String} options.className class of the control
* @param {String} options.title title of the control
* @param {String} options.html html to insert in the control
* @param {ol.interaction} options.interaction interaction associated with the control
* @param {bool} options.active the control is created active, default false
* @param {bool} options.disable the control is created disabled, default false
* @param {ol.control.Bar} options.bar a subbar associated with the control (drawn when active if control is nested in a ol.control.Bar)
* @param {bool} options.autoActive the control will activate when shown in an ol.control.Bar, default false
* @param {function} options.onToggle callback when control is clicked (or use change:active event)
* @param {String} options.className class of the control
* @param {String} options.title title of the control
* @param {String} options.html html to insert in the control
* @param {ol.interaction} options.interaction interaction associated with the control
* @param {bool} options.active the control is created active, default false
* @param {bool} options.disable the control is created disabled, default false
* @param {ol.control.Bar} options.bar a subbar associated with the control (drawn when active if control is nested in a ol.control.Bar)
* @param {bool} options.autoActive the control will activate when shown in an ol.control.Bar, default false
* @param {function} options.onToggle callback when control is clicked (or use change:active event)
*/
var ol_control_Toggle = function(options)
{ options = options || {};
var self = this;
var ol_control_Toggle = function(options) {
options = options || {};
var self = this;
this.interaction_ = options.interaction;
if (this.interaction_)
{ this.interaction_.on("change:active", function(e)
{ self.setActive(!e.oldValue);
});
}
this.interaction_ = options.interaction;
if (this.interaction_) {
this.interaction_.setActive(options.active);
this.interaction_.on("change:active", function() {
self.setActive(self.interaction_.getActive());
});
}
if (options.toggleFn) options.onToggle = options.toggleFn; // compat old version
options.handleClick = function()
{ self.toggle();
if (options.onToggle) options.onToggle.call(self, self.getActive());
};
options.className = (options.className||"") + " ol-toggle";
ol_control_Button.call(this, options);
if (options.toggleFn) options.onToggle = options.toggleFn; // compat old version
options.handleClick = function() {
self.toggle();
if (options.onToggle) options.onToggle.call(self, self.getActive());
};
options.className = (options.className||"") + " ol-toggle";
ol_control_Button.call(this, options);
this.set("title", options.title);
this.set("title", options.title);
this.set ("autoActivate", options.autoActivate);
if (options.bar)
{ this.subbar_ = options.bar;
this.subbar_.setTarget(this.element);
this.subbar_.element.classList.add("ol-option-bar");
}
this.set ("autoActivate", options.autoActivate);
if (options.bar) {
this.subbar_ = options.bar;
this.subbar_.setTarget(this.element);
this.subbar_.element.classList.add("ol-option-bar");
}
this.setActive (options.active);
this.setDisable (options.disable);
this.setActive (options.active);
this.setDisable (options.disable);
};

@@ -66,23 +67,23 @@ ol_ext_inherits(ol_control_Toggle, ol_control_Button);

*/
ol_control_Toggle.prototype.setMap = function(map)
{ if (!map && this.getMap())
{ if (this.interaction_)
{ this.getMap().removeInteraction (this.interaction_);
}
if (this.subbar_) this.getMap().removeControl (this.subbar_);
}
ol_control_Toggle.prototype.setMap = function(map) {
if (!map && this.getMap()) {
if (this.interaction_) {
this.getMap().removeInteraction (this.interaction_);
}
if (this.subbar_) this.getMap().removeControl (this.subbar_);
}
ol_control_Control.prototype.setMap.call(this, map);
ol_control_Control.prototype.setMap.call(this, map);
if (map)
{ if (this.interaction_) map.addInteraction (this.interaction_);
if (this.subbar_) map.addControl (this.subbar_);
}
if (map) {
if (this.interaction_) map.addInteraction (this.interaction_);
if (this.subbar_) map.addControl (this.subbar_);
}
};
/** Get the subbar associated with a control
* @return {ol_control_Bar}
*/
ol_control_Toggle.prototype.getSubBar = function ()
{ return this.subbar_;
* @return {ol_control_Bar}
*/
ol_control_Toggle.prototype.getSubBar = function () {
return this.subbar_;
};

@@ -95,5 +96,5 @@

*/
ol_control_Toggle.prototype.getDisable = function()
{ var button = this.element.querySelector("button");
return button && button.disabled;
ol_control_Toggle.prototype.getDisable = function() {
var button = this.element.querySelector("button");
return button && button.disabled;
};

@@ -104,8 +105,8 @@

*/
ol_control_Toggle.prototype.setDisable = function(b)
{ if (this.getDisable()==b) return;
this.element.querySelector("button").disabled = b;
if (b && this.getActive()) this.setActive(false);
ol_control_Toggle.prototype.setDisable = function(b) {
if (this.getDisable()==b) return;
this.element.querySelector("button").disabled = b;
if (b && this.getActive()) this.setActive(false);
this.dispatchEvent({ type:'change:disable', key:'disable', oldValue:!b, disable:b });
this.dispatchEvent({ type:'change:disable', key:'disable', oldValue:!b, disable:b });
};

@@ -118,25 +119,24 @@

*/
ol_control_Toggle.prototype.getActive = function()
{ return this.element.classList.contains("ol-active");
ol_control_Toggle.prototype.getActive = function() {
return this.element.classList.contains("ol-active");
};
/** Toggle control state active/deactive
*/
ol_control_Toggle.prototype.toggle = function()
{ if (this.getActive()) this.setActive(false);
else this.setActive(true);
*/
ol_control_Toggle.prototype.toggle = function() {
if (this.getActive()) this.setActive(false);
else this.setActive(true);
};
/** Change control state
* @param {bool} b activate or deactivate the control, default false
*/
ol_control_Toggle.prototype.setActive = function(b)
{
if (this.interaction_) this.interaction_.setActive (b);
if (this.subbar_) this.subbar_.setActive(b);
if (this.getActive()===b) return;
if (b) this.element.classList.add("ol-active");
else this.element.classList.remove("ol-active");
* @param {bool} b activate or deactivate the control, default false
*/
ol_control_Toggle.prototype.setActive = function(b) {
if (this.interaction_) this.interaction_.setActive (b);
if (this.subbar_) this.subbar_.setActive(b);
if (this.getActive()===b) return;
if (b) this.element.classList.add("ol-active");
else this.element.classList.remove("ol-active");
this.dispatchEvent({ type:'change:active', key:'active', oldValue:!b, active:b });
this.dispatchEvent({ type:'change:active', key:'active', oldValue:!b, active:b });
};

@@ -147,4 +147,4 @@

*/
ol_control_Toggle.prototype.setInteraction = function(i)
{ this.interaction_ = i;
ol_control_Toggle.prototype.setInteraction = function(i) {
this.interaction_ = i;
};

@@ -155,6 +155,6 @@

*/
ol_control_Toggle.prototype.getInteraction = function()
{ return this.interaction_;
ol_control_Toggle.prototype.getInteraction = function() {
return this.interaction_;
};
export default ol_control_Toggle
/* Copyright (c) 2017 Jean-Marc VIGLINO,
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
released under the CeCILL-B license (French BSD license)
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt).
*/

@@ -19,94 +19,93 @@

*/
var ol_filter_Fold = function(options)
{ options = options || {};
ol_filter_Base.call(this, options);
var ol_filter_Fold = function(options) {
options = options || {};
ol_filter_Base.call(this, options);
this.set("fold", options.fold || [8,4]);
this.set("margin", options.margin || 8);
this.set("padding", options.padding || 8);
if (typeof options.fsize == "number") options.fsize = [options.fsize,options.fsize];
this.set("fsize", options.fsize || [8,10]);
this.set("fold", options.fold || [8,4]);
this.set("margin", options.margin || 8);
this.set("padding", options.padding || 8);
if (typeof options.fsize == "number") options.fsize = [options.fsize,options.fsize];
this.set("fsize", options.fsize || [8,10]);
};
ol_ext_inherits(ol_filter_Fold, ol_filter_Base);
ol_filter_Fold.prototype.drawLine_ = function(ctx, d, m)
{ var canvas = ctx.canvas;
var fold = this.get("fold");
var w = canvas.width;
var h = canvas.height;
var x, y, i;
ol_filter_Fold.prototype.drawLine_ = function(ctx, d, m) {
var canvas = ctx.canvas;
var fold = this.get("fold");
var w = canvas.width;
var h = canvas.height;
var x, y, i;
ctx.beginPath();
ctx.moveTo ( m, m );
for (i=1; i<=fold[0]; i++)
{ x = i*w/fold[0] - (i==fold[0] ? m : 0);
y = d[1]*(i%2) +m;
ctx.lineTo ( x, y );
}
for (i=1; i<=fold[1]; i++)
{ x = w - d[0]*(i%2) - m;
y = i*h/fold[1] - (i==fold[1] ? d[0]*(fold[0]%2) + m : 0);
ctx.lineTo ( x, y );
}
for (i=fold[0]; i>0; i--)
{ x = i*w/fold[0] - (i==fold[0] ? d[0]*(fold[1]%2) + m : 0);
y = h - d[1]*(i%2) -m;
ctx.lineTo ( x, y );
}
for (i=fold[1]; i>0; i--)
{ x = d[0]*(i%2) + m;
y = i*h/fold[1] - (i==fold[1] ? m : 0);
ctx.lineTo ( x, y );
}
ctx.closePath();
ctx.beginPath();
ctx.moveTo ( m, m );
for (i=1; i<=fold[0]; i++) {
x = i*w/fold[0] - (i==fold[0] ? m : 0);
y = d[1]*(i%2) +m;
ctx.lineTo ( x, y );
}
for (i=1; i<=fold[1]; i++) {
x = w - d[0]*(i%2) - m;
y = i*h/fold[1] - (i==fold[1] ? d[0]*(fold[0]%2) + m : 0);
ctx.lineTo ( x, y );
}
for (i=fold[0]; i>0; i--) {
x = i*w/fold[0] - (i==fold[0] ? d[0]*(fold[1]%2) + m : 0);
y = h - d[1]*(i%2) -m;
ctx.lineTo ( x, y );
}
for (i=fold[1]; i>0; i--) {
x = d[0]*(i%2) + m;
y = i*h/fold[1] - (i==fold[1] ? m : 0);
ctx.lineTo ( x, y );
}
ctx.closePath();
};
ol_filter_Fold.prototype.precompose = function(e)
{ var ctx = e.context;
ol_filter_Fold.prototype.precompose = function(e) {
var ctx = e.context;
ctx.save();
ctx.shadowColor = "rgba(0,0,0,0.3)";
ctx.shadowBlur = 8;
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 3;
this.drawLine_(ctx, this.get("fsize"), this.get("margin"));
ctx.fillStyle="#fff";
ctx.fill();
ctx.strokeStyle = "rgba(0,0,0,0.1)";
ctx.stroke();
ctx.restore();
ctx.save();
ctx.shadowColor = "rgba(0,0,0,0.3)";
ctx.shadowBlur = 8;
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 3;
this.drawLine_(ctx, this.get("fsize"), this.get("margin"));
ctx.fillStyle="#fff";
ctx.fill();
ctx.strokeStyle = "rgba(0,0,0,0.1)";
ctx.stroke();
ctx.restore();
ctx.save();
this.drawLine_(ctx, this.get("fsize"), this.get("margin") + this.get("padding"));
ctx.clip();
ctx.save();
this.drawLine_(ctx, this.get("fsize"), this.get("margin") + this.get("padding"));
ctx.clip();
};
ol_filter_Fold.prototype.postcompose = function(e)
{ var ctx = e.context;
var canvas = ctx.canvas;
ol_filter_Fold.prototype.postcompose = function(e) {
var ctx = e.context;
var canvas = ctx.canvas;
ctx.restore();
ctx.save();
this.drawLine_(ctx, this.get("fsize"), this.get("margin"));
ctx.clip();
ctx.restore();
ctx.save();
this.drawLine_(ctx, this.get("fsize"), this.get("margin"));
ctx.clip();
var fold = this.get("fold");
var w = canvas.width/fold[0];
var h = canvas.height/fold[1];
var fold = this.get("fold");
var w = canvas.width/fold[0];
var h = canvas.height/fold[1];
var grd = ctx.createRadialGradient(5*w/8,5*w/8,w/4,w/2,w/2,w);
grd.addColorStop(0,"transparent");
grd.addColorStop(1,"rgba(0,0,0,0.2)");
ctx.fillStyle = grd;
ctx.scale (1,h/w);
for (var i=0; i<fold[0]; i++) for (var j=0; j<fold[1]; j++)
{ ctx.save()
ctx.translate(i*w, j*w);
ctx.fillRect(0,0,w,w);
ctx.restore()
}
ctx.restore();
var grd = ctx.createRadialGradient(5*w/8,5*w/8,w/4,w/2,w/2,w);
grd.addColorStop(0,"transparent");
grd.addColorStop(1,"rgba(0,0,0,0.2)");
ctx.fillStyle = grd;
ctx.scale (1,h/w);
for (var i=0; i<fold[0]; i++) for (var j=0; j<fold[1]; j++) {
ctx.save()
ctx.translate(i*w, j*w);
ctx.fillRect(0,0,w,w);
ctx.restore()
}
ctx.restore();
};
export default ol_filter_Fold

@@ -115,3 +115,3 @@ /* Gulp file to create dist

gulp.src([
"./src/util/ext.js", "./src/util/*.js",
"!./src/util/getVectorContext.js", "./src/util/ext.js", "./src/util/*.js",
"./src/control/CanvasBase.js","./src/control/SelectBase.js","./src/control/Search.js","./src/control/SearchJSON.js","./src/control/SearchPhoton.js","./src/control/SearchGeoportail.js",

@@ -118,0 +118,0 @@ "./src/control/LayerSwitcher.js", "./src/control/*.js",

{
"name": "openlayers-ext",
"version": "3.1.5",
"version": "3.1.6",
"description": "A set of cool extensions for OpenLayers (ol).",
"main": "index.js",
"dependencies": {
"ajax": "0.0.4",
"openlayers": "^4.6.5"

@@ -9,0 +8,0 @@ },

{
"name": "ol-ext",
"version": "3.1.5",
"version": "3.1.6",
"description": "A set of cool extensions for OpenLayers (ol) in node modules structure",
"main": "dist/ol-ext.js",
"style": "dist/ol-ext.css",
"dependencies": {
"ajax": "0.0.4",
"ol": "^5.3.0"
"peerDependencies": {
"ol": ">= 5.3.0"
},

@@ -11,0 +10,0 @@ "devDependencies": {

@@ -103,3 +103,3 @@ /* Copyright (c) 2015 Jean-Marc VIGLINO,

// Calculate extent on change
this.on('change', function(e) {
this.on('change', function() {
this.set('extent', this.calculateExtent());

@@ -250,3 +250,3 @@ }.bind(this));

opt_extent[i] = ext[i];
};
}
return ext;

@@ -253,0 +253,0 @@ } else {

@@ -159,12 +159,2 @@ /* Copyright (c) 2019 Jean-Marc VIGLINO,

var url = this.getFeatureInfoUrl(coord, resolution, null, options);
/*
if (!this.ajax) this.ajax = new ol_ext_Ajax();
this.ajax.send(url, undefined, {
INFO_FORMAT: options.INFO_FORMAT,
options: {
encode: false
},
});
*/
ol_ext_Ajax.get({

@@ -171,0 +161,0 @@ url: url,

@@ -28,2 +28,3 @@ import ol_ext_inherits from '../util/ext'

* @param {string} options.error
* @param {*} options.options get options
*/

@@ -30,0 +31,0 @@ ol_ext_Ajax.get = function(options) {

@@ -1,11 +0,17 @@

/* Export getVector context for backward compatibility ol5 / ol6
* using ol5: export-> null
* using ol6: export-> getVectorContext
/** Export getVector context for backward compatibility ol5 / ol6
* Create a brand new function for ol5 copy of ol6 function.
* Will be ignored using openlayers-ext package or ol5
*/
import * as ol_render from 'ol/render';
import { multiply as multiplyTransform } from 'ol/transform';
import CanvasImmediateRenderer from 'ol/render/canvas/Immediate';
if (!ol_render.hasOwnProperty('getVectorContext')) {
ol_render.getVectorContext = null;
function getVectorContext(event) {
const frameState = event.frameState;
const transform = multiplyTransform(event.inversePixelTransform.slice(), frameState.coordinateToPixelTransform);
return new CanvasImmediateRenderer(
event.context, frameState.pixelRatio, frameState.extent, transform,
frameState.viewState.rotation
);
}
export default ol_render.getVectorContext;
export default getVectorContext

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc