Socket
Socket
Sign inDemoInstall

openlayers-ext

Package Overview
Dependencies
2
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.0.1

4

lib/control/GeolocationBar.js

@@ -25,3 +25,3 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO,

zoom: options.zoom,
followTrack: true,
followTrack: options.followTrack,
minAccuracy: options.minAccuracy || 10000

@@ -34,3 +34,3 @@ });

interaction.pause(true);
interaction.setFollowTrack(true);
interaction.setFollowTrack(options.followTrack);
element.removeClass('pauseTrack');

@@ -37,0 +37,0 @@ }

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

* @require jQuery
*
* @fires drawlist
*
* @constructor

@@ -18,3 +19,3 @@ * @extends {ol.control.Control}

* @param {boolean} trash add a trash button to delete the layer, default false
* @param {function} oninfo callback on click on info button, if none no info button is shown
* @param {function} oninfo callback on click on info button, if none no info button is shown DEPRECATED: use on(info) instead
* @param {boolean} extent add an extent button to zoom to the extent of the layer

@@ -483,3 +484,5 @@ * @param {function} onextent callback when click on extent, default fits view to extent

e.preventDefault();
self.oninfo($(this).closest('li').data("layer"));
var l = $(this).closest('li').data("layer");
self.oninfo(l);
self.dispatchEvent({ type: "info", layer: l });
};

@@ -489,4 +492,6 @@ function zoomExtent(e)

e.preventDefault();
if (self.onextent) self.onextent($(this).closest('li').data("layer"));
else self.map_.getView().fit ($(this).closest('li').data("layer").getExtent(), self.map_.getSize());
var l = $(this).closest('li').data("layer");
if (self.onextent) self.onextent(l);
else self.map_.getView().fit (l.getExtent(), self.map_.getSize());
self.dispatchEvent({ type: "extent", layer: l });
};

@@ -619,3 +624,6 @@ function removeLayer(e)

else if (layer instanceof ol.layer.Heatmap) li.addClass('ol-layer-heatmap');
// Dispatch a dralist event to allow customisation
this.dispatchEvent({ type:'drawlist', layer:layer, li:li.get(0) });
}
this.viewChange();
if (ul==this.panel_) this.overflow();

@@ -622,0 +630,0 @@ };

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

* @param {olx.interaction.DrawHoleOptions} options extend olx.interaction.DrawOptions
* @param {Array<ol.layer.Vector> | undefined} options.layers A list of layers from which polygons should be selected. Alternatively, a filter function can be provided. default: all visible layers
* @param {Array<ol.layer.Vector> | function | undefined} options.layers A list of layers from which polygons should be selected. Alternatively, a filter function can be provided. default: all visible layers
* @param { ol.style.Style | Array<ol.style.Style> | StyleFunction | undefined } Style for the selected features, default: default edit style
*/

@@ -17,3 +18,3 @@ ol.interaction.DrawHole = function(options)

// Select interaction for the current feature
this._select = new ol.interaction.Select();
this._select = new ol.interaction.Select({ style: options.style });
this._select.setActive(false);

@@ -20,0 +21,0 @@ // Geometry function that test points inside the current

@@ -8,3 +8,3 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO,

* @extends {ol.interaction.Interaction}
* @fires beforesplit, aftersplit
* @fires beforesplit, aftersplit, pointermove
* @param {olx.interaction.SplitOptions}

@@ -202,4 +202,4 @@ * - source {ol.source.Vector|Array{ol.source.Vector}} a list of source to split (configured with useSpatialIndex set to true)

var current = this.getClosestFeature(e);
if (current && this.filterSplit_(current.feature))
{ var coord, p, l;
if (current && this.filterSplit_(current.feature)) {
var p, l;
// Draw sketch

@@ -211,5 +211,18 @@ this.overlayLayer_.getSource().addFeature(current.feature);

//
l = new ol.Feature(new ol.geom.LineString([e.coordinate,current.coord]));
l = new ol.Feature(current.link);
l._sketch_ = true;
this.overlayLayer_.getSource().addFeature(l);
// move event
this.dispatchEvent({
type: 'pointermove',
coordinate: e.coordinate,
frameState: e.frameState,
originalEvent: e.originalEvent,
map: e.map,
pixel: e.pixel,
feature: current.feature,
linkGeometry: current.link
});
} else {
this.dispatchEvent(e);
}

@@ -216,0 +229,0 @@ var element = map.getTargetElement();

@@ -29,3 +29,4 @@ /** Interaction rotate

features: this.handles_,
useSpatialIndex: false
useSpatialIndex: false,
wrapX: false // For vector editing across the -180° and 180° meridians to work properly, this should be set to false
}),

@@ -37,39 +38,39 @@ name:'Transform overlay',

return (self.style[(feature.get('handle')||'default')+(feature.get('constraint')||'')+(feature.get('option')||'')]);
}
},
});
// Extend pointer
ol.interaction.Pointer.call(this, {
// Extend pointer
ol.interaction.Pointer.call(this, {
handleDownEvent: this.handleDownEvent_,
handleDragEvent: this.handleDragEvent_,
handleMoveEvent: this.handleMoveEvent_,
handleUpEvent: this.handleUpEvent_
});
// Collection of feature to transform
this.features_ = options.features;
// 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;
this.addFn_ = options.addCondition || function() { return false; };
/* Translate when click on feature */
this.set('translateFeature', (options.translateFeature!==false));
/* Can translate the feature */
this.set('translate', (options.translate!==false));
/* Can stretch the feature */
this.set('stretch', (options.stretch!==false));
/* Can scale the feature */
this.set('scale', (options.scale!==false));
/* Can rotate the feature */
this.set('rotate', (options.rotate!==false));
/* Keep aspect ratio */
this.set('keepAspectRatio', (options.keepAspectRatio || function(e){ return e.originalEvent.shiftKey }));
/* Modify center */
this.set('modifyCenter', (options.modifyCenter || function(e){ return e.originalEvent.metaKey || e.originalEvent.ctrlKey }));
/* */
this.set('hitTolerance', (options.hitTolerance || 0));
handleDragEvent: this.handleDragEvent_,
handleMoveEvent: this.handleMoveEvent_,
handleUpEvent: this.handleUpEvent_
});
// Collection of feature to transform
this.features_ = options.features;
// 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;
this.addFn_ = options.addCondition || function() { return false; };
/* Translate when click on feature */
this.set('translateFeature', (options.translateFeature!==false));
/* Can translate the feature */
this.set('translate', (options.translate!==false));
/* Can stretch the feature */
this.set('stretch', (options.stretch!==false));
/* Can scale the feature */
this.set('scale', (options.scale!==false));
/* Can rotate the feature */
this.set('rotate', (options.rotate!==false));
/* Keep aspect ratio */
this.set('keepAspectRatio', (options.keepAspectRatio || function(e){ return e.originalEvent.shiftKey }));
/* Modify center */
this.set('modifyCenter', (options.modifyCenter || function(e){ return e.originalEvent.metaKey || e.originalEvent.ctrlKey }));
/* */
this.set('hitTolerance', (options.hitTolerance || 0));
this.selection_ = [];
// Force redraw when changed
this.on ('propertychange', function() {
// Force redraw when changed
this.on ('propertychange', function() {
this.drawSketch_();
});
// setstyle
});
// setstyle
this.setDefaultStyle();

@@ -103,8 +104,8 @@ };

if (this.getMap()) this.getMap().removeLayer(this.overlayLayer_);
ol.interaction.Pointer.prototype.setMap.call (this, map);
this.overlayLayer_.setMap(map);
if (map !== null) {
this.isTouch = /touch/.test(map.getViewport().className);
this.setDefaultStyle();
}
ol.interaction.Pointer.prototype.setMap.call (this, map);
this.overlayLayer_.setMap(map);
if (map !== null) {
this.isTouch = /touch/.test(map.getViewport().className);
this.setDefaultStyle();
}
};

@@ -118,4 +119,4 @@ /**

this.select(null);
this.overlayLayer_.setVisible(b);
ol.interaction.Pointer.prototype.setActive.call (this, b);
this.overlayLayer_.setVisible(b);
ol.interaction.Pointer.prototype.setActive.call (this, b);
};

@@ -126,7 +127,7 @@ /** Set efault sketch style

// Style
var stroke = new ol.style.Stroke({ color: [255,0,0,1], width: 1 });
var strokedash = new ol.style.Stroke({ color: [255,0,0,1], width: 1, lineDash:[4,4] });
var fill0 = new ol.style.Fill({ color:[255,0,0,0.01] });
var fill = new ol.style.Fill({ color:[255,255,255,0.8] });
var circle = new ol.style.RegularShape({
var stroke = new ol.style.Stroke({ color: [255,0,0,1], width: 1 });
var strokedash = new ol.style.Stroke({ color: [255,0,0,1], width: 1, lineDash:[4,4] });
var fill0 = new ol.style.Fill({ color:[255,0,0,0.01] });
var fill = new ol.style.Fill({ color:[255,255,255,0.8] });
var circle = new ol.style.RegularShape({
fill: fill,

@@ -137,4 +138,4 @@ stroke: stroke,

});
circle.getAnchor()[0] = this.isTouch ? -10 : -5;
var bigpt = new ol.style.RegularShape({
circle.getAnchor()[0] = this.isTouch ? -10 : -5;
var bigpt = new ol.style.RegularShape({
fill: fill,

@@ -146,3 +147,3 @@ stroke: stroke,

});
var smallpt = new ol.style.RegularShape({
var smallpt = new ol.style.RegularShape({
fill: fill,

@@ -154,21 +155,21 @@ stroke: stroke,

});
function createStyle (img, stroke, fill) {
function createStyle (img, stroke, fill) {
return [ new ol.style.Style({image:img, stroke:stroke, fill:fill}) ];
}
/** Style for handles */
this.style = {
}
/** Style for handles */
this.style = {
'default': createStyle (bigpt, strokedash, fill0),
'translate': createStyle (bigpt, stroke, fill),
'rotate': createStyle (circle, stroke, fill),
'rotate0': createStyle (bigpt, stroke, fill),
'scale': createStyle (bigpt, stroke, fill),
'scale1': createStyle (bigpt, stroke, fill),
'scale2': createStyle (bigpt, stroke, fill),
'scale3': createStyle (bigpt, stroke, fill),
'scalev': createStyle (smallpt, stroke, fill),
'scaleh1': createStyle (smallpt, stroke, fill),
'scalev2': createStyle (smallpt, stroke, fill),
'scaleh3': createStyle (smallpt, stroke, fill),
};
this.drawSketch_();
'translate': createStyle (bigpt, stroke, fill),
'rotate': createStyle (circle, stroke, fill),
'rotate0': createStyle (bigpt, stroke, fill),
'scale': createStyle (bigpt, stroke, fill),
'scale1': createStyle (bigpt, stroke, fill),
'scale2': createStyle (bigpt, stroke, fill),
'scale3': createStyle (bigpt, stroke, fill),
'scalev': createStyle (smallpt, stroke, fill),
'scaleh1': createStyle (smallpt, stroke, fill),
'scalev2': createStyle (smallpt, stroke, fill),
'scaleh3': createStyle (smallpt, stroke, fill),
};
this.drawSketch_();
}

@@ -182,17 +183,17 @@ /**

if (!olstyle) return;
if (olstyle instanceof Array) this.style[style] = olstyle;
else this.style[style] = [ olstyle ];
for (var i=0; i<this.style[style].length; i++) {
if (olstyle instanceof Array) this.style[style] = olstyle;
else this.style[style] = [ olstyle ];
for (var i=0; i<this.style[style].length; i++) {
var im = this.style[style][i].getImage();
if (im) {
if (im) {
if (style == 'rotate') im.getAnchor()[0] = -5;
if (this.isTouch) im.setScale(1.8);
}
var tx = this.style[style][i].getText();
if (tx) {
if (this.isTouch) im.setScale(1.8);
}
var tx = this.style[style][i].getText();
if (tx) {
if (style == 'rotate') tx.setOffsetX(this.isTouch ? 14 : 7);
if (this.isTouch) tx.setScale(1.8);
}
}
this.drawSketch_();
if (this.isTouch) tx.setScale(1.8);
}
}
this.drawSketch_();
};

@@ -205,35 +206,35 @@ /** Get Feature at pixel

ol.interaction.Transform.prototype.getFeatureAtPixel_ = function(pixel) {
var self = this;
return this.getMap().forEachFeatureAtPixel(pixel,
function(feature, layer) {
var self = this;
return this.getMap().forEachFeatureAtPixel(pixel,
function(feature, layer) {
var found = false;
// Overlay ?
if (!layer) {
// Overlay ?
if (!layer) {
if (feature===self.bbox_) return false;
self.handles_.forEach (function(f) { if (f===feature) found=true; });
if (found) return { feature: feature, handle:feature.get('handle'), constraint:feature.get('constraint'), option:feature.get('option') };
}
// filter condition
if (self._filter) {
if (self._filter(feature,layer)) return { feature: feature };
else return null;
}
// feature belong to a layer
else if (self.layers_) {
self.handles_.forEach (function(f) { if (f===feature) found=true; });
if (found) return { feature: feature, handle:feature.get('handle'), constraint:feature.get('constraint'), option:feature.get('option') };
}
// filter condition
if (self._filter) {
if (self._filter(feature,layer)) return { feature: feature };
else return null;
}
// feature belong to a layer
else if (self.layers_) {
for (var i=0; i<self.layers_.length; i++) {
if (self.layers_[i]===layer) return { feature: feature };
}
return null;
}
// feature in the collection
else if (self.features_) {
}
return null;
}
// feature in the collection
else if (self.features_) {
self.features_.forEach (function(f) { if (f===feature) found=true; });
if (found) return { feature: feature };
else return null;
}
// Others
else return { feature: feature };
},
{ hitTolerance: this.get('hitTolerance') }
) || {};
if (found) return { feature: feature };
else return null;
}
// Others
else return { feature: feature };
},
{ hitTolerance: this.get('hitTolerance') }
) || {};
}

@@ -244,4 +245,4 @@ /** Draw transform sketch

ol.interaction.Transform.prototype.drawSketch_ = function(center) {
this.overlayLayer_.getSource().clear();
if (!this.selection_.length) return;
this.overlayLayer_.getSource().clear();
if (!this.selection_.length) return;
var ext = this.selection_[0].getGeometry().getExtent();

@@ -256,45 +257,45 @@ // Clone and extend

this.overlayLayer_.getSource().addFeature(new ol.Feature( { geometry: new ol.geom.Point(this.center_), handle:'rotate0' }) );
var geom = ol.geom.Polygon.fromExtent(ext);
var f = this.bbox_ = new ol.Feature(geom);
this.overlayLayer_.getSource().addFeature (f);
}
}
else {
if (this.ispt_) {
var geom = ol.geom.Polygon.fromExtent(ext);
var f = this.bbox_ = new ol.Feature(geom);
this.overlayLayer_.getSource().addFeature (f);
}
}
else {
if (this.ispt_) {
var p = this.getMap().getPixelFromCoordinate([ext[0], ext[1]]);
ext = ol.extent.boundingExtent([
ext = ol.extent.boundingExtent([
this.getMap().getCoordinateFromPixel([p[0]-10, p[1]-10]),
this.getMap().getCoordinateFromPixel([p[0]+10, p[1]+10])
]);
}
var geom = ol.geom.Polygon.fromExtent(ext);
var f = this.bbox_ = new ol.Feature(geom);
var features = [];
var g = geom.getCoordinates()[0];
if (!this.ispt_) {
}
var geom = ol.geom.Polygon.fromExtent(ext);
var f = this.bbox_ = new ol.Feature(geom);
var features = [];
var g = geom.getCoordinates()[0];
if (!this.ispt_) {
features.push(f);
// Middle
if (this.get('stretch') && this.get('scale')) for (var i=0; i<g.length-1; i++) {
// Middle
if (this.get('stretch') && this.get('scale')) for (var i=0; i<g.length-1; i++) {
f = new ol.Feature( { geometry: new ol.geom.Point([(g[i][0]+g[i+1][0])/2,(g[i][1]+g[i+1][1])/2]), handle:'scale', constraint:i%2?"h":"v", option:i });
features.push(f);
}
// Handles
if (this.get('scale')) for (var i=0; i<g.length-1; i++) {
features.push(f);
}
// Handles
if (this.get('scale')) for (var i=0; i<g.length-1; i++) {
f = new ol.Feature( { geometry: new ol.geom.Point(g[i]), handle:'scale', option:i });
features.push(f);
}
// Center
if (this.get('translate') && !this.get('translateFeature')) {
features.push(f);
}
// Center
if (this.get('translate') && !this.get('translateFeature')) {
f = new ol.Feature( { geometry: new ol.geom.Point([(g[0][0]+g[2][0])/2, (g[0][1]+g[2][1])/2]), handle:'translate' });
features.push(f);
}
}
// Rotate
if (this.get('rotate')) {
features.push(f);
}
}
// Rotate
if (this.get('rotate')) {
f = new ol.Feature( { geometry: new ol.geom.Point(g[3]), handle:'rotate' });
features.push(f);
}
// Add sketch
this.overlayLayer_.getSource().addFeatures(features);
}
features.push(f);
}
// Add sketch
this.overlayLayer_.getSource().addFeatures(features);
}
};

@@ -306,13 +307,13 @@ /** Select a feature to transform

ol.interaction.Transform.prototype.select = function(feature, add) {
if (!feature) {
this.selection_ = [];
return;
}
if (!feature.getGeometry || !feature.getGeometry()) return;
// Add to selection
if (add) this.selection_.push(feature);
else this.selection_ = [feature];
this.ispt_ = (this.selection_.length===1 ? (this.selection_[0].getGeometry().getType() == "Point") : false);
this.drawSketch_();
this.dispatchEvent({ type:'select', feature: feature, features: this.selection_ });
if (!feature) {
this.selection_ = [];
return;
}
if (!feature.getGeometry || !feature.getGeometry()) return;
// Add to selection
if (add) this.selection_.push(feature);
else this.selection_ = [feature];
this.ispt_ = (this.selection_.length===1 ? (this.selection_[0].getGeometry().getType() == "Point") : false);
this.drawSketch_();
this.dispatchEvent({ type:'select', feature: feature, features: this.selection_ });
}

@@ -324,44 +325,44 @@ /**

ol.interaction.Transform.prototype.handleDownEvent_ = function(evt) {
var sel = this.getFeatureAtPixel_(evt.pixel);
var feature = sel.feature;
if (this.selection_.length
&& this.selection_.indexOf(feature) >=0
&& ((this.ispt_ && this.get('translate')) || this.get('translateFeature'))
){
sel.handle = 'translate';
}
if (sel.handle) {
this.mode_ = sel.handle;
this.opt_ = sel.option;
this.constraint_ = sel.constraint;
// Save info
this.coordinate_ = evt.coordinate;
this.pixel_ = evt.pixel;
this.geoms_ = [];
var extent = ol.extent.createEmpty();
var sel = this.getFeatureAtPixel_(evt.pixel);
var feature = sel.feature;
if (this.selection_.length
&& this.selection_.indexOf(feature) >=0
&& ((this.ispt_ && this.get('translate')) || this.get('translateFeature'))
){
sel.handle = 'translate';
}
if (sel.handle) {
this.mode_ = sel.handle;
this.opt_ = sel.option;
this.constraint_ = sel.constraint;
// Save info
this.coordinate_ = evt.coordinate;
this.pixel_ = evt.pixel;
this.geoms_ = [];
var extent = ol.extent.createEmpty();
for (var i=0, f; f=this.selection_[i]; i++) {
this.geoms_.push(f.getGeometry().clone());
extent = ol.extent.extend(extent, f.getGeometry().getExtent());
this.geoms_.push(f.getGeometry().clone());
extent = ol.extent.extend(extent, f.getGeometry().getExtent());
}
this.extent_ = (ol.geom.Polygon.fromExtent(extent)).getCoordinates()[0];
if (this.mode_==='rotate') {
this.center_ = this.getCenter() || ol.extent.getCenter(extent);
// we are now rotating (cursor down on rotate mode), so apply the grabbing cursor
var element = evt.map.getTargetElement();
element.style.cursor = this.Cursors.rotate0;
this.previousCursor_ = element.style.cursor;
} else {
this.center_ = ol.extent.getCenter(extent);
}
this.angle_ = Math.atan2(this.center_[1]-evt.coordinate[1], this.center_[0]-evt.coordinate[0]);
this.dispatchEvent({
type: this.mode_+'start',
feature: this.selection_[0], // backward compatibility
features: this.selection_,
pixel: evt.pixel,
coordinate: evt.coordinate
});
return true;
}
else {
this.extent_ = (ol.geom.Polygon.fromExtent(extent)).getCoordinates()[0];
if (this.mode_==='rotate') {
this.center_ = this.getCenter() || ol.extent.getCenter(extent);
// we are now rotating (cursor down on rotate mode), so apply the grabbing cursor
var element = evt.map.getTargetElement();
element.style.cursor = this.Cursors.rotate0;
this.previousCursor_ = element.style.cursor;
} else {
this.center_ = ol.extent.getCenter(extent);
}
this.angle_ = Math.atan2(this.center_[1]-evt.coordinate[1], this.center_[0]-evt.coordinate[0]);
this.dispatchEvent({
type: this.mode_+'start',
feature: this.selection_[0], // backward compatibility
features: this.selection_,
pixel: evt.pixel,
coordinate: evt.coordinate
});
return true;
}
else {
if (feature){

@@ -375,7 +376,7 @@ if (!this.addFn_(evt)) this.selection_ = [];

}
this.ispt_ = this.selection_.length===1 ? (this.selection_[0].getGeometry().getType() == "Point") : false;
this.drawSketch_();
this.dispatchEvent({ type:'select', feature: feature, features: this.selection_, pixel: evt.pixel, coordinate: evt.coordinate });
return false;
}
this.ispt_ = this.selection_.length===1 ? (this.selection_[0].getGeometry().getType() == "Point") : false;
this.drawSketch_();
this.dispatchEvent({ type:'select', feature: feature, features: this.selection_, pixel: evt.pixel, coordinate: evt.coordinate });
return false;
}
};

@@ -387,3 +388,3 @@ /**

ol.interaction.Transform.prototype.getFeatures = function() {
return this.selection_;
return this.selection_;
};

@@ -395,3 +396,3 @@ /**

ol.interaction.Transform.prototype.getCenter = function() {
return this.get('center');
return this.get('center');
};

@@ -403,3 +404,3 @@ /**

ol.interaction.Transform.prototype.setCenter = function(c) {
return this.set('center', c);
return this.set('center', c);
}

@@ -410,29 +411,29 @@ /**

ol.interaction.Transform.prototype.handleDragEvent_ = function(evt) {
switch (this.mode_) {
case 'rotate': {
var a = Math.atan2(this.center_[1]-evt.coordinate[1], this.center_[0]-evt.coordinate[0]);
if (!this.ispt) {
// var geometry = this.geom_.clone();
// geometry.rotate(a-this.angle_, this.center_);
// this.feature_.setGeometry(geometry);
for (var i=0, f; f=this.selection_[i]; i++) {
var geometry = this.geoms_[i].clone();
geometry.rotate(a - this.angle_, this.center_);
f.setGeometry(geometry);
}
}
this.drawSketch_(true);
this.dispatchEvent({
type:'rotating',
feature: this.selection_[0],
features: this.selection_,
angle: a-this.angle_,
pixel: evt.pixel,
coordinate: evt.coordinate
});
break;
}
case 'translate': {
var deltaX = evt.coordinate[0] - this.coordinate_[0];
var deltaY = evt.coordinate[1] - this.coordinate_[1];
switch (this.mode_) {
case 'rotate': {
var a = Math.atan2(this.center_[1]-evt.coordinate[1], this.center_[0]-evt.coordinate[0]);
if (!this.ispt) {
// var geometry = this.geom_.clone();
// geometry.rotate(a-this.angle_, this.center_);
// this.feature_.setGeometry(geometry);
for (var i=0, f; f=this.selection_[i]; i++) {
var geometry = this.geoms_[i].clone();
geometry.rotate(a - this.angle_, this.center_);
f.setGeometry(geometry);
}
}
this.drawSketch_(true);
this.dispatchEvent({
type:'rotating',
feature: this.selection_[0],
features: this.selection_,
angle: a-this.angle_,
pixel: evt.pixel,
coordinate: evt.coordinate
});
break;
}
case 'translate': {
var deltaX = evt.coordinate[0] - this.coordinate_[0];
var deltaY = evt.coordinate[1] - this.coordinate_[1];
//this.feature_.getGeometry().translate(deltaX, deltaY);

@@ -442,31 +443,31 @@ for (var i=0, f; f=this.selection_[i]; i++) {

}
this.handles_.forEach(function(f) {
f.getGeometry().translate(deltaX, deltaY);
});
this.coordinate_ = evt.coordinate;
this.dispatchEvent({
type:'translating',
feature: this.selection_[0],
features: this.selection_,
delta:[deltaX,deltaY],
pixel: evt.pixel,
coordinate: evt.coordinate
});
break;
}
case 'scale': {
var center = this.center_;
if (this.get('modifyCenter')(evt)) {
center = this.extent_[(Number(this.opt_)+2)%4];
}
var scx = (evt.coordinate[0] - center[0]) / (this.coordinate_[0] - center[0]);
var scy = (evt.coordinate[1] - center[1]) / (this.coordinate_[1] - center[1]);
if (this.constraint_) {
if (this.constraint_=="h") scx=1;
else scy=1;
} else {
if (this.get('keepAspectRatio')(evt)) {
scx = scy = Math.min(scx,scy);
}
}
this.handles_.forEach(function(f) {
f.getGeometry().translate(deltaX, deltaY);
});
this.coordinate_ = evt.coordinate;
this.dispatchEvent({
type:'translating',
feature: this.selection_[0],
features: this.selection_,
delta:[deltaX,deltaY],
pixel: evt.pixel,
coordinate: evt.coordinate
});
break;
}
case 'scale': {
var center = this.center_;
if (this.get('modifyCenter')(evt)) {
center = this.extent_[(Number(this.opt_)+2)%4];
}
var scx = (evt.coordinate[0] - center[0]) / (this.coordinate_[0] - center[0]);
var scy = (evt.coordinate[1] - center[1]) / (this.coordinate_[1] - center[1]);
if (this.constraint_) {
if (this.constraint_=="h") scx=1;
else scy=1;
} else {
if (this.get('keepAspectRatio')(evt)) {
scx = scy = Math.min(scx,scy);
}
}
for (var i=0, f; f=this.selection_[i]; i++) {

@@ -484,14 +485,14 @@ var geometry = this.geoms_[i].clone();

}
this.drawSketch_();
this.dispatchEvent({
type:'scaling',
feature: this.selection_[0],
features: this.selection_,
scale:[scx,scy],
pixel: evt.pixel,
coordinate: evt.coordinate
});
}
default: break;
}
this.drawSketch_();
this.dispatchEvent({
type:'scaling',
feature: this.selection_[0],
features: this.selection_,
scale:[scx,scy],
pixel: evt.pixel,
coordinate: evt.coordinate
});
}
default: break;
}
};

@@ -502,19 +503,19 @@ /**

ol.interaction.Transform.prototype.handleMoveEvent_ = function(evt) {
// console.log("handleMoveEvent");
if (!this.mode_)
{ var map = evt.map;
var sel = this.getFeatureAtPixel_(evt.pixel);
var element = evt.map.getTargetElement();
if (sel.feature)
{ var c = sel.handle ? this.Cursors[(sel.handle||'default')+(sel.constraint||'')+(sel.option||'')] : this.Cursors.select;
if (this.previousCursor_===undefined)
{ this.previousCursor_ = element.style.cursor;
}
element.style.cursor = c;
}
else
{ if (this.previousCursor_!==undefined) element.style.cursor = this.previousCursor_;
this.previousCursor_ = undefined;
}
}
// console.log("handleMoveEvent");
if (!this.mode_)
{ var map = evt.map;
var sel = this.getFeatureAtPixel_(evt.pixel);
var element = evt.map.getTargetElement();
if (sel.feature)
{ var c = sel.handle ? this.Cursors[(sel.handle||'default')+(sel.constraint||'')+(sel.option||'')] : this.Cursors.select;
if (this.previousCursor_===undefined)
{ this.previousCursor_ = element.style.cursor;
}
element.style.cursor = c;
}
else
{ if (this.previousCursor_!==undefined) element.style.cursor = this.previousCursor_;
this.previousCursor_ = undefined;
}
}
};

@@ -533,12 +534,12 @@ /**

//dispatchEvent
this.dispatchEvent({
type:this.mode_+'end',
feature: this.selection_[0],
features: this.selection_,
oldgeom: this.geoms_[0],
oldgeoms: this.geoms_
});
this.drawSketch_();
this.mode_ = null;
return false;
this.dispatchEvent({
type:this.mode_+'end',
feature: this.selection_[0],
features: this.selection_,
oldgeom: this.geoms_[0],
oldgeoms: this.geoms_
});
this.drawSketch_();
this.mode_ = null;
return false;
};

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

*/
ol.layer.Layer.prototype.getPreview = function(lonlat, resolution)
ol.layer.Base.prototype.getPreview = function(lonlat, resolution)
{ if (this.get("preview")) return [ this.get("preview") ];

@@ -58,0 +58,0 @@ if (!resolution) resolution = 150;

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

// SPARQL request: for more info @see http://fr.dbpedia.org/
query = "PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> "
var query = "PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> "
+ "SELECT DISTINCT * WHERE { "

@@ -88,0 +88,0 @@ + "?subject geo:lat ?lat . "

{
"name": "openlayers-ext",
"version": "3.0.0",
"version": "3.0.1",
"description": "A set of cool extensions for OpenLayers (ol).",

@@ -5,0 +5,0 @@ "main": "index.js",

{
"name": "openlayers-ext",
"version": "3.0.0",
"version": "3.0.1",
"description": "A set of cool extensions for OpenLayers (ol).",

@@ -5,0 +5,0 @@ "main": "index.js",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc