Compare commits
60 Commits
v4.6.0-bet
...
v4.6.4-bac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
849ef07639 | ||
|
|
3696237894 | ||
|
|
af013db6d8 | ||
|
|
9b0cd2a7c8 | ||
|
|
f7a1aba38e | ||
|
|
6e9fc2cbad | ||
|
|
61245fb83a | ||
|
|
e065c851de | ||
|
|
ed29dde552 | ||
|
|
8a73db9331 | ||
|
|
72ca7b28c6 | ||
|
|
f11d55fde6 | ||
|
|
48217bc218 | ||
|
|
c76c445e43 | ||
|
|
3bba8ef061 | ||
|
|
a699cc348b | ||
|
|
f010f7b9c1 | ||
|
|
5d27dcc27c | ||
|
|
52bbebf9aa | ||
|
|
578f900435 | ||
|
|
3bc1de3f6c | ||
|
|
992bfdc126 | ||
|
|
a96b8c5ca6 | ||
|
|
2bce90470e | ||
|
|
50053c1b3f | ||
|
|
0c5134b789 | ||
|
|
ca3e11a10b | ||
|
|
7245805c90 | ||
|
|
5234a4dd21 | ||
|
|
b262b8535e | ||
|
|
45ae731aa6 | ||
|
|
8bc61504c8 | ||
|
|
5641430590 | ||
|
|
2e2d8ea3d7 | ||
|
|
d4f23e0ea9 | ||
|
|
607e836df4 | ||
|
|
8afcd1c2ff | ||
|
|
ebfdddbb8e | ||
|
|
14e3fd9214 | ||
|
|
9c8c9c1a17 | ||
|
|
c7cb26a066 | ||
|
|
b4a5142aaa | ||
|
|
e96d190e1e | ||
|
|
41efec1e74 | ||
|
|
7941a33069 | ||
|
|
8a9f32fa09 | ||
|
|
90d8224a08 | ||
|
|
55f7468c68 | ||
|
|
fca0b0771d | ||
|
|
19bceff077 | ||
|
|
c3db3e2f6f | ||
|
|
73f64a9e89 | ||
|
|
74bf846ffe | ||
|
|
4e8714d619 | ||
|
|
9307c35c17 | ||
|
|
3bb62a2c41 | ||
|
|
b58073dd06 | ||
|
|
9cc7cca447 | ||
|
|
5a252e628b | ||
|
|
343a4085a0 |
@@ -2,6 +2,104 @@
|
||||
|
||||
### 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`
|
||||
|
||||
To update your applications, simply replace `exceedLength` with `overflow`.
|
||||
|
||||
91
changelog/v4.6.0.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# v4.6.0
|
||||
|
||||
### Summary
|
||||
|
||||
The 4.6 release includes enhancements and fixes from 30 or so pull requests. Headlining this release, vector layers got new `textBackgroundFill`, `textBackgroundStroke` and `padding` options that can be used to render background boxes for text. `ol.source.ImageVector` is now deprecated and replaced by a more convenient way to render vectors as images: by simply setting `renderMode: 'image'` on the vector layer.
|
||||
|
||||
Please note that if you are using `closure-util` to build your OpenLayers based application, it is time to migrate to using the [`ol` package](https://www.npmjs.com/package/ol) and a module bundler like webpack. OpenLayers has not had a dependency on the Closure Library since the [3.19 release](https://github.com/openlayers/openlayers/releases/tag/v3.19.0); and with the 5.0 release we will be moving completely away from `goog.require` and `goog.provide`, dropping support for `closure-util`, and going with ES modules for our sources.
|
||||
|
||||
See the [wiki](https://github.com/openlayers/openlayers/wiki/OpenLayers-v5.x) about upcoming changes in 5.0 and tips on how to upgrade. We likely won't have another 4.x release before the 5.0 release. If you're interested in continuing to get feature enhancements in future releases, migrating to the `ol` package now will make the transition easier.
|
||||
|
||||
|
||||
### Upgrade notes
|
||||
|
||||
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow`
|
||||
|
||||
To update your applications, simply replace `exceedLength` with `overflow`.
|
||||
|
||||
#### Deprecation of `ol.source.ImageVector`
|
||||
|
||||
Rendering vector sources as image is now directly supported by `ol.layer.Vector` with the new `renderMode: 'image'` configuration option. Change code like this:
|
||||
|
||||
```js
|
||||
new ol.layer.Image({
|
||||
source: new ol.source.ImageVector({
|
||||
style: myStyle,
|
||||
source: new ol.source.Vector({
|
||||
url: 'my/data.json',
|
||||
format: new ol.format.GeoJSON()
|
||||
})
|
||||
})
|
||||
});
|
||||
```
|
||||
to:
|
||||
|
||||
```js
|
||||
new ol.layer.Vector({
|
||||
renderMode: 'image',
|
||||
style: myStyle,
|
||||
source: new ol.source.Vector({
|
||||
url: 'my/data.json',
|
||||
format: new ol.format.GeoJSON()
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## Detailed changes
|
||||
|
||||
See below for the full list of changes.
|
||||
|
||||
* [#7538](https://github.com/openlayers/openlayers/pull/7538) - removeFromLoadedExtents to remove extents that failed to load ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7537](https://github.com/openlayers/openlayers/pull/7537) - Fix Draw.removeLastPoint exception when no points to remove ([@walkermatt](https://github.com/walkermatt))
|
||||
* [#7461](https://github.com/openlayers/openlayers/pull/7461) - Use the matrixSet projection by default ([@oterral](https://github.com/oterral))
|
||||
* [#5883](https://github.com/openlayers/openlayers/pull/5883) - Fixes setUrl() for WMTS sources (ol.source.WMTS) ([@bylexus](https://github.com/bylexus))
|
||||
* [#7531](https://github.com/openlayers/openlayers/pull/7531) - Update the ol package readme ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7372](https://github.com/openlayers/openlayers/pull/7372) - Add method to set max cache size in ol.style.IconImageCache ([@notnotse](https://github.com/notnotse))
|
||||
* [#7530](https://github.com/openlayers/openlayers/pull/7530) - Check forward/back 1 world if wrapping ([@raiyni](https://github.com/raiyni))
|
||||
* [#7526](https://github.com/openlayers/openlayers/pull/7526) - Allow clicks to be stopped while drawing ([@tschaub](https://github.com/tschaub))
|
||||
* [#7524](https://github.com/openlayers/openlayers/pull/7524) - Snap view center to pixel ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7521](https://github.com/openlayers/openlayers/pull/7521) - fix setMinZoom/setMaxZoom ([@cs09g](https://github.com/cs09g))
|
||||
* [#7519](https://github.com/openlayers/openlayers/pull/7519) - Reuse declutter tree for hit detection ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7499](https://github.com/openlayers/openlayers/pull/7499) - Remove attributions from olx.FrameState instances ([@openlayers](https://github.com/openlayers))
|
||||
* [#7501](https://github.com/openlayers/openlayers/pull/7501) - Option to render vector layers as images ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7516](https://github.com/openlayers/openlayers/pull/7516) - Deprecate exceedLength and replace with overflow ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7510](https://github.com/openlayers/openlayers/pull/7510) - Do not fade the states layer ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7513](https://github.com/openlayers/openlayers/pull/7513) - Make strokeKey safer ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7514](https://github.com/openlayers/openlayers/pull/7514) - Prune the label cache less aggressively ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7505](https://github.com/openlayers/openlayers/pull/7505) - Remove ol.DeviceOrientation link from API index ([@fredj](https://github.com/fredj))
|
||||
* [#7497](https://github.com/openlayers/openlayers/pull/7497) - Use getGeometry ([@nicholas-l](https://github.com/nicholas-l))
|
||||
* [#7495](https://github.com/openlayers/openlayers/pull/7495) - Remove layer renderers when viewport is removed ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7492](https://github.com/openlayers/openlayers/pull/7492) - Remove unneeded type cast from examples ([@fredj](https://github.com/fredj))
|
||||
* [#7489](https://github.com/openlayers/openlayers/pull/7489) - Allow string to be passed as ol.interaction.Draw type ([@fredj](https://github.com/fredj))
|
||||
* [#7445](https://github.com/openlayers/openlayers/pull/7445) - Load css rules from full-screen.css in examples ([@fredj](https://github.com/fredj))
|
||||
* [#7481](https://github.com/openlayers/openlayers/pull/7481) - Make zoom to extent control extensible ([@gberaudo](https://github.com/gberaudo))
|
||||
* [#7477](https://github.com/openlayers/openlayers/pull/7477) - Make text states available for replay time ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7482](https://github.com/openlayers/openlayers/pull/7482) - Reset rotation after rendering ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7480](https://github.com/openlayers/openlayers/pull/7480) - Create a new image when loading tile after an error ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7476](https://github.com/openlayers/openlayers/pull/7476) - Reset text measurements when available fonts change ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7454](https://github.com/openlayers/openlayers/pull/7454) - Add text background rendering and text padding ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7468](https://github.com/openlayers/openlayers/pull/7468) - Add new API-key for HERE example ([@chrismayer](https://github.com/chrismayer))
|
||||
* [#7465](https://github.com/openlayers/openlayers/pull/7465) - Export ol.proj.Projection#getAxisOrientation function ([@fredj](https://github.com/fredj))
|
||||
* [#7462](https://github.com/openlayers/openlayers/pull/7462) - Respect metersPerUnit in ScaleLine control ([@ahocevar](https://github.com/ahocevar))
|
||||
|
||||
|
||||
Additionally a number of updates where made to our dependencies:
|
||||
* [#7536](https://github.com/openlayers/openlayers/pull/7536) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||
* [#7533](https://github.com/openlayers/openlayers/pull/7533) - Update marked to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||
* [#7527](https://github.com/openlayers/openlayers/pull/7527) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||
* [#7511](https://github.com/openlayers/openlayers/pull/7511) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||
* [#7512](https://github.com/openlayers/openlayers/pull/7512) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||
* [#7484](https://github.com/openlayers/openlayers/pull/7484) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||
9
changelog/v4.6.1.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 4.6.1
|
||||
|
||||
The v4.6.1 release fixes a number of issues in the 4.6 releases.
|
||||
|
||||
## Fixes
|
||||
|
||||
* [#7543](https://github.com/openlayers/openlayers/pull/7543) - Donut polygon labels do not get a chance to get rendered ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7542](https://github.com/openlayers/openlayers/pull/7542) - Still respect deprecated exceedLength option ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7541](https://github.com/openlayers/openlayers/pull/7541) - Fix case of vectorrendertype.js ([@ahocevar](https://github.com/ahocevar))
|
||||
7
changelog/v4.6.2.md
Normal 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
@@ -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
@@ -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
@@ -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
261
dist/ol.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;
|
||||
}
|
||||
1075
dist/ol.js
vendored
Normal file
@@ -3003,8 +3003,10 @@ 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),
|
||||
* maxPoints: (number|undefined),
|
||||
* minPoints: (number|undefined),
|
||||
* finishCondition: (ol.EventsConditionType|undefined),
|
||||
@@ -3047,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}
|
||||
@@ -3064,6 +3074,15 @@ olx.interaction.DrawOptions.prototype.snapTolerance;
|
||||
olx.interaction.DrawOptions.prototype.type;
|
||||
|
||||
|
||||
/**
|
||||
* Stop click, singleclick, and doubleclick events from firing during drawing.
|
||||
* Default is `false`.
|
||||
* @type {boolean|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DrawOptions.prototype.stopClick;
|
||||
|
||||
|
||||
/**
|
||||
* The number of points that can be drawn before a polygon ring or line string
|
||||
* is finished. The default is no restriction.
|
||||
@@ -6674,6 +6693,37 @@ olx.source.VectorOptions.prototype.format;
|
||||
* The loader function used to load features, from a remote source for example.
|
||||
* If this is not set and `url` is set, the source will create and use an XHR
|
||||
* feature loader.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* var vectorSource = new ol.source.Vector({
|
||||
* format: new ol.format.GeoJSON(),
|
||||
* loader: function(extent, resolution, projection) {
|
||||
* var proj = projection.getCode();
|
||||
* var url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
|
||||
* 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
|
||||
* 'outputFormat=application/json&srsname=' + proj + '&' +
|
||||
* 'bbox=' + extent.join(',') + ',' + proj;
|
||||
* var xhr = new XMLHttpRequest();
|
||||
* xhr.open('GET', url);
|
||||
* var onError = function() {
|
||||
* vectorSource.removeLoadedExtent(extent);
|
||||
* }
|
||||
* xhr.onerror = onError;
|
||||
* xhr.onload = function() {
|
||||
* if (xhr.status == 200) {
|
||||
* vectorSource.addFeatures(
|
||||
* vectorSource.getFormat().readFeatures(xhr.responseText));
|
||||
* } else {
|
||||
* onError();
|
||||
* }
|
||||
* }
|
||||
* xhr.send();
|
||||
* },
|
||||
* strategy: ol.loadingstrategy.bbox
|
||||
* });
|
||||
* ```
|
||||
* @type {ol.FeatureLoader|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -8484,7 +8534,7 @@ olx.view.FitOptions.prototype.callback;
|
||||
* pixelToCoordinateTransform: ol.Transform,
|
||||
* postRenderFunctions: Array.<ol.PostRenderFunction>,
|
||||
* size: ol.Size,
|
||||
* skippedFeatureUids: Object.<string, boolean>,
|
||||
* skippedFeatureUids: !Object.<string, boolean>,
|
||||
* tileQueue: ol.TileQueue,
|
||||
* time: number,
|
||||
* usedTiles: Object.<string, Object.<string, ol.TileRange>>,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openlayers",
|
||||
"version": "4.5.0",
|
||||
"version": "4.6.4-backports.2",
|
||||
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
||||
"keywords": [
|
||||
"map",
|
||||
@@ -40,7 +40,7 @@
|
||||
"dependencies": {
|
||||
"async": "2.6.0",
|
||||
"closure-util": "1.26.0",
|
||||
"fs-extra": "4.0.2",
|
||||
"fs-extra": "4.0.3",
|
||||
"jsdoc": "3.5.5",
|
||||
"nomnom": "1.8.1",
|
||||
"pbf": "3.1.0",
|
||||
@@ -73,7 +73,7 @@
|
||||
"karma-firefox-launcher": "^1.0.1",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sauce-launcher": "^1.1.0",
|
||||
"marked": "0.3.6",
|
||||
"marked": "0.3.7",
|
||||
"metalsmith": "2.3.0",
|
||||
"metalsmith-layouts": "1.8.1",
|
||||
"mocha": "4.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ol",
|
||||
"version": "4.5.0",
|
||||
"version": "4.6.4",
|
||||
"description": "OpenLayers as ES2015 modules",
|
||||
"main": "index.js",
|
||||
"module": "index.js",
|
||||
|
||||
@@ -37,6 +37,7 @@ See the following examples for more detail on bundling OpenLayers with your appl
|
||||
* Using [Rollup & Uglify](https://gist.github.com/tschaub/8beb328ea72b36446fc2198d008287de)
|
||||
* Using [Rollup & Closure Compiler](https://gist.github.com/tschaub/32a5692bedac5254da24fa3b12072f35)
|
||||
* Using [Webpack & Uglify](https://gist.github.com/tschaub/79025aef325cd2837364400a105405b8)
|
||||
* Using [Webpack & Closure Compiler](https://gist.github.com/ahocevar/8ceafc6293455ba491dd9be12c15761f)
|
||||
* Using [Browserify & Uglify](https://gist.github.com/tschaub/4bfb209a8f809823f1495b2e4436018e)
|
||||
|
||||
## Module Identifiers
|
||||
@@ -46,7 +47,3 @@ The module identifiers above (e.g. `ol/map`) are like the `ol.Map` names in the
|
||||
Constructors are exported from dedicated modules. For example, the `ol/layer/tile` module exports the `Tile` layer constructor.
|
||||
|
||||
Utility functions are available as properties of the default export from utility modules. For example, the `getCenter` function is a property of the default export from the `ol/extent` utility module.
|
||||
|
||||
## Caveats
|
||||
|
||||
* The WebGL renderer is not available in this package.
|
||||
|
||||
@@ -13,6 +13,7 @@ ol.events.EventType = {
|
||||
CHANGE: 'change',
|
||||
|
||||
CLEAR: 'clear',
|
||||
CONTEXTMENU: 'contextmenu',
|
||||
CLICK: 'click',
|
||||
DBLCLICK: 'dblclick',
|
||||
DRAGENTER: 'dragenter',
|
||||
|
||||
@@ -24,7 +24,8 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
|
||||
/** @type {Array.<number>} */
|
||||
var intersections = [];
|
||||
// Calculate intersections with the horizontal line
|
||||
var end = ends[0];
|
||||
for (var r = 0, rr = ends.length; r < rr; ++r) {
|
||||
var end = ends[r];
|
||||
x1 = flatCoordinates[end - stride];
|
||||
y1 = flatCoordinates[end - stride + 1];
|
||||
for (i = offset; i < end; i += stride) {
|
||||
@@ -37,6 +38,7 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
}
|
||||
// Find the longest segment of the horizontal line that has its center point
|
||||
// inside the linear ring.
|
||||
var pointX = NaN;
|
||||
|
||||
@@ -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
|
||||
@@ -97,6 +112,14 @@ ol.interaction.Draw = function(options) {
|
||||
*/
|
||||
this.mode_ = ol.interaction.Draw.getMode_(this.type_);
|
||||
|
||||
/**
|
||||
* Stop click, singleclick, and doubleclick events from firing during drawing.
|
||||
* Default is `false`.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.stopClick_ = !!options.stopClick;
|
||||
|
||||
/**
|
||||
* The number of points that must be drawn before a polygon ring or line
|
||||
* string can be finished. The default is 3 for polygon rings and 2 for
|
||||
@@ -160,7 +183,12 @@ ol.interaction.Draw = function(options) {
|
||||
var geometry = opt_geometry;
|
||||
if (geometry) {
|
||||
if (mode === ol.interaction.Draw.Mode_.POLYGON) {
|
||||
if (coordinates[0].length) {
|
||||
// Add a closing coordinate to match the first
|
||||
geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]);
|
||||
} else {
|
||||
geometry.setCoordinates([]);
|
||||
}
|
||||
} else {
|
||||
geometry.setCoordinates(coordinates);
|
||||
}
|
||||
@@ -178,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).
|
||||
@@ -242,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
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -308,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) {
|
||||
@@ -318,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;
|
||||
};
|
||||
|
||||
@@ -343,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 {
|
||||
@@ -360,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;
|
||||
@@ -384,6 +455,9 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
|
||||
this.finishCoordinate_ = null;
|
||||
this.abortDrawing_();
|
||||
}
|
||||
if (!pass && this.stopClick_) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
return pass;
|
||||
};
|
||||
|
||||
@@ -406,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_) {
|
||||
@@ -488,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(
|
||||
|
||||
@@ -172,7 +172,9 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
|
||||
// contact. isMouseActionButton returns true in these cases (evt.button is set
|
||||
// to 0).
|
||||
// See http://www.w3.org/TR/pointerevents/#button-states
|
||||
if (!this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
|
||||
// We only fire click, singleclick, and doubleclick if nobody has called
|
||||
// event.stopPropagation() or event.preventDefault().
|
||||
if (!newEvent.propagationStopped && !this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
|
||||
this.emulateClick_(this.down_);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
@@ -1139,11 +1143,15 @@ ol.PluggableMap.prototype.renderFrame_ = function(time) {
|
||||
layerStates[ol.getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
|
||||
}
|
||||
viewState = view.getState();
|
||||
var center = viewState.center;
|
||||
var pixelResolution = viewState.resolution / this.pixelRatio_;
|
||||
center[0] = Math.round(center[0] / pixelResolution) * pixelResolution;
|
||||
center[1] = Math.round(center[1] / pixelResolution) * pixelResolution;
|
||||
frameState = /** @type {olx.FrameState} */ ({
|
||||
animate: false,
|
||||
coordinateToPixelTransform: this.coordinateToPixelTransform_,
|
||||
extent: extent,
|
||||
focus: !this.focus_ ? viewState.center : this.focus_,
|
||||
focus: !this.focus_ ? center : this.focus_,
|
||||
index: this.frameIndex_++,
|
||||
layerStates: layerStates,
|
||||
layerStatesArray: layerStatesArray,
|
||||
|
||||
@@ -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);
|
||||
@@ -281,7 +283,7 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
*/
|
||||
ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey) {
|
||||
var label;
|
||||
var key = strokeKey + textKey + text + fillKey;
|
||||
var key = strokeKey + textKey + text + fillKey + this.pixelRatio;
|
||||
|
||||
var labelCache = ol.render.canvas.labelCache;
|
||||
if (!labelCache.containsKey(key)) {
|
||||
@@ -323,19 +325,19 @@ ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey
|
||||
if (fillKey) {
|
||||
context.fillStyle = fillState.fillStyle;
|
||||
}
|
||||
context.textBaseline = 'top';
|
||||
context.textBaseline = 'middle';
|
||||
context.textAlign = 'center';
|
||||
var leftRight = (0.5 - align);
|
||||
var x = align * label.width / scale + leftRight * strokeWidth;
|
||||
var i;
|
||||
if (strokeKey) {
|
||||
for (i = 0; i < numLines; ++i) {
|
||||
context.strokeText(lines[i], x + leftRight * widths[i], 0.5 * strokeWidth + i * lineHeight);
|
||||
context.strokeText(lines[i], x + leftRight * widths[i], 0.5 * (strokeWidth + lineHeight) + i * lineHeight);
|
||||
}
|
||||
}
|
||||
if (fillKey) {
|
||||
for (i = 0; i < numLines; ++i) {
|
||||
context.fillText(lines[i], x + leftRight * widths[i], 0.5 * strokeWidth + i * lineHeight);
|
||||
context.fillText(lines[i], x + leftRight * widths[i], 0.5 * (strokeWidth + lineHeight) + i * lineHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ goog.require('ol');
|
||||
goog.require('ol.ImageCanvas');
|
||||
goog.require('ol.LayerType');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.VectorRenderType');
|
||||
goog.require('ol.obj');
|
||||
@@ -35,6 +36,11 @@ ol.renderer.canvas.ImageLayer = function(imageLayer) {
|
||||
*/
|
||||
this.imageTransform_ = ol.transform.create();
|
||||
|
||||
/**
|
||||
* @type {!Array.<string>}
|
||||
*/
|
||||
this.skippedFeatures_ = [];
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.renderer.canvas.VectorLayer}
|
||||
@@ -127,8 +133,9 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
|
||||
projection = sourceProjection;
|
||||
}
|
||||
}
|
||||
if (this.vectorRenderer_) {
|
||||
var context = this.vectorRenderer_.context;
|
||||
var vectorRenderer = this.vectorRenderer_;
|
||||
if (vectorRenderer) {
|
||||
var context = vectorRenderer.context;
|
||||
var imageFrameState = /** @type {olx.FrameState} */ (ol.obj.assign({}, frameState, {
|
||||
size: [
|
||||
ol.extent.getWidth(renderedExtent) / viewResolution,
|
||||
@@ -138,12 +145,16 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
|
||||
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.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.skippedFeatures_ = skippedFeatures;
|
||||
}
|
||||
} else {
|
||||
image = imageSource.getImage(
|
||||
renderedExtent, viewResolution, pixelRatio, projection);
|
||||
|
||||
@@ -69,6 +69,12 @@ ol.renderer.canvas.VectorLayer = function(vectorLayer) {
|
||||
*/
|
||||
this.replayGroup_ = null;
|
||||
|
||||
/**
|
||||
* A new replay group had to be created by `prepareFrame()`
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.replayGroupChanged = true;
|
||||
|
||||
/**
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
@@ -343,6 +349,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
|
||||
this.renderedRevision_ == vectorLayerRevision &&
|
||||
this.renderedRenderOrder_ == vectorLayerRenderOrder &&
|
||||
ol.extent.containsExtent(this.renderedExtent_, extent)) {
|
||||
this.replayGroupChanged = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -400,6 +407,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
|
||||
this.renderedExtent_ = extent;
|
||||
this.replayGroup_ = replayGroup;
|
||||
|
||||
this.replayGroupChanged = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -762,6 +762,26 @@ ol.source.Vector.prototype.loadFeatures = function(
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Remove an extent from the list of loaded extents.
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @api
|
||||
*/
|
||||
ol.source.Vector.prototype.removeLoadedExtent = function(extent) {
|
||||
var loadedExtentsRtree = this.loadedExtentsRtree_;
|
||||
var obj;
|
||||
loadedExtentsRtree.forEachInExtent(extent, function(object) {
|
||||
if (ol.extent.equals(object.extent, extent)) {
|
||||
obj = object;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (obj) {
|
||||
loadedExtentsRtree.remove(obj);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Remove a single feature from the source. If you want to remove all features
|
||||
* at once, use the {@link ol.source.Vector#clear source.clear()} method
|
||||
|
||||
@@ -105,8 +105,9 @@ ol.source.WMTS = function(options) {
|
||||
/**
|
||||
* @param {string} template Template.
|
||||
* @return {ol.TileUrlFunctionType} Tile URL function.
|
||||
* @private
|
||||
*/
|
||||
function createFromWMTSTemplate(template) {
|
||||
this.createFromWMTSTemplate_ = function(template) {
|
||||
|
||||
// TODO: we may want to create our own appendParams function so that params
|
||||
// order conforms to wmts spec guidance, and so that we can avoid to escape
|
||||
@@ -146,11 +147,11 @@ ol.source.WMTS = function(options) {
|
||||
return url;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var tileUrlFunction = (urls && urls.length > 0) ?
|
||||
ol.TileUrlFunction.createFromTileUrlFunctions(
|
||||
urls.map(createFromWMTSTemplate)) :
|
||||
urls.map(this.createFromWMTSTemplate_)) :
|
||||
ol.TileUrlFunction.nullTileUrlFunction;
|
||||
|
||||
ol.source.TileImage.call(this, {
|
||||
@@ -175,6 +176,18 @@ ol.source.WMTS = function(options) {
|
||||
};
|
||||
ol.inherits(ol.source.WMTS, ol.source.TileImage);
|
||||
|
||||
/**
|
||||
* Set the URLs to use for requests.
|
||||
* URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}.
|
||||
* @override
|
||||
*/
|
||||
ol.source.WMTS.prototype.setUrls = function(urls) {
|
||||
this.urls = urls;
|
||||
var key = urls.join('\n');
|
||||
this.setTileUrlFunction(this.fixedTileUrlFunction ?
|
||||
this.fixedTileUrlFunction.bind(this) :
|
||||
ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the dimensions, i.e. those passed to the constructor through the
|
||||
@@ -314,8 +327,9 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var tileMatrixSet = ol.array.find(tileMatrixSets, function(el) {
|
||||
return el['Identifier'] == elt['TileMatrixSet'];
|
||||
});
|
||||
var supportedCRS = tileMatrixSet['SupportedCRS'].replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3');
|
||||
var proj1 = ol.proj.get(supportedCRS);
|
||||
var supportedCRS = tileMatrixSet['SupportedCRS'];
|
||||
var proj1 = ol.proj.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
ol.proj.get(supportedCRS);
|
||||
var proj2 = ol.proj.get(config['projection']);
|
||||
if (proj1 && proj2) {
|
||||
return ol.proj.equivalent(proj1, proj2);
|
||||
@@ -374,11 +388,18 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
});
|
||||
|
||||
var projection;
|
||||
var code = matrixSetObj['SupportedCRS'];
|
||||
if (code) {
|
||||
projection = ol.proj.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
ol.proj.get(code);
|
||||
}
|
||||
if ('projection' in config) {
|
||||
projection = ol.proj.get(config['projection']);
|
||||
} else {
|
||||
projection = ol.proj.get(matrixSetObj['SupportedCRS'].replace(
|
||||
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'));
|
||||
var projConfig = ol.proj.get(config['projection']);
|
||||
if (projConfig) {
|
||||
if (!projection || ol.proj.equivalent(projConfig, projection)) {
|
||||
projection = projConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var wgs84BoundingBox = l['WGS84BoundingBox'];
|
||||
@@ -411,6 +432,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var gets = wmtsCap['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'];
|
||||
|
||||
for (var i = 0, ii = gets.length; i < ii; ++i) {
|
||||
if (gets[i]['Constraint']) {
|
||||
var constraint = ol.array.find(gets[i]['Constraint'], function(element) {
|
||||
return element['name'] == 'GetEncoding';
|
||||
});
|
||||
@@ -427,6 +449,10 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (gets[i]['href']) {
|
||||
requestEncoding = ol.source.WMTSRequestEncoding.KVP;
|
||||
urls.push(/** @type {string} */ (gets[i]['href']));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (urls.length === 0) {
|
||||
|
||||
@@ -2,4 +2,8 @@ goog.provide('ol.style');
|
||||
|
||||
goog.require('ol.style.IconImageCache');
|
||||
|
||||
/**
|
||||
* The {@link ol.style.IconImageCache} for {@link ol.style.Icon} images.
|
||||
* @api
|
||||
*/
|
||||
ol.style.iconImageCache = new ol.style.IconImageCache();
|
||||
|
||||
@@ -4,6 +4,7 @@ goog.require('ol.color');
|
||||
|
||||
|
||||
/**
|
||||
* Singleton class. Available through {@link ol.style.iconImageCache}.
|
||||
* @constructor
|
||||
*/
|
||||
ol.style.IconImageCache = function() {
|
||||
@@ -21,7 +22,6 @@ ol.style.IconImageCache = function() {
|
||||
this.cacheSize_ = 0;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
@@ -91,3 +91,16 @@ ol.style.IconImageCache.prototype.set = function(src, crossOrigin, color, iconIm
|
||||
this.cache_[key] = iconImage;
|
||||
++this.cacheSize_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the cache size of the icon cache. Default is `32`. Change this value when
|
||||
* your map uses more than 32 different icon images and you are not caching icon
|
||||
* styles on the application level.
|
||||
* @param {number} maxCacheSize Cache max size.
|
||||
* @api
|
||||
*/
|
||||
ol.style.IconImageCache.prototype.setSize = function(maxCacheSize) {
|
||||
this.maxCacheSize_ = maxCacheSize;
|
||||
this.expire();
|
||||
};
|
||||
|
||||
@@ -78,11 +78,14 @@ ol.style.Text = function(opt_options) {
|
||||
*/
|
||||
this.placement_ = options.placement !== undefined ? options.placement : ol.style.TextPlacement.POINT;
|
||||
|
||||
//TODO Use options.overflow directly after removing @deprecated exceedLength
|
||||
var overflow = options.overflow === undefined ? options.exceedLength : options.overflow;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.overflow_ = options.overflow !== undefined ? options.overflow : false;
|
||||
this.overflow_ = overflow !== undefined ? overflow : false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -152,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
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -92,9 +92,9 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = function(matrixSet, opt_exten
|
||||
var tileWidthPropName = 'TileWidth';
|
||||
var tileHeightPropName = 'TileHeight';
|
||||
|
||||
var projection;
|
||||
projection = ol.proj.get(matrixSet[supportedCRSPropName].replace(
|
||||
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'));
|
||||
var code = matrixSet[supportedCRSPropName];
|
||||
var projection = ol.proj.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
ol.proj.get(code);
|
||||
var metersPerUnit = projection.getMetersPerUnit();
|
||||
// swap origin x and y coordinates if axis orientation is lat/long
|
||||
var switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';
|
||||
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
test/rendering/ol/layer/expected/vector.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
@@ -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) {
|
||||
createMap('canvas');
|
||||
source = new ol.source.Vector({
|
||||
|
||||
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -163,7 +163,7 @@ describe('ol.rendering.style.Text', function() {
|
||||
it('renders correct stroke with pixelRatio != 1', function(done) {
|
||||
createMap('canvas', 2);
|
||||
createFeatures();
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-canvas-hidpi.png', 2.8, done);
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-canvas-hidpi.png', 2.9, done);
|
||||
});
|
||||
|
||||
it('renders text correctly with scale != 1', function(done) {
|
||||
@@ -260,6 +260,104 @@ describe('ol.rendering.style.Text', function() {
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-align-offset-canvas.png', 6, done);
|
||||
});
|
||||
|
||||
it('renders text along a MultiLineString', function(done) {
|
||||
createMap('canvas');
|
||||
var line = new ol.geom.LineString();
|
||||
line.setFlatCoordinates('XY', nicePath);
|
||||
var geom = new ol.geom.MultiLineString(null);
|
||||
geom.appendLineString(line);
|
||||
line = line.clone();
|
||||
line.translate(0, 50);
|
||||
geom.appendLineString(line);
|
||||
line = line.clone();
|
||||
line.translate(0, -100);
|
||||
geom.appendLineString(line);
|
||||
var feature = new ol.Feature(geom);
|
||||
feature.setStyle(new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
text: 'Hello world',
|
||||
placement: 'line',
|
||||
font: 'bold 30px sans-serif'
|
||||
})
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-multilinestring.png', 7, done);
|
||||
});
|
||||
|
||||
it('renders text along a Polygon', function(done) {
|
||||
createMap('canvas');
|
||||
var geom = new ol.geom.Polygon(null);
|
||||
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
|
||||
var feature = new ol.Feature(geom);
|
||||
feature.setStyle(new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
text: 'Hello world',
|
||||
font: 'bold 24px sans-serif',
|
||||
placement: 'line',
|
||||
overflow: true
|
||||
})
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-polygon.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
|
||||
it('renders text along a MultiPolygon', function(done) {
|
||||
createMap('canvas');
|
||||
var geom = new ol.geom.Polygon(null);
|
||||
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
|
||||
var multiPolygon = new ol.geom.MultiPolygon(null);
|
||||
multiPolygon.appendPolygon(geom);
|
||||
geom = geom.clone();
|
||||
geom.translate(0, 30);
|
||||
multiPolygon.appendPolygon(geom);
|
||||
geom = geom.clone();
|
||||
geom.translate(0, -60);
|
||||
multiPolygon.appendPolygon(geom);
|
||||
var feature = new ol.Feature(multiPolygon);
|
||||
feature.setStyle(new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
text: 'Hello world',
|
||||
font: 'bold 24px sans-serif',
|
||||
placement: 'line',
|
||||
overflow: true
|
||||
})
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-multipolygon.png', 4.4, done);
|
||||
});
|
||||
|
||||
it('renders text background', function(done) {
|
||||
createMap('canvas');
|
||||
createFeatures();
|
||||
var features = vectorSource.getFeatures();
|
||||
features[0].getStyle().getText().setBackgroundFill(new ol.style.Fill({
|
||||
color: 'red'
|
||||
}));
|
||||
features[1].getStyle().getText().setBackgroundFill(new ol.style.Fill({
|
||||
color: 'red'
|
||||
}));
|
||||
features[1].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({
|
||||
color: 'blue',
|
||||
width: 3
|
||||
}));
|
||||
features[2].getStyle().getText().setBackgroundFill(new ol.style.Fill({
|
||||
color: 'red'
|
||||
}));
|
||||
features[2].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({
|
||||
color: 'blue',
|
||||
width: 3
|
||||
}));
|
||||
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);
|
||||
});
|
||||
|
||||
describe('Text along an ugly upside down path, keep text upright', function() {
|
||||
|
||||
it('renders text along a linestring with auto-align', function(done) {
|
||||
@@ -347,97 +445,7 @@ describe('ol.rendering.style.Text', function() {
|
||||
createLineString(nicePath, 'left');
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-linestring-left-nice-rotated.png', 4.5, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('renders text along a MultiLineString', function(done) {
|
||||
createMap('canvas');
|
||||
var line = new ol.geom.LineString();
|
||||
line.setFlatCoordinates('XY', nicePath);
|
||||
var geom = new ol.geom.MultiLineString(null);
|
||||
geom.appendLineString(line);
|
||||
line.translate(0, 50);
|
||||
geom.appendLineString(line);
|
||||
line.translate(0, -100);
|
||||
geom.appendLineString(line);
|
||||
var feature = new ol.Feature(geom);
|
||||
feature.setStyle(new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
text: 'Hello world',
|
||||
placement: 'line',
|
||||
font: 'bold 30px sans-serif'
|
||||
})
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-multilinestring.png', 7, done);
|
||||
});
|
||||
|
||||
it('renders text along a Polygon', function(done) {
|
||||
createMap('canvas');
|
||||
var geom = new ol.geom.Polygon(null);
|
||||
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
|
||||
var feature = new ol.Feature(geom);
|
||||
feature.setStyle(new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
text: 'Hello world',
|
||||
font: 'bold 24px sans-serif',
|
||||
placement: 'line',
|
||||
overflow: true
|
||||
})
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-polygon.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
|
||||
it('renders text along a MultiPolygon', function(done) {
|
||||
createMap('canvas');
|
||||
var geom = new ol.geom.Polygon(null);
|
||||
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
|
||||
var multiPolygon = new ol.geom.MultiPolygon(null);
|
||||
multiPolygon.appendPolygon(geom);
|
||||
geom.translate(0, 30);
|
||||
multiPolygon.appendPolygon(geom);
|
||||
geom.translate(0, -60);
|
||||
multiPolygon.appendPolygon(geom);
|
||||
var feature = new ol.Feature(multiPolygon);
|
||||
feature.setStyle(new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
text: 'Hello world',
|
||||
font: 'bold 24px sans-serif',
|
||||
placement: 'line',
|
||||
overflow: true
|
||||
})
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-multipolygon.png', 4.4, done);
|
||||
});
|
||||
|
||||
it('renders text background', function(done) {
|
||||
createMap('canvas');
|
||||
createFeatures();
|
||||
var features = vectorSource.getFeatures();
|
||||
features[0].getStyle().getText().setBackgroundFill(new ol.style.Fill({
|
||||
color: 'red'
|
||||
}));
|
||||
features[1].getStyle().getText().setBackgroundFill(new ol.style.Fill({
|
||||
color: 'red'
|
||||
}));
|
||||
features[1].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({
|
||||
color: 'blue',
|
||||
width: 3
|
||||
}));
|
||||
features[2].getStyle().getText().setBackgroundFill(new ol.style.Fill({
|
||||
color: 'red'
|
||||
}));
|
||||
features[2].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({
|
||||
color: 'blue',
|
||||
width: 3
|
||||
}));
|
||||
features[2].getStyle().getText().setPadding([5, 10, 15, 0]);
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
expectResemble(map, 'rendering/ol/style/expected/text-background.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
|
||||
where('WebGL').it('tests the webgl renderer without rotation', function(done) {
|
||||
|
||||
@@ -550,6 +550,17 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(interiorPoint.layout).to.be('XYM');
|
||||
expect(interiorPoint.getCoordinates()).to.eql([0.5, 0.5, 1]);
|
||||
});
|
||||
|
||||
it('returns XYM point for donut polygons', function() {
|
||||
var geom = new ol.geom.Polygon([
|
||||
[[0.5, 0.5], [0.5, 2.5], [2.5, 2.5], [2.5, 0.5], [0.5, 0.5]],
|
||||
[[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]
|
||||
]);
|
||||
var interiorPoint = geom.getInteriorPoint();
|
||||
expect(interiorPoint.getType()).to.be('Point');
|
||||
expect(interiorPoint.layout).to.be('XYM');
|
||||
expect(interiorPoint.getCoordinates()).to.eql([0.75, 1.5, 0.5]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.geom.Polygon.fromExtent', function() {
|
||||
|
||||
@@ -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();
|
||||
@@ -585,6 +625,29 @@ describe('ol.interaction.Draw', function() {
|
||||
expect(source.getFeatures()).to.have.length(0);
|
||||
});
|
||||
|
||||
it('will tolerate removeLastPoint being called when no coordinates', function() {
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
simulateEvent('pointerdown', 10, 20);
|
||||
simulateEvent('pointerup', 10, 20);
|
||||
|
||||
// second point
|
||||
simulateEvent('pointermove', 40, 30);
|
||||
simulateEvent('pointerdown', 40, 30);
|
||||
simulateEvent('pointerup', 40, 30);
|
||||
|
||||
simulateEvent('pointermove', 100, 100);
|
||||
|
||||
expect(function() {
|
||||
draw.removeLastPoint();
|
||||
draw.removeLastPoint();
|
||||
draw.removeLastPoint();
|
||||
}).to.not.throwException();
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('draws polygon with clicks, finishing on last point', function() {
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
|
||||
@@ -290,6 +290,14 @@ describe('ol.renderer.canvas.VectorLayer', function() {
|
||||
], 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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
|
||||
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.loadingstrategy');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.Vector');
|
||||
|
||||
@@ -417,6 +419,44 @@ describe('ol.source.Vector', 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() {
|
||||
|
||||
it('stores the infinity extent in the Rtree', function() {
|
||||
@@ -451,6 +491,19 @@ describe('ol.source.Vector', function() {
|
||||
expect(count1).to.eql(1);
|
||||
expect(count2).to.eql(1);
|
||||
});
|
||||
|
||||
it('removes extents with #removeLoadedExtent()', function(done) {
|
||||
var source = new ol.source.Vector();
|
||||
source.setLoader(function(bbox, resolution, projection) {
|
||||
setTimeout(function() {
|
||||
expect(source.loadedExtentsRtree_.getAll()).to.have.length(1);
|
||||
source.removeLoadedExtent(bbox);
|
||||
expect(source.loadedExtentsRtree_.getAll()).to.have.length(0);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
source.loadFeatures([-10000, -10000, 10000, 10000], 1, ol.proj.get('EPSG:3857'));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -11,10 +11,11 @@ describe('ol.source.WMTS', function() {
|
||||
|
||||
describe('when creating options from capabilities', function() {
|
||||
var parser = new ol.format.WMTSCapabilities();
|
||||
var capabilities;
|
||||
var capabilities, content;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
|
||||
try {
|
||||
content = xml;
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
@@ -113,6 +114,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
expect(options.projection.getCode()).to.be.eql('EPSG:3857');
|
||||
});
|
||||
|
||||
it('can find a MatrixSet by equivalent SRS identifier', function() {
|
||||
@@ -123,8 +125,57 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
expect(options.projection.getCode()).to.be.eql('EPSG:900913');
|
||||
});
|
||||
|
||||
it('can find the default MatrixSet', function() {
|
||||
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
|
||||
expect(options.matrixSet).to.be.eql('BigWorldPixel');
|
||||
expect(options.projection.getCode()).to.be.eql('urn:ogc:def:crs:OGC:1.3:CRS84');
|
||||
});
|
||||
|
||||
it('uses the projection of the default MatrixSet if the config\'s projection is not supported', function() {
|
||||
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
projection: new ol.proj.Projection({
|
||||
code: 'EPSG:2056',
|
||||
units: 'm'
|
||||
})
|
||||
});
|
||||
|
||||
expect(options.matrixSet).to.be.eql('BigWorldPixel');
|
||||
expect(options.projection.getCode()).to.be.eql('urn:ogc:def:crs:OGC:1.3:CRS84');
|
||||
});
|
||||
|
||||
it('doesn\'t fail if the GetCap doesn\'t contains Constraint tags', function() {
|
||||
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
var tmpCapabilities = parser.read(tmpXml);
|
||||
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
|
||||
var options = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
});
|
||||
|
||||
it('set KVP as default request encoding if the GetCap doesn\'t contains Constraint and ResourceUrl tags', function() {
|
||||
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
tmpXml = tmpXml.replace(/<ResourceURL[\s\S]*?"\/>/g, '');
|
||||
|
||||
var tmpCapabilities = parser.read(tmpXml);
|
||||
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
|
||||
expect(tmpCapabilities['Contents']['Layer'][0]['ResourceURL']).to.be(undefined);
|
||||
var options = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql('http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when creating tileUrlFunction', function() {
|
||||
@@ -230,6 +281,70 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setUrls()', function() {
|
||||
it('sets the URL for the source', function() {
|
||||
var source = new ol.source.WMTS({});
|
||||
|
||||
var urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
];
|
||||
source.setUrls(urls);
|
||||
|
||||
expect(source.getUrls()).to.eql(urls);
|
||||
});
|
||||
|
||||
it('updates the key for the source', function() {
|
||||
var source = new ol.source.WMTS({});
|
||||
|
||||
var urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
];
|
||||
source.setUrls(urls);
|
||||
|
||||
expect(source.getKey()).to.eql(urls.join('\n'));
|
||||
});
|
||||
|
||||
it('generates the correct tileUrlFunction during application of setUrl()', function() {
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
var source = new ol.source.WMTS({
|
||||
projection: projection,
|
||||
requestEncoding: 'REST',
|
||||
urls: [
|
||||
'http://1.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg',
|
||||
'http://2.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg'
|
||||
],
|
||||
tileGrid: new ol.tilegrid.WMTS({
|
||||
matrixIds: [0, 1, 2, 3, 4, 5, 6, 7],
|
||||
origin: [2690000, 1285000],
|
||||
resolutions: [4000, 3750, 3500, 3250, 3000, 2750, 2500, 2250]
|
||||
})
|
||||
});
|
||||
|
||||
var urls = [
|
||||
'https://a.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg',
|
||||
'https://b.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg'
|
||||
];
|
||||
source.setUrls(urls);
|
||||
var tileUrl1 = source.tileUrlFunction([2, 9, 4], 1, projection);
|
||||
expect(tileUrl1).to.match(/https\:\/\/[ab]\.example\.com\/2\/-5\/9\.jpg/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('url option', function() {
|
||||
it('expands url template', function() {
|
||||
var tileSource = new ol.source.WMTS({
|
||||
url: '{1-3}'
|
||||
});
|
||||
|
||||
var urls = tileSource.getUrls();
|
||||
expect(urls).to.eql(['1', '2', '3']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getUrls', function() {
|
||||
|
||||
var sourceOptions;
|
||||
|
||||
@@ -66,4 +66,25 @@ describe('ol.style.IconImageCache', function() {
|
||||
expect(cache.get('4', null, null)).to.not.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setSize', function() {
|
||||
it('sets max cache size and expires cache', function() {
|
||||
var cache = ol.style.iconImageCache;
|
||||
|
||||
var i, src, iconImage;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
src = i + '';
|
||||
iconImage = new ol.style.IconImage(null, src);
|
||||
cache.set(src, null, null, iconImage);
|
||||
}
|
||||
|
||||
expect(cache.cacheSize_).to.eql(3);
|
||||
|
||||
cache.setSize(2);
|
||||
|
||||
expect(cache.maxCacheSize_).to.eql(2);
|
||||
expect(cache.cacheSize_).to.eql(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,6 +54,12 @@ describe('ol.style.Text', function() {
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#319FD3'
|
||||
}),
|
||||
backgroundFill: new _ol_style_Fill_({
|
||||
color: 'white'
|
||||
}),
|
||||
backgroundStroke: new _ol_style_Stroke_({
|
||||
color: 'black'
|
||||
})
|
||||
});
|
||||
var clone = original.clone();
|
||||
@@ -68,6 +74,8 @@ describe('ol.style.Text', function() {
|
||||
expect(original.getTextBaseline()).to.eql(clone.getTextBaseline());
|
||||
expect(original.getStroke().getColor()).to.eql(clone.getStroke().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() {
|
||||
|
||||