openlayers-ext
Advanced tools
Comparing version 2.0.6 to 3.0.0
@@ -57,4 +57,4 @@ # Developing | ||
// Import ol classes | ||
import ol from 'ol' | ||
import ol_control_Control from 'ol/control/control' | ||
import {inherits as ol_inherits} from 'ol' | ||
import ol_control_Control from 'ol/control/Control' | ||
@@ -65,3 +65,3 @@ // Create my control | ||
} | ||
ol.inherits(ol_control_MyControl, ol_control_Control); | ||
ol_inherits(ol_control_MyControl, ol_control_Control); | ||
@@ -68,0 +68,0 @@ // Export my control |
@@ -36,4 +36,6 @@ /* Gulp file to create dist | ||
if (content) { | ||
// Prevent ol_has_DEVICE_PIXEL_RATIO | ||
//content = content.replace(/ol_has_DEVICE_PIXEL_RATIO/g,"ol.has.DEVICE_PIXEL_RATIO"); | ||
// change ol_namespace_Class_Att => ol.namespace.Class.Att | ||
content = content.replace(/(\bol_([a-z,A-Z]*)_([a-z,A-Z]*)_([a-z,A-Z]*))/g,"ol.$2.$3.$4"); | ||
content = content.replace(/(\bol_([a-z,A-Z]*)_([a-z,A-Z]*)_([a-z,A-Z]*)\b)/g,"ol.$2.$3.$4"); | ||
// change ol_namespace_Class => ol.namespace.Class | ||
@@ -110,7 +112,8 @@ content = content.replace(/(\bol_([a-z,A-Z]*)_([a-z,A-Z]*))/g,"ol.$2.$3"); | ||
"./src/control/Search.js","./src/control/SearchJSON.js","./src/control/SearchPhoton.js","./src/control/SearchGeoportail.js", | ||
"./src/control/LayerSwitcher.js", "./src/control/*.js", "!./src/control/PirateMap.js", | ||
"./src/control/LayerSwitcher.js", "./src/control/*.js", | ||
"!./src/control/PirateMap.js", "!./src/control/Cloud.js", | ||
"./src/featureanimation/FeatureAnimation.js", "./src/featureanimation/*.js", | ||
"./src/filter/Base.js", "./src/filter/Mask.js", "./src/filter/*.js", | ||
"./src/interaction/*.js", | ||
"./src/source/*.js", | ||
"./src/interaction/*.js", | ||
"./src/source/*.js", | ||
"./src/layer/*.js", | ||
@@ -148,2 +151,3 @@ "./src/overlay/*.js", | ||
gulp.src([ | ||
"./src/control/Cloud.js", | ||
"./src/style/FontMakiDef.js", "./src/style/FontAwesomeDef.js", | ||
@@ -150,0 +154,0 @@ "./src/utils/*.js", |
@@ -68,3 +68,3 @@ /* Copyright (c) 2015 Jean-Marc VIGLINO, | ||
this.setCanvas (this.isCanvas_); | ||
} | ||
}; | ||
/** | ||
@@ -71,0 +71,0 @@ * Draw attribution in the final canvas |
@@ -204,3 +204,3 @@ /* Copyright (c) 2015 Jean-Marc VIGLINO, | ||
{ var ex = map.getView().calculateExtent(map.getSize()); | ||
if (!ol.extent.intersects(ex, ex0)) | ||
if (!ol.extent.intersects(ex, ex0)) | ||
{ $(this).addClass("ol-layer-hidden"); | ||
@@ -207,0 +207,0 @@ } |
@@ -92,3 +92,3 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO, | ||
*/ | ||
ol.easing.bounceFn = function (bounce, amplitude) | ||
let bounceFn = function (bounce, amplitude) | ||
{ var a = (2*bounce+1) * Math.PI/2; | ||
@@ -107,3 +107,3 @@ var b = amplitude>0 ? -1/amplitude : -100; | ||
*/ | ||
ol.easing.elasticFn = function (bounce, amplitude) | ||
let elasticFn = function (bounce, amplitude) | ||
{ var a = 3*bounce * Math.PI/2; | ||
@@ -124,3 +124,3 @@ var b = amplitude>0 ? -1/amplitude : -100; | ||
center: evt.coordinate, | ||
easing: ol.easing.elasticFn(2,0.3), | ||
easing: elasticFn(2,0.3), | ||
duration: 1000 | ||
@@ -127,0 +127,0 @@ }); |
@@ -206,6 +206,5 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO, | ||
// Distance beetween 2 coords | ||
var wgs84Sphere = new ol.Sphere(6378137); | ||
var proj = options.projection || this.getMap().getView().getProjection(); | ||
function dist2d(p1,p2) | ||
{ return wgs84Sphere.haversineDistance( | ||
{ return ol.sphere.getDistance( | ||
ol.proj.transform(p1, proj, 'EPSG:4326'), | ||
@@ -212,0 +211,0 @@ ol.proj.transform(p2, proj, 'EPSG:4326')); |
@@ -13,3 +13,3 @@ /* | ||
*/ | ||
ol.coordinate.clockwise = function (a, b, o) { | ||
let clockwise = function (a, b, o) { | ||
return ((a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) <= 0); | ||
@@ -28,3 +28,3 @@ }; | ||
for (var i = 0; i < points.length; i++) { | ||
while (lower.length >= 2 && ol.coordinate.clockwise(lower[lower.length - 2], lower[lower.length - 1], points[i])) { | ||
while (lower.length >= 2 && clockwise(lower[lower.length - 2], lower[lower.length - 1], points[i])) { | ||
lower.pop(); | ||
@@ -37,3 +37,3 @@ } | ||
for (var i = points.length - 1; i >= 0; i--) { | ||
while (upper.length >= 2 && ol.coordinate.clockwise(upper[upper.length - 2], upper[upper.length - 1], points[i])) { | ||
while (upper.length >= 2 && clockwise(upper[upper.length - 2], upper[upper.length - 1], points[i])) { | ||
upper.pop(); | ||
@@ -40,0 +40,0 @@ } |
@@ -49,67 +49,3 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO, | ||
}; | ||
/** Split a lineString by a point or a list of points | ||
* NB: points must be on the line, use getClosestPoint() to get one | ||
* @param {ol.Coordinate | Array<ol.Coordinate>} pt points to split the line | ||
* @param {Number} tol distance tolerance for 2 points to be equal | ||
*/ | ||
ol.geom.LineString.prototype.splitAt = function(pt, tol) | ||
{ if (!pt) return [this]; | ||
if (!tol) tol = 1e-10; | ||
// Test if list of points | ||
if (pt.length && pt[0].length) | ||
{ var result = [this]; | ||
for (var i=0; i<pt.length; i++) | ||
{ var r = []; | ||
for (var k=0; k<result.length; k++) | ||
{ var ri = result[k].splitAt(pt[i], tol); | ||
r = r.concat(ri); | ||
} | ||
result = r; | ||
} | ||
return result; | ||
} | ||
// Nothing to do | ||
if (ol.coordinate.equal(pt,this.getFirstCoordinate()) | ||
|| ol.coordinate.equal(pt,this.getLastCoordinate())) | ||
{ return [this]; | ||
} | ||
// Get | ||
var c0 = this.getCoordinates(); | ||
var ci=[c0[0]], p0, p1; | ||
var c = []; | ||
for (var i=0; i<c0.length-1; i++) | ||
{ // Filter equal points | ||
if (ol.coordinate.equal(c0[i],c0[i+1])) continue; | ||
// Extremity found | ||
if (ol.coordinate.equal(pt,c0[i+1])) | ||
{ ci.push(c0[i+1]); | ||
c.push(new ol.geom.LineString(ci)); | ||
ci = []; | ||
} | ||
// Test alignement | ||
else if (!ol.coordinate.equal(pt,c0[i])) | ||
{ var d1, d2; | ||
if (c0[i][0] == c0[i+1][0]) | ||
{ d1 = d2 = (c0[i][1]-pt[1]) / (c0[i][1]-c0[i+1][1]); | ||
} | ||
else if (c0[i][1] == c0[i+1][1]) | ||
{ d1 = d2 = (c0[i][0]-pt[0]) / (c0[i][0]-c0[i+1][0]); | ||
} | ||
else | ||
{ d1 = (c0[i][0]-pt[0]) / (c0[i][0]-c0[i+1][0]); | ||
d2 = (c0[i][1]-pt[1]) / (c0[i][1]-c0[i+1][1]); | ||
} | ||
if (Math.abs(d1-d2)<tol && 0<=d1 && d1<=1) | ||
{ ci.push(pt); | ||
c.push (new ol.geom.LineString(ci)); | ||
ci = [pt]; | ||
} | ||
} | ||
ci.push(c0[i+1]); | ||
} | ||
if (ci.length>1) c.push (new ol.geom.LineString(ci)); | ||
if (c.length) return c; | ||
else return [this]; | ||
} | ||
/** Offset a polyline | ||
/** Offset a polyline | ||
* @param {Array<ol.coordinate>} coords | ||
@@ -122,61 +58,61 @@ * @param {Number} offset | ||
ol.coordinate.offsetCoords = function (coords, offset) { | ||
var path = []; | ||
var N = coords.length-1; | ||
var max = N; | ||
var mi, mi1, li, li1, ri, ri1, si, si1, Xi1, Yi1; | ||
var p0, p1, p2; | ||
var isClosed = ol.coordinate.equal(coords[0],coords[N]); | ||
if (!isClosed) { | ||
p0 = coords[0]; | ||
p1 = coords[1]; | ||
p2 = [ | ||
p0[0] + (p1[1] - p0[1]) / ol.coordinate.dist2d(p0,p1) *offset, | ||
p0[1] - (p1[0] - p0[0]) / ol.coordinate.dist2d(p0,p1) *offset | ||
]; | ||
path.push(p2); | ||
coords.push(coords[N]) | ||
N++; | ||
max--; | ||
} | ||
for (var i = 0; i < max; i++) { | ||
p0 = coords[i]; | ||
p1 = coords[(i+1) % N]; | ||
p2 = coords[(i+2) % N]; | ||
mi = (p1[1] - p0[1])/(p1[0] - p0[0]); | ||
mi1 = (p2[1] - p1[1])/(p2[0] - p1[0]); | ||
// Prevent alignements | ||
if (Math.abs(mi-mi1) > 1e-10) { | ||
li = Math.sqrt((p1[0] - p0[0])*(p1[0] - p0[0])+(p1[1] - p0[1])*(p1[1] - p0[1])); | ||
li1 = Math.sqrt((p2[0] - p1[0])*(p2[0] - p1[0])+(p2[1] - p1[1])*(p2[1] - p1[1])); | ||
ri = p0[0] + offset*(p1[1] - p0[1])/li; | ||
ri1 = p1[0] + offset*(p2[1] - p1[1])/li1; | ||
si = p0[1] - offset*(p1[0] - p0[0])/li; | ||
si1 = p1[1] - offset*(p2[0] - p1[0])/li1; | ||
Xi1 = (mi1*ri1-mi*ri+si-si1) / (mi1-mi); | ||
Yi1 = (mi*mi1*(ri1-ri)+mi1*si-mi*si1) / (mi1-mi); | ||
// Correction for vertical lines | ||
if(p1[0] - p0[0] == 0) { | ||
Xi1 = p1[0] + offset*(p1[1] - p0[1])/Math.abs(p1[1] - p0[1]); | ||
Yi1 = mi1*Xi1 - mi1*ri1 + si1; | ||
} | ||
if (p2[0] - p1[0] == 0 ) { | ||
Xi1 = p2[0] + offset*(p2[1] - p1[1])/Math.abs(p2[1] - p1[1]); | ||
Yi1 = mi*Xi1 - mi*ri + si; | ||
} | ||
path.push([Xi1, Yi1]); | ||
} | ||
} | ||
if (isClosed) { | ||
path.push(path[0]); | ||
} else { | ||
coords.pop(); | ||
p0 = coords[coords.length-1]; | ||
p1 = coords[coords.length-2]; | ||
p2 = [ | ||
p0[0] - (p1[1] - p0[1]) / ol.coordinate.dist2d(p0,p1) *offset, | ||
p0[1] + (p1[0] - p0[0]) / ol.coordinate.dist2d(p0,p1) *offset | ||
]; | ||
path.push(p2); | ||
} | ||
return path; | ||
var path = []; | ||
var N = coords.length-1; | ||
var max = N; | ||
var mi, mi1, li, li1, ri, ri1, si, si1, Xi1, Yi1; | ||
var p0, p1, p2; | ||
var isClosed = ol.coordinate.equal(coords[0],coords[N]); | ||
if (!isClosed) { | ||
p0 = coords[0]; | ||
p1 = coords[1]; | ||
p2 = [ | ||
p0[0] + (p1[1] - p0[1]) / ol.coordinate.dist2d(p0,p1) *offset, | ||
p0[1] - (p1[0] - p0[0]) / ol.coordinate.dist2d(p0,p1) *offset | ||
]; | ||
path.push(p2); | ||
coords.push(coords[N]) | ||
N++; | ||
max--; | ||
} | ||
for (var i = 0; i < max; i++) { | ||
p0 = coords[i]; | ||
p1 = coords[(i+1) % N]; | ||
p2 = coords[(i+2) % N]; | ||
mi = (p1[1] - p0[1])/(p1[0] - p0[0]); | ||
mi1 = (p2[1] - p1[1])/(p2[0] - p1[0]); | ||
// Prevent alignements | ||
if (Math.abs(mi-mi1) > 1e-10) { | ||
li = Math.sqrt((p1[0] - p0[0])*(p1[0] - p0[0])+(p1[1] - p0[1])*(p1[1] - p0[1])); | ||
li1 = Math.sqrt((p2[0] - p1[0])*(p2[0] - p1[0])+(p2[1] - p1[1])*(p2[1] - p1[1])); | ||
ri = p0[0] + offset*(p1[1] - p0[1])/li; | ||
ri1 = p1[0] + offset*(p2[1] - p1[1])/li1; | ||
si = p0[1] - offset*(p1[0] - p0[0])/li; | ||
si1 = p1[1] - offset*(p2[0] - p1[0])/li1; | ||
Xi1 = (mi1*ri1-mi*ri+si-si1) / (mi1-mi); | ||
Yi1 = (mi*mi1*(ri1-ri)+mi1*si-mi*si1) / (mi1-mi); | ||
// Correction for vertical lines | ||
if(p1[0] - p0[0] == 0) { | ||
Xi1 = p1[0] + offset*(p1[1] - p0[1])/Math.abs(p1[1] - p0[1]); | ||
Yi1 = mi1*Xi1 - mi1*ri1 + si1; | ||
} | ||
if (p2[0] - p1[0] == 0 ) { | ||
Xi1 = p2[0] + offset*(p2[1] - p1[1])/Math.abs(p2[1] - p1[1]); | ||
Yi1 = mi*Xi1 - mi*ri + si; | ||
} | ||
path.push([Xi1, Yi1]); | ||
} | ||
} | ||
if (isClosed) { | ||
path.push(path[0]); | ||
} else { | ||
coords.pop(); | ||
p0 = coords[coords.length-1]; | ||
p1 = coords[coords.length-2]; | ||
p2 = [ | ||
p0[0] - (p1[1] - p0[1]) / ol.coordinate.dist2d(p0,p1) *offset, | ||
p0[1] + (p1[0] - p0[0]) / ol.coordinate.dist2d(p0,p1) *offset | ||
]; | ||
path.push(p2); | ||
} | ||
return path; | ||
} | ||
@@ -186,23 +122,50 @@ /** Find the segment a point belongs to | ||
* @param {Array<ol.coordinate>} coords | ||
* @return {} the index (-1 if not found) and the segment | ||
* @return {} the index (-1 if not found) and the segment | ||
*/ | ||
ol.coordinate.findSegment = function (pt, coords) { | ||
for (var i=0; i<coords.length-1; i++) { | ||
var p0 = coords[i]; | ||
var p1 = coords[i+1]; | ||
if (ol.coordinate.equal(pt, p0) || ol.coordinate.equal(pt, p1)) { | ||
return { index:1, segment: [p0,p1] }; | ||
} else { | ||
var d0 = ol.coordinate.dist2d(p0,p1); | ||
var v0 = [ (p1[0] - p0[0]) / d0, (p1[1] - p0[1]) / d0 ]; | ||
var d1 = ol.coordinate.dist2d(p0,pt); | ||
var v1 = [ (pt[0] - p0[0]) / d1, (pt[1] - p0[1]) / d1 ]; | ||
if (Math.abs(v0[0]*v1[1] - v0[1]*v1[0]) < 1e-10) { | ||
return { index:1, segment: [p0,p1] }; | ||
} | ||
} | ||
} | ||
return { index: -1 }; | ||
for (var i=0; i<coords.length-1; i++) { | ||
var p0 = coords[i]; | ||
var p1 = coords[i+1]; | ||
if (ol.coordinate.equal(pt, p0) || ol.coordinate.equal(pt, p1)) { | ||
return { index:1, segment: [p0,p1] }; | ||
} else { | ||
var d0 = ol.coordinate.dist2d(p0,p1); | ||
var v0 = [ (p1[0] - p0[0]) / d0, (p1[1] - p0[1]) / d0 ]; | ||
var d1 = ol.coordinate.dist2d(p0,pt); | ||
var v1 = [ (pt[0] - p0[0]) / d1, (pt[1] - p0[1]) / d1 ]; | ||
if (Math.abs(v0[0]*v1[1] - v0[1]*v1[0]) < 1e-10) { | ||
return { index:1, segment: [p0,p1] }; | ||
} | ||
} | ||
} | ||
return { index: -1 }; | ||
}; | ||
/* Use | ||
*/ | ||
/** | ||
* Split a Polygon geom with horizontal lines | ||
* @param {Array<ol.coordinate>} geom | ||
* @param {Number} y the y to split | ||
* @param {Number} n contour index | ||
* @return {Array<Array<ol.coordinate>>} | ||
*/ | ||
ol.coordinate.splitH = function (geom, y, n) { | ||
var x, abs; | ||
var list = []; | ||
for (var i=0; i<geom.length-1; i++) { | ||
// Hole separator? | ||
if (!geom[i].length || !geom[i+1].length) continue; | ||
// Intersect | ||
if (geom[i][1]<=y && geom[i+1][1]>y || geom[i][1]>=y && geom[i+1][1]<y) { | ||
abs = (y-geom[i][1]) / (geom[i+1][1]-geom[i][1]); | ||
x = abs * (geom[i+1][0]-geom[i][0]) + geom[i][0]; | ||
list.push ({ contour: n, index: i, pt: [x,y], abs: abs }); | ||
} | ||
} | ||
// Sort x | ||
list.sort(function(a,b) { return a.pt[0] - b.pt[0] }); | ||
// Horizontal segement | ||
var result = []; | ||
for (var j=0; j<list.length-1; j += 2) { | ||
result.push([list[j], list[j+1]]) | ||
} | ||
return result; | ||
}; |
@@ -7,31 +7,2 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO, | ||
/** | ||
* Split a Polygon geom with horizontal lines | ||
* @param {Array<ol.coordinate>} geom | ||
* @param {Number} y the y to split | ||
* @param {Number} n contour index | ||
* @return {Array<Array<ol.coordinate>>} | ||
*/ | ||
ol.coordinate.splitH = function (geom, y, n) { | ||
var x, abs; | ||
var list = []; | ||
for (var i=0; i<geom.length-1; i++) { | ||
// Hole separator? | ||
if (!geom[i].length || !geom[i+1].length) continue; | ||
// Intersect | ||
if (geom[i][1]<=y && geom[i+1][1]>y || geom[i][1]>=y && geom[i+1][1]<y) { | ||
abs = (y-geom[i][1]) / (geom[i+1][1]-geom[i][1]); | ||
x = abs * (geom[i+1][0]-geom[i][0]) + geom[i][0]; | ||
list.push ({ contour: n, index: i, pt: [x,y], abs: abs }); | ||
} | ||
} | ||
// Sort x | ||
list.sort(function(a,b) { return a.pt[0] - b.pt[0] }); | ||
// Horizontal segement | ||
var result = []; | ||
for (var j=0; j<list.length-1; j += 2) { | ||
result.push([list[j], list[j+1]]) | ||
} | ||
return result; | ||
}; | ||
/** | ||
* Calculate a MultiPolyline to fill a Polygon with a scribble effect that appears hand-made | ||
@@ -53,8 +24,9 @@ * @param {} options | ||
var scribble = scribbles[0]; | ||
for (var i=0, s; s=scribbles[i]; i++) { | ||
ls = s.getLineStrings(); | ||
for (k=0; k<ls.length; k++) { | ||
scribble.appendLineString(ls[k]); | ||
var ls; | ||
for (var i = 0, s; s = scribbles[i]; i++) { | ||
ls = s.getLineStrings(); | ||
for (var k = 0; k < ls.length; k++) { | ||
scribble.appendLineString(ls[k]); | ||
} | ||
} | ||
} | ||
return scribble; | ||
@@ -61,0 +33,0 @@ }; |
@@ -13,3 +13,3 @@ /* | ||
*/ | ||
/** | ||
/** | ||
* @constructor | ||
@@ -16,0 +16,0 @@ * @extends {ol.interaction.Pointer} |
@@ -12,4 +12,4 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO, | ||
*/ | ||
ol.interaction.SnapGuides = function(options) | ||
{ if (!options) options = {}; | ||
ol.interaction.SnapGuides = function(options) { | ||
if (!options) options = {}; | ||
// Intersect 2 guides | ||
@@ -64,6 +64,7 @@ function getIntersectionPoint (d1, d2) | ||
*/ | ||
this.overlayLayer_ = new ol.layer.Vector( | ||
{ source: this.overlaySource_, | ||
style: function(f) | ||
{ return sketchStyle; | ||
console.log('CREATE OVERLAY') | ||
this.overlayLayer_ = new ol.layer.Vector({ | ||
source: this.overlaySource_, | ||
style: function(f) { | ||
return sketchStyle; | ||
}, | ||
@@ -74,32 +75,31 @@ name:'Snap overlay', | ||
// Use snap interaction | ||
ol.interaction.Interaction.call(this, | ||
{ handleEvent: function(e) | ||
{ if (this.getActive()) | ||
{ var features = this.overlaySource_.getFeatures(); | ||
var prev = null; | ||
var p = null; | ||
var res = e.frameState.viewState.resolution; | ||
for (var i=0, f; f = features[i]; i++) | ||
{ var c = f.getGeometry().getClosestPoint(e.coordinate); | ||
if ( dist2D(c, e.coordinate) / res < this.snapDistance_) | ||
{ // Intersection on 2 lines | ||
if (prev) | ||
{ var c2 = getIntersectionPoint(prev.getGeometry().getCoordinates(), f.getGeometry().getCoordinates()); | ||
if (c2) | ||
{ if (dist2D(c2, e.coordinate) / res < this.snapDistance_) | ||
{ p = c2; | ||
} | ||
ol.interaction.Interaction.call(this, { | ||
handleEvent: function(e) { | ||
if (this.getActive()) { | ||
var features = this.overlaySource_.getFeatures(); | ||
var prev = null; | ||
var p = null; | ||
var res = e.frameState.viewState.resolution; | ||
for (var i=0, f; f = features[i]; i++) { | ||
var c = f.getGeometry().getClosestPoint(e.coordinate); | ||
if ( dist2D(c, e.coordinate) / res < this.snapDistance_) { | ||
// Intersection on 2 lines | ||
if (prev) { | ||
var c2 = getIntersectionPoint(prev.getGeometry().getCoordinates(), f.getGeometry().getCoordinates()); | ||
if (c2) { | ||
if (dist2D(c2, e.coordinate) / res < this.snapDistance_) { | ||
p = c2; | ||
} | ||
} | ||
else | ||
{ p = c; | ||
} | ||
prev = f; | ||
} else { | ||
p = c; | ||
} | ||
prev = f; | ||
} | ||
if (p) e.coordinate = p; | ||
} | ||
return true; | ||
if (p) e.coordinate = p; | ||
} | ||
}); | ||
return true; | ||
} | ||
}); | ||
}; | ||
@@ -113,4 +113,4 @@ ol.inherits(ol.interaction.SnapGuides, ol.interaction.Interaction); | ||
*/ | ||
ol.interaction.SnapGuides.prototype.setMap = function(map) | ||
{ if (this.getMap()) this.getMap().removeLayer(this.overlayLayer_); | ||
ol.interaction.SnapGuides.prototype.setMap = function(map) { | ||
if (this.getMap()) this.getMap().removeLayer(this.overlayLayer_); | ||
ol.interaction.Interaction.prototype.setMap.call (this, map); | ||
@@ -148,4 +148,4 @@ this.overlayLayer_.setMap(map); | ||
*/ | ||
ol.interaction.SnapGuides.prototype.addGuide = function(v, ortho) | ||
{ if (v) | ||
ol.interaction.SnapGuides.prototype.addGuide = function(v, ortho) { | ||
if (v) | ||
{ var map = this.getMap(); | ||
@@ -155,3 +155,8 @@ // Limit extent | ||
extent = ol.extent.buffer(extent, Math.max (1e5+1, (extent[2]-extent[0])*100)); | ||
extent = ol.extent.getIntersection(extent, this.projExtent_); | ||
//extent = ol.extent.boundingExtent(extent, this.projExtent_); | ||
if (extent[0]<this.projExtent_[0]) extent[0]=this.projExtent_[0]; | ||
if (extent[1]<this.projExtent_[1]) extent[1]=this.projExtent_[1]; | ||
if (extent[2]>this.projExtent_[2]) extent[2]=this.projExtent_[2]; | ||
if (extent[3]>this.projExtent_[3]) extent[3]=this.projExtent_[3]; | ||
// | ||
var dx = v[0][0] - v[1][0]; | ||
@@ -193,4 +198,4 @@ var dy = v[0][1] - v[1][1]; | ||
*/ | ||
ol.interaction.SnapGuides.prototype.setDrawInteraction = function(drawi) | ||
{ var self = this; | ||
ol.interaction.SnapGuides.prototype.setDrawInteraction = function(drawi) { | ||
var self = this; | ||
// Number of points currently drawing | ||
@@ -200,7 +205,7 @@ var nb = 0; | ||
var features = []; | ||
function setGuides(e) | ||
{ var coord = []; | ||
function setGuides(e) { | ||
var coord = []; | ||
var s = 2; | ||
switch (e.target.getType()) | ||
{ case 'LineString': | ||
switch (e.target.getType()) { | ||
case 'LineString': | ||
coord = e.target.getCoordinates(); | ||
@@ -216,4 +221,4 @@ s = 2; | ||
var l = coord.length; | ||
if (l != nb && l > s) | ||
{ self.clearGuides(features); | ||
if (l != nb && l > s) { | ||
self.clearGuides(features); | ||
features = self.addOrthoGuide([coord[l-s],coord[l-s-1]]); | ||
@@ -226,9 +231,9 @@ features = features.concat(self.addGuide([coord[0],coord[1]])); | ||
// New drawing | ||
drawi.on ("drawstart", function(e) | ||
{ // When geom is changing add a new orthogonal direction | ||
drawi.on ("drawstart", function(e) { | ||
// When geom is changing add a new orthogonal direction | ||
e.feature.getGeometry().on("change", setGuides); | ||
}); | ||
// end drawing, clear directions | ||
drawi.on ("drawend", function(e) | ||
{ self.clearGuides(features); | ||
drawi.on ("drawend", function(e) { | ||
self.clearGuides(features); | ||
e.feature.getGeometry().un("change", setGuides); | ||
@@ -235,0 +240,0 @@ nb = 0; |
@@ -8,3 +8,3 @@ /* | ||
*/ | ||
/** | ||
/** | ||
* @constructor | ||
@@ -11,0 +11,0 @@ * @extends {ol.interaction.Pointer} |
@@ -6,2 +6,3 @@ /** Interaction rotate | ||
* @param {any} options | ||
* @param {function} options.filter A function that takes a Feature and a Layer and returns true if the feature may be transformed or false otherwise. | ||
* @param {Array<ol.Layer>} options.layers array of layers to transform, | ||
@@ -45,5 +46,6 @@ * @param {ol.Collection<ol.Feature>} options.features collection of feature to transform, | ||
}); | ||
/** Collection of feature to transform */ | ||
// Collection of feature to transform | ||
this.features_ = options.features; | ||
/** List of layers to transform */ | ||
// Filter or list of layers to transform | ||
if (typeof(options.filter)==='function') this._filter = options.filter; | ||
this.layers_ = options.layers ? (options.layers instanceof Array) ? options.layers:[options.layers] : null; | ||
@@ -206,4 +208,9 @@ this.addFn_ = options.addCondition || function() { return false; }; | ||
} | ||
// filter condition | ||
if (self._filter) { | ||
if (self._filter(feature,layer)) return { feature: feature }; | ||
else return null; | ||
} | ||
// feature belong to a layer | ||
if (self.layers_) { | ||
else if (self.layers_) { | ||
for (var i=0; i<self.layers_.length; i++) { | ||
@@ -210,0 +217,0 @@ if (self.layers_[i]===layer) return { feature: feature }; |
/* | ||
Copyright (c) 2015 Jean-Marc VIGLINO, | ||
Copyright (c) 2015 Jean-Marc VIGLINO, | ||
released under the CeCILL-B license (http://www.cecill.info/). | ||
ol.layer.AnimatedCluster is a vector layer that animate cluster | ||
ol.layer.AnimatedCluster is a vector layer that animate cluster | ||
*/ | ||
@@ -6,0 +6,0 @@ /** |
@@ -68,6 +68,6 @@ /** ol.layer.Vector.prototype.setRender3D | ||
*/ | ||
ol.render3D.prototype.setLayer = function(l) | ||
{ if (this.layer_) this.layer_.un ('postcompose', this.onPostcompose_, this); | ||
ol.render3D.prototype.setLayer = function(l) { | ||
if (this._listener) ol.Observable.unByKey(this._listener); | ||
this.layer_ = l; | ||
l.on ('postcompose', this.onPostcompose_, this); | ||
this._listener = l.on ('postcompose', this.onPostcompose_.bind(this)); | ||
} | ||
@@ -74,0 +74,0 @@ /** Create a function that return height of a feature |
@@ -31,3 +31,3 @@ /* Copyright (c) 2015 Jean-Marc VIGLINO, | ||
/** Default attribution */ | ||
if (!options.attributions) options.attributions = [ new ol.Attribution({ html:"© <a href='http://dbpedia.org/'>DBpedia</a> CC-by-SA" }) ]; | ||
if (!options.attributions) options.attributions = [ "© <a href='http://dbpedia.org/'>DBpedia</a> CC-by-SA" ]; | ||
// Bbox strategy : reload at each move | ||
@@ -34,0 +34,0 @@ if (!options.strategy) options.strategy = ol.loadingstrategy.bbox; |
@@ -24,3 +24,3 @@ /* Copyright (c) 2017 Jean-Marc VIGLINO, | ||
/** Default attribution */ | ||
if (!options.attributions) options.attributions = [ new ol.Attribution({ html:"© <a href='https://www.mapillary.com/'>Mapillary</a>" }) ]; | ||
if (!options.attributions) options.attributions = [ "© <a href='https://www.mapillary.com/'>Mapillary</a>" ]; | ||
// Bbox strategy : reload at each move | ||
@@ -27,0 +27,0 @@ if (!options.strategy) options.strategy = ol.loadingstrategy.bbox; |
@@ -26,3 +26,3 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO, | ||
/** Default attribution */ | ||
if (!options.attributions) options.attributions = [ new ol.Attribution({ html:"© <a href='https://commons.wikimedia.org/'>Wikimedia Commons</a>" }) ]; | ||
if (!options.attributions) options.attributions = [ "© <a href='https://commons.wikimedia.org/'>Wikimedia Commons</a>" ]; | ||
// Bbox strategy : reload at each move | ||
@@ -29,0 +29,0 @@ if (!options.strategy) options.strategy = ol.loadingstrategy.bbox; |
{ | ||
"name": "openlayers-ext", | ||
"version": "2.0.6", | ||
"version": "3.0.0", | ||
"description": "A set of cool extensions for OpenLayers (ol).", | ||
@@ -9,4 +9,3 @@ "main": "index.js", | ||
"jquery": "^3.2.1", | ||
"jspdf": "^1.3.5", | ||
"openlayers": "^4.6.4" | ||
"openlayers": "^5.0.3" | ||
}, | ||
@@ -13,0 +12,0 @@ "devDependencies": { |
{ | ||
"name": "openlayers-ext", | ||
"version": "2.0.6", | ||
"version": "3.0.0", | ||
"description": "A set of cool extensions for OpenLayers (ol).", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"jquery": "^3.2.1", | ||
"openlayers": "^4.6.4" | ||
"openlayers": "^5.0.3" | ||
}, | ||
@@ -12,0 +12,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4319014
242
38885
- Removedabbrev@1.1.1(transitive)
- Removedaccepts@1.3.8(transitive)
- Removedacorn@4.0.135.2.1(transitive)
- Removedafter@0.8.2(transitive)
- Removedajv@4.11.8(transitive)
- Removedalign-text@0.1.4(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@1.0.0(transitive)
- Removedaproba@1.2.0(transitive)
- Removedare-we-there-yet@1.1.7(transitive)
- Removedarraybuffer.slice@0.0.7(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@0.2.01.0.0(transitive)
- Removedasync@1.5.22.6.0(transitive)
- Removedasync-limiter@1.0.1(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.6.0(transitive)
- Removedaws4@1.13.0(transitive)
- Removedbabylon@7.0.0-beta.19(transitive)
- Removedbacko2@1.0.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase64-arraybuffer@0.1.5(transitive)
- Removedbase64id@1.0.0(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbetter-assert@1.0.2(transitive)
- Removedbinary@0.3.0(transitive)
- Removedblob@0.0.5(transitive)
- Removedbluebird@3.5.5(transitive)
- Removedboom@2.10.1(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbuffers@0.1.1(transitive)
- Removedbuiltin-modules@2.0.0(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcallsite@1.0.0(transitive)
- Removedcamelcase@1.2.1(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcatharsis@0.8.11(transitive)
- Removedcenter-align@0.1.3(transitive)
- Removedchainsaw@0.1.0(transitive)
- Removedchalk@0.4.0(transitive)
- Removedcliui@2.1.0(transitive)
- Removedclosure-util@1.26.0(transitive)
- Removedco@4.6.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcomponent-bind@1.0.0(transitive)
- Removedcomponent-emitter@1.2.1(transitive)
- Removedcomponent-inherit@0.0.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconsole-control-strings@1.1.0(transitive)
- Removedcookie@0.3.1(transitive)
- Removedcore-util-is@1.0.21.0.3(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddebug@2.6.93.1.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddecompress-zip@0.3.0(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddelegates@1.0.0(transitive)
- Removeddepd@1.1.2(transitive)
- Removeddestroy@1.0.4(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.2(transitive)
- Removedengine.io@3.1.5(transitive)
- Removedengine.io-client@3.1.6(transitive)
- Removedengine.io-parser@2.1.3(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedestree-walker@0.5.20.6.1(transitive)
- Removedetag@1.8.1(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedforeachasync@3.0.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.1.4(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfs-extra@4.0.24.0.3(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedgauge@2.7.4(transitive)
- Removedgaze@1.1.2(transitive)
- Removedget-down@1.2.0(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedglob@7.1.2(transitive)
- Removedglobule@1.3.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedgraceful-fs@4.1.11(transitive)
- Removedhandlebars@4.0.11(transitive)
- Removedhar-schema@1.0.5(transitive)
- Removedhar-validator@4.2.1(transitive)
- Removedhas-binary2@1.0.3(transitive)
- Removedhas-color@0.1.7(transitive)
- Removedhas-cors@1.1.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-unicode@2.0.1(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhawk@3.1.3(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhttp-errors@1.6.3(transitive)
- Removedhttp-signature@1.1.1(transitive)
- Removedieee754@1.2.1(transitive)
- Removedindexof@0.0.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.32.0.4(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-core-module@2.13.1(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedis-module@1.0.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisarray@0.0.11.0.02.0.12.0.5(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjs2xmlparser@3.0.0(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjsdoc@3.5.5(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-stable-stringify@1.1.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedjsonify@0.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedjunk@2.1.0(transitive)
- Removedkind-of@3.2.2(transitive)
- Removedklaw@2.0.0(transitive)
- Removedlazy-cache@1.0.4(transitive)
- Removedlodash@4.17.214.17.4(transitive)
- Removedlongest@1.0.1(transitive)
- Removedmagic-string@0.22.5(transitive)
- Removedmarked@0.3.19(transitive)
- Removedmime@1.4.1(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimatch@3.0.4(transitive)
- Removedminimist@0.0.8(transitive)
- Removedminipass@2.9.0(transitive)
- Removedminizlib@1.3.3(transitive)
- Removedmkdirp@0.5.1(transitive)
- Removedmkpath@0.1.0(transitive)
- Removedmout@1.0.0(transitive)
- Removedms@2.0.0(transitive)
- Removednegotiator@0.6.3(transitive)
- Removednomnom@1.8.1(transitive)
- Removednopt@1.0.103.0.6(transitive)
- Removednpmlog@4.1.2(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedoauth-sign@0.8.2(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedobject-component@0.0.3(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedon-finished@2.3.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedopenlayers@4.6.5(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedparseqs@0.0.5(transitive)
- Removedparseuri@0.0.5(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpbf@3.1.0(transitive)
- Removedperformance-now@0.2.0(transitive)
- Removedpixelworks@1.1.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedprotocol-buffers-schema@3.6.0(transitive)
- Removedpunycode@1.4.1(transitive)
- Removedq@1.5.0(transitive)
- Removedqs@6.4.1(transitive)
- Removedquickselect@1.1.1(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedrbush@2.0.1(transitive)
- Removedreadable-stream@1.1.142.3.8(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedrequest@2.81.0(transitive)
- Removedrequest-progress@3.0.0(transitive)
- Removedrequizzle@0.2.4(transitive)
- Removedresolve@1.22.8(transitive)
- Removedresolve-protobuf-schema@2.1.0(transitive)
- Removedretry@0.10.1(transitive)
- Removedright-align@0.1.3(transitive)
- Removedrimraf@2.2.82.6.2(transitive)
- Removedrollup@0.52.3(transitive)
- Removedrollup-plugin-cleanup@2.0.1(transitive)
- Removedrollup-plugin-commonjs@8.4.1(transitive)
- Removedrollup-plugin-node-resolve@3.4.0(transitive)
- Removedrollup-pluginutils@2.8.2(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsend@0.16.1(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedsetprototypeof@1.1.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedsntp@1.0.9(transitive)
- Removedsocket.io@2.0.4(transitive)
- Removedsocket.io-adapter@1.1.2(transitive)
- Removedsocket.io-client@2.0.4(transitive)
- Removedsocket.io-parser@3.1.3(transitive)
- Removedsource-map@0.4.40.5.7(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstatuses@1.3.11.5.0(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstring_decoder@0.10.311.1.1(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedstrip-ansi@0.1.13.0.1(transitive)
- Removedstrip-json-comments@2.0.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtaffydb@2.6.2(transitive)
- Removedtar@3.1.5(transitive)
- Removedtemp@0.8.3(transitive)
- Removedthrottleit@1.0.1(transitive)
- Removedtmp@0.0.31(transitive)
- Removedto-array@0.1.4(transitive)
- Removedtouch@0.0.3(transitive)
- Removedtough-cookie@2.3.4(transitive)
- Removedtraverse@0.3.9(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduglify-js@2.8.29(transitive)
- Removeduglify-to-browserify@1.0.2(transitive)
- Removedultron@1.1.1(transitive)
- Removedunderscore@1.6.01.8.3(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@3.4.0(transitive)
- Removeduws@9.14.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedvlq@0.2.3(transitive)
- Removedwalk@2.3.9(transitive)
- Removedwide-align@1.1.5(transitive)
- Removedwindow-size@0.1.0(transitive)
- Removedwordwrap@0.0.20.0.3(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedws@3.3.3(transitive)
- Removedxmlcreate@1.0.2(transitive)
- Removedxmlhttprequest-ssl@1.5.5(transitive)
- Removedyallist@3.1.1(transitive)
- Removedyargs@3.10.0(transitive)
- Removedyeast@0.1.2(transitive)
Updatedopenlayers@^5.0.3