Compare commits
8 Commits
main
...
v4.6.4-bac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af013db6d8 | ||
|
|
9b0cd2a7c8 | ||
|
|
f7a1aba38e | ||
|
|
6e9fc2cbad | ||
|
|
61245fb83a | ||
|
|
e065c851de | ||
|
|
ed29dde552 | ||
|
|
8a73db9331 |
@@ -1,5 +1,103 @@
|
||||
## Upgrade notes
|
||||
|
||||
### Next release
|
||||
|
||||
#### Changed behavior of the `Draw` interaction
|
||||
|
||||
For better drawing experience, two changes were made to the behavior of the Draw interaction:
|
||||
|
||||
1. On long press, the current vertex can be dragged to its desired position.
|
||||
2. On touch move (e.g. when panning the map on a mobile device), no draw cursor is shown, and the geometry being drawn is not updated. But because of 1., the draw cursor will appear on long press. Mouse moves are not affected by this change.
|
||||
|
||||
#### Changes in proj4 integration
|
||||
|
||||
Because relying on a globally available proj4 is not practical with ES modules, we have made a change to the way we integrate proj4:
|
||||
|
||||
* The `setProj4()` function from the `ol/proj` module was removed.
|
||||
* A new `ol/proj/proj4` module with a `register()` function was added. Regardless of whether the application imports `proj4` or uses a global `proj4`, this function needs to be called with the proj4 instance as argument whenever projection definitions were added to proj4's registry with (`proj4.defs`).
|
||||
|
||||
It is also recommended to no longer use a global `proj4`. Instead,
|
||||
|
||||
npm install proj4
|
||||
|
||||
and import it:
|
||||
|
||||
```js
|
||||
import proj4 from 'proj4';
|
||||
```
|
||||
|
||||
Applications can be updated by importing the `register` function from the `ol/proj/proj4` module
|
||||
|
||||
```js
|
||||
import {register} from 'ol/proj/proj4'
|
||||
```
|
||||
|
||||
and calling it before using projections, and any time the proj4 registry was changed by `proj4.defs()` calls:
|
||||
|
||||
```js
|
||||
register(proj4);
|
||||
```
|
||||
|
||||
#### Removal of logos
|
||||
|
||||
The map and sources no longer accept a `logo` option. Instead, if you wish to append a logo to your map, add the desired markup directly in your HTML. In addition, you can use the `attributions` property of a source to display arbitrary markup per-source with the attribution control.
|
||||
|
||||
#### Replacement of `ol/Sphere` constructor with `ol/sphere` functions
|
||||
|
||||
The `ol/Sphere` constructor has been removed. If you were using the `getGeodesicArea` method, use the `getArea` function instead. If you were using the `haversineDistance` method, use the `getDistance` function instead.
|
||||
|
||||
Examples before:
|
||||
```js
|
||||
// using ol@4
|
||||
import Sphere from 'ol/sphere';
|
||||
|
||||
var sphere = new Sphere(Sphere.DEFAULT_RADIUS);
|
||||
var area = sphere.getGeodesicArea(polygon);
|
||||
var distance = sphere.haversineDistance(g1, g2);
|
||||
```
|
||||
|
||||
Examples after:
|
||||
```js
|
||||
// using ol@5
|
||||
import {circular as circularPolygon} from 'ol/geom/Polygon';
|
||||
import {getArea, getDistance} from 'ol/sphere';
|
||||
|
||||
var area = getArea(polygon);
|
||||
var distance = getDistance(g1, g2);
|
||||
var circle = circularPolygon(center, radius);
|
||||
```
|
||||
|
||||
#### New signature for the `circular` function for creating polygons
|
||||
|
||||
The `circular` function exported from `ol/geom/Polygon` no longer requires a `Sphere` as the first argument.
|
||||
|
||||
Example before:
|
||||
```js
|
||||
// using ol@4
|
||||
import Polygon from 'ol/geom/polygon';
|
||||
import Sphere from 'ol/sphere';
|
||||
|
||||
var poly = Polygon.circular(new Sphere(Sphere.DEFAULT_RADIUS), center, radius);
|
||||
```
|
||||
|
||||
Example after:
|
||||
```js
|
||||
// using ol@5
|
||||
import {circular as circularPolygon} from 'ol/geom/Polygon';
|
||||
|
||||
var poly = circularPolygon(center, radius);
|
||||
```
|
||||
|
||||
#### Removal of optional this arguments.
|
||||
|
||||
The following methods did get the optional this (i.e. opt_this) arguments removed. Please use closures, the es6 arrow function or the bind method to achieve this effect (Bind is explained here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
|
||||
|
||||
* Collection#forEach
|
||||
* geom/LineString#forEachSegment
|
||||
* Observable#on, #once, #un
|
||||
* source/TileUTFGrid#forDataAtCoordinateAndResolution
|
||||
* source/Vector#forEachFeature, #forEachFeatureInExtent, #forEachFeatureIntersectingExtent
|
||||
|
||||
### v4.6.0
|
||||
|
||||
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow`
|
||||
|
||||
261
dist/ol-debug.css
vendored
Normal file
261
dist/ol-debug.css
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
.ol-box {
|
||||
box-sizing: border-box;
|
||||
border-radius: 2px;
|
||||
border: 2px solid blue;
|
||||
}
|
||||
|
||||
.ol-mouse-position {
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.ol-scale-line {
|
||||
background: rgba(0,60,136,0.3);
|
||||
border-radius: 4px;
|
||||
bottom: 8px;
|
||||
left: 8px;
|
||||
padding: 2px;
|
||||
position: absolute;
|
||||
}
|
||||
.ol-scale-line-inner {
|
||||
border: 1px solid #eee;
|
||||
border-top: none;
|
||||
color: #eee;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
margin: 1px;
|
||||
will-change: contents, width;
|
||||
}
|
||||
.ol-overlay-container {
|
||||
will-change: left,right,top,bottom;
|
||||
}
|
||||
|
||||
.ol-unsupported {
|
||||
display: none;
|
||||
}
|
||||
.ol-viewport, .ol-unselectable {
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
}
|
||||
.ol-selectable {
|
||||
-webkit-touch-callout: default;
|
||||
-webkit-user-select: auto;
|
||||
-moz-user-select: auto;
|
||||
-ms-user-select: auto;
|
||||
user-select: auto;
|
||||
}
|
||||
.ol-grabbing {
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
.ol-grab {
|
||||
cursor: move;
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
.ol-control {
|
||||
position: absolute;
|
||||
background-color: rgba(255,255,255,0.4);
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
}
|
||||
.ol-control:hover {
|
||||
background-color: rgba(255,255,255,0.6);
|
||||
}
|
||||
.ol-zoom {
|
||||
top: .5em;
|
||||
left: .5em;
|
||||
}
|
||||
.ol-rotate {
|
||||
top: .5em;
|
||||
right: .5em;
|
||||
transition: opacity .25s linear, visibility 0s linear;
|
||||
}
|
||||
.ol-rotate.ol-hidden {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity .25s linear, visibility 0s linear .25s;
|
||||
}
|
||||
.ol-zoom-extent {
|
||||
top: 4.643em;
|
||||
left: .5em;
|
||||
}
|
||||
.ol-full-screen {
|
||||
right: .5em;
|
||||
top: .5em;
|
||||
}
|
||||
@media print {
|
||||
.ol-control {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.ol-control button {
|
||||
display: block;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
color: white;
|
||||
font-size: 1.14em;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
height: 1.375em;
|
||||
width: 1.375em;
|
||||
line-height: .4em;
|
||||
background-color: rgba(0,60,136,0.5);
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.ol-control button::-moz-focus-inner {
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
.ol-zoom-extent button {
|
||||
line-height: 1.4em;
|
||||
}
|
||||
.ol-compass {
|
||||
display: block;
|
||||
font-weight: normal;
|
||||
font-size: 1.2em;
|
||||
will-change: transform;
|
||||
}
|
||||
.ol-touch .ol-control button {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.ol-touch .ol-zoom-extent {
|
||||
top: 5.5em;
|
||||
}
|
||||
.ol-control button:hover,
|
||||
.ol-control button:focus {
|
||||
text-decoration: none;
|
||||
background-color: rgba(0,60,136,0.7);
|
||||
}
|
||||
.ol-zoom .ol-zoom-in {
|
||||
border-radius: 2px 2px 0 0;
|
||||
}
|
||||
.ol-zoom .ol-zoom-out {
|
||||
border-radius: 0 0 2px 2px;
|
||||
}
|
||||
|
||||
|
||||
.ol-attribution {
|
||||
text-align: right;
|
||||
bottom: .5em;
|
||||
right: .5em;
|
||||
max-width: calc(100% - 1.3em);
|
||||
}
|
||||
|
||||
.ol-attribution ul {
|
||||
margin: 0;
|
||||
padding: 0 .5em;
|
||||
font-size: .7rem;
|
||||
line-height: 1.375em;
|
||||
color: #000;
|
||||
text-shadow: 0 0 2px #fff;
|
||||
}
|
||||
.ol-attribution li {
|
||||
display: inline;
|
||||
list-style: none;
|
||||
line-height: inherit;
|
||||
}
|
||||
.ol-attribution li:not(:last-child):after {
|
||||
content: " ";
|
||||
}
|
||||
.ol-attribution img {
|
||||
max-height: 2em;
|
||||
max-width: inherit;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.ol-attribution ul, .ol-attribution button {
|
||||
display: inline-block;
|
||||
}
|
||||
.ol-attribution.ol-collapsed ul {
|
||||
display: none;
|
||||
}
|
||||
.ol-attribution.ol-logo-only ul {
|
||||
display: block;
|
||||
}
|
||||
.ol-attribution:not(.ol-collapsed) {
|
||||
background: rgba(255,255,255,0.8);
|
||||
}
|
||||
.ol-attribution.ol-uncollapsible {
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
border-radius: 4px 0 0;
|
||||
height: 1.1em;
|
||||
line-height: 1em;
|
||||
}
|
||||
.ol-attribution.ol-logo-only {
|
||||
background: transparent;
|
||||
bottom: .4em;
|
||||
height: 1.1em;
|
||||
line-height: 1em;
|
||||
}
|
||||
.ol-attribution.ol-uncollapsible img {
|
||||
margin-top: -.2em;
|
||||
max-height: 1.6em;
|
||||
}
|
||||
.ol-attribution.ol-logo-only button,
|
||||
.ol-attribution.ol-uncollapsible button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ol-zoomslider {
|
||||
top: 4.5em;
|
||||
left: .5em;
|
||||
height: 200px;
|
||||
}
|
||||
.ol-zoomslider button {
|
||||
position: relative;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
.ol-touch .ol-zoomslider {
|
||||
top: 5.5em;
|
||||
}
|
||||
|
||||
.ol-overviewmap {
|
||||
left: 0.5em;
|
||||
bottom: 0.5em;
|
||||
}
|
||||
.ol-overviewmap.ol-uncollapsible {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
border-radius: 0 4px 0 0;
|
||||
}
|
||||
.ol-overviewmap .ol-overviewmap-map,
|
||||
.ol-overviewmap button {
|
||||
display: inline-block;
|
||||
}
|
||||
.ol-overviewmap .ol-overviewmap-map {
|
||||
border: 1px solid #7b98bc;
|
||||
height: 150px;
|
||||
margin: 2px;
|
||||
width: 150px;
|
||||
}
|
||||
.ol-overviewmap:not(.ol-collapsed) button{
|
||||
bottom: 1px;
|
||||
left: 2px;
|
||||
position: absolute;
|
||||
}
|
||||
.ol-overviewmap.ol-collapsed .ol-overviewmap-map,
|
||||
.ol-overviewmap.ol-uncollapsible button {
|
||||
display: none;
|
||||
}
|
||||
.ol-overviewmap:not(.ol-collapsed) {
|
||||
background: rgba(255,255,255,0.8);
|
||||
}
|
||||
.ol-overviewmap-box {
|
||||
border: 2px dotted rgba(0,60,136,0.7);
|
||||
}
|
||||
|
||||
.ol-overviewmap .ol-overviewmap-box:hover {
|
||||
cursor: move;
|
||||
}
|
||||
96548
dist/ol-debug.js
vendored
Normal file
96548
dist/ol-debug.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/ol.css
vendored
Normal file
1
dist/ol.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.ol-box{box-sizing:border-box;border-radius:2px;border:2px solid #00f}.ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;will-change:contents,width}.ol-overlay-container{will-change:left,right,top,bottom}.ol-unsupported{display:none}.ol-unselectable,.ol-viewport{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.ol-control{position:absolute;background-color:rgba(255,255,255,.4);border-radius:4px;padding:2px}.ol-control:hover{background-color:rgba(255,255,255,.6)}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}@media print{.ol-control{display:none}}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:rgba(0,60,136,.5);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;font-size:1.2em;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:focus,.ol-control button:hover{text-decoration:none;background-color:rgba(0,60,136,.7)}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em)}.ol-attribution ul{margin:0;padding:0 .5em;font-size:.7rem;line-height:1.375em;color:#000;text-shadow:0 0 2px #fff}.ol-attribution li{display:inline;list-style:none;line-height:inherit}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button,.ol-attribution ul{display:inline-block}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution.ol-logo-only ul{display:block}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0;height:1.1em;line-height:1em}.ol-attribution.ol-logo-only{background:0 0;bottom:.4em;height:1.1em;line-height:1em}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-logo-only button,.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{top:4.5em;left:.5em;height:200px}.ol-zoomslider button{position:relative;height:10px}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{left:.5em;bottom:.5em}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:inline-block}.ol-overviewmap .ol-overviewmap-map{border:1px solid #7b98bc;height:150px;margin:2px;width:150px}.ol-overviewmap:not(.ol-collapsed) button{bottom:1px;left:2px;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-overviewmap-box{border:2px dotted rgba(0,60,136,.7)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}
|
||||
1075
dist/ol.js
vendored
Normal file
1075
dist/ol.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -3003,6 +3003,7 @@ olx.interaction.DragZoomOptions.prototype.out;
|
||||
* @typedef {{clickTolerance: (number|undefined),
|
||||
* features: (ol.Collection.<ol.Feature>|undefined),
|
||||
* source: (ol.source.Vector|undefined),
|
||||
* dragVertexDelay: (number|undefined),
|
||||
* snapTolerance: (number|undefined),
|
||||
* type: (ol.geom.GeometryType|string),
|
||||
* stopClick: (boolean|undefined),
|
||||
@@ -3048,6 +3049,14 @@ olx.interaction.DrawOptions.prototype.features;
|
||||
olx.interaction.DrawOptions.prototype.source;
|
||||
|
||||
|
||||
/**
|
||||
* Delay in milliseconds after pointerdown before the current vertex can be
|
||||
* dragged to its exact position. Default is 500 ms.
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
olx.interaction.DrawOptions.prototype.dragVertexDelay;
|
||||
|
||||
|
||||
/**
|
||||
* Pixel distance for snapping to the drawing finish. Default is `12`.
|
||||
* @type {number|undefined}
|
||||
|
||||
@@ -13,6 +13,7 @@ ol.events.EventType = {
|
||||
CHANGE: 'change',
|
||||
|
||||
CLEAR: 'clear',
|
||||
CONTEXTMENU: 'contextmenu',
|
||||
CLICK: 'click',
|
||||
DBLCLICK: 'dblclick',
|
||||
DRAGENTER: 'dragenter',
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
goog.provide('ol.interaction.Draw');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.MapBrowserEventType');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.Object');
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.events');
|
||||
@@ -22,6 +24,7 @@ goog.require('ol.interaction.DrawEventType');
|
||||
goog.require('ol.interaction.Pointer');
|
||||
goog.require('ol.interaction.Property');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.MouseSource');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.Style');
|
||||
|
||||
@@ -56,6 +59,18 @@ ol.interaction.Draw = function(options) {
|
||||
*/
|
||||
this.downPx_ = null;
|
||||
|
||||
/**
|
||||
* @type {number|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.downTimeout_;
|
||||
|
||||
/**
|
||||
* @type {number|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.lastDragTime_;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
@@ -191,6 +206,12 @@ ol.interaction.Draw = function(options) {
|
||||
*/
|
||||
this.geometryFunction_ = geometryFunction;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.dragVertexDelay_ = options.dragVertexDelay !== undefined ? options.dragVertexDelay : 500;
|
||||
|
||||
/**
|
||||
* Finish coordinate for the feature (first point for polygons, last point for
|
||||
* linestrings).
|
||||
@@ -255,7 +276,8 @@ ol.interaction.Draw = function(options) {
|
||||
wrapX: options.wrapX ? options.wrapX : false
|
||||
}),
|
||||
style: options.style ? options.style :
|
||||
ol.interaction.Draw.getDefaultStyleFunction()
|
||||
ol.interaction.Draw.getDefaultStyleFunction(),
|
||||
updateWhileInteracting: true
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -321,8 +343,27 @@ ol.interaction.Draw.prototype.setMap = function(map) {
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Draw.handleEvent = function(event) {
|
||||
if (event.originalEvent.type === ol.events.EventType.CONTEXTMENU) {
|
||||
// Avoid context menu for long taps when drawing on mobile
|
||||
event.preventDefault();
|
||||
}
|
||||
this.freehand_ = this.mode_ !== ol.interaction.Draw.Mode_.POINT && this.freehandCondition_(event);
|
||||
var pass = true;
|
||||
let move = event.type === ol.MapBrowserEventType.POINTERMOVE;
|
||||
let pass = true;
|
||||
if (this.lastDragTime_ && event.type === ol.MapBrowserEventType.POINTERDRAG) {
|
||||
const now = Date.now();
|
||||
if (now - this.lastDragTime_ >= this.dragVertexDelay_) {
|
||||
this.downPx_ = event.pixel;
|
||||
this.shouldHandle_ = !this.freehand_;
|
||||
move = true;
|
||||
} else {
|
||||
this.lastDragTime_ = undefined;
|
||||
}
|
||||
if (this.shouldHandle_ && this.downTimeout_) {
|
||||
clearTimeout(this.downTimeout_);
|
||||
this.downTimeout_ = undefined;
|
||||
}
|
||||
}
|
||||
if (this.freehand_ &&
|
||||
event.type === ol.MapBrowserEventType.POINTERDRAG &&
|
||||
this.sketchFeature_ !== null) {
|
||||
@@ -331,11 +372,18 @@ ol.interaction.Draw.handleEvent = function(event) {
|
||||
} else if (this.freehand_ &&
|
||||
event.type === ol.MapBrowserEventType.POINTERDOWN) {
|
||||
pass = false;
|
||||
} else if (event.type === ol.MapBrowserEventType.POINTERMOVE) {
|
||||
} else if (move) {
|
||||
pass = event.type === ol.MapBrowserEventType.POINTERMOVE;
|
||||
if (pass && this.freehand_) {
|
||||
pass = this.handlePointerMove_(event);
|
||||
} else if (event.pointerEvent.pointerType == ol.pointer.MouseSource.POINTER_TYPE ||
|
||||
(event.type === ol.MapBrowserEventType.POINTERDRAG && !this.downTimeout_)) {
|
||||
this.handlePointerMove_(event);
|
||||
}
|
||||
} else if (event.type === ol.MapBrowserEventType.DBLCLICK) {
|
||||
pass = false;
|
||||
}
|
||||
|
||||
return ol.interaction.Pointer.handleEvent.call(this, event) && pass;
|
||||
};
|
||||
|
||||
@@ -356,6 +404,11 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
|
||||
}
|
||||
return true;
|
||||
} else if (this.condition_(event)) {
|
||||
this.lastDragTime_ = Date.now();
|
||||
this.downTimeout_ = setTimeout(function() {
|
||||
this.handlePointerMove_(new ol.MapBrowserPointerEvent(
|
||||
ol.MapBrowserEventType.POINTERMOVE, event.map, event.pointerEvent, true, event.frameState));
|
||||
}.bind(this), this.dragVertexDelay_);
|
||||
this.downPx_ = event.pixel;
|
||||
return true;
|
||||
} else {
|
||||
@@ -373,6 +426,11 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
|
||||
ol.interaction.Draw.handleUpEvent_ = function(event) {
|
||||
var pass = true;
|
||||
|
||||
if (this.downTimeout_) {
|
||||
clearTimeout(this.downTimeout_);
|
||||
this.downTimeout_ = undefined;
|
||||
}
|
||||
|
||||
this.handlePointerMove_(event);
|
||||
|
||||
var circleMode = this.mode_ === ol.interaction.Draw.Mode_.CIRCLE;
|
||||
@@ -422,6 +480,9 @@ ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
|
||||
this.shouldHandle_ = this.freehand_ ?
|
||||
squaredDistance > this.squaredClickTolerance_ :
|
||||
squaredDistance <= this.squaredClickTolerance_;
|
||||
if (!this.shouldHandle_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.finishCoordinate_) {
|
||||
@@ -504,9 +565,6 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
|
||||
this.sketchLineCoords_ = this.sketchCoords_[0];
|
||||
} else {
|
||||
this.sketchCoords_ = [start.slice(), start.slice()];
|
||||
if (this.mode_ === ol.interaction.Draw.Mode_.CIRCLE) {
|
||||
this.sketchLineCoords_ = this.sketchCoords_;
|
||||
}
|
||||
}
|
||||
if (this.sketchLineCoords_) {
|
||||
this.sketchLine_ = new ol.Feature(
|
||||
|
||||
@@ -205,6 +205,8 @@ ol.PluggableMap = function(options) {
|
||||
*/
|
||||
this.keyHandlerKeys_ = null;
|
||||
|
||||
ol.events.listen(this.viewport_, ol.events.EventType.CONTEXTMENU,
|
||||
this.handleBrowserEvent, this);
|
||||
ol.events.listen(this.viewport_, ol.events.EventType.WHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
ol.events.listen(this.viewport_, ol.events.EventType.MOUSEWHEEL,
|
||||
@@ -428,6 +430,8 @@ ol.PluggableMap.prototype.addOverlayInternal_ = function(overlay) {
|
||||
*/
|
||||
ol.PluggableMap.prototype.disposeInternal = function() {
|
||||
this.mapBrowserEventHandler_.dispose();
|
||||
ol.events.unlisten(this.viewport_, ol.events.EventType.CONTEXTMENU,
|
||||
this.handleBrowserEvent, this);
|
||||
ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL,
|
||||
|
||||
@@ -215,7 +215,7 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function(geometr
|
||||
var state = this.state;
|
||||
var fillStyle = state.fillStyle;
|
||||
if (fillStyle !== undefined) {
|
||||
this.updateFillStyle(state, this.applyFill, geometry);
|
||||
this.updateFillStyle(state, this.createFill, geometry);
|
||||
}
|
||||
if (state.strokeStyle !== undefined) {
|
||||
this.updateStrokeStyle(state, this.applyStroke);
|
||||
|
||||
@@ -270,7 +270,16 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image,
|
||||
ol.extent.createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box);
|
||||
}
|
||||
var canvas = context.canvas;
|
||||
var intersects = box[0] <= canvas.width && box[2] >= 0 && box[1] <= canvas.height && box[3] >= 0;
|
||||
var strokePadding = strokeInstruction ? (/** @type {number} */ (strokeInstruction[2]) * scale / 2) : 0;
|
||||
var intersects =
|
||||
box[0] - strokePadding <= canvas.width && box[2] + strokePadding >= 0 &&
|
||||
box[1] - strokePadding <= canvas.height && box[3] + strokePadding >= 0;
|
||||
|
||||
if (snapToPixel) {
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
}
|
||||
|
||||
if (declutterGroup) {
|
||||
if (!intersects && declutterGroup[4] == 1) {
|
||||
return;
|
||||
@@ -956,15 +965,16 @@ ol.render.canvas.Replay.prototype.setFillStrokeStyle = function(fillStyle, strok
|
||||
/**
|
||||
* @param {ol.CanvasFillStrokeState} state State.
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
* @return {Array.<*>} Fill instruction.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
|
||||
ol.render.canvas.Replay.prototype.createFill = function(state, geometry) {
|
||||
var fillStyle = state.fillStyle;
|
||||
var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle];
|
||||
if (typeof fillStyle !== 'string') {
|
||||
var fillExtent = geometry.getExtent();
|
||||
fillInstruction.push([fillExtent[0], fillExtent[3]]);
|
||||
}
|
||||
this.instructions.push(fillInstruction);
|
||||
return fillInstruction;
|
||||
};
|
||||
|
||||
|
||||
@@ -972,24 +982,35 @@ ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
|
||||
* @param {ol.CanvasFillStrokeState} state State.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.applyStroke = function(state) {
|
||||
this.instructions.push([
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth * this.pixelRatio, state.lineCap,
|
||||
state.lineJoin, state.miterLimit,
|
||||
this.applyPixelRatio(state.lineDash), state.lineDashOffset * this.pixelRatio
|
||||
]);
|
||||
this.instructions.push(this.createStroke(state));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.CanvasFillStrokeState} state State.
|
||||
* @param {function(this:ol.render.canvas.Replay, ol.CanvasFillStrokeState, (ol.geom.Geometry|ol.render.Feature))} applyFill Apply fill.
|
||||
* @return {Array.<*>} Stroke instruction.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.createStroke = function(state) {
|
||||
return [
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth * this.pixelRatio, state.lineCap,
|
||||
state.lineJoin, state.miterLimit,
|
||||
this.applyPixelRatio(state.lineDash), state.lineDashOffset * this.pixelRatio
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.CanvasFillStrokeState} state State.
|
||||
* @param {function(this:ol.render.canvas.Replay, ol.CanvasFillStrokeState, (ol.geom.Geometry|ol.render.Feature)):Array.<*>} createFill Create fill.
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.updateFillStyle = function(state, applyFill, geometry) {
|
||||
ol.render.canvas.Replay.prototype.updateFillStyle = function(state, createFill, geometry) {
|
||||
var fillStyle = state.fillStyle;
|
||||
if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) {
|
||||
applyFill.call(this, state, geometry);
|
||||
if (fillStyle !== undefined) {
|
||||
this.instructions.push(createFill.call(this, state, geometry));
|
||||
}
|
||||
state.currentFillStyle = fillStyle;
|
||||
}
|
||||
};
|
||||
@@ -1014,7 +1035,9 @@ ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStrok
|
||||
state.currentLineJoin != lineJoin ||
|
||||
state.currentLineWidth != lineWidth ||
|
||||
state.currentMiterLimit != miterLimit) {
|
||||
if (strokeStyle !== undefined) {
|
||||
applyStroke.call(this, state);
|
||||
}
|
||||
state.currentStrokeStyle = strokeStyle;
|
||||
state.currentLineCap = lineCap;
|
||||
state.currentLineDash = lineDash;
|
||||
|
||||
@@ -263,8 +263,10 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
this.beginGeometry(geometry, feature);
|
||||
if (textState.backgroundFill || textState.backgroundStroke) {
|
||||
this.setFillStrokeStyle(textState.backgroundFill, textState.backgroundStroke);
|
||||
this.updateFillStyle(this.state, this.applyFill, geometry);
|
||||
this.updateFillStyle(this.state, this.createFill, geometry);
|
||||
this.hitDetectionInstructions.push(this.createFill(this.state, geometry));
|
||||
this.updateStrokeStyle(this.state, this.applyStroke);
|
||||
this.hitDetectionInstructions.push(this.createStroke(this.state));
|
||||
}
|
||||
this.drawTextImage_(label, begin, end);
|
||||
this.endGeometry(geometry, feature);
|
||||
|
||||
@@ -155,7 +155,9 @@ ol.style.Text.prototype.clone = function() {
|
||||
fill: this.getFill() ? this.getFill().clone() : undefined,
|
||||
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
|
||||
offsetX: this.getOffsetX(),
|
||||
offsetY: this.getOffsetY()
|
||||
offsetY: this.getOffsetY(),
|
||||
backgroundFill: this.getBackgroundFill() ? this.getBackgroundFill().clone() : undefined,
|
||||
backgroundStroke: this.getBackgroundStroke() ? this.getBackgroundStroke().clone() : undefined
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -352,6 +352,9 @@ describe('ol.rendering.style.Text', function() {
|
||||
}));
|
||||
features[2].getStyle().getText().setPadding([5, 10, 15, 0]);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
map.once('postrender', function() {
|
||||
expect(map.getFeaturesAtPixel([178, 120])).to.have.length(1);
|
||||
});
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-background.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
|
||||
|
||||
@@ -105,6 +105,15 @@ describe('ol.interaction.Draw', function() {
|
||||
expect(draw.freehandCondition_(event)).to.be(true);
|
||||
});
|
||||
|
||||
it('accepts a dragVertexDelay option', function() {
|
||||
const draw = new ol.interaction.Draw({
|
||||
source: source,
|
||||
type: 'LineString',
|
||||
dragVertexDelay: 42
|
||||
});
|
||||
expect(draw.dragVertexDelay_).to.be(42);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('specifying a geometryName', function() {
|
||||
@@ -341,7 +350,6 @@ describe('ol.interaction.Draw', function() {
|
||||
simulateEvent('pointermove', 20, 30);
|
||||
|
||||
// freehand
|
||||
simulateEvent('pointerdown', 20, 30, true);
|
||||
simulateEvent('pointermove', 20, 30, true);
|
||||
simulateEvent('pointerdrag', 20, 30, true);
|
||||
simulateEvent('pointermove', 30, 40, true);
|
||||
@@ -398,6 +406,38 @@ describe('ol.interaction.Draw', function() {
|
||||
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
|
||||
});
|
||||
|
||||
it('allows dragging of the vertex after dragVertexDelay', function(done) {
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
simulateEvent('pointerdown', 10, 20);
|
||||
simulateEvent('pointerup', 10, 20);
|
||||
|
||||
// second point, drag vertex
|
||||
simulateEvent('pointermove', 15, 20);
|
||||
simulateEvent('pointerdown', 15, 20);
|
||||
setTimeout(function() {
|
||||
simulateEvent('pointermove', 20, 10);
|
||||
simulateEvent('pointerdrag', 20, 10);
|
||||
simulateEvent('pointerup', 20, 10);
|
||||
// third point
|
||||
simulateEvent('pointermove', 30, 20);
|
||||
simulateEvent('pointerdown', 30, 20);
|
||||
simulateEvent('pointerup', 30, 20);
|
||||
|
||||
// finish on third point
|
||||
simulateEvent('pointerdown', 30, 20);
|
||||
simulateEvent('pointerup', 30, 20);
|
||||
|
||||
const features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
const geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry.getCoordinates()).to.eql([[10, -20], [20, -10], [30, -20]]);
|
||||
|
||||
done();
|
||||
}, 600);
|
||||
});
|
||||
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
|
||||
Reference in New Issue
Block a user