Compare commits

...

21 Commits

Author SHA1 Message Date
Andreas Hocevar
849ef07639 Add version and dist for v4.6.4-backports.2 2018-01-22 16:39:58 +01:00
Andreas Hocevar
3696237894 Merge pull request #7661 from ahocevar/background-fill-stroke
Background fill stroke
2018-01-22 16:03:42 +01:00
Andreas Hocevar
af013db6d8 Update backport dist 2018-01-18 12:09:42 +01:00
Andreas Hocevar
9b0cd2a7c8 Backport changes for #7703 2018-01-18 12:04:04 +01:00
Andreas Hocevar
f7a1aba38e Merge pull request #7703 from ahocevar/draw-state
Improved drawing experience on touch devices
2018-01-18 11:32:28 +01:00
Andreas Hocevar
6e9fc2cbad Backport changes for #7668 2018-01-18 11:15:26 +01:00
Andreas Hocevar
61245fb83a Merge pull request #7668 from ahocevar/hit-detect-text-background
Hit detect text background
2018-01-18 10:50:32 +01:00
Andreas Hocevar
e065c851de Add dist for backport 2017-12-28 12:31:11 +01:00
Andreas Hocevar
ed29dde552 Clone backgroundFill and backgroundStroke 2017-12-27 11:51:34 +01:00
Andreas Hocevar
8a73db9331 Apply fill and stroke only when set 2017-12-27 09:31:41 +01:00
Andreas Hocevar
72ca7b28c6 Update package version to 4.6.4 2017-12-11 11:31:38 +01:00
Andreas Hocevar
f11d55fde6 Changelog for v4.6.4 2017-12-11 11:29:50 +01:00
Andreas Hocevar
48217bc218 Handle skipping and unskipping features with renderMode: 'image' 2017-12-11 11:23:34 +01:00
Andreas Hocevar
c76c445e43 Update package version to 4.6.3 2017-12-08 11:17:36 +01:00
Andreas Hocevar
3bba8ef061 Changelog for v4.6.3 2017-12-08 11:16:52 +01:00
Andreas Hocevar
a699cc348b Fix pull request link 2017-12-08 11:14:24 +01:00
Andreas Hocevar
f010f7b9c1 Only compose image vector frame when the replay group has changed 2017-12-08 11:12:05 +01:00
Andreas Hocevar
5d27dcc27c Update package version to 4.6.2 2017-12-07 08:36:40 +01:00
Andreas Hocevar
52bbebf9aa Changelog for v4.6.2 2017-12-07 08:36:03 +01:00
Andreas Hocevar
578f900435 Revert "Merge pull request #7530 from raiyni/crossing-dateline"
This reverts commit fca0b0771d, reversing
changes made to c3db3e2f6f.
2017-12-07 08:33:19 +01:00
Andreas Hocevar
3bc1de3f6c Make sure we do not request features for wrapped extent 2017-12-07 08:33:09 +01:00
27 changed files with 98545 additions and 38 deletions

View File

@@ -1,5 +1,103 @@
## Upgrade notes ## 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 ### v4.6.0
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow` #### Renamed `exceedLength` option of `ol.style.Text` to `overflow`

7
changelog/v4.6.2.md Normal file
View File

@@ -0,0 +1,7 @@
# 4.6.2
The v4.6.2 release fixes a regression that could cause tremendous amounts of unneeded vector data to be fetched from the source.
## Fixes
* [#7546](https://github.com/openlayers/openlayers/pull/7546) - Do not request features for wrapped extent ([@ahocevar](https://github.com/ahocevar))

7
changelog/v4.6.3.md Normal file
View File

@@ -0,0 +1,7 @@
# 4.6.3
The v4.6.3 release fixes a performance issue when `renderMode: 'image'` is set on an `ol.layer.Vector`.
## Fixes
* [#7554](https://github.com/openlayers/openlayers/pull/7554) - Only compose image vector frame when the replay group has changed ([@ahocevar](https://github.com/ahocevar))

7
changelog/v4.6.4.md Normal file
View File

@@ -0,0 +1,7 @@
# 4.6.4
The v4.6.4 release fixes a feature selection issue when `renderMode: 'image'` is set on an `ol.layer.Vector`.
## Fixes
* [#7559](https://github.com/openlayers/openlayers/pull/7559) - Handle skipping and unskipping features with renderMode: 'image' ([@ahocevar](https://github.com/ahocevar))

261
dist/ol-debug.css vendored Normal file
View 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

File diff suppressed because one or more lines are too long

261
dist/ol.css vendored Normal file
View 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;
}

1075
dist/ol.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -3003,6 +3003,7 @@ olx.interaction.DragZoomOptions.prototype.out;
* @typedef {{clickTolerance: (number|undefined), * @typedef {{clickTolerance: (number|undefined),
* features: (ol.Collection.<ol.Feature>|undefined), * features: (ol.Collection.<ol.Feature>|undefined),
* source: (ol.source.Vector|undefined), * source: (ol.source.Vector|undefined),
* dragVertexDelay: (number|undefined),
* snapTolerance: (number|undefined), * snapTolerance: (number|undefined),
* type: (ol.geom.GeometryType|string), * type: (ol.geom.GeometryType|string),
* stopClick: (boolean|undefined), * stopClick: (boolean|undefined),
@@ -3048,6 +3049,14 @@ olx.interaction.DrawOptions.prototype.features;
olx.interaction.DrawOptions.prototype.source; 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`. * Pixel distance for snapping to the drawing finish. Default is `12`.
* @type {number|undefined} * @type {number|undefined}
@@ -8525,7 +8534,7 @@ olx.view.FitOptions.prototype.callback;
* pixelToCoordinateTransform: ol.Transform, * pixelToCoordinateTransform: ol.Transform,
* postRenderFunctions: Array.<ol.PostRenderFunction>, * postRenderFunctions: Array.<ol.PostRenderFunction>,
* size: ol.Size, * size: ol.Size,
* skippedFeatureUids: Object.<string, boolean>, * skippedFeatureUids: !Object.<string, boolean>,
* tileQueue: ol.TileQueue, * tileQueue: ol.TileQueue,
* time: number, * time: number,
* usedTiles: Object.<string, Object.<string, ol.TileRange>>, * usedTiles: Object.<string, Object.<string, ol.TileRange>>,

View File

@@ -1,6 +1,6 @@
{ {
"name": "openlayers", "name": "openlayers",
"version": "4.6.1", "version": "4.6.4-backports.2",
"description": "Build tools and sources for developing OpenLayers based mapping applications", "description": "Build tools and sources for developing OpenLayers based mapping applications",
"keywords": [ "keywords": [
"map", "map",

View File

@@ -1,6 +1,6 @@
{ {
"name": "ol", "name": "ol",
"version": "4.6.1", "version": "4.6.4",
"description": "OpenLayers as ES2015 modules", "description": "OpenLayers as ES2015 modules",
"main": "index.js", "main": "index.js",
"module": "index.js", "module": "index.js",

View File

@@ -13,6 +13,7 @@ ol.events.EventType = {
CHANGE: 'change', CHANGE: 'change',
CLEAR: 'clear', CLEAR: 'clear',
CONTEXTMENU: 'contextmenu',
CLICK: 'click', CLICK: 'click',
DBLCLICK: 'dblclick', DBLCLICK: 'dblclick',
DRAGENTER: 'dragenter', DRAGENTER: 'dragenter',

View File

@@ -1,8 +1,10 @@
goog.provide('ol.interaction.Draw'); goog.provide('ol.interaction.Draw');
goog.require('ol'); goog.require('ol');
goog.require('ol.events.EventType');
goog.require('ol.Feature'); goog.require('ol.Feature');
goog.require('ol.MapBrowserEventType'); goog.require('ol.MapBrowserEventType');
goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.events'); goog.require('ol.events');
@@ -22,6 +24,7 @@ goog.require('ol.interaction.DrawEventType');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
goog.require('ol.interaction.Property'); goog.require('ol.interaction.Property');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.pointer.MouseSource');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
goog.require('ol.style.Style'); goog.require('ol.style.Style');
@@ -56,6 +59,18 @@ ol.interaction.Draw = function(options) {
*/ */
this.downPx_ = null; this.downPx_ = null;
/**
* @type {number|undefined}
* @private
*/
this.downTimeout_;
/**
* @type {number|undefined}
* @private
*/
this.lastDragTime_;
/** /**
* @type {boolean} * @type {boolean}
* @private * @private
@@ -191,6 +206,12 @@ ol.interaction.Draw = function(options) {
*/ */
this.geometryFunction_ = geometryFunction; 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 * Finish coordinate for the feature (first point for polygons, last point for
* linestrings). * linestrings).
@@ -255,7 +276,8 @@ ol.interaction.Draw = function(options) {
wrapX: options.wrapX ? options.wrapX : false wrapX: options.wrapX ? options.wrapX : false
}), }),
style: options.style ? options.style : 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 * @api
*/ */
ol.interaction.Draw.handleEvent = function(event) { 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); 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_ && if (this.freehand_ &&
event.type === ol.MapBrowserEventType.POINTERDRAG && event.type === ol.MapBrowserEventType.POINTERDRAG &&
this.sketchFeature_ !== null) { this.sketchFeature_ !== null) {
@@ -331,11 +372,18 @@ ol.interaction.Draw.handleEvent = function(event) {
} else if (this.freehand_ && } else if (this.freehand_ &&
event.type === ol.MapBrowserEventType.POINTERDOWN) { event.type === ol.MapBrowserEventType.POINTERDOWN) {
pass = false; 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); 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) { } else if (event.type === ol.MapBrowserEventType.DBLCLICK) {
pass = false; pass = false;
} }
return ol.interaction.Pointer.handleEvent.call(this, event) && pass; return ol.interaction.Pointer.handleEvent.call(this, event) && pass;
}; };
@@ -356,6 +404,11 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
} }
return true; return true;
} else if (this.condition_(event)) { } 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; this.downPx_ = event.pixel;
return true; return true;
} else { } else {
@@ -373,6 +426,11 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
ol.interaction.Draw.handleUpEvent_ = function(event) { ol.interaction.Draw.handleUpEvent_ = function(event) {
var pass = true; var pass = true;
if (this.downTimeout_) {
clearTimeout(this.downTimeout_);
this.downTimeout_ = undefined;
}
this.handlePointerMove_(event); this.handlePointerMove_(event);
var circleMode = this.mode_ === ol.interaction.Draw.Mode_.CIRCLE; var circleMode = this.mode_ === ol.interaction.Draw.Mode_.CIRCLE;
@@ -422,6 +480,9 @@ ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
this.shouldHandle_ = this.freehand_ ? this.shouldHandle_ = this.freehand_ ?
squaredDistance > this.squaredClickTolerance_ : squaredDistance > this.squaredClickTolerance_ :
squaredDistance <= this.squaredClickTolerance_; squaredDistance <= this.squaredClickTolerance_;
if (!this.shouldHandle_) {
return true;
}
} }
if (this.finishCoordinate_) { if (this.finishCoordinate_) {
@@ -504,9 +565,6 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
this.sketchLineCoords_ = this.sketchCoords_[0]; this.sketchLineCoords_ = this.sketchCoords_[0];
} else { } else {
this.sketchCoords_ = [start.slice(), start.slice()]; this.sketchCoords_ = [start.slice(), start.slice()];
if (this.mode_ === ol.interaction.Draw.Mode_.CIRCLE) {
this.sketchLineCoords_ = this.sketchCoords_;
}
} }
if (this.sketchLineCoords_) { if (this.sketchLineCoords_) {
this.sketchLine_ = new ol.Feature( this.sketchLine_ = new ol.Feature(

View File

@@ -205,6 +205,8 @@ ol.PluggableMap = function(options) {
*/ */
this.keyHandlerKeys_ = null; this.keyHandlerKeys_ = null;
ol.events.listen(this.viewport_, ol.events.EventType.CONTEXTMENU,
this.handleBrowserEvent, this);
ol.events.listen(this.viewport_, ol.events.EventType.WHEEL, ol.events.listen(this.viewport_, ol.events.EventType.WHEEL,
this.handleBrowserEvent, this); this.handleBrowserEvent, this);
ol.events.listen(this.viewport_, ol.events.EventType.MOUSEWHEEL, ol.events.listen(this.viewport_, ol.events.EventType.MOUSEWHEEL,
@@ -428,6 +430,8 @@ ol.PluggableMap.prototype.addOverlayInternal_ = function(overlay) {
*/ */
ol.PluggableMap.prototype.disposeInternal = function() { ol.PluggableMap.prototype.disposeInternal = function() {
this.mapBrowserEventHandler_.dispose(); this.mapBrowserEventHandler_.dispose();
ol.events.unlisten(this.viewport_, ol.events.EventType.CONTEXTMENU,
this.handleBrowserEvent, this);
ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL, ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL,
this.handleBrowserEvent, this); this.handleBrowserEvent, this);
ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL, ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL,

View File

@@ -215,7 +215,7 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function(geometr
var state = this.state; var state = this.state;
var fillStyle = state.fillStyle; var fillStyle = state.fillStyle;
if (fillStyle !== undefined) { if (fillStyle !== undefined) {
this.updateFillStyle(state, this.applyFill, geometry); this.updateFillStyle(state, this.createFill, geometry);
} }
if (state.strokeStyle !== undefined) { if (state.strokeStyle !== undefined) {
this.updateStrokeStyle(state, this.applyStroke); this.updateStrokeStyle(state, this.applyStroke);

View File

@@ -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); ol.extent.createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box);
} }
var canvas = context.canvas; 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 (declutterGroup) {
if (!intersects && declutterGroup[4] == 1) { if (!intersects && declutterGroup[4] == 1) {
return; return;
@@ -956,15 +965,16 @@ ol.render.canvas.Replay.prototype.setFillStrokeStyle = function(fillStyle, strok
/** /**
* @param {ol.CanvasFillStrokeState} state State. * @param {ol.CanvasFillStrokeState} state State.
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. * @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 fillStyle = state.fillStyle;
var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle]; var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle];
if (typeof fillStyle !== 'string') { if (typeof fillStyle !== 'string') {
var fillExtent = geometry.getExtent(); var fillExtent = geometry.getExtent();
fillInstruction.push([fillExtent[0], fillExtent[3]]); 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. * @param {ol.CanvasFillStrokeState} state State.
*/ */
ol.render.canvas.Replay.prototype.applyStroke = function(state) { ol.render.canvas.Replay.prototype.applyStroke = function(state) {
this.instructions.push([ this.instructions.push(this.createStroke(state));
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 {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. * @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; var fillStyle = state.fillStyle;
if (typeof fillStyle !== 'string' || state.currentFillStyle != 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; state.currentFillStyle = fillStyle;
} }
}; };
@@ -1014,7 +1035,9 @@ ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStrok
state.currentLineJoin != lineJoin || state.currentLineJoin != lineJoin ||
state.currentLineWidth != lineWidth || state.currentLineWidth != lineWidth ||
state.currentMiterLimit != miterLimit) { state.currentMiterLimit != miterLimit) {
if (strokeStyle !== undefined) {
applyStroke.call(this, state); applyStroke.call(this, state);
}
state.currentStrokeStyle = strokeStyle; state.currentStrokeStyle = strokeStyle;
state.currentLineCap = lineCap; state.currentLineCap = lineCap;
state.currentLineDash = lineDash; state.currentLineDash = lineDash;

View File

@@ -263,8 +263,10 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
this.beginGeometry(geometry, feature); this.beginGeometry(geometry, feature);
if (textState.backgroundFill || textState.backgroundStroke) { if (textState.backgroundFill || textState.backgroundStroke) {
this.setFillStrokeStyle(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.updateStrokeStyle(this.state, this.applyStroke);
this.hitDetectionInstructions.push(this.createStroke(this.state));
} }
this.drawTextImage_(label, begin, end); this.drawTextImage_(label, begin, end);
this.endGeometry(geometry, feature); this.endGeometry(geometry, feature);

View File

@@ -4,6 +4,7 @@ goog.require('ol');
goog.require('ol.ImageCanvas'); goog.require('ol.ImageCanvas');
goog.require('ol.LayerType'); goog.require('ol.LayerType');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.array');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.layer.VectorRenderType'); goog.require('ol.layer.VectorRenderType');
goog.require('ol.obj'); goog.require('ol.obj');
@@ -35,6 +36,11 @@ ol.renderer.canvas.ImageLayer = function(imageLayer) {
*/ */
this.imageTransform_ = ol.transform.create(); this.imageTransform_ = ol.transform.create();
/**
* @type {!Array.<string>}
*/
this.skippedFeatures_ = [];
/** /**
* @private * @private
* @type {ol.renderer.canvas.VectorLayer} * @type {ol.renderer.canvas.VectorLayer}
@@ -127,8 +133,9 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
projection = sourceProjection; projection = sourceProjection;
} }
} }
if (this.vectorRenderer_) { var vectorRenderer = this.vectorRenderer_;
var context = this.vectorRenderer_.context; if (vectorRenderer) {
var context = vectorRenderer.context;
var imageFrameState = /** @type {olx.FrameState} */ (ol.obj.assign({}, frameState, { var imageFrameState = /** @type {olx.FrameState} */ (ol.obj.assign({}, frameState, {
size: [ size: [
ol.extent.getWidth(renderedExtent) / viewResolution, ol.extent.getWidth(renderedExtent) / viewResolution,
@@ -138,12 +145,16 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
rotation: 0 rotation: 0
})) }))
})); }));
if (this.vectorRenderer_.prepareFrame(imageFrameState, layerState)) { var skippedFeatures = Object.keys(imageFrameState.skippedFeatureUids).sort();
if (vectorRenderer.prepareFrame(imageFrameState, layerState) &&
(vectorRenderer.replayGroupChanged ||
!ol.array.equals(skippedFeatures, this.skippedFeatures_))) {
context.canvas.width = imageFrameState.size[0] * pixelRatio; context.canvas.width = imageFrameState.size[0] * pixelRatio;
context.canvas.height = imageFrameState.size[1] * pixelRatio; context.canvas.height = imageFrameState.size[1] * pixelRatio;
this.vectorRenderer_.composeFrame(imageFrameState, layerState, context); vectorRenderer.composeFrame(imageFrameState, layerState, context);
}
this.image_ = new ol.ImageCanvas(renderedExtent, viewResolution, pixelRatio, context.canvas); this.image_ = new ol.ImageCanvas(renderedExtent, viewResolution, pixelRatio, context.canvas);
this.skippedFeatures_ = skippedFeatures;
}
} else { } else {
image = imageSource.getImage( image = imageSource.getImage(
renderedExtent, viewResolution, pixelRatio, projection); renderedExtent, viewResolution, pixelRatio, projection);

View File

@@ -69,6 +69,12 @@ ol.renderer.canvas.VectorLayer = function(vectorLayer) {
*/ */
this.replayGroup_ = null; this.replayGroup_ = null;
/**
* A new replay group had to be created by `prepareFrame()`
* @type {boolean}
*/
this.replayGroupChanged = true;
/** /**
* @type {CanvasRenderingContext2D} * @type {CanvasRenderingContext2D}
*/ */
@@ -181,11 +187,11 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
ol.render.canvas.rotateAtOffset(replayContext, -rotation, ol.render.canvas.rotateAtOffset(replayContext, -rotation,
width / 2, height / 2); width / 2, height / 2);
replayGroup.replay(replayContext, transform, rotation, skippedFeatureUids); replayGroup.replay(replayContext, transform, rotation, skippedFeatureUids);
if (vectorSource.getWrapX() && projection.canWrapX()) { if (vectorSource.getWrapX() && projection.canWrapX() &&
!ol.extent.containsExtent(projectionExtent, extent)) {
var startX = extent[0]; var startX = extent[0];
var worldWidth = ol.extent.getWidth(projectionExtent); var worldWidth = ol.extent.getWidth(projectionExtent);
var world = 0; var world = 0;
startX -= worldWidth;
var offsetX; var offsetX;
while (startX < projectionExtent[0]) { while (startX < projectionExtent[0]) {
--world; --world;
@@ -196,7 +202,6 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
} }
world = 0; world = 0;
startX = extent[2]; startX = extent[2];
startX += worldWidth;
while (startX > projectionExtent[2]) { while (startX > projectionExtent[2]) {
++world; ++world;
offsetX = worldWidth * world; offsetX = worldWidth * world;
@@ -326,7 +331,8 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
vectorLayerRenderBuffer * resolution); vectorLayerRenderBuffer * resolution);
var projectionExtent = viewState.projection.getExtent(); var projectionExtent = viewState.projection.getExtent();
if (vectorSource.getWrapX() && viewState.projection.canWrapX()) { if (vectorSource.getWrapX() && viewState.projection.canWrapX() &&
!ol.extent.containsExtent(projectionExtent, frameState.extent)) {
// For the replay group, we need an extent that intersects the real world // For the replay group, we need an extent that intersects the real world
// (-180° to +180°). To support geometries in a coordinate range from -540° // (-180° to +180°). To support geometries in a coordinate range from -540°
// to +540°, we add at least 1 world width on each side of the projection // to +540°, we add at least 1 world width on each side of the projection
@@ -343,6 +349,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
this.renderedRevision_ == vectorLayerRevision && this.renderedRevision_ == vectorLayerRevision &&
this.renderedRenderOrder_ == vectorLayerRenderOrder && this.renderedRenderOrder_ == vectorLayerRenderOrder &&
ol.extent.containsExtent(this.renderedExtent_, extent)) { ol.extent.containsExtent(this.renderedExtent_, extent)) {
this.replayGroupChanged = false;
return true; return true;
} }
@@ -400,6 +407,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
this.renderedExtent_ = extent; this.renderedExtent_ = extent;
this.replayGroup_ = replayGroup; this.replayGroup_ = replayGroup;
this.replayGroupChanged = true;
return true; return true;
}; };

View File

@@ -155,7 +155,9 @@ ol.style.Text.prototype.clone = function() {
fill: this.getFill() ? this.getFill().clone() : undefined, fill: this.getFill() ? this.getFill().clone() : undefined,
stroke: this.getStroke() ? this.getStroke().clone() : undefined, stroke: this.getStroke() ? this.getStroke().clone() : undefined,
offsetX: this.getOffsetX(), offsetX: this.getOffsetX(),
offsetY: this.getOffsetY() offsetY: this.getOffsetY(),
backgroundFill: this.getBackgroundFill() ? this.getBackgroundFill().clone() : undefined,
backgroundStroke: this.getBackgroundStroke() ? this.getBackgroundStroke().clone() : undefined
}); });
}; };

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -248,6 +248,32 @@ describe('ol.rendering.layer.Vector', function() {
}); });
}); });
it('unskips features correctly with renderMode: \'image\'', function(done) {
createMap('canvas');
addCircle(500);
addPolygon(300);
map.skipFeature(source.getFeatures()[1]);
map.addLayer(new ol.layer.Vector({
renderMode: 'image',
source: source,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255,0,0,0.5)'
}),
stroke: new ol.style.Stroke({
width: 2,
color: 'black'
})
})
}));
map.renderSync();
map.unskipFeature(source.getFeatures()[1]);
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector.png',
IMAGE_TOLERANCE, done);
});
});
it('renders fill/stroke batches correctly with the canvas renderer', function(done) { it('renders fill/stroke batches correctly with the canvas renderer', function(done) {
createMap('canvas'); createMap('canvas');
source = new ol.source.Vector({ source = new ol.source.Vector({

View File

@@ -352,6 +352,9 @@ describe('ol.rendering.style.Text', function() {
})); }));
features[2].getStyle().getText().setPadding([5, 10, 15, 0]); features[2].getStyle().getText().setPadding([5, 10, 15, 0]);
map.getView().fit(vectorSource.getExtent()); 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); expectResemble(map, 'rendering/ol/style/expected/text-background.png', IMAGE_TOLERANCE, done);
}); });

View File

@@ -105,6 +105,15 @@ describe('ol.interaction.Draw', function() {
expect(draw.freehandCondition_(event)).to.be(true); 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() { describe('specifying a geometryName', function() {
@@ -341,7 +350,6 @@ describe('ol.interaction.Draw', function() {
simulateEvent('pointermove', 20, 30); simulateEvent('pointermove', 20, 30);
// freehand // freehand
simulateEvent('pointerdown', 20, 30, true);
simulateEvent('pointermove', 20, 30, true); simulateEvent('pointermove', 20, 30, true);
simulateEvent('pointerdrag', 20, 30, true); simulateEvent('pointerdrag', 20, 30, true);
simulateEvent('pointermove', 30, 40, true); simulateEvent('pointermove', 30, 40, true);
@@ -398,6 +406,38 @@ describe('ol.interaction.Draw', function() {
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]); 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() { it('triggers draw events', function() {
var ds = sinon.spy(); var ds = sinon.spy();
var de = sinon.spy(); var de = sinon.spy();

View File

@@ -290,6 +290,14 @@ describe('ol.renderer.canvas.VectorLayer', function() {
], buffer)); ], buffer));
}); });
it('sets replayGroupChanged correctly', function() {
frameState.extent = [-10000, -10000, 10000, 10000];
renderer.prepareFrame(frameState, {});
expect(renderer.replayGroupChanged).to.be(true);
renderer.prepareFrame(frameState, {});
expect(renderer.replayGroupChanged).to.be(false);
});
}); });
}); });

View File

@@ -1,10 +1,12 @@
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.Feature'); goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.geom.Point'); goog.require('ol.geom.Point');
goog.require('ol.geom.LineString'); goog.require('ol.geom.LineString');
goog.require('ol.layer.Vector');
goog.require('ol.loadingstrategy');
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
@@ -417,6 +419,44 @@ describe('ol.source.Vector', function() {
describe('#loadFeatures', function() { describe('#loadFeatures', function() {
describe('with the "bbox" strategy', function() {
it('requests the view extent plus render buffer', function(done) {
var center = [-97.6114, 38.8403];
var source = new ol.source.Vector({
strategy: ol.loadingstrategy.bbox,
loader: function(extent) {
setTimeout(function() {
var lonLatExtent = ol.proj.transformExtent(extent, 'EPSG:3857', 'EPSG:4326');
expect(lonLatExtent[0]).to.roughlyEqual(-99.261474609, 1e-9);
expect(lonLatExtent[2]).to.roughlyEqual(-95.965576171, 1e-9);
done();
}, 0);
}
});
var div = document.createElement('div');
div.style.width = div.style.height = '100px';
document.body.appendChild(div);
var map = new ol.Map({
target: div,
layers: [
new ol.layer.Vector({
source: source
})
],
view: new ol.View({
center: ol.proj.fromLonLat(center),
zoom: 7
})
});
map.renderSync();
map.setTarget(null);
document.body.removeChild(div);
});
});
describe('with no loader and the "all" strategy', function() { describe('with no loader and the "all" strategy', function() {
it('stores the infinity extent in the Rtree', function() { it('stores the infinity extent in the Rtree', function() {

View File

@@ -54,6 +54,12 @@ describe('ol.style.Text', function() {
}), }),
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
color: '#319FD3' color: '#319FD3'
}),
backgroundFill: new _ol_style_Fill_({
color: 'white'
}),
backgroundStroke: new _ol_style_Stroke_({
color: 'black'
}) })
}); });
var clone = original.clone(); var clone = original.clone();
@@ -68,6 +74,8 @@ describe('ol.style.Text', function() {
expect(original.getTextBaseline()).to.eql(clone.getTextBaseline()); expect(original.getTextBaseline()).to.eql(clone.getTextBaseline());
expect(original.getStroke().getColor()).to.eql(clone.getStroke().getColor()); expect(original.getStroke().getColor()).to.eql(clone.getStroke().getColor());
expect(original.getFill().getColor()).to.eql(clone.getFill().getColor()); expect(original.getFill().getColor()).to.eql(clone.getFill().getColor());
expect(original.getBackgroundStroke().getColor()).to.eql(clone.getBackgroundStroke().getColor());
expect(original.getBackgroundFill().getColor()).to.eql(clone.getBackgroundFill().getColor());
}); });
it('the clone does not reference the same objects as the original', function() { it('the clone does not reference the same objects as the original', function() {