Compare commits

..

1 Commits

Author SHA1 Message Date
Tim Schaub
aa7aee5ab3 4.0.0-beta.1 2017-02-06 16:23:06 -07:00
148 changed files with 664 additions and 3011 deletions

View File

@@ -3,10 +3,7 @@ sudo: false
language: node_js
node_js:
- "6.1"
addons:
firefox: "52.0"
- "6"
cache:
directories:
@@ -20,7 +17,7 @@ before_install:
before_script:
- "rm src/ol/renderer/webgl/*shader.js"
- "sh -e /etc/init.d/xvfb start"
- "npm ls || true"
- "npm ls"
script: "make ci"

View File

@@ -4,7 +4,7 @@ Thanks for your interest in contributing to OpenLayers.
## Asking Questions
Please ask questions about using the library on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers).
Please ask questions about using the library on [stackoverflow using the tag 'openlayers-3'](http://stackoverflow.com/questions/tagged/openlayers-3).
When you want to get involved and discuss new features or changes, please use [the mailing list](https://groups.google.com/forum/#!forum/openlayers-dev).

View File

@@ -308,5 +308,4 @@ package:
@cp -r package build
@cd ./src && cp -r ol/* ../build/package
@rm build/package/typedefs.js
@cp css/ol.css build/package
./node_modules/.bin/jscodeshift --transform transforms/module.js build/package

View File

@@ -31,6 +31,6 @@ Please see our guide on [contributing](CONTRIBUTING.md) if you're interested in
## Community
- Need help? Find it on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers)
- Need help? Find it on [stackoverflow using the tag 'openlayers-3'](http://stackoverflow.com/questions/tagged/openlayers-3)
- Follow [@openlayers](https://twitter.com/openlayers) on Twitter
- Discuss with openlayers users on IRC in `#openlayers` at `chat.freenode`

View File

@@ -2,56 +2,10 @@
### Next release
### v4.1.0
#### Adding duplicate layers to a map throws
Previously, you could do this:
```js
map.addLayer(layer);
map.addLayer(layer);
```
However, after adding a duplicate layer, things failed if you tried to remove that layer.
Now, `map.addLayer()` throws if you try adding a layer that has already been added to the map.
#### Simpler `constrainResolution` configuration
The `constrainResolution` configuration for `ol.interaction.PinchZoom` and `ol.interaction.MouseWheelZoom`
can now be set directly with an option in `ol.interaction.defaults`:
```js
ol.interaction.defaults({
constrainResolution: true
});
```
### v4.0.0
#### Simpler `ol.source.Zoomify` `url` configuration
Instead specifying a base url, the `url` for the `ol.source.Zoomify` source can now be a template. The `{TileGroup}`, `{x}`, `{y}`, `{z}` and placeholders must be included in the `url` in this case. the `url` can now also include subdomain placeholders:
```js
new ol.source.Zoomify({
url: 'https://{a-f}.example.com/cgi-bin/iipsrv.fcgi?zoomify=/a/b/{TileGroup}/{z}-{x}-{y}.jpg'
});
```
#### Removal of deprecated methods
The deprecated `ol.animation` functions and `map.beforeRender()` method have been removed. Use `view.animate()` instead.
The `unByKey()` method has been removed from `ol.Observable` instances. Use the `ol.Observable.unByKey()` static function instead.
```js
var key = map.on('moveend', function() { ...});
map.unByKey(key);
```
New code:
```js
var key = map.on('moveend', function() { ...});
ol.Observable.unByKey(key);
```
#### Simplified `ol.View#fit()` API
In most cases, it is no longer necessary to provide an `ol.Size` (previously the 2nd argument) to `ol.View#fit()`. By default, the size of the first map that uses the view will be used. If you want to specify a different size, it goes in the options now (previously the 3rd argument, now the 2nd).

View File

@@ -1,183 +0,0 @@
# 4.0.0
Starting with this version, OpenLayers introduces [Semantic Versioning](http://semver.org). Unlike the switch from v2.x to v3.x, which marked a complete rewrite of the library with an entirely new API, major version increments now simply mean that users should pay attention to the *'Breaking changes'* section of the upgrade notes.
For users of mainstream bundlers and minifiers, OpenLayers is now also available as a set of ES2015 modules. See https://npmjs.com/package/ol/. With that package, bundling only the needed parts of the library with an application is now completely hassle free.
Version 4.0.0 includes enhancements and fixes from 107 pull requests since the previous release.
Among these changes, [#6381](https://github.com/openlayers/openlayers/pull/6381) adds an example which shows how to use [geojson-vt](https://www.npmjs.com/package/geojson-vt) for highly efficient rendering of GeoJSON data as vector tiles.
Several improvements were made to `ol.source.Zoomify`, including projection support ([#6387](https://github.com/openlayers/openlayers/pull/6387)) and support for URL templates ([#6475](https://github.com/openlayers/openlayers/pull/6475)).
Also the `ol.source.ImageArcGISRest` saw some enhancements, including HiDPI/Retina support and a fix that avoids non-integer DPI values ([#6300](https://github.com/openlayers/openlayers/pull/6300) and [#6467](https://github.com/openlayers/openlayers/pull/6467)).
On the topic of drawing tools, @tst-ppenev completed an effort to make the `ol.interaction.Modify` interaction support modification of `ol.geom.Circle` geometries ([#6457](https://github.com/openlayers/openlayers/pull/6457)).
## Breaking changes
### Simplified `ol.View#fit()` API
In most cases, it is no longer necessary to provide an `ol.Size` (previously the 2nd argument) to `ol.View#fit()`. By default, the size of the first map that uses the view will be used. If you want to specify a different size, it goes in the options now (previously the 3rd argument, now the 2nd).
Most common use case - old API:
```js
map.getView().fit(extent, map.getSize());
```
Most common use case - new API:
```js
map.getView().fit(extent);
```
Advanced use - old API:
```js
map.getView().fit(extent, [200, 100], {padding: 10});
```
Advanced use - new API:
```js
map.getView().fit(extent, {size: [200, 100], padding 10});
```
### Removal of deprecated methods
The deprecated `ol.animation` functions and `map.beforeRender()` method have been removed. Use `view.animate()` instead.
The `unByKey()` method has been removed from `ol.Observable` instances. Use the `ol.Observable.unByKey()` static function instead.
```js
var key = map.on('moveend', function() { ...});
map.unByKey(key);
```
New code:
```js
var key = map.on('moveend', function() { ...});
ol.Observable.unByKey(key);
```
## Upgrade notes
### Simpler `ol.source.Zoomify` `url` configuration
Instead specifying a base url, the `url` for the `ol.source.Zoomify` source can now be a template. The `{TileGroup}`, `{x}`, `{y}`, `{z}` and placeholders must be included in the `url` in this case. the `url` can now also include subdomain placeholders:
```js
new ol.source.Zoomify({
url: 'https://{a-f}.example.com/cgi-bin/iipsrv.fcgi?zoomify=/a/b/{TileGroup}/{z}-{x}-{y}.jpg'
});
```
#### Removed build flags (`@define`)
The `ol.DEBUG`, `ol.ENABLE_TILE`, `ol.ENABLE_IMAGE`, `ol.ENABLE_VECTOR`, and `ol.ENABLE_VECTOR_TILE` build flags are no longer necessary and have been removed. If you were using these in a `define` array for a custom build, you can remove them.
If you leave `ol.ENABLE_WEBGL` set to `true` in your build, you should set `ol.DEBUG_WEBGL` to `false` to avoid including debuggable shader sources.
## List of all changes
* [#6477](https://github.com/openlayers/openlayers/pull/6477) - Save and restore context when rotating ([@ahocevar](https://github.com/ahocevar))
* [#6475](https://github.com/openlayers/openlayers/pull/6475) - Use an url template for ol.source.Zoomify ([@fredj](https://github.com/fredj))
* [#6478](https://github.com/openlayers/openlayers/pull/6478) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6472](https://github.com/openlayers/openlayers/pull/6472) - Use fixed pixel ratio for hit tolerance tests ([@ahocevar](https://github.com/ahocevar))
* [#6468](https://github.com/openlayers/openlayers/pull/6468) - Remove console.assert in ol.structs.PriorityQueue tests ([@fredj](https://github.com/fredj))
* [#6467](https://github.com/openlayers/openlayers/pull/6467) - Round the DPI value in ol.source.ImageArcGISRest ([@fredj](https://github.com/fredj))
* [#6466](https://github.com/openlayers/openlayers/pull/6466) - Small XML error in KML test ([@tchandelle](https://github.com/tchandelle))
* [#6410](https://github.com/openlayers/openlayers/pull/6410) - fixed the degreesToStringHDMS_() function to promote a seconds value … ([@rjackson64840](https://github.com/rjackson64840))
* [#6461](https://github.com/openlayers/openlayers/pull/6461) - Add button to edit examples in CodePen ([@tchandelle](https://github.com/tchandelle))
* [#6320](https://github.com/openlayers/openlayers/pull/6320) - Use the 'openlayers' tag instead of 'openlayers-3' ([@ahocevar](https://github.com/ahocevar))
* [#6460](https://github.com/openlayers/openlayers/pull/6460) - Remove ol.Observable#unByKey ([@fredj](https://github.com/fredj))
* [#6463](https://github.com/openlayers/openlayers/pull/6463) - chore(package): update clean-css-cli to version 4.0.5 ([@openlayers](https://github.com/openlayers))
* [#6459](https://github.com/openlayers/openlayers/pull/6459) - Use ol.coordinate.distance ([@fredj](https://github.com/fredj))
* [#6457](https://github.com/openlayers/openlayers/pull/6457) - Add Circle Modification ([@tst-ppenev](https://github.com/tst-ppenev))
* [#6455](https://github.com/openlayers/openlayers/pull/6455) - Make all @api annotations imply stability ([@tschaub](https://github.com/tschaub))
* [#6452](https://github.com/openlayers/openlayers/pull/6452) - Remove deprecated methods ([@tschaub](https://github.com/tschaub))
* [#6361](https://github.com/openlayers/openlayers/pull/6361) - Remove "margin" at the bottom of the canvas ([@tchandelle](https://github.com/tchandelle))
* [#6450](https://github.com/openlayers/openlayers/pull/6450) - Update coveralls to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6302](https://github.com/openlayers/openlayers/pull/6302) - Publish a package for use with ES module bundlers ([@tschaub](https://github.com/tschaub))
* [#6446](https://github.com/openlayers/openlayers/pull/6446) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6445](https://github.com/openlayers/openlayers/pull/6445) - Fix pinch zooming ([@tschaub](https://github.com/tschaub))
* [#6444](https://github.com/openlayers/openlayers/pull/6444) - Disallow pinch zooming beyond min/max resolution ([@tschaub](https://github.com/tschaub))
* [#6443](https://github.com/openlayers/openlayers/pull/6443) - goog.require cleanup ([@openlayers](https://github.com/openlayers))
* [#6439](https://github.com/openlayers/openlayers/pull/6439) - Improve tile render performance ([@ahocevar](https://github.com/ahocevar))
* [#6442](https://github.com/openlayers/openlayers/pull/6442) - Fix missing goog.require ([@fredj](https://github.com/fredj))
* [#6441](https://github.com/openlayers/openlayers/pull/6441) - Update metalsmith-layouts to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6437](https://github.com/openlayers/openlayers/pull/6437) - Fit on circle ([@tchandelle](https://github.com/tchandelle))
* [#6427](https://github.com/openlayers/openlayers/pull/6427) - Ensure WMS width and height are always integers ([@ahocevar](https://github.com/ahocevar))
* [#6432](https://github.com/openlayers/openlayers/pull/6432) - Use ol.proj.EPSG3857.WORLD_EXTENT in ol.source.TileImage tests ([@fredj](https://github.com/fredj))
* [#6424](https://github.com/openlayers/openlayers/pull/6424) - Update dependencies to enable Greenkeeper 🌴 ([@openlayers](https://github.com/openlayers))
* [#6422](https://github.com/openlayers/openlayers/pull/6422) - Don't listen twice to move and end events in ol.control.ZoomSlider ([@fredj](https://github.com/fredj))
* [#6426](https://github.com/openlayers/openlayers/pull/6426) - Add rewrite_polyfills to custom builds tutorial ([@probins](https://github.com/probins))
* [#6365](https://github.com/openlayers/openlayers/pull/6365) - Make enums for draw and modify interactions public ([@gberaudo](https://github.com/gberaudo))
* [#6294](https://github.com/openlayers/openlayers/pull/6294) - Update code for closure-compiler v20170124 ([@fredj](https://github.com/fredj))
* [#6413](https://github.com/openlayers/openlayers/pull/6413) - Accept ol.StyleFunction in ol.Feature#setStyle() ([@ahocevar](https://github.com/ahocevar))
* [#6398](https://github.com/openlayers/openlayers/pull/6398) - Be more tolerant of map and position value ([@fredj](https://github.com/fredj))
* [#6399](https://github.com/openlayers/openlayers/pull/6399) - Small doc fix in VectorTileOptions renderMode ([@tchandelle](https://github.com/tchandelle))
* [#6396](https://github.com/openlayers/openlayers/pull/6396) - Show current year in attribution in "HERE Map Tile API" example ([@chrismayer](https://github.com/chrismayer))
* [#6390](https://github.com/openlayers/openlayers/pull/6390) - Tag deprecated functions with @deprecated ([@fredj](https://github.com/fredj))
* [#6370](https://github.com/openlayers/openlayers/pull/6370) - Feature apidoc, fix events and observable properties ([@tchandelle](https://github.com/tchandelle))
* [#6376](https://github.com/openlayers/openlayers/pull/6376) - Make ol.format.filter.or/and accept n filter conditions ([@tsauerwein](https://github.com/tsauerwein))
* [#6393](https://github.com/openlayers/openlayers/pull/6393) - Only stop animation when animating ([@ahocevar](https://github.com/ahocevar))
* [#6387](https://github.com/openlayers/openlayers/pull/6387) - Add projection option to ol.source.Zoomify ([@ahocevar](https://github.com/ahocevar))
* [#6386](https://github.com/openlayers/openlayers/pull/6386) - Snap : only listen to change event triggered by the feature ([@tchandelle](https://github.com/tchandelle))
* [#6383](https://github.com/openlayers/openlayers/pull/6383) - Modify interaction: check if interaction is active before drawing modifying vertex ([@tchandelle](https://github.com/tchandelle))
* [#6381](https://github.com/openlayers/openlayers/pull/6381) - geojson-vt integration example ([@drnextgis](https://github.com/drnextgis))
* [#6373](https://github.com/openlayers/openlayers/pull/6373) - Use the ol.DEBUG_WEBGL flag to debug shader sources ([@tschaub](https://github.com/tschaub))
* [#6379](https://github.com/openlayers/openlayers/pull/6379) - Set the overview map target in ol.control.OverviewMap.setMap ([@fredj](https://github.com/fredj))
* [#6375](https://github.com/openlayers/openlayers/pull/6375) - Use present in license text ([@bartvde](https://github.com/bartvde))
* [#6371](https://github.com/openlayers/openlayers/pull/6371) - Adjust copyright to include 2017 ([@kolosov-sergey](https://github.com/kolosov-sergey))
* [#6364](https://github.com/openlayers/openlayers/pull/6364) - Make sure moveTo is called after beginPath ([@ahocevar](https://github.com/ahocevar))
* [#6285](https://github.com/openlayers/openlayers/pull/6285) - Make size argument of ol.View#calculateExtent() optional ([@ahocevar](https://github.com/ahocevar))
* [#6357](https://github.com/openlayers/openlayers/pull/6357) - Fix GeoJSONCRSCode definition ([@fredj](https://github.com/fredj))
* [#6362](https://github.com/openlayers/openlayers/pull/6362) - Remove empty file ([@fredj](https://github.com/fredj))
* [#6358](https://github.com/openlayers/openlayers/pull/6358) - Ensure polygons without stroke are fully filled ([@ahocevar](https://github.com/ahocevar))
* [#6356](https://github.com/openlayers/openlayers/pull/6356) - Bring custom builds tutorial up to date ([@probins](https://github.com/probins))
* [#6359](https://github.com/openlayers/openlayers/pull/6359) - When applying a pending fill, also apply a pending stroke ([@ahocevar](https://github.com/ahocevar))
* [#6360](https://github.com/openlayers/openlayers/pull/6360) - Remove ol.array.flatten function ([@openlayers](https://github.com/openlayers))
* [#6353](https://github.com/openlayers/openlayers/pull/6353) - API doc : add highlight style to the active anchor ([@tchandelle](https://github.com/tchandelle))
* [#6355](https://github.com/openlayers/openlayers/pull/6355) - Remove test.geojson which was accidently committed in 57342a6 ([@ahocevar](https://github.com/ahocevar))
* [#6349](https://github.com/openlayers/openlayers/pull/6349) - Better documentation for icon-color example ([@ahocevar](https://github.com/ahocevar))
* [#6351](https://github.com/openlayers/openlayers/pull/6351) - Only consider pointerdown event if the last pointerup has been emitted ([@tchandelle](https://github.com/tchandelle))
* [#6345](https://github.com/openlayers/openlayers/pull/6345) - Mitigate rounding errors in GetMap width/height calculation ([@giohappy](https://github.com/giohappy))
* [#6344](https://github.com/openlayers/openlayers/pull/6344) - No special raster reprojection handling for Chrome ([@ahocevar](https://github.com/ahocevar))
* [#6339](https://github.com/openlayers/openlayers/pull/6339) - Code cleanup ([@fredj](https://github.com/fredj))
* [#6337](https://github.com/openlayers/openlayers/pull/6337) - Constrain center in DragZoom interaction ([@tchandelle](https://github.com/tchandelle))
* [#6336](https://github.com/openlayers/openlayers/pull/6336) - Remove unused ol.format.Feature.getExtensions function ([@fredj](https://github.com/fredj))
* [#6333](https://github.com/openlayers/openlayers/pull/6333) - Use API key for Thunderforest resources ([@ahocevar](https://github.com/ahocevar))
* [#6300](https://github.com/openlayers/openlayers/pull/6300) - Add missing hidpi option for ol.source.ImageArcGISRest ([@fredj](https://github.com/fredj))
* [#6109](https://github.com/openlayers/openlayers/pull/6109) - Export Map as PNG (IE issue) ([@NaveenKY](https://github.com/NaveenKY))
* [#6332](https://github.com/openlayers/openlayers/pull/6332) - Constrain the center in zoomByDelta ([@tchandelle](https://github.com/tchandelle))
* [#6331](https://github.com/openlayers/openlayers/pull/6331) - Remove unused map parameter from ol.interaction.Interaction ([@tchandelle](https://github.com/tchandelle))
* [#6326](https://github.com/openlayers/openlayers/pull/6326) - Add lineDashOffset to stroke style ([@tchandelle](https://github.com/tchandelle))
* [#6328](https://github.com/openlayers/openlayers/pull/6328) - ol.geom.polygon documentation update on the coordinates format ([@quentin-ol](https://github.com/quentin-ol))
* [#6324](https://github.com/openlayers/openlayers/pull/6324) - Ensure resolution stays in range when pinching ([@tschaub](https://github.com/tschaub))
* [#6329](https://github.com/openlayers/openlayers/pull/6329) - Fix WMTS theme location for sea-levels layer ([@thomasmoelhave](https://github.com/thomasmoelhave))
* [#6323](https://github.com/openlayers/openlayers/pull/6323) - Fix typo in Introduction ([@hdsnet](https://github.com/hdsnet))
* [#6305](https://github.com/openlayers/openlayers/pull/6305) - Moved hit Tolerance parameter to own example. ([@KlausBenndorf](https://github.com/KlausBenndorf))
* [#6319](https://github.com/openlayers/openlayers/pull/6319) - Remove the '3' from OpenLayers ([@ahocevar](https://github.com/ahocevar))
* [#6314](https://github.com/openlayers/openlayers/pull/6314) - WebGL conditional compilation ([@ahocevar](https://github.com/ahocevar))
* [#6313](https://github.com/openlayers/openlayers/pull/6313) - Remove ol.DEBUG ([@tschaub](https://github.com/tschaub))
* [#6317](https://github.com/openlayers/openlayers/pull/6317) - Update sinon to version 1.17.7 🚀 ([@openlayers](https://github.com/openlayers))
* [#6312](https://github.com/openlayers/openlayers/pull/6312) - Make layers responsible for creating layer renderers ([@tschaub](https://github.com/tschaub))
* [#6308](https://github.com/openlayers/openlayers/pull/6308) - Dedicated modules for shared enums ([@tschaub](https://github.com/tschaub))
* [#6307](https://github.com/openlayers/openlayers/pull/6307) - Dedicated modules for enums ([@tschaub](https://github.com/tschaub))
* [#6297](https://github.com/openlayers/openlayers/pull/6297) - Update resemblejs to version 2.2.3 🚀 ([@openlayers](https://github.com/openlayers))
* [#6296](https://github.com/openlayers/openlayers/pull/6296) - Fix #6295. Update reference link in sphere.js ([@jbelien](https://github.com/jbelien))
* [#6255](https://github.com/openlayers/openlayers/pull/6255) - Don't reset the css cursor if it's not needed ([@fredj](https://github.com/fredj))
* [#6290](https://github.com/openlayers/openlayers/pull/6290) - Use interim tiles ([@ahocevar](https://github.com/ahocevar))
* [#6291](https://github.com/openlayers/openlayers/pull/6291) - Document olx.AtPixelOptions#hitTolerance default value ([@fredj](https://github.com/fredj))
* [#6283](https://github.com/openlayers/openlayers/pull/6283) - Avoid modifying coordinate in forEachLayerAtCoordinate ([@tschaub](https://github.com/tschaub))
* [#6278](https://github.com/openlayers/openlayers/pull/6278) - Add missing require for ol.View ([@tschaub](https://github.com/tschaub))
* [#6280](https://github.com/openlayers/openlayers/pull/6280) - Continue loading tiles when image is not ready yet ([@ahocevar](https://github.com/ahocevar))
* [#6277](https://github.com/openlayers/openlayers/pull/6277) - Name modules more like their provide ([@tschaub](https://github.com/tschaub))
* [#6264](https://github.com/openlayers/openlayers/pull/6264) - Remove the requirement to provide a size to ol.View#fit() ([@ahocevar](https://github.com/ahocevar))
* [#6274](https://github.com/openlayers/openlayers/pull/6274) - Update clean-css to version 3.4.23 🚀 ([@openlayers](https://github.com/openlayers))
* [#6269](https://github.com/openlayers/openlayers/pull/6269) - Update derequire to version 2.0.6 🚀 ([@openlayers](https://github.com/openlayers))
* [#6270](https://github.com/openlayers/openlayers/pull/6270) - Add a magnify example ([@tschaub](https://github.com/tschaub))
* [#6261](https://github.com/openlayers/openlayers/pull/6261) - Fit Zoomify view to image extent ([@ahocevar](https://github.com/ahocevar))
* [#6259](https://github.com/openlayers/openlayers/pull/6259) - Simplify Zoomify example ([@ahocevar](https://github.com/ahocevar))
* [#6260](https://github.com/openlayers/openlayers/pull/6260) - Enhance documentation for ol.View#fit ([@marcjansen](https://github.com/marcjansen))
* [#6258](https://github.com/openlayers/openlayers/pull/6258) - Set geometry name properly ([@ahocevar](https://github.com/ahocevar))
* [#6251](https://github.com/openlayers/openlayers/pull/6251) - Take image pixel ratio into account for rendered resolution ([@ahocevar](https://github.com/ahocevar))
* [#6244](https://github.com/openlayers/openlayers/pull/6244) - Enforces spacing around commas ([@fredj](https://github.com/fredj))
* [#6246](https://github.com/openlayers/openlayers/pull/6246) - Re-render vector tiles when layer has changed ([@ahocevar](https://github.com/ahocevar))
* [#6243](https://github.com/openlayers/openlayers/pull/6243) - Consistent spacing between keys and values in object literal ([@fredj](https://github.com/fredj))
* [#6238](https://github.com/openlayers/openlayers/pull/6238) - Update eslint to version 3.12.1 🚀 ([@openlayers](https://github.com/openlayers))
* [#6236](https://github.com/openlayers/openlayers/pull/6236) - Update clean-css to version 3.4.22 🚀 ([@openlayers](https://github.com/openlayers))

View File

@@ -1,11 +0,0 @@
# 4.0.1
## Summary
The v4.0.1 release is a patch release that addresses a regression in the v4.0.0 release. The fix makes pinch zooming work again properly when the two fingers are not placed on the screen at the same time.
See the [v4.0.0 release notes](https://github.com/openlayers/openlayers/releases/tag/v4.0.0) for details on upgrading from v3.20.x.
## Fix
* [#6486](https://github.com/openlayers/openlayers/pull/6486) - Do not set center when touches count has changed ([@ahocevar](https://github.com/ahocevar))

View File

@@ -1,127 +0,0 @@
# 4.1.0
## Summary
The v4.1.0 release includes features and fixes from 91 pull requests.
#### Interactive overview map
The extent rectangle on the overview map can now be dragged to control the view for the main map.
#### Setting min and max zoom for a view
You can now change the min or max zoom for a view after it has been created. This can be useful if you want to limit how far out users can zoom based on changes in viewport width (use `view.setMinZoom()` for this).
#### Adding duplicate layers to a map throws
Previously, you could do this:
```js
map.addLayer(layer);
map.addLayer(layer);
```
However, after adding a duplicate layer, things failed if you tried to remove that layer.
Now, `map.addLayer()` throws if you try adding a layer that has already been added to the map.
#### Simpler `constrainResolution` configuration
The `constrainResolution` configuration for `ol.interaction.PinchZoom` and `ol.interaction.MouseWheelZoom`
can now be set directly with an option in `ol.interaction.defaults`:
```js
ol.interaction.defaults({
constrainResolution: true
});
```
## Detailed changes
* [#6675](https://github.com/openlayers/openlayers/pull/6675) - Reset cursor when translate interaction is removed or deactivated ([@tchandelle](https://github.com/tchandelle))
* [#6707](https://github.com/openlayers/openlayers/pull/6707) - Set version when building ol package ([@tschaub](https://github.com/tschaub))
* [#6706](https://github.com/openlayers/openlayers/pull/6706) - Add ol.source.Cluster#getDistance function ([@fredj](https://github.com/fredj))
* [#6695](https://github.com/openlayers/openlayers/pull/6695) - Unique layers ([@tschaub](https://github.com/tschaub))
* [#6704](https://github.com/openlayers/openlayers/pull/6704) - Include typedefs.js in closure compiler tutorial build configurations ([@openlayers](https://github.com/openlayers))
* [#6702](https://github.com/openlayers/openlayers/pull/6702) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6693](https://github.com/openlayers/openlayers/pull/6693) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6691](https://github.com/openlayers/openlayers/pull/6691) - Move eslint globals to to test/.eslintrc ([@fredj](https://github.com/fredj))
* [#6689](https://github.com/openlayers/openlayers/pull/6689) - Add new constrainResolution option to olx.interaction.DefaultsOptions ([@fredj](https://github.com/fredj))
* [#6692](https://github.com/openlayers/openlayers/pull/6692) - Improve docs for MouseWheelZoom constrainResolution ([@ahocevar](https://github.com/ahocevar))
* [#6687](https://github.com/openlayers/openlayers/pull/6687) - Clip image only if the layer extent intersects the view extent ([@tchandelle](https://github.com/tchandelle))
* [#6686](https://github.com/openlayers/openlayers/pull/6686) - Update finishCoordinate in ol.interaction.Draw#removeLastPoint ([@fredj](https://github.com/fredj))
* [#6682](https://github.com/openlayers/openlayers/pull/6682) - Add example, docs and typedef for MouseWheelZoom's constrainResolution option ([@ahocevar](https://github.com/ahocevar))
* [#6683](https://github.com/openlayers/openlayers/pull/6683) - Add this jsdoc tag to ol.interaction.DragBox.defaultBoxEndCondition ([@fredj](https://github.com/fredj))
* [#6681](https://github.com/openlayers/openlayers/pull/6681) - Add constrainResolution in olx.interaction.PinchZoomOptions typedef ([@fredj](https://github.com/fredj))
* [#6671](https://github.com/openlayers/openlayers/pull/6671) - Add constraintResolution option to MouseWheelZoom for zoom with trackpad ([@kaiCu](https://github.com/kaiCu))
* [#6680](https://github.com/openlayers/openlayers/pull/6680) - Remove ol.DRAG_BOX_HYSTERESIS_PIXELS define and add option ([@fredj](https://github.com/fredj))
* [#6666](https://github.com/openlayers/openlayers/pull/6666) - Use the optional extent in ol.structs.RBush#getExtent ([@fredj](https://github.com/fredj))
* [#6670](https://github.com/openlayers/openlayers/pull/6670) - fix(package): update browserify to version 14.3.0 ([@openlayers](https://github.com/openlayers))
* [#6664](https://github.com/openlayers/openlayers/pull/6664) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6659](https://github.com/openlayers/openlayers/pull/6659) - Add crossOrigin to examples using ol.style.Icon ([@openlayers](https://github.com/openlayers))
* [#6658](https://github.com/openlayers/openlayers/pull/6658) - Fixes for raster source rendering ([@tschaub](https://github.com/tschaub))
* [#6620](https://github.com/openlayers/openlayers/pull/6620) - Fix the parsing of flat coordinates in GML2 for 3D geometies ([@Jenselme](https://github.com/Jenselme))
* [#6657](https://github.com/openlayers/openlayers/pull/6657) - Update coveralls to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6644](https://github.com/openlayers/openlayers/pull/6644) - Allow minZoom and maxZoom to be set on a view ([@tschaub](https://github.com/tschaub))
* [#6636](https://github.com/openlayers/openlayers/pull/6636) - Add test for the metric unit displayed in the scaleline ([@fredj](https://github.com/fredj))
* [#6598](https://github.com/openlayers/openlayers/pull/6598) - Add support of micrometers to scaleline ([@hajjimurad](https://github.com/hajjimurad))
* [#6643](https://github.com/openlayers/openlayers/pull/6643) - Add common transforms by default ([@tschaub](https://github.com/tschaub))
* [#6567](https://github.com/openlayers/openlayers/pull/6567) - Overlay visible before updating render position ([@nagytech](https://github.com/nagytech))
* [#6634](https://github.com/openlayers/openlayers/pull/6634) - Fix custom build when openlayers is installed from yarn package manager ([@Toilal](https://github.com/Toilal))
* [#6639](https://github.com/openlayers/openlayers/pull/6639) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6635](https://github.com/openlayers/openlayers/pull/6635) - Add missing externs to custom builds examples ([@Toilal](https://github.com/Toilal))
* [#6631](https://github.com/openlayers/openlayers/pull/6631) - Fix request image size caclulation ([@ahocevar](https://github.com/ahocevar))
* [#6627](https://github.com/openlayers/openlayers/pull/6627) - Change css selector for user-select none ([@bartvde](https://github.com/bartvde))
* [#6626](https://github.com/openlayers/openlayers/pull/6626) - Respect cacheSize for reprojected caches ([@ahocevar](https://github.com/ahocevar))
* [#6623](https://github.com/openlayers/openlayers/pull/6623) - Fix outerWidth and outerHeight calculation in IE ([@ahocevar](https://github.com/ahocevar))
* [#6625](https://github.com/openlayers/openlayers/pull/6625) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6622](https://github.com/openlayers/openlayers/pull/6622) - Fix proj4 type ([@gberaudo](https://github.com/gberaudo))
* [#6617](https://github.com/openlayers/openlayers/pull/6617) - Use GeoServer/GWC caching when possible ([@ahocevar](https://github.com/ahocevar))
* [#6614](https://github.com/openlayers/openlayers/pull/6614) - Filter write util method ([@adube](https://github.com/adube))
* [#6616](https://github.com/openlayers/openlayers/pull/6616) - Fix closing tag in gml tests ([@fredj](https://github.com/fredj))
* [#6612](https://github.com/openlayers/openlayers/pull/6612) - Add support for WFS 1.0.0 to ol.format.WFS#writeTransaction ([@Jenselme](https://github.com/Jenselme))
* [#5887](https://github.com/openlayers/openlayers/pull/5887) - Interactive overview map ([@felixveysseyre](https://github.com/felixveysseyre))
* [#6610](https://github.com/openlayers/openlayers/pull/6610) - Fix event type case of MSPointerDown ([@ahocevar](https://github.com/ahocevar))
* [#6611](https://github.com/openlayers/openlayers/pull/6611) - Update jquery to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6609](https://github.com/openlayers/openlayers/pull/6609) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6606](https://github.com/openlayers/openlayers/pull/6606) - Reset dragSegments after vertex deletion ([@ahocevar](https://github.com/ahocevar))
* [#6523](https://github.com/openlayers/openlayers/pull/6523) - Add Gml2 serializers to support WFS-T 1.0.0 ([@Jenselme](https://github.com/Jenselme))
* [#6579](https://github.com/openlayers/openlayers/pull/6579) - Update slimerjs to v0.10.3 ([@fredj](https://github.com/fredj))
* [#6577](https://github.com/openlayers/openlayers/pull/6577) - Adding crossOrigin to optionsFromCapabilities ([@fredj](https://github.com/fredj))
* [#6604](https://github.com/openlayers/openlayers/pull/6604) - Fix RegularShape documentation ([@ahocevar](https://github.com/ahocevar))
* [#6603](https://github.com/openlayers/openlayers/pull/6603) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6601](https://github.com/openlayers/openlayers/pull/6601) - Update jquery to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6600](https://github.com/openlayers/openlayers/pull/6600) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6578](https://github.com/openlayers/openlayers/pull/6578) - Add ol.RenderOrderFunction typedef ([@icholy](https://github.com/icholy))
* [#6589](https://github.com/openlayers/openlayers/pull/6589) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6592](https://github.com/openlayers/openlayers/pull/6592) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6594](https://github.com/openlayers/openlayers/pull/6594) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6580](https://github.com/openlayers/openlayers/pull/6580) - Remove unused esprima package ([@fredj](https://github.com/fredj))
* [#6570](https://github.com/openlayers/openlayers/pull/6570) - Don't use deprecated sinon.stub(obj, 'meth', fn) ([@openlayers](https://github.com/openlayers))
* [#6569](https://github.com/openlayers/openlayers/pull/6569) - Return null if the layer was not found in the WMTS capabilities ([@fredj](https://github.com/fredj))
* [#6551](https://github.com/openlayers/openlayers/pull/6551) - Use the default fill and stroke color ([@fredj](https://github.com/fredj))
* [#6560](https://github.com/openlayers/openlayers/pull/6560) - Dont crash if feature loader xhr response returns 500 ([@geosense](https://github.com/geosense))
* [#6559](https://github.com/openlayers/openlayers/pull/6559) - Remove unneeded type cast ([@fredj](https://github.com/fredj))
* [#6558](https://github.com/openlayers/openlayers/pull/6558) - Update coveralls to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6553](https://github.com/openlayers/openlayers/pull/6553) - Update proj4 to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6554](https://github.com/openlayers/openlayers/pull/6554) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6549](https://github.com/openlayers/openlayers/pull/6549) - Make getAnimating and cancelAnimations @api ([@bartvde](https://github.com/bartvde))
* [#6547](https://github.com/openlayers/openlayers/pull/6547) - Clean up left-over code from animation changes ([@bartvde](https://github.com/bartvde))
* [#6540](https://github.com/openlayers/openlayers/pull/6540) - More precise ol.Geolocation#getAccuracyGeometry return type ([@openlayers](https://github.com/openlayers))
* [#6539](https://github.com/openlayers/openlayers/pull/6539) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6535](https://github.com/openlayers/openlayers/pull/6535) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6529](https://github.com/openlayers/openlayers/pull/6529) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6530](https://github.com/openlayers/openlayers/pull/6530) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6515](https://github.com/openlayers/openlayers/pull/6515) - Add view methods for getting max zoom, min zoom, and any zoom for a resolution ([@tschaub](https://github.com/tschaub))
* [#6520](https://github.com/openlayers/openlayers/pull/6520) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6518](https://github.com/openlayers/openlayers/pull/6518) - Fix olx.style.IconOptions.prototype.src type ([@fredj](https://github.com/fredj))
* [#6513](https://github.com/openlayers/openlayers/pull/6513) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#6512](https://github.com/openlayers/openlayers/pull/6512) - Complete animations at target values ([@tschaub](https://github.com/tschaub))
* [#6511](https://github.com/openlayers/openlayers/pull/6511) - Revert accidently committed example change ([@ahocevar](https://github.com/ahocevar))
* [#6507](https://github.com/openlayers/openlayers/pull/6507) - ol.DEBUG no longer needed in transforms/module.js ([@probins](https://github.com/probins))
* [#6505](https://github.com/openlayers/openlayers/pull/6505) - Update ol package to include Browserify config ([@tschaub](https://github.com/tschaub))
* [#6504](https://github.com/openlayers/openlayers/pull/6504) - Determine if we should handle the drawing while the pointer is moving ([@tchandelle](https://github.com/tchandelle))
* [#6499](https://github.com/openlayers/openlayers/pull/6499) - Be more tolerant when comparing vertices when modifying a circle ([@tchandelle](https://github.com/tchandelle))
* [#6498](https://github.com/openlayers/openlayers/pull/6498) - Travis failing on master - use Node v6.1.x ([@ahocevar](https://github.com/ahocevar))
* [#6493](https://github.com/openlayers/openlayers/pull/6493) - Vector tile cleanup ([@ahocevar](https://github.com/ahocevar))
* [#6483](https://github.com/openlayers/openlayers/pull/6483) - Fix renderer.canvas.TileLayer to calculate correct canvas height for drawing. ([@nearmap](https://github.com/nearmap))
* [#6488](https://github.com/openlayers/openlayers/pull/6488) - Do not draw circle when pointer not moved and freehand is on ([@tchandelle](https://github.com/tchandelle))
* [#6491](https://github.com/openlayers/openlayers/pull/6491) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))

View File

@@ -1,13 +0,0 @@
# 4.1.1
## Summary
This is a patch release to fix several minor issues and two regressions in the [4.1.0 release](https://github.com/openlayers/openlayers/releases/tag/v4.1.0).
## Changes
* [#6711](https://github.com/openlayers/openlayers/pull/6711) - Correct path to cleancss ([@tschaub](https://github.com/tschaub))
* [#6728](https://github.com/openlayers/openlayers/pull/6728) - Fix tissot examples docs ([@fredj](https://github.com/fredj))
* [#6732](https://github.com/openlayers/openlayers/pull/6732) - Use firefox < 53 in travis ([@fredj](https://github.com/fredj))
* [#6741](https://github.com/openlayers/openlayers/pull/6741) - Allow user selection in overlay container ([@fredj](https://github.com/fredj))
* [#6755](https://github.com/openlayers/openlayers/pull/6755) - Add missing goog.require ([@fredj](https://github.com/fredj))

View File

@@ -59,16 +59,14 @@
<div class="row-fluid">
<div id="source-controls">
<a id="copy-button"><i class="fa fa-clipboard"></i> Copy</a>
<a id="codepen-button"><i class="fa fa-codepen"></i> Edit</a>
<a id="jsfiddle-button"><i class="fa fa-jsfiddle"></i> Edit</a>
</div>
<form method="POST" id="codepen-form" target="_blank" action="https://codepen.io/pen/define/">
<textarea class="hidden" name="title">{{ title }}</textarea>
<textarea class="hidden" name="description">{{ shortdesc }}</textarea>
<form method="POST" id="jsfiddle-form" target="_blank" action="https://jsfiddle.net/api/post/library/pure/">
<textarea class="hidden" name="js">{{ js.source }}</textarea>
<textarea class="hidden" name="css">{{ css.source }}</textarea>
<textarea class="hidden" name="html">{{ contents }}</textarea>
<input type="hidden" name="wrap" value="l">
<input type="hidden" name="resources" value="https://openlayers.org/en/v{{ olVersion }}/css/ol.css,https://openlayers.org/en/v{{ olVersion }}/build/ol.js{{ extraResources }}">
<input type="hidden" name="data">
</form>
<pre><code id="example-source" class="language-markup">&lt;!DOCTYPE html&gt;
&lt;html&gt;

View File

@@ -34,21 +34,16 @@
.ol-unsupported {
display: none;
}
.ol-viewport, .ol-unselectable {
.ol-viewport .ol-unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-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-control {
position: absolute;
background-color: rgba(255,255,255,0.4);
@@ -244,7 +239,3 @@
.ol-overviewmap-box {
border: 2px dotted rgba(0,60,136,0.7);
}
.ol-overviewmap .ol-overviewmap-box:hover {
cursor: move;
}

View File

@@ -220,7 +220,3 @@ The `{-y}` placeholder requires a tile grid with extent.
### 57
At least 2 conditions are required.
### 58
Duplicate item added to a unique collection. For example, it may be that you tried to add the same layer to a map twice. Check for calls to `map.addLayer()` or other places where the map's layer collection is modified.

View File

@@ -7,7 +7,7 @@ layout: doc.hbs
Certain questions arise more often than others when users ask for help. This
document tries to list some of the common questions that frequently get asked,
e.g. on [Stack Overflow](http://stackoverflow.com/questions/tagged/openlayers).
e.g. on [Stack Overflow](http://stackoverflow.com/questions/tagged/openlayers-3).
If you think a question (and naturally its answer) should be added here, feel
free to ping us or to send a pull request enhancing this document.

View File

@@ -19,4 +19,4 @@ We have put together a document that lists [Frequently Asked Questions (FAQ)](fa
# More questions?
If you cannot find an answer in the documentation or the FAQ, you can ask your question on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers).
If you cannot find an answer in the documentation or the FAQ, you can ask your question on [stackoverflow using the tag 'openlayers-3'](http://stackoverflow.com/questions/tagged/openlayers-3).

View File

@@ -172,7 +172,6 @@ The minimum config file looks like this:
"ol.ENABLE_WEBGL=false"
],
"js": [
"node_modules/openlayers/src/ol/typedefs.js",
"node_modules/openlayers/externs/olx.js",
"node_modules/openlayers/externs/oli.js"
],
@@ -224,7 +223,6 @@ Here is a version of `config.json` with more compilation checks enabled:
"ol.ENABLE_WEBGL=false"
],
"js": [
"node_modules/openlayers/src/ol/typedefs.js",
"node_modules/openlayers/externs/olx.js",
"node_modules/openlayers/externs/oli.js"
],

View File

@@ -51,9 +51,7 @@ Creating a custom build requires writing a build configuration file. The format
"compile": {
"externs": [
"externs/bingmaps.js",
"externs/cartodb.js",
"externs/closure-compiler.js",
"externs/esrijson.js",
"externs/geojson.js",
"externs/oli.js",
"externs/olx.js",
@@ -203,16 +201,9 @@ Now let's try a more complicated example: [`heatmaps-earthquakes`](https://openl
],
"compile": {
"externs": [
"externs/bingmaps.js",
"externs/cartodb.js",
"externs/closure-compiler.js",
"externs/esrijson.js",
"externs/geojson.js",
"externs/olx.js",
"externs/oli.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js"
"externs/oli.js"
],
"define": [
"ol.ENABLE_WEBGL=false",

View File

@@ -45,7 +45,7 @@ The easiest way to use a custom projection is to add the [Proj4js](http://proj4j
Following example shows definition of a [British National Grid](https://epsg.io/27700):
``` html
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.14/proj4.js"></script>
```
``` javascript

View File

@@ -11,8 +11,7 @@ var layers = [
source: new ol.source.TileWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
'TILED': true
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}
})
})

View File

@@ -6,7 +6,7 @@ goog.require('ol.source.TileWMS');
var wmsSource = new ol.source.TileWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {'LAYERS': 'ne:ne', 'TILED': true},
params: {'LAYERS': 'ne:ne'},
serverType: 'geoserver',
crossOrigin: 'anonymous'
});

View File

@@ -26,7 +26,6 @@ var madrid = new ol.Feature({
rome.setStyle(new ol.style.Style({
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
color: '#8959A8',
crossOrigin: 'anonymous',
src: 'data/dot.png'
}))
}));
@@ -34,7 +33,6 @@ rome.setStyle(new ol.style.Style({
london.setStyle(new ol.style.Style({
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
color: '#4271AE',
crossOrigin: 'anonymous',
src: 'data/dot.png'
}))
}));
@@ -42,7 +40,6 @@ london.setStyle(new ol.style.Style({
madrid.setStyle(new ol.style.Style({
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
color: [113, 140, 0],
crossOrigin: 'anonymous',
src: 'data/dot.png'
}))
}));

View File

@@ -15,7 +15,6 @@ function createStyle(src, img) {
return new ol.style.Style({
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
anchor: [0.5, 0.96],
crossOrigin: 'anonymous',
src: src,
img: img,
imgSize: img ? [img.width, img.height] : undefined

View File

@@ -51,7 +51,6 @@ for (i = 0; i < iconCount; ++i) {
rotation: info.rotation,
scale: info.scale,
size: info.size,
crossOrigin: 'anonymous',
src: 'data/Butterfly.png'
});
}

View File

@@ -1,12 +0,0 @@
---
layout: example.html
title: View Min-Zoom
shortdesc: Demonstrates how the view's minimum zoom level can be changed.
docs: >
The <code>minZoom</code> option for a view limits how far out you can
zoom. This property can be updated by calling <code>view.setMinZoom(newMinZoom)</code>.
In this example, the minimum zoom level is set so that you only see one
world at a time. Resize your browser window to change the threshold.
tags: "min, zoom"
---
<div id="map" class="map"></div>

View File

@@ -1,36 +0,0 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
var viewport = document.getElementById('map');
function getMinZoom() {
var width = viewport.clientWidth;
return Math.ceil(Math.LOG2E * Math.log(width / 256));
}
var initialZoom = getMinZoom();
var view = new ol.View({
center: [0, 0],
minZoom: initialZoom,
zoom: initialZoom
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
view: view
});
window.addEventListener('resize', function() {
var minZoom = getMinZoom();
if (minZoom !== view.getMinZoom()) {
view.setMinZoom(minZoom);
}
});

View File

@@ -1,12 +0,0 @@
---
layout: example.html
title: Mousewheel/Trackpad Zoom
shortdesc: Restrict wheel/trackpad zooming to integer zoom levels.
docs: >
By default, the `ol.interaction.MouseWheelZoom` can leave the map at
fractional zoom levels. If instead you want to constrain wheel/trackpad
zooming to integer zoom levels, set <code>constrainResolution: true</code>
when constructing the interaction.
tags: "trackpad, mousewheel, zoom, interaction"
---
<div id="map" class="map"></div>

View File

@@ -1,25 +0,0 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.interaction');
goog.require('ol.interaction.MouseWheelZoom');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
var map = new ol.Map({
interactions: ol.interaction.defaults({mouseWheelZoom: false}).extend([
new ol.interaction.MouseWheelZoom({
constrainResolution: true // force zooming to a integer zoom
})
]),
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});

View File

@@ -8,7 +8,7 @@ docs: >
in <a href="https://epsg.io/">EPSG.io</a> database.
tags: "reprojection, projection, proj4js, epsg.io"
resources:
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js
---
<div id="map" class="map"></div>
<form class="form-inline">

View File

@@ -6,6 +6,6 @@ docs: >
This example shows client-side reprojection of single image source.
tags: "reprojection, projection, proj4js, image, imagestatic"
resources:
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js
---
<div id="map" class="map"></div>

View File

@@ -6,7 +6,7 @@ docs: >
This example shows client-side raster reprojection between various projections.
tags: "reprojection, projection, proj4js, osm, wms, wmts, hidpi"
resources:
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js
---
<div id="map" class="map"></div>
<form class="form-inline">

View File

@@ -72,8 +72,7 @@ layers['wms4326'] = new ol.layer.Tile({
url: 'https://ahocevar.com/geoserver/wms',
crossOrigin: '',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
'TILED': true
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
},
projection: 'EPSG:4326'
})
@@ -100,15 +99,13 @@ fetch(url).then(function(response) {
return response.text();
}).then(function(text) {
var result = parser.read(text);
var options = ol.source.WMTS.optionsFromCapabilities(result, {
layer: 'OSM_Land_Mask',
matrixSet: 'EPSG3413_250m'
});
var options = ol.source.WMTS.optionsFromCapabilities(result,
{layer: 'OSM_Land_Mask', matrixSet: 'EPSG3413_250m'});
options.crossOrigin = '';
options.projection = 'EPSG:3413';
options.wrapX = false;
layers['wmts3413'] = new ol.layer.Tile({
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
source: new ol.source.WMTS(options)
});
});
@@ -134,7 +131,7 @@ layers['states'] = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'https://ahocevar.com/geoserver/wms',
crossOrigin: '',
params: {'LAYERS': 'topp:states'},
params: {'LAYERS': 'topp:states', 'TILED': true},
serverType: 'geoserver',
tileGrid: new ol.tilegrid.TileGrid({
extent: [-13884991, 2870341, -7455066, 6338219],

View File

@@ -10,40 +10,11 @@
});
}
var codepenButton = document.getElementById('codepen-button');
if (codepenButton) {
codepenButton.onclick = function(event) {
var fiddleButton = document.getElementById('jsfiddle-button');
if (fiddleButton) {
fiddleButton.onclick = function(event) {
event.preventDefault();
var form = document.getElementById('codepen-form');
// Doc : https://blog.codepen.io/documentation/api/prefill/
var resources = form.resources.value.split(',');
var data = {
title: form.title.value,
description: form.description.value,
layout: 'left',
html: form.html.value,
css: form.css.value,
js: form.js.value,
css_external: resources.filter(function(resource) {
return resource.lastIndexOf('.css') === resource.length - 4;
}).join(';'),
js_external: resources.filter(function(resource) {
return resource.lastIndexOf('.js') === resource.length - 3;
}).join(';')
};
// binary flags to display html, css, js and/or console tabs
data.editors = '' + Number(data.html.length > 0) +
Number(data.css.length > 0) +
Number(data.js.length > 0) +
Number(data.js.indexOf('console') > 0);
form.data.value = JSON.stringify(data);
form.submit();
document.getElementById('jsfiddle-form').submit();
};
}

View File

@@ -106,7 +106,7 @@ pre[class*="language-"] {
cursor: pointer;
}
#codepen-button {
#jsfiddle-button {
text-decoration: none;
cursor: pointer;
}

View File

@@ -6,6 +6,6 @@ docs: >
This example shows client-side reprojection of OpenStreetMap to NAD83 Indiana East, including a ScaleLine control with US units.
tags: "reprojection, projection, openstreetmap, nad83, tile, scaleline"
resources:
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js
---
<div id="map" class="map"></div>

View File

@@ -6,6 +6,6 @@ docs: >
Example of a Sphere Mollweide map with a Graticule component.
tags: "graticule, Mollweide, projection, proj4js"
resources:
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js
---
<div id="map" class="map"></div>

View File

@@ -3,7 +3,7 @@ layout: example.html
title: Tissot Indicatrix
shortdesc: Draw Tissot's indicatrices on maps.
docs: >
Example of [Tissot indicatrix](http://en.wikipedia.org/wiki/Tissot's_indicatrix) maps. The map on the top is an `EPSG:4326` map. The one on the bottom is `EPSG:3857`.
Example of [Tissot indicatrix](http://en.wikipedia.org/wiki/Tissot's_indicatrix)</a> maps. The map on the left is an EPSG:4326 map. The one on the right is EPSG:3857.
tags: "tissot, circle"
---
<h4>EPSG:4326</h4>

View File

@@ -22,8 +22,7 @@ var map4326 = new ol.Map({
source: new ol.source.TileWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
'TILED': true
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}
})
}),
@@ -43,8 +42,7 @@ var map3857 = new ol.Map({
source: new ol.source.TileWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
'TILED': true
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}
})
}),

View File

@@ -6,7 +6,7 @@ docs: >
With [Proj4js](http://proj4js.org/) integration, OpenLayers can transform coordinates between arbitrary projections.
tags: "wms, single image, proj4js, projection"
resources:
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js
- https://epsg.io/21781-1753.js
---
<div id="map" class="map"></div>

View File

@@ -15,7 +15,6 @@ var layers = [
source: new ol.source.ImageWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {'LAYERS': 'topp:states'},
ratio: 1,
serverType: 'geoserver'
})
})

View File

@@ -34,6 +34,6 @@ fetch(capabilitiesUrl).then(function(response) {
});
options.tilePixelRatio = tilePixelRatio;
map.addLayer(new ol.layer.Tile({
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
source: new ol.source.WMTS(options)
}));
});

View File

@@ -5,10 +5,10 @@ shortdesc: Demonstrates displaying IGN (France) WMTS layers.
docs: >
In this example an IGN WMTS layer is displayed.
For more information on IGN's WMTS service see the
[IGN Géoportail API web page](http://api.ign.fr/accueil)
and
[Descriptif technique des web services du Géoportail](http://www.geoportail.gouv.fr/depot/api/cgu/DT_APIGeoportail.pdf)
(french).
<a href="http://professionnels.ign.fr/api-sig">IGN Géoportail API web page
</a> and
<a href="http://www.geoportail.gouv.fr/depot/api/cgu/DT_APIGeoportail.pdf">
Descriptif technique des web services du Géoportail</a> (french).
tags: "french, ign, geoportail, wmts"
---
<div id="map" class="map"></div>

View File

@@ -12,10 +12,8 @@ fetch('data/WMTSCapabilities.xml').then(function(response) {
return response.text();
}).then(function(text) {
var result = parser.read(text);
var options = ol.source.WMTS.optionsFromCapabilities(result, {
layer: 'layer-7328',
matrixSet: 'EPSG:3857'
});
var options = ol.source.WMTS.optionsFromCapabilities(result,
{layer: 'layer-7328', matrixSet: 'EPSG:3857'});
map = new ol.Map({
layers: [
@@ -25,7 +23,7 @@ fetch('data/WMTSCapabilities.xml').then(function(response) {
}),
new ol.layer.Tile({
opacity: 1,
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
source: new ol.source.WMTS(options)
})
],
target: 'map',

View File

@@ -8,21 +8,6 @@ var olx;
/* typedefs for object literals provided by applications */
/**
* @typedef {{unique: (boolean|undefined)}}
*/
olx.CollectionOptions;
/**
* Disallow the same item from being added to the collection twice. Default is
* false.
* @type {boolean|undefined}
* @api
*/
olx.CollectionOptions.prototype.unique;
/**
* @typedef {{html: string,
* tileRanges: (Object.<string, Array.<ol.TileRange>>|undefined)}}
@@ -2300,8 +2285,7 @@ olx.format.WFSWriteGetFeatureOptions.prototype.resultType;
* srsName: (string|undefined),
* handle: (string|undefined),
* nativeElements: Array.<Object>,
* gmlOptions: (olx.format.GMLOptions|undefined),
* version: (string|undefined)}}
* gmlOptions: (olx.format.GMLOptions|undefined)}}
*/
olx.format.WFSWriteTransactionOptions;
@@ -2363,15 +2347,6 @@ olx.format.WFSWriteTransactionOptions.prototype.nativeElements;
olx.format.WFSWriteTransactionOptions.prototype.gmlOptions;
/**
* WFS version to use for the transaction. Can be either `1.0.0` or `1.1.0`.
* Default is `1.1.0`.
* @type {string|undefined}
* @api
*/
olx.format.WFSWriteTransactionOptions.prototype.version;
/**
* @typedef {{splitCollection: (boolean|undefined)}}
*/
@@ -2413,9 +2388,7 @@ olx.interaction;
/**
* Interactions for the map. Default is `true` for all options.
* @typedef {{
* altShiftDragRotate: (boolean|undefined),
* constrainResolution: (boolean|undefined),
* @typedef {{altShiftDragRotate: (boolean|undefined),
* doubleClickZoom: (boolean|undefined),
* keyboard: (boolean|undefined),
* mouseWheelZoom: (boolean|undefined),
@@ -2424,8 +2397,7 @@ olx.interaction;
* pinchRotate: (boolean|undefined),
* pinchZoom: (boolean|undefined),
* zoomDelta: (number|undefined),
* zoomDuration: (number|undefined)
* }}
* zoomDuration: (number|undefined)}}
*/
olx.interaction.DefaultsOptions;
@@ -2438,15 +2410,6 @@ olx.interaction.DefaultsOptions;
olx.interaction.DefaultsOptions.prototype.altShiftDragRotate;
/**
* Zoom to the closest integer zoom level after the wheel/trackpad or
* pinch gesture ends. Default is `false`.
* @type {boolean|undefined}
* @api
*/
olx.interaction.DefaultsOptions.prototype.constrainResolution;
/**
* Whether double click zoom is desired. Default is `true`.
* @type {boolean|undefined}
@@ -2577,7 +2540,6 @@ olx.interaction.DragAndDropOptions.prototype.target;
/**
* @typedef {{className: (string|undefined),
* condition: (ol.EventsConditionType|undefined),
* minArea: (number|undefined),
* boxEndCondition: (ol.DragBoxEndConditionType|undefined)}}
*/
olx.interaction.DragBoxOptions;
@@ -2601,19 +2563,19 @@ olx.interaction.DragBoxOptions.prototype.className;
olx.interaction.DragBoxOptions.prototype.condition;
/**
* The minimum area of the box in pixel, this value is used by the default
* `boxEndCondition` function. Default is `64`.
* @type {number|undefined}
* @api
*/
olx.interaction.DragBoxOptions.prototype.minArea;
/**
* A function that takes a {@link ol.MapBrowserEvent} and two
* {@link ol.Pixel}s to indicate whether a `boxend` event should be fired.
* Default is `true` if the area of the box is bigger than the `minArea` option.
* {@link ol.Pixel}s to indicate whether a boxend event should be fired.
* Default is:
* ```js
* function(mapBrowserEvent,
* startPixel, endPixel) {
* var width = endPixel[0] - startPixel[0];
* var height = endPixel[1] - startPixel[1];
* return width * width + height * height >=
* ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED;
* }
* ```
* @type {ol.DragBoxEndConditionType|undefined}
* @api
*/
@@ -3114,8 +3076,7 @@ olx.interaction.ModifyOptions.prototype.wrapX;
/**
* @typedef {{constrainResolution: (boolean|undefined),
* duration: (number|undefined),
* @typedef {{duration: (number|undefined),
* timeout: (number|undefined),
* useAnchor: (boolean|undefined)}}
*/
@@ -3138,16 +3099,6 @@ olx.interaction.MouseWheelZoomOptions.prototype.duration;
olx.interaction.MouseWheelZoomOptions.prototype.timeout;
/**
* When using a trackpad or magic mouse, zoom to the closest integer zoom level
* after the scroll gesture ends.
* Default is `false`.
* @type {boolean|undefined}
* @api
*/
olx.interaction.MouseWheelZoomOptions.prototype.constrainResolution;
/**
* Enable zooming using the mouse's location as the anchor. Default is `true`.
* When set to false, zooming in and out will zoom to the center of the screen
@@ -3182,10 +3133,7 @@ olx.interaction.PinchRotateOptions.prototype.threshold;
/**
* @typedef {{
* duration: (number|undefined),
* constrainResolution: (boolean|undefined)
* }}
* @typedef {{duration: (number|undefined)}}
*/
olx.interaction.PinchZoomOptions;
@@ -3933,7 +3881,7 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError;
/**
* @typedef {{renderOrder: (ol.RenderOrderFunction|null|undefined),
* @typedef {{renderOrder: (function(ol.Feature, ol.Feature):number|null|undefined),
* minResolution: (number|undefined),
* maxResolution: (number|undefined),
* opacity: (number|undefined),
@@ -3952,7 +3900,7 @@ olx.layer.VectorOptions;
* Render order. Function to be used when sorting features before rendering. By
* default features are drawn in the order that they are created. Use `null` to
* avoid the sort, but get an undefined draw order.
* @type {ol.RenderOrderFunction|null|undefined}
* @type {function(ol.Feature, ol.Feature):number|null|undefined}
* @api
*/
olx.layer.VectorOptions.prototype.renderOrder;
@@ -4067,7 +4015,7 @@ olx.layer.VectorOptions.prototype.visible;
* preload: (number|undefined),
* renderBuffer: (number|undefined),
* renderMode: (ol.layer.VectorTileRenderType|string|undefined),
* renderOrder: (ol.RenderOrderFunction|undefined),
* renderOrder: (function(ol.Feature, ol.Feature):number|undefined),
* source: (ol.source.VectorTile|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
* updateWhileAnimating: (boolean|undefined),
@@ -4110,7 +4058,7 @@ olx.layer.VectorTileOptions.prototype.renderMode;
/**
* Render order. Function to be used when sorting features before rendering. By
* default features are drawn in the order that they are created.
* @type {ol.RenderOrderFunction|undefined}
* @type {function(ol.Feature, ol.Feature):number|undefined}
* @api
*/
olx.layer.VectorTileOptions.prototype.renderOrder;
@@ -6811,13 +6759,7 @@ olx.source.ZoomifyOptions.prototype.reprojectionErrorThreshold;
/**
* URL template or base URL of the Zoomify service. A base URL is the fixed part
* of the URL, excluding the tile group, z, x, and y folder structure, e.g.
* `http://my.zoomify.info/IMAGE.TIF/`. A URL template must include
* `{TileGroup}`, `{x}`, `{y}`, and `{z}` placeholders, e.g.
* `http://my.zoomify.info/IMAGE.TIF/{TileGroup}/{z}-{x}-{y}.jpg`.
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
* used instead of defining each one separately in the `urls` option.
* Prefix of URL template.
* @type {!string}
* @api
*/
@@ -7038,7 +6980,7 @@ olx.style.IconOptions.prototype.opacity;
/**
* Scale. Default is `1`.
* Scale.
* @type {number|undefined}
* @api
*/
@@ -7096,7 +7038,7 @@ olx.style.IconOptions.prototype.imgSize;
/**
* Image source URI.
* @type {string|undefined}
* @type {string}
* @api
*/
olx.style.IconOptions.prototype.src;
@@ -7145,7 +7087,7 @@ olx.style.RegularShapeOptions.prototype.radius;
/**
* Outer radius of a star.
* Inner radius of a star.
* @type {number|undefined}
* @api
*/
@@ -7153,7 +7095,7 @@ olx.style.RegularShapeOptions.prototype.radius1;
/**
* Inner radius of a star.
* Outer radius of a star.
* @type {number|undefined}
* @api
*/

View File

@@ -7,31 +7,25 @@
/**
* @constructor
*/
var Proj4 = function() {};
var proj4 = function() {};
/**
* @param {ol.Coordinate} coordinates
* @return {ol.Coordinate}
* @type {function(Array.<number>): Array.<number>}
*/
Proj4.prototype.forward = function(coordinates) {};
proj4.prototype.forward;
/**
* @param {ol.Coordinate} coordinates
* @return {ol.Coordinate}
* @type {function(Array.<number>): Array.<number>}
*/
Proj4.prototype.inverse = function(coordinates) {};
proj4.prototype.inverse;
/**
* @param {string} name
* @param {(string|Object)=} opt_def
* @return {undefined|Object.<string, Object.<{axis: string, units: string, to_meter: number}>>}
* @return {undefined|Object.<string, Object.<{axis: string, units: string,
* to_meter: number}>>}
*/
Proj4.prototype.defs = function(name, opt_def) {};
/**
* @type {Proj4}
*/
var proj4;
proj4.defs = function(name, opt_def) {};

View File

@@ -1,6 +1,6 @@
{
"name": "openlayers",
"version": "4.1.1",
"version": "4.0.0-beta.1",
"description": "Build tools and sources for developing OpenLayers based mapping applications",
"keywords": [
"map",
@@ -30,11 +30,11 @@
"css/ol.css"
],
"dependencies": {
"async": "2.3.0",
"browserify": "14.3.0",
"closure-util": "1.18.0",
"async": "2.1.4",
"browserify": "14.0.0",
"closure-util": "1.17.0",
"derequire": "2.0.6",
"fs-extra": "2.1.2",
"fs-extra": "2.0.0",
"glob": "7.1.1",
"handlebars": "4.0.6",
"jsdoc": "3.4.3",
@@ -50,26 +50,27 @@
"walk": "2.3.9"
},
"devDependencies": {
"clean-css-cli": "4.0.12",
"coveralls": "2.13.0",
"clean-css-cli": "4.0.0",
"coveralls": "2.11.16",
"debounce": "^1.0.0",
"eslint": "3.18.0",
"eslint": "3.15.0",
"eslint-config-openlayers": "7.0.0",
"eslint-plugin-openlayers-internal": "^3.1.0",
"esprima": "2.x",
"expect.js": "0.3.1",
"gaze": "^1.0.0",
"istanbul": "0.4.5",
"jquery": "3.2.1",
"jquery": "3.1.1",
"jscodeshift": "^0.3.30",
"mocha": "3.2.0",
"mocha-phantomjs-core": "^2.1.0",
"mustache": "2.3.0",
"phantomjs-prebuilt": "2.1.14",
"proj4": "2.4.3",
"proj4": "2.3.17",
"resemblejs": "2.2.3",
"serve-files": "1.0.1",
"sinon": "2.1.0",
"slimerjs": "0.10.3"
"sinon": "1.17.7",
"slimerjs": "0.906.2"
},
"eslintConfig": {
"extends": "openlayers",
@@ -88,6 +89,15 @@
"openlayers-internal"
],
"rules": {
"no-console": [
2,
{
"allow": [
"assert",
"warn"
]
}
],
"no-constant-condition": 0,
"openlayers-internal/enum": 2,
"openlayers-internal/no-duplicate-requires": 2,

View File

@@ -1,6 +1,6 @@
{
"name": "ol",
"version": "4.1.1",
"version": "3.21.0-beta.17",
"description": "OpenLayers as ES2015 modules",
"main": "index.js",
"module": "index.js",
@@ -10,15 +10,5 @@
"pixelworks": "1.1.0",
"rbush": "2.0.1",
"vector-tile": "1.3.0"
},
"browserify": {
"transform": [
[
"babelify",
{
"plugins": ["transform-es2015-modules-commonjs"]
}
]
]
}
}

View File

@@ -2,6 +2,8 @@
OpenLayers as ES2015 modules.
**Note: This package is in beta and the API is subject to change before a final stable release.**
## Usage
Add the `ol` package as a dependency to your project.
@@ -49,4 +51,5 @@ Utility functions are available as properties of the default export from utility
## Caveats
* Module identifiers and the structure of the exports are subject to change while this package is in beta.
* The WebGL renderer is not available in this package.

View File

@@ -13,12 +13,11 @@ goog.require('ol');
*/
ol.AssertionError = function(code) {
var path = ol.VERSION ? ol.VERSION.split('-')[0] : 'latest';
/**
* @type {string}
*/
this.message = 'Assertion failed. See https://openlayers.org/en/' + path +
this.message = 'Assertion failed. See ' +
(ol.VERSION ? 'https://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') +
'/doc/errors/#' + code + ' for details.';
/**

View File

@@ -6,7 +6,6 @@
goog.provide('ol.Collection');
goog.require('ol');
goog.require('ol.AssertionError');
goog.require('ol.CollectionEventType');
goog.require('ol.Object');
goog.require('ol.events.Event');
@@ -24,34 +23,19 @@ goog.require('ol.events.Event');
* @extends {ol.Object}
* @fires ol.Collection.Event
* @param {!Array.<T>=} opt_array Array.
* @param {olx.CollectionOptions=} opt_options Collection options.
* @template T
* @api
*/
ol.Collection = function(opt_array, opt_options) {
ol.Collection = function(opt_array) {
ol.Object.call(this);
var options = opt_options || {};
/**
* @private
* @type {boolean}
*/
this.unique_ = !!options.unique;
/**
* @private
* @type {!Array.<T>}
*/
this.array_ = opt_array ? opt_array : [];
if (this.unique_) {
for (var i = 0, ii = this.array_.length; i < ii; ++i) {
this.assertUnique_(this.array_[i], i);
}
}
this.updateLength_();
};
@@ -141,9 +125,6 @@ ol.Collection.prototype.getLength = function() {
* @api
*/
ol.Collection.prototype.insertAt = function(index, elem) {
if (this.unique_) {
this.assertUnique_(elem);
}
this.array_.splice(index, 0, elem);
this.updateLength_();
this.dispatchEvent(
@@ -169,9 +150,6 @@ ol.Collection.prototype.pop = function() {
* @api
*/
ol.Collection.prototype.push = function(elem) {
if (this.unique_) {
this.assertUnique_(elem);
}
var n = this.getLength();
this.insertAt(n, elem);
return this.getLength();
@@ -222,9 +200,6 @@ ol.Collection.prototype.removeAt = function(index) {
ol.Collection.prototype.setAt = function(index, elem) {
var n = this.getLength();
if (index < n) {
if (this.unique_) {
this.assertUnique_(elem, index);
}
var prev = this.array_[index];
this.array_[index] = elem;
this.dispatchEvent(
@@ -249,20 +224,6 @@ ol.Collection.prototype.updateLength_ = function() {
};
/**
* @private
* @param {T} elem Element.
* @param {number=} opt_except Optional index to ignore.
*/
ol.Collection.prototype.assertUnique_ = function(elem, opt_except) {
for (var i = 0, ii = this.array_.length; i < ii; ++i) {
if (this.array_[i] === elem && i !== opt_except) {
throw new ol.AssertionError(58);
}
}
};
/**
* @enum {string}
* @private

View File

@@ -148,44 +148,6 @@ ol.control.OverviewMap = function(opt_options) {
render: render,
target: options.target
});
/* Interactive map */
var scope = this;
var overlay = this.boxOverlay_;
var overlayBox = this.boxOverlay_.getElement();
/* Functions definition */
var computeDesiredMousePosition = function(mousePosition) {
return {
clientX: mousePosition.clientX - (overlayBox.offsetWidth / 2),
clientY: mousePosition.clientY + (overlayBox.offsetHeight / 2)
};
};
var move = function(event) {
var coordinates = ovmap.getEventCoordinate(computeDesiredMousePosition(event));
overlay.setPosition(coordinates);
};
var endMoving = function(event) {
var coordinates = ovmap.getEventCoordinate(event);
scope.getMap().getView().setCenter(coordinates);
window.removeEventListener('mousemove', move);
window.removeEventListener('mouseup', endMoving);
};
/* Binding */
overlayBox.addEventListener('mousedown', function() {
window.addEventListener('mousemove', move);
window.addEventListener('mouseup', endMoving);
});
};
ol.inherits(ol.control.OverviewMap, ol.control.Control);

View File

@@ -120,8 +120,16 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
// upon it
return;
}
if (view.getRotation() !== undefined) {
var currentRotation = view.getRotation();
if (currentRotation !== undefined) {
if (this.duration_ > 0) {
currentRotation = currentRotation % (2 * Math.PI);
if (currentRotation < -Math.PI) {
currentRotation += 2 * Math.PI;
}
if (currentRotation > Math.PI) {
currentRotation -= 2 * Math.PI;
}
view.animate({
rotation: 0,
duration: this.duration_,

View File

@@ -203,10 +203,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
pointResolution /= 1852;
suffix = 'nm';
} else if (units == ol.control.ScaleLineUnits.METRIC) {
if (nominalCount < 0.001) {
suffix = 'μm';
pointResolution *= 1000000;
} else if (nominalCount < 1) {
if (nominalCount < 1) {
suffix = 'mm';
pointResolution *= 1000;
} else if (nominalCount < 1000) {

View File

@@ -112,26 +112,10 @@ ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres, opt_fraction
var normalizedDegrees = ol.math.modulo(degrees + 180, 360) - 180;
var x = Math.abs(3600 * normalizedDegrees);
var dflPrecision = opt_fractionDigits || 0;
var precision = Math.pow(10, dflPrecision);
var deg = Math.floor(x / 3600);
var min = Math.floor((x - deg * 3600) / 60);
var sec = x - (deg * 3600) - (min * 60);
sec = Math.ceil(sec * precision) / precision;
if (sec >= 60) {
sec = 0;
min += 1;
}
if (min >= 60) {
min = 0;
deg += 1;
}
return deg + '\u00b0 ' + ol.string.padNumber(min, 2) + '\u2032 ' +
ol.string.padNumber(sec, 2, dflPrecision) + '\u2033 ' +
hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);
return Math.floor(x / 3600) + '\u00b0 ' +
ol.string.padNumber(Math.floor((x / 60) % 60), 2) + '\u2032 ' +
ol.string.padNumber((x % 60), 2, dflPrecision) + '\u2033 ' +
hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);
};

View File

@@ -10,14 +10,6 @@ goog.provide('ol.css');
ol.css.CLASS_HIDDEN = 'ol-hidden';
/**
* The CSS class that we'll give the DOM elements to have them selectable.
*
* @const
* @type {string}
*/
ol.css.CLASS_SELECTABLE = 'ol-selectable';
/**
* The CSS class that we'll give the DOM elements to have them unselectable.
*

View File

@@ -28,7 +28,7 @@ ol.dom.createCanvasContext2D = function(opt_width, opt_height) {
*/
ol.dom.outerWidth = function(element) {
var width = element.offsetWidth;
var style = getComputedStyle(element);
var style = element.currentStyle || getComputedStyle(element);
width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
return width;
@@ -44,7 +44,7 @@ ol.dom.outerWidth = function(element) {
*/
ol.dom.outerHeight = function(element) {
var height = element.offsetHeight;
var style = getComputedStyle(element);
var style = element.currentStyle || getComputedStyle(element);
height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
return height;

View File

@@ -26,7 +26,7 @@ ol.events.EventType = {
MOUSEOUT: 'mouseout',
MOUSEUP: 'mouseup',
MOUSEWHEEL: 'mousewheel',
MSPOINTERDOWN: 'MSPointerDown',
MSPOINTERDOWN: 'mspointerdown',
RESIZE: 'resize',
TOUCHSTART: 'touchstart',
TOUCHMOVE: 'touchmove',

View File

@@ -64,12 +64,6 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
failure.call(this);
}
}.bind(this);
/**
* @private
*/
xhr.onerror = function() {
failure.call(this);
}.bind(this);
xhr.send();
});
};

View File

@@ -2,11 +2,8 @@ goog.provide('ol.format.GML2');
goog.require('ol');
goog.require('ol.extent');
goog.require('ol.format.Feature');
goog.require('ol.format.GMLBase');
goog.require('ol.format.XSD');
goog.require('ol.geom.Geometry');
goog.require('ol.obj');
goog.require('ol.proj');
goog.require('ol.xml');
@@ -60,6 +57,7 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]);
var containerSrs = context['srsName'];
var containerDimension = node.parentNode.getAttribute('srsDimension');
var axisOrientation = 'enu';
if (containerSrs) {
var proj = ol.proj.get(containerSrs);
@@ -67,14 +65,24 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
axisOrientation = proj.getAxisOrientation();
}
}
var coordsGroups = s.trim().split(/\s+/);
var coords = s.split(/[\s,]+/);
// The "dimension" attribute is from the GML 3.0.1 spec.
var dim = 2;
if (node.getAttribute('srsDimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('srsDimension'));
} else if (node.getAttribute('dimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('dimension'));
} else if (containerDimension) {
dim = ol.format.XSD.readNonNegativeIntegerString(containerDimension);
}
var x, y, z;
var flatCoordinates = [];
for (var i = 0, ii = coordsGroups.length; i < ii; i++) {
var coords = coordsGroups[i].split(/,+/);
x = parseFloat(coords[0]);
y = parseFloat(coords[1]);
z = (coords.length === 3) ? parseFloat(coords[2]) : 0;
for (var i = 0, ii = coords.length; i < ii; i += dim) {
x = parseFloat(coords[i]);
y = parseFloat(coords[i + 1]);
z = (dim === 3) ? parseFloat(coords[i + 2]) : 0;
if (axisOrientation.substr(0, 2) === 'en') {
flatCoordinates.push(x, y, z);
} else {
@@ -196,569 +204,3 @@ ol.format.GML2.prototype.GEOMETRY_PARSERS_ = {
'Box': ol.xml.makeReplacer(ol.format.GML2.prototype.readBox_)
}
};
/**
* @const
* @param {*} value Value.
* @param {Array.<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @return {Node|undefined} Node.
* @private
*/
ol.format.GML2.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
var context = objectStack[objectStack.length - 1];
var multiSurface = context['multiSurface'];
var surface = context['surface'];
var multiCurve = context['multiCurve'];
var nodeName;
if (!Array.isArray(value)) {
nodeName = /** @type {ol.geom.Geometry} */ (value).getType();
if (nodeName === 'MultiPolygon' && multiSurface === true) {
nodeName = 'MultiSurface';
} else if (nodeName === 'Polygon' && surface === true) {
nodeName = 'Surface';
} else if (nodeName === 'MultiLineString' && multiCurve === true) {
nodeName = 'MultiCurve';
}
} else {
nodeName = 'Envelope';
}
return ol.xml.createElementNS('http://www.opengis.net/gml',
nodeName);
};
/**
* @param {Node} node Node.
* @param {ol.Feature} feature Feature.
* @param {Array.<*>} objectStack Node stack.
*/
ol.format.GML2.prototype.writeFeatureElement = function(node, feature, objectStack) {
var fid = feature.getId();
if (fid) {
node.setAttribute('fid', fid);
}
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var featureNS = context['featureNS'];
var geometryName = feature.getGeometryName();
if (!context.serializers) {
context.serializers = {};
context.serializers[featureNS] = {};
}
var properties = feature.getProperties();
var keys = [], values = [];
for (var key in properties) {
var value = properties[key];
if (value !== null) {
keys.push(key);
values.push(value);
if (key == geometryName || value instanceof ol.geom.Geometry) {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = ol.xml.makeChildAppender(
this.writeGeometryElement, this);
}
} else {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = ol.xml.makeChildAppender(
ol.format.XSD.writeStringTextNode);
}
}
}
}
var item = ol.obj.assign({}, context);
item.node = node;
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
(item), context.serializers,
ol.xml.makeSimpleNodeFactory(undefined, featureNS),
values,
objectStack, keys);
};
/**
* @param {Node} node Node.
* @param {ol.geom.Geometry|ol.Extent} geometry Geometry.
* @param {Array.<*>} objectStack Node stack.
*/
ol.format.GML2.prototype.writeGeometryElement = function(node, geometry, objectStack) {
var context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]);
var item = ol.obj.assign({}, context);
item.node = node;
var value;
if (Array.isArray(geometry)) {
if (context.dataProjection) {
value = ol.proj.transformExtent(
geometry, context.featureProjection, context.dataProjection);
} else {
value = geometry;
}
} else {
value =
ol.format.Feature.transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context);
}
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
(item), ol.format.GML2.GEOMETRY_SERIALIZERS_,
this.GEOMETRY_NODE_FACTORY_, [value],
objectStack, undefined, this);
};
/**
* @param {Node} node Node.
* @param {ol.geom.LineString} geometry LineString geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (node.nodeName !== 'LineStringSegment' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'LineString' ||
node.nodeName === 'LineStringSegment') {
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
this.writeCoordinates_(coordinates, geometry, objectStack);
} else if (node.nodeName === 'Curve') {
var segments = ol.xml.createElementNS(node.namespaceURI, 'segments');
node.appendChild(segments);
this.writeCurveSegments_(segments,
geometry, objectStack);
}
};
/**
* @param {string} namespaceURI XML namespace.
* @returns {Node} coordinates node.
* @private
*/
ol.format.GML2.prototype.createCoordinatesNode_ = function(namespaceURI) {
var coordinates = ol.xml.createElementNS(namespaceURI, 'coordinates');
coordinates.setAttribute('decimal', '.');
coordinates.setAttribute('cs', ',');
coordinates.setAttribute('ts', ' ');
return coordinates;
};
/**
* @param {Node} node Node.
* @param {ol.geom.LineString|ol.geom.LinearRing} value Geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeCoordinates_ = function(node, value, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
// only 2d for simple features profile
var points = value.getCoordinates();
var len = points.length;
var parts = new Array(len);
var point;
for (var i = 0; i < len; ++i) {
point = points[i];
parts[i] = this.getCoords_(point, srsName);
}
ol.format.XSD.writeStringTextNode(node, parts.join(' '));
};
/**
* @param {Node} node Node.
* @param {ol.geom.LineString} line LineString geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) {
var child = ol.xml.createElementNS(node.namespaceURI,
'LineStringSegment');
node.appendChild(child);
this.writeCurveOrLineString_(child, line, objectStack);
};
/**
* @param {Node} node Node.
* @param {ol.geom.Polygon} geometry Polygon geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (node.nodeName !== 'PolygonPatch' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') {
var rings = geometry.getLinearRings();
ol.xml.pushSerializeAndPop(
{node: node, srsName: srsName},
ol.format.GML2.RING_SERIALIZERS_,
this.RING_NODE_FACTORY_,
rings, objectStack, undefined, this);
} else if (node.nodeName === 'Surface') {
var patches = ol.xml.createElementNS(node.namespaceURI, 'patches');
node.appendChild(patches);
this.writeSurfacePatches_(
patches, geometry, objectStack);
}
};
/**
* @param {*} value Value.
* @param {Array.<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @return {Node} Node.
* @private
*/
ol.format.GML2.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
var context = objectStack[objectStack.length - 1];
var parentNode = context.node;
var exteriorWritten = context['exteriorWritten'];
if (exteriorWritten === undefined) {
context['exteriorWritten'] = true;
}
return ol.xml.createElementNS(parentNode.namespaceURI,
exteriorWritten !== undefined ? 'innerBoundaryIs' : 'outerBoundaryIs');
};
/**
* @param {Node} node Node.
* @param {ol.geom.Polygon} polygon Polygon geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) {
var child = ol.xml.createElementNS(node.namespaceURI, 'PolygonPatch');
node.appendChild(child);
this.writeSurfaceOrPolygon_(child, polygon, objectStack);
};
/**
* @param {Node} node Node.
* @param {ol.geom.LinearRing} ring LinearRing geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeRing_ = function(node, ring, objectStack) {
var linearRing = ol.xml.createElementNS(node.namespaceURI, 'LinearRing');
node.appendChild(linearRing);
this.writeLinearRing_(linearRing, ring, objectStack);
};
/**
* @param {Array.<number>} point Point geometry.
* @param {string=} opt_srsName Optional srsName
* @return {string} The coords string.
* @private
*/
ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName) {
var axisOrientation = 'enu';
if (opt_srsName) {
axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation();
}
return ((axisOrientation.substr(0, 2) === 'en') ?
point[0] + ',' + point[1] :
point[1] + ',' + point[0]);
};
/**
* @param {Node} node Node.
* @param {ol.geom.MultiLineString} geometry MultiLineString geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
var curve = context['curve'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var lines = geometry.getLineStrings();
ol.xml.pushSerializeAndPop({node: node, srsName: srsName, curve: curve},
ol.format.GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines,
objectStack, undefined, this);
};
/**
* @param {Node} node Node.
* @param {ol.geom.Point} geometry Point geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writePoint_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
var point = geometry.getCoordinates();
var coord = this.getCoords_(point, srsName);
ol.format.XSD.writeStringTextNode(coordinates, coord);
};
/**
* @param {Node} node Node.
* @param {ol.geom.MultiPoint} geometry MultiPoint geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeMultiPoint_ = function(node, geometry,
objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var points = geometry.getPoints();
ol.xml.pushSerializeAndPop({node: node, srsName: srsName},
ol.format.GML2.POINTMEMBER_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('pointMember'), points,
objectStack, undefined, this);
};
/**
* @param {Node} node Node.
* @param {ol.geom.Point} point Point geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writePointMember_ = function(node, point, objectStack) {
var child = ol.xml.createElementNS(node.namespaceURI, 'Point');
node.appendChild(child);
this.writePoint_(child, point, objectStack);
};
/**
* @param {Node} node Node.
* @param {ol.geom.LineString} line LineString geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
if (child) {
node.appendChild(child);
this.writeCurveOrLineString_(child, line, objectStack);
}
};
/**
* @param {Node} node Node.
* @param {ol.geom.LinearRing} geometry LinearRing geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeLinearRing_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
this.writeCoordinates_(coordinates, geometry, objectStack);
};
/**
* @param {Node} node Node.
* @param {ol.geom.MultiPolygon} geometry MultiPolygon geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
var surface = context['surface'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var polygons = geometry.getPolygons();
ol.xml.pushSerializeAndPop({node: node, srsName: srsName, surface: surface},
ol.format.GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons,
objectStack, undefined, this);
};
/**
* @param {Node} node Node.
* @param {ol.geom.Polygon} polygon Polygon geometry.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(
polygon, objectStack);
if (child) {
node.appendChild(child);
this.writeSurfaceOrPolygon_(child, polygon, objectStack);
}
};
/**
* @param {Node} node Node.
* @param {ol.Extent} extent Extent.
* @param {Array.<*>} objectStack Node stack.
* @private
*/
ol.format.GML2.prototype.writeEnvelope = function(node, extent, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var keys = ['lowerCorner', 'upperCorner'];
var values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]];
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
({node: node}), ol.format.GML2.ENVELOPE_SERIALIZERS_,
ol.xml.OBJECT_PROPERTY_NODE_FACTORY,
values,
objectStack, keys, this);
};
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
* @private
*/
ol.format.GML2.GEOMETRY_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'Curve': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeCurveOrLineString_),
'MultiCurve': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeMultiCurveOrLineString_),
'Point': ol.xml.makeChildAppender(ol.format.GML2.prototype.writePoint_),
'MultiPoint': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeMultiPoint_),
'LineString': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeCurveOrLineString_),
'MultiLineString': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeMultiCurveOrLineString_),
'LinearRing': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeLinearRing_),
'Polygon': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeSurfaceOrPolygon_),
'MultiPolygon': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_),
'Surface': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeSurfaceOrPolygon_),
'MultiSurface': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_),
'Envelope': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeEnvelope)
}
};
/**
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
* @private
*/
ol.format.GML2.RING_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'outerBoundaryIs': ol.xml.makeChildAppender(ol.format.GML2.prototype.writeRing_),
'innerBoundaryIs': ol.xml.makeChildAppender(ol.format.GML2.prototype.writeRing_)
}
};
/**
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
* @private
*/
ol.format.GML2.POINTMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'pointMember': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writePointMember_)
}
};
/**
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
* @private
*/
ol.format.GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'lineStringMember': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeLineStringOrCurveMember_),
'curveMember': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeLineStringOrCurveMember_)
}
};
/**
* @const
* @param {*} value Value.
* @param {Array.<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @return {Node|undefined} Node.
* @private
*/
ol.format.GML2.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
var parentNode = objectStack[objectStack.length - 1].node;
return ol.xml.createElementNS('http://www.opengis.net/gml',
ol.format.GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]);
};
/**
* @const
* @type {Object.<string, string>}
* @private
*/
ol.format.GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = {
'MultiLineString': 'lineStringMember',
'MultiCurve': 'curveMember',
'MultiPolygon': 'polygonMember',
'MultiSurface': 'surfaceMember'
};
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
* @private
*/
ol.format.GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'surfaceMember': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeSurfaceOrPolygonMember_),
'polygonMember': ol.xml.makeChildAppender(
ol.format.GML2.prototype.writeSurfaceOrPolygonMember_)
}
};
/**
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
* @private
*/
ol.format.GML2.ENVELOPE_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'lowerCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode),
'upperCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode)
}
};

View File

@@ -2,7 +2,6 @@ goog.provide('ol.format.WFS');
goog.require('ol');
goog.require('ol.asserts');
goog.require('ol.format.GML2');
goog.require('ol.format.GML3');
goog.require('ol.format.GMLBase');
goog.require('ol.format.filter');
@@ -54,8 +53,7 @@ ol.format.WFS = function(opt_options) {
* @type {string}
*/
this.schemaLocation_ = options.schemaLocation ?
options.schemaLocation :
ol.format.WFS.SCHEMA_LOCATIONS[ol.format.WFS.DEFAULT_VERSION];
options.schemaLocation : ol.format.WFS.SCHEMA_LOCATION;
ol.format.XMLFeature.call(this);
};
@@ -90,23 +88,12 @@ ol.format.WFS.OGCNS = 'http://www.opengis.net/ogc';
ol.format.WFS.WFSNS = 'http://www.opengis.net/wfs';
/**
* @const
* @type {Object.<string, string>}
*/
ol.format.WFS.SCHEMA_LOCATIONS = {
'1.1.0': 'http://www.opengis.net/wfs ' +
'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd',
'1.0.0': 'http://www.opengis.net/wfs ' +
'http://schemas.opengis.net/wfs/1.0.0/wfs.xsd'
};
/**
* @const
* @type {string}
*/
ol.format.WFS.DEFAULT_VERSION = '1.1.0';
ol.format.WFS.SCHEMA_LOCATION = 'http://www.opengis.net/wfs ' +
'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd';
/**
@@ -373,14 +360,9 @@ ol.format.WFS.writeFeature_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1];
var featureType = context['featureType'];
var featureNS = context['featureNS'];
var gmlVersion = context['gmlVersion'];
var child = ol.xml.createElementNS(featureNS, featureType);
node.appendChild(child);
if (gmlVersion === 2) {
ol.format.GML2.prototype.writeFeatureElement(child, feature, objectStack);
} else {
ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack);
}
ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack);
};
@@ -451,8 +433,7 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
}
}
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (
{'gmlVersion': context['gmlVersion'], node: node,
'srsName': context['srsName']}),
{node: node, 'srsName': context['srsName']}),
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Property'), values,
objectStack);
@@ -469,21 +450,14 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
*/
ol.format.WFS.writeProperty_ = function(node, pair, objectStack) {
var name = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Name');
var context = objectStack[objectStack.length - 1];
var gmlVersion = context['gmlVersion'];
node.appendChild(name);
ol.format.XSD.writeStringTextNode(name, pair.name);
if (pair.value !== undefined && pair.value !== null) {
var value = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Value');
node.appendChild(value);
if (pair.value instanceof ol.geom.Geometry) {
if (gmlVersion === 2) {
ol.format.GML2.prototype.writeGeometryElement(value,
pair.value, objectStack);
} else {
ol.format.GML3.prototype.writeGeometryElement(value,
pair.value, objectStack);
}
ol.format.GML3.prototype.writeGeometryElement(value,
pair.value, objectStack);
} else {
ol.format.XSD.writeStringTextNode(value, pair.value);
}
@@ -782,20 +756,6 @@ ol.format.WFS.GETFEATURE_SERIALIZERS_ = {
};
/**
* Encode filter as WFS `Filter` and return the Node.
*
* @param {ol.format.filter.Filter} filter Filter.
* @return {Node} Result.
* @api
*/
ol.format.WFS.writeFilter = function(filter) {
var child = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'Filter');
ol.format.WFS.writeFilterCondition_(child, filter, []);
return child;
};
/**
* @param {Node} node Node.
* @param {Array.<string>} featureTypes Feature types.
@@ -891,11 +851,8 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
options) {
var objectStack = [];
var node = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Transaction');
var version = options.version ?
options.version : ol.format.WFS.DEFAULT_VERSION;
var gmlVersion = version === '1.0.0' ? 2 : 3;
node.setAttribute('service', 'WFS');
node.setAttribute('version', version);
node.setAttribute('version', '1.1.0');
var baseObj;
/** @type {ol.XmlNodeStackItem} */
var obj;
@@ -905,13 +862,12 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
node.setAttribute('handle', options.handle);
}
}
var schemaLocation = ol.format.WFS.SCHEMA_LOCATIONS[version];
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', schemaLocation);
'xsi:schemaLocation', this.schemaLocation_);
if (inserts) {
obj = {node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'gmlVersion': gmlVersion, 'srsName': options.srsName};
'srsName': options.srsName};
ol.obj.assign(obj, baseObj);
ol.xml.pushSerializeAndPop(obj,
ol.format.WFS.TRANSACTION_SERIALIZERS_,
@@ -921,7 +877,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
if (updates) {
obj = {node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'gmlVersion': gmlVersion, 'srsName': options.srsName};
'srsName': options.srsName};
ol.obj.assign(obj, baseObj);
ol.xml.pushSerializeAndPop(obj,
ol.format.WFS.TRANSACTION_SERIALIZERS_,
@@ -931,7 +887,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
if (deletes) {
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'gmlVersion': gmlVersion, 'srsName': options.srsName},
'srsName': options.srsName},
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
objectStack);
@@ -939,7 +895,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
if (options.nativeElements) {
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
'gmlVersion': gmlVersion, 'srsName': options.srsName},
'srsName': options.srsName},
ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements,
objectStack);

View File

@@ -192,12 +192,12 @@ ol.Geolocation.prototype.getAccuracy = function() {
/**
* Get a geometry of the position accuracy.
* @return {?ol.geom.Polygon} A geometry of the position accuracy.
* @return {?ol.geom.Geometry} A geometry of the position accuracy.
* @observable
* @api
*/
ol.Geolocation.prototype.getAccuracyGeometry = function() {
return /** @type {?ol.geom.Polygon} */ (
return /** @type {?ol.geom.Geometry} */ (
this.get(ol.GeolocationProperty.ACCURACY_GEOMETRY) || null);
};

View File

@@ -47,6 +47,12 @@ ol.DEFAULT_TILE_SIZE = 256;
ol.DEFAULT_WMS_VERSION = '1.3.0';
/**
* @define {number} Hysteresis pixels.
*/
ol.DRAG_BOX_HYSTERESIS_PIXELS = 8;
/**
* @define {boolean} Enable the Canvas renderer. Default is `true`. Setting
* this to false at compile time in advanced mode removes all code

View File

@@ -75,7 +75,6 @@ ol.interaction.defaults = function(opt_options) {
var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true;
if (pinchZoom) {
interactions.push(new ol.interaction.PinchZoom({
constrainResolution: options.constrainResolution,
duration: options.zoomDuration
}));
}
@@ -93,7 +92,6 @@ ol.interaction.defaults = function(opt_options) {
options.mouseWheelZoom : true;
if (mouseWheelZoom) {
interactions.push(new ol.interaction.MouseWheelZoom({
constrainResolution: options.constrainResolution,
duration: options.zoomDuration
}));
}

View File

@@ -8,6 +8,15 @@ goog.require('ol.interaction.Pointer');
goog.require('ol.render.Box');
/**
* @const
* @type {number}
*/
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED =
ol.DRAG_BOX_HYSTERESIS_PIXELS *
ol.DRAG_BOX_HYSTERESIS_PIXELS;
/**
* @classdesc
* Allows the user to draw a vector box by clicking and dragging on the map,
@@ -41,12 +50,6 @@ ol.interaction.DragBox = function(opt_options) {
*/
this.box_ = new ol.render.Box(options.className || 'ol-dragbox');
/**
* @type {number}
* @private
*/
this.minArea_ = options.minArea !== undefined ? options.minArea : 64;
/**
* @type {ol.Pixel}
* @private
@@ -73,17 +76,18 @@ ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
/**
* The default condition for determining whether the boxend event
* should fire.
* @param {ol.MapBrowserEvent} mapBrowserEvent The originating MapBrowserEvent
* leading to the box end.
* @param {ol.Pixel} startPixel The starting pixel of the box.
* @param {ol.Pixel} endPixel The end pixel of the box.
* @param {ol.MapBrowserEvent} mapBrowserEvent The originating MapBrowserEvent
* leading to the box end.
* @param {ol.Pixel} startPixel The starting pixel of the box.
* @param {ol.Pixel} endPixel The end pixel of the box.
* @return {boolean} Whether or not the boxend condition should be fired.
* @this {ol.interaction.DragBox}
*/
ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel) {
ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent,
startPixel, endPixel) {
var width = endPixel[0] - startPixel[0];
var height = endPixel[1] - startPixel[1];
return width * width + height * height >= this.minArea_;
return width * width + height * height >=
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED;
};

View File

@@ -39,11 +39,6 @@ ol.interaction.DragPan = function(opt_options) {
*/
this.lastCentroid = null;
/**
* @type {number}
*/
this.lastPointersCount_;
/**
* @private
* @type {ol.EventsConditionType}
@@ -67,33 +62,25 @@ ol.inherits(ol.interaction.DragPan, ol.interaction.Pointer);
* @private
*/
ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
var targetPointers = this.targetPointers;
var centroid =
ol.interaction.Pointer.centroid(targetPointers);
if (targetPointers.length == this.lastPointersCount_) {
if (this.kinetic_) {
this.kinetic_.update(centroid[0], centroid[1]);
}
if (this.lastCentroid) {
var deltaX = this.lastCentroid[0] - centroid[0];
var deltaY = centroid[1] - this.lastCentroid[1];
var map = mapBrowserEvent.map;
var view = map.getView();
var viewState = view.getState();
var center = [deltaX, deltaY];
ol.coordinate.scale(center, viewState.resolution);
ol.coordinate.rotate(center, viewState.rotation);
ol.coordinate.add(center, viewState.center);
center = view.constrainCenter(center);
view.setCenter(center);
}
} else if (this.kinetic_) {
// reset so we don't overestimate the kinetic energy after
// after one finger down, tiny drag, second finger down
this.kinetic_.begin();
ol.interaction.Pointer.centroid(this.targetPointers);
if (this.kinetic_) {
this.kinetic_.update(centroid[0], centroid[1]);
}
if (this.lastCentroid) {
var deltaX = this.lastCentroid[0] - centroid[0];
var deltaY = centroid[1] - this.lastCentroid[1];
var map = mapBrowserEvent.map;
var view = map.getView();
var viewState = view.getState();
var center = [deltaX, deltaY];
ol.coordinate.scale(center, viewState.resolution);
ol.coordinate.rotate(center, viewState.rotation);
ol.coordinate.add(center, viewState.center);
center = view.constrainCenter(center);
view.setCenter(center);
}
this.lastCentroid = centroid;
this.lastPointersCount_ = targetPointers.length;
};

View File

@@ -44,12 +44,6 @@ ol.interaction.Draw = function(options) {
handleUpEvent: ol.interaction.Draw.handleUpEvent_
});
/**
* @type {boolean}
* @private
*/
this.shouldHandle_ = false;
/**
* @type {ol.Pixel}
* @private
@@ -331,8 +325,6 @@ ol.interaction.Draw.handleEvent = function(event) {
* @private
*/
ol.interaction.Draw.handleDownEvent_ = function(event) {
this.shouldHandle_ = !this.freehand_;
if (this.freehand_) {
this.downPx_ = event.pixel;
if (!this.finishCoordinate_) {
@@ -355,13 +347,18 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
* @private
*/
ol.interaction.Draw.handleUpEvent_ = function(event) {
var downPx = this.downPx_;
var clickPx = event.pixel;
var dx = downPx[0] - clickPx[0];
var dy = downPx[1] - clickPx[1];
var squaredDistance = dx * dx + dy * dy;
var pass = true;
this.handlePointerMove_(event);
var shouldHandle = this.freehand_ ?
squaredDistance > this.squaredClickTolerance_ :
squaredDistance <= this.squaredClickTolerance_;
var circleMode = this.mode_ === ol.interaction.Draw.Mode_.CIRCLE;
if (this.shouldHandle_) {
if (shouldHandle) {
this.handlePointerMove_(event);
if (!this.finishCoordinate_) {
this.startDrawing_(event);
if (this.mode_ === ol.interaction.Draw.Mode_.POINT) {
@@ -377,9 +374,8 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
this.addToDrawing_(event);
}
pass = false;
} else if (this.freehand_) {
} else if (circleMode) {
this.finishCoordinate_ = null;
this.abortDrawing_();
}
return pass;
};
@@ -392,19 +388,6 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
* @private
*/
ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
if (this.downPx_ &&
((!this.freehand_ && this.shouldHandle_) ||
(this.freehand_ && !this.shouldHandle_))) {
var downPx = this.downPx_;
var clickPx = event.pixel;
var dx = downPx[0] - clickPx[0];
var dy = downPx[1] - clickPx[1];
var squaredDistance = dx * dx + dy * dy;
this.shouldHandle_ = this.freehand_ ?
squaredDistance > this.squaredClickTolerance_ :
squaredDistance <= this.squaredClickTolerance_;
}
if (this.finishCoordinate_) {
this.modifyDrawing_(event);
} else {
@@ -603,18 +586,12 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
* @api
*/
ol.interaction.Draw.prototype.removeLastPoint = function() {
if (!this.sketchFeature_) {
return;
}
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, sketchLineGeom;
if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) {
coordinates = this.sketchCoords_;
coordinates.splice(-2, 1);
this.geometryFunction_(coordinates, geometry);
if (coordinates.length >= 2) {
this.finishCoordinate_ = coordinates[coordinates.length - 2].slice();
}
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.splice(-2, 1);

View File

@@ -327,7 +327,9 @@ ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) {
var vertexPixel = map.getPixelFromCoordinate(vertex);
//if the distance is within tolerance, snap to the segment
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
if (Math.sqrt(ol.coordinate.squaredDistance(pixel, vertexPixel)) <=
this.pixelTolerance_) {
//test if we should further snap to a vertex
var pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
var pixel2 = map.getPixelFromCoordinate(closestSegment[1]);

View File

@@ -550,7 +550,6 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
return false;
}
this.handlePointerAtPixel_(evt.pixel, evt.map);
var pixelCoordinate = evt.map.getCoordinateFromPixel(evt.pixel);
this.dragSegments_.length = 0;
this.modified_ = false;
var vertexFeature = this.vertexFeature_;
@@ -576,7 +575,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
if (segmentDataMatch.geometry.getType() === ol.geom.GeometryType.CIRCLE &&
segmentDataMatch.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) {
var closestVertex = ol.interaction.Modify.closestOnSegmentData_(pixelCoordinate, segmentDataMatch);
var closestVertex = ol.interaction.Modify.closestOnSegmentData_(vertex, segmentDataMatch);
if (ol.coordinate.equals(closestVertex, vertex) && !componentSegments[uid][0]) {
this.dragSegments_.push([segmentDataMatch, 0]);
componentSegments[uid][0] = segmentDataMatch;
@@ -1088,7 +1087,6 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
dragSegments.length = 0;
}
}

View File

@@ -50,12 +50,6 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
*/
this.useAnchor_ = options.useAnchor !== undefined ? options.useAnchor : true;
/**
* @private
* @type {boolean}
*/
this.constrainResolution_ = options.constrainResolution || false;
/**
* @private
* @type {?ol.Coordinate}
@@ -192,16 +186,6 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
view.setCenter(view.constrainCenter(center));
}
view.setResolution(resolution);
if (rebound === 0 && this.constrainResolution_) {
view.animate({
resolution: view.constrainResolution(resolution, delta > 0 ? -1 : 1),
easing: ol.easing.easeOut,
anchor: this.lastAnchor_,
duration: this.duration_
});
}
if (rebound > 0) {
view.animate({
resolution: minResolution,

View File

@@ -371,7 +371,8 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
closestSegment));
vertexPixel = map.getPixelFromCoordinate(vertex);
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
if (Math.sqrt(ol.coordinate.squaredDistance(pixel, vertexPixel)) <=
this.pixelTolerance_) {
snapped = true;
if (this.vertex_) {
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);

View File

@@ -2,13 +2,10 @@ goog.provide('ol.interaction.Translate');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.Object');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.functions');
goog.require('ol.array');
goog.require('ol.interaction.Pointer');
goog.require('ol.interaction.Property');
goog.require('ol.interaction.TranslateEventType');
@@ -85,11 +82,6 @@ ol.interaction.Translate = function(opt_options) {
* @private
*/
this.lastFeature_ = null;
ol.events.listen(this,
ol.Object.getChangeEventType(ol.interaction.Property.ACTIVE),
this.handleActiveChanged_, this);
};
ol.inherits(ol.interaction.Translate, ol.interaction.Pointer);
@@ -241,43 +233,6 @@ ol.interaction.Translate.prototype.setHitTolerance = function(hitTolerance) {
};
/**
* @inheritDoc
*/
ol.interaction.Translate.prototype.setMap = function(map) {
var oldMap = this.getMap();
ol.interaction.Pointer.prototype.setMap.call(this, map);
this.updateState_(oldMap);
};
/**
* @private
*/
ol.interaction.Translate.prototype.handleActiveChanged_ = function() {
this.updateState_(null);
};
/**
* @param {ol.Map} oldMap Old map.
* @private
*/
ol.interaction.Translate.prototype.updateState_ = function(oldMap) {
var map = this.getMap();
var active = this.getActive();
if ((!map || !active) && this.previousCursor_ !== undefined) {
if (!map) {
map = oldMap;
}
var elem = map.getTargetElement();
elem.style.cursor = this.previousCursor_;
this.previousCursor_ = undefined;
}
};
/**
* @classdesc
* Events emitted by {@link ol.interaction.Translate} instances are instances of

View File

@@ -54,14 +54,14 @@ ol.layer.Group = function(opt_options) {
if (layers) {
if (Array.isArray(layers)) {
layers = new ol.Collection(layers.slice(), {unique: true});
layers = new ol.Collection(layers.slice());
} else {
ol.asserts.assert(layers instanceof ol.Collection,
43); // Expected `layers` to be an array or an `ol.Collection`
layers = layers;
}
} else {
layers = new ol.Collection(undefined, {unique: true});
layers = new ol.Collection();
}
this.setLayers(layers);

View File

@@ -102,7 +102,7 @@ ol.layer.Vector.prototype.getRenderBuffer = function() {
* order.
*/
ol.layer.Vector.prototype.getRenderOrder = function() {
return /** @type {ol.RenderOrderFunction|null|undefined} */ (
return /** @type {function(ol.Feature, ol.Feature):number|null|undefined} */ (
this.get(ol.layer.Vector.Property_.RENDER_ORDER));
};
@@ -157,7 +157,7 @@ ol.layer.Vector.prototype.getUpdateWhileInteracting = function() {
/**
* @param {ol.RenderOrderFunction|null|undefined} renderOrder
* @param {function(ol.Feature, ol.Feature):number|null|undefined} renderOrder
* Render order.
*/
ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {

View File

@@ -71,7 +71,7 @@ ol.layer.VectorTile.prototype.createRenderer = function(mapRenderer) {
* @api
*/
ol.layer.VectorTile.prototype.getPreload = function() {
return /** @type {number} */ (this.get(ol.layer.TileProperty.PRELOAD));
return /** @type {number} */ (this.get(ol.layer.VectorTile.Property_.PRELOAD));
};
@@ -91,7 +91,7 @@ ol.layer.VectorTile.prototype.getRenderMode = function() {
*/
ol.layer.VectorTile.prototype.getUseInterimTilesOnError = function() {
return /** @type {boolean} */ (
this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR));
this.get(ol.layer.VectorTile.Property_.USE_INTERIM_TILES_ON_ERROR));
};
@@ -116,3 +116,13 @@ ol.layer.VectorTile.prototype.setUseInterimTilesOnError = function(useInterimTil
this.set(
ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
};
/**
* @enum {string}
* @private
*/
ol.layer.VectorTile.Property_ = {
PRELOAD: 'preload',
USE_INTERIM_TILES_ON_ERROR: 'useInterimTilesOnError'
};

View File

@@ -30,6 +30,7 @@ goog.require('ol.has');
goog.require('ol.interaction');
goog.require('ol.layer.Group');
goog.require('ol.obj');
goog.require('ol.proj.common');
goog.require('ol.renderer.Map');
goog.require('ol.renderer.Type');
goog.require('ol.renderer.canvas.Map');
@@ -1500,3 +1501,5 @@ ol.Map.createOptionsInternal = function(options) {
};
};
ol.proj.common.add();

View File

@@ -154,3 +154,15 @@ ol.Observable.prototype.un = function(type, listener, opt_this) {
ol.events.unlisten(this, /** @type {string} */ (type), listener, opt_this);
}
};
/**
* Removes an event listener using the key returned by `on()` or `once()`.
* Note that using the {@link ol.Observable.unByKey} static function is to
* be preferred.
* @param {ol.EventsKey|Array.<ol.EventsKey>} key The key returned by `on()`
* or `once()` (or an array of keys).
* @function
* @api
*/
ol.Observable.prototype.unByKey = ol.Observable.unByKey;

View File

@@ -4,7 +4,6 @@ goog.require('ol');
goog.require('ol.MapEventType');
goog.require('ol.Object');
goog.require('ol.OverlayPositioning');
goog.require('ol.css');
goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.extent');
@@ -59,7 +58,7 @@ ol.Overlay = function(options) {
* @type {Element}
*/
this.element_ = document.createElement('DIV');
this.element_.className = 'ol-overlay-container ' + ol.css.CLASS_SELECTABLE;
this.element_.className = 'ol-overlay-container';
this.element_.style.position = 'absolute';
/**
@@ -465,8 +464,6 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
var positioning = this.getPositioning();
this.setVisible(true);
var offsetX = offset[0];
var offsetY = offset[1];
if (positioning == ol.OverlayPositioning.BOTTOM_RIGHT ||
@@ -517,6 +514,8 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
this.rendered_.top_ = style.top = top;
}
}
this.setVisible(true);
};

View File

@@ -2,8 +2,6 @@ goog.provide('ol.proj');
goog.require('ol');
goog.require('ol.extent');
goog.require('ol.proj.EPSG3857');
goog.require('ol.proj.EPSG4326');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
goog.require('ol.proj.proj4');
@@ -31,7 +29,7 @@ if (ol.ENABLE_PROJ4JS) {
* import proj4 from 'proj4';
* ol.proj.setProj4(proj4);
*
* @param {Proj4} proj4 Proj4.
* @param {proj4} proj4 Proj4.
* @api
*/
ol.proj.setProj4 = function(proj4) {
@@ -469,24 +467,3 @@ ol.proj.transformWithProjections = function(point, sourceProjection, destination
sourceProjection, destinationProjection);
return transformFn(point);
};
/**
* Add transforms to and from EPSG:4326 and EPSG:3857. This function is called
* by when this module is executed and should only need to be called again after
* `ol.proj.clearAllProjections()` is called (e.g. in tests).
*/
ol.proj.addCommon = function() {
// Add transformations that don't alter coordinates to convert within set of
// projections with equal meaning.
ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS);
ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS);
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
// coordinates and back.
ol.proj.addEquivalentTransforms(
ol.proj.EPSG4326.PROJECTIONS,
ol.proj.EPSG3857.PROJECTIONS,
ol.proj.EPSG3857.fromEPSG4326,
ol.proj.EPSG3857.toEPSG4326);
};
ol.proj.addCommon();

View File

@@ -1,13 +1,24 @@
goog.provide('ol.proj.common');
goog.require('ol.proj');
goog.require('ol.proj.EPSG3857');
goog.require('ol.proj.EPSG4326');
/**
* Deprecated. Transforms between EPSG:4326 and EPSG:3857 are now included by
* default. There is no need to call this function in application code and it
* will be removed in a future major release.
* @deprecated This function is no longer necessary.
* FIXME empty description for jsdoc
* @api
*/
ol.proj.common.add = ol.proj.addCommon;
ol.proj.common.add = function() {
// Add transformations that don't alter coordinates to convert within set of
// projections with equal meaning.
ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS);
ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS);
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
// coordinates and back.
ol.proj.addEquivalentTransforms(
ol.proj.EPSG4326.PROJECTIONS,
ol.proj.EPSG3857.PROJECTIONS,
ol.proj.EPSG3857.fromEPSG4326,
ol.proj.EPSG3857.toEPSG4326);
};

View File

@@ -2,6 +2,7 @@ goog.provide('ol.proj.EPSG3857');
goog.require('ol');
goog.require('ol.math');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
@@ -15,7 +16,7 @@ goog.require('ol.proj.Units');
* @param {string} code Code.
* @private
*/
ol.proj.EPSG3857.Projection_ = function(code) {
ol.proj.EPSG3857_ = function(code) {
ol.proj.Projection.call(this, {
code: code,
units: ol.proj.Units.METERS,
@@ -27,7 +28,7 @@ ol.proj.EPSG3857.Projection_ = function(code) {
}
});
};
ol.inherits(ol.proj.EPSG3857.Projection_, ol.proj.Projection);
ol.inherits(ol.proj.EPSG3857_, ol.proj.Projection);
/**
@@ -84,7 +85,7 @@ ol.proj.EPSG3857.CODES = [
* @type {Array.<ol.proj.Projection>}
*/
ol.proj.EPSG3857.PROJECTIONS = ol.proj.EPSG3857.CODES.map(function(code) {
return new ol.proj.EPSG3857.Projection_(code);
return new ol.proj.EPSG3857_(code);
});

View File

@@ -1,6 +1,7 @@
goog.provide('ol.proj.EPSG4326');
goog.require('ol');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
goog.require('ol.sphere.WGS84');
@@ -20,7 +21,7 @@ goog.require('ol.sphere.WGS84');
* @param {string=} opt_axisOrientation Axis orientation.
* @private
*/
ol.proj.EPSG4326.Projection_ = function(code, opt_axisOrientation) {
ol.proj.EPSG4326_ = function(code, opt_axisOrientation) {
ol.proj.Projection.call(this, {
code: code,
units: ol.proj.Units.DEGREES,
@@ -31,7 +32,7 @@ ol.proj.EPSG4326.Projection_ = function(code, opt_axisOrientation) {
worldExtent: ol.proj.EPSG4326.EXTENT
});
};
ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection);
ol.inherits(ol.proj.EPSG4326_, ol.proj.Projection);
/**
@@ -57,12 +58,12 @@ ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.sphere.WGS84.radius / 180;
* @type {Array.<ol.proj.Projection>}
*/
ol.proj.EPSG4326.PROJECTIONS = [
new ol.proj.EPSG4326.Projection_('CRS:84'),
new ol.proj.EPSG4326.Projection_('EPSG:4326', 'neu'),
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:EPSG::4326', 'neu'),
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:OGC:1.3:CRS84'),
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:OGC:2:84'),
new ol.proj.EPSG4326.Projection_('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
new ol.proj.EPSG4326.Projection_('urn:x-ogc:def:crs:EPSG:4326', 'neu')
new ol.proj.EPSG4326_('CRS:84'),
new ol.proj.EPSG4326_('EPSG:4326', 'neu'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:EPSG::4326', 'neu'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:OGC:1.3:CRS84'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:OGC:2:84'),
new ol.proj.EPSG4326_('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
new ol.proj.EPSG4326_('urn:x-ogc:def:crs:EPSG:4326', 'neu')
];

View File

@@ -3,14 +3,14 @@ goog.provide('ol.proj.proj4');
/**
* @private
* @type {Proj4}
* @type {proj4}
*/
ol.proj.proj4.cache_ = null;
/**
* Store the proj4 function.
* @param {Proj4} proj4 The proj4 function.
* @param {proj4} proj4 The proj4 function.
*/
ol.proj.proj4.set = function(proj4) {
ol.proj.proj4.cache_ = proj4;
@@ -19,7 +19,7 @@ ol.proj.proj4.set = function(proj4) {
/**
* Get proj4.
* @return {Proj4} The proj4 function set above or available globally.
* @return {proj4} The proj4 function set above or available globally.
*/
ol.proj.proj4.get = function() {
return ol.proj.proj4.cache_ || window['proj4'];

View File

@@ -3,7 +3,6 @@ goog.provide('ol.renderer.canvas.IntermediateCanvas');
goog.require('ol');
goog.require('ol.coordinate');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.renderer.canvas.Layer');
goog.require('ol.transform');
@@ -30,6 +29,12 @@ ol.renderer.canvas.IntermediateCanvas = function(layer) {
*/
this.hitCanvasContext_ = null;
/**
* @protected
* @type {number}
*/
this.renderedResolution;
};
ol.inherits(ol.renderer.canvas.IntermediateCanvas, ol.renderer.canvas.Layer);
@@ -46,9 +51,7 @@ ol.renderer.canvas.IntermediateCanvas.prototype.composeFrame = function(frameSta
// clipped rendering if layer extent is set
var extent = layerState.extent;
var clipped = extent !== undefined &&
!ol.extent.containsExtent(extent, frameState.extent) &&
ol.extent.intersects(extent, frameState.extent);
var clipped = extent !== undefined;
if (clipped) {
this.clip(context, frameState, /** @type {ol.Extent} */ (extent));
}

View File

@@ -145,10 +145,7 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
var layerStatesArray = frameState.layerStatesArray;
ol.array.stableSort(layerStatesArray, ol.renderer.Map.sortByZIndex);
if (rotation) {
context.save();
ol.render.canvas.rotateAtOffset(context, rotation, width / 2, height / 2);
}
ol.render.canvas.rotateAtOffset(context, rotation, width / 2, height / 2);
var viewResolution = frameState.viewState.resolution;
var i, ii, layer, layerRenderer, layerState;
@@ -165,9 +162,7 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
}
}
if (rotation) {
context.restore();
}
ol.render.canvas.rotateAtOffset(context, -rotation, width / 2, height / 2);
this.dispatchComposeEvent_(
ol.render.EventType.POSTCOMPOSE, frameState);

View File

@@ -26,7 +26,7 @@ ol.renderer.canvas.TileLayer = function(tileLayer) {
* @protected
* @type {CanvasRenderingContext2D}
*/
this.context = this.context === null ? null : ol.dom.createCanvasContext2D();
this.context = ol.dom.createCanvasContext2D();
/**
* @private
@@ -178,20 +178,19 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
this.renderedRevision != sourceRevision) ||
oversampling != this.oversampling_) {
var tilePixelSize = tileSource.getTilePixelSize(z, pixelRatio, projection);
var width = Math.round(tileRange.getWidth() * tilePixelSize[0] / oversampling);
var height = Math.round(tileRange.getHeight() * tilePixelSize[0] / oversampling);
var context = this.context;
if (context) {
var tilePixelSize = tileSource.getTilePixelSize(z, pixelRatio, projection);
var width = Math.round(tileRange.getWidth() * tilePixelSize[0] / oversampling);
var height = Math.round(tileRange.getHeight() * tilePixelSize[1] / oversampling);
var canvas = context.canvas;
if (canvas.width != width || canvas.height != height) {
this.oversampling_ = oversampling;
canvas.width = width;
canvas.height = height;
} else {
context.clearRect(0, 0, width, height);
oversampling = this.oversampling_;
}
var canvas = context.canvas;
var opaque = tileSource.getOpaque(projection);
if (canvas.width != width || canvas.height != height) {
this.oversampling_ = oversampling;
canvas.width = width;
canvas.height = height;
} else {
context.clearRect(0, 0, width, height);
oversampling = this.oversampling_;
}
this.renderedTiles.length = 0;
@@ -214,6 +213,9 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
y = (imageExtent[3] - tileExtent[3]) / tileResolution * tilePixelRatio / oversampling;
w = currentTilePixelSize[0] * currentScale / oversampling;
h = currentTilePixelSize[1] * currentScale / oversampling;
if (!opaque) {
context.clearRect(x, y, w, h);
}
this.drawTileImage(tile, frameState, layerState, x, y, w, h, tileGutter);
this.renderedTiles.push(tile);
}
@@ -259,9 +261,6 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
* @param {number} gutter Tile gutter.
*/
ol.renderer.canvas.TileLayer.prototype.drawTileImage = function(tile, frameState, layerState, x, y, w, h, gutter) {
if (!this.getLayer().getSource().getOpaque(frameState.viewState.projection)) {
this.context.clearRect(x, y, w, h);
}
var image = tile.getImage();
if (image) {
this.context.drawImage(image, gutter, gutter,
@@ -274,8 +273,7 @@ ol.renderer.canvas.TileLayer.prototype.drawTileImage = function(tile, frameState
* @inheritDoc
*/
ol.renderer.canvas.TileLayer.prototype.getImage = function() {
var context = this.context;
return context ? context.canvas : null;
return this.context.canvas;
};

View File

@@ -1,7 +1,6 @@
goog.provide('ol.renderer.canvas.VectorTileLayer');
goog.require('ol');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.proj.Units');
@@ -23,8 +22,6 @@ goog.require('ol.transform');
*/
ol.renderer.canvas.VectorTileLayer = function(layer) {
this.context = null;
ol.renderer.canvas.TileLayer.call(this, layer);
/**
@@ -77,17 +74,9 @@ ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS = {
* @inheritDoc
*/
ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame = function(frameState, layerState) {
var layer = this.getLayer();
var layerRevision = layer.getRevision();
var layerRevision = this.getLayer().getRevision();
if (this.renderedLayerRevision_ != layerRevision) {
this.renderedTiles.length = 0;
var renderMode = layer.getRenderMode();
if (!this.context && renderMode != ol.layer.VectorTileRenderType.VECTOR) {
this.context = ol.dom.createCanvasContext2D();
}
if (this.context && renderMode == ol.layer.VectorTileRenderType.VECTOR) {
this.context = null;
}
}
this.renderedLayerRevision_ = layerRevision;
return ol.renderer.canvas.TileLayer.prototype.prepareFrame.apply(this, arguments);
@@ -195,10 +184,11 @@ ol.renderer.canvas.VectorTileLayer.prototype.drawTileImage = function(
tile, frameState, layerState, x, y, w, h, gutter) {
var vectorTile = /** @type {ol.VectorTile} */ (tile);
this.createReplayGroup_(vectorTile, frameState);
if (this.context) {
var layer = this.getLayer();
if (layer.getRenderMode() != ol.layer.VectorTileRenderType.VECTOR) {
this.renderTileImage_(vectorTile, frameState, layerState);
ol.renderer.canvas.TileLayer.prototype.drawTileImage.apply(this, arguments);
}
ol.renderer.canvas.TileLayer.prototype.drawTileImage.apply(this, arguments);
};

View File

@@ -74,16 +74,6 @@ ol.source.Cluster = function(options) {
ol.inherits(ol.source.Cluster, ol.source.Vector);
/**
* Get the distance in pixels between clusters.
* @return {number} Distance.
* @api
*/
ol.source.Cluster.prototype.getDistance = function() {
return this.distance_;
};
/**
* Get a reference to the wrapped source.
* @return {ol.source.Vector} Source.

View File

@@ -208,7 +208,7 @@ ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixe
params['BBOX'] = extent.join(',');
params['BBOXSR'] = srid;
params['IMAGESR'] = srid;
params['DPI'] = Math.round(90 * pixelRatio);
params['DPI'] = 90 * pixelRatio;
var url = this.url_;

View File

@@ -79,8 +79,10 @@ ol.source.ImageStatic.prototype.handleImageChange = function(evt) {
imageWidth = this.imageSize_[0];
imageHeight = this.imageSize_[1];
} else {
imageWidth = image.width;
imageHeight = image.height;
// TODO: remove the type cast when a closure-compiler > 20160315 is used.
// see: https://github.com/google/closure-compiler/pull/1664
imageWidth = /** @type {number} */ (image.width);
imageHeight = /** @type {number} */ (image.height);
}
var resolution = ol.extent.getHeight(imageExtent) / imageHeight;
var targetWidth = Math.ceil(ol.extent.getWidth(imageExtent) / resolution);

View File

@@ -194,11 +194,11 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix
var center = ol.extent.getCenter(extent);
var viewWidth = Math.ceil(ol.extent.getWidth(extent) / imageResolution);
var viewHeight = Math.ceil(ol.extent.getHeight(extent) / imageResolution);
var viewExtent = ol.extent.getForViewAndSize(center, imageResolution, 0,
var viewExtent = ol.extent.getForViewAndSize(center, resolution, 0,
[viewWidth, viewHeight]);
var requestWidth = Math.ceil(this.ratio_ * ol.extent.getWidth(extent) / imageResolution);
var requestHeight = Math.ceil(this.ratio_ * ol.extent.getHeight(extent) / imageResolution);
var requestExtent = ol.extent.getForViewAndSize(center, imageResolution, 0,
var requestExtent = ol.extent.getForViewAndSize(center, resolution, 0,
[requestWidth, requestHeight]);
var image = this.image_;

View File

@@ -65,6 +65,12 @@ ol.source.Raster = function(options) {
this.changed, this);
}
/**
* @private
* @type {CanvasRenderingContext2D}
*/
this.canvasContext_ = ol.dom.createCanvasContext2D();
/**
* @private
* @type {ol.TileQueue}
@@ -82,11 +88,11 @@ ol.source.Raster = function(options) {
}
/**
* The most recently requested frame state.
* @type {olx.FrameState}
* The most recently rendered state.
* @type {?ol.SourceRasterRenderedState}
* @private
*/
this.requestedFrameState_;
this.renderedState_ = null;
/**
* The most recently rendered image canvas.
@@ -95,12 +101,6 @@ ol.source.Raster = function(options) {
*/
this.renderedImageCanvas_ = null;
/**
* The most recently rendered revision.
* @type {number}
*/
this.renderedRevision_;
/**
* @private
* @type {olx.FrameState}
@@ -176,11 +176,13 @@ ol.source.Raster.prototype.updateFrameState_ = function(extent, resolution, proj
ol.obj.assign({}, frameState.viewState));
var center = ol.extent.getCenter(extent);
var width = Math.round(ol.extent.getWidth(extent) / resolution);
var height = Math.round(ol.extent.getHeight(extent) / resolution);
frameState.extent = extent.slice();
frameState.focus = center;
frameState.size[0] = Math.round(ol.extent.getWidth(extent) / resolution);
frameState.size[1] = Math.round(ol.extent.getHeight(extent) / resolution);
frameState.extent = extent;
frameState.focus = ol.extent.getCenter(extent);
frameState.size[0] = width;
frameState.size[1] = height;
var viewState = frameState.viewState;
viewState.center = center;
@@ -190,6 +192,66 @@ ol.source.Raster.prototype.updateFrameState_ = function(extent, resolution, proj
};
/**
* Determine if the most recently rendered image canvas is dirty.
* @param {ol.Extent} extent The requested extent.
* @param {number} resolution The requested resolution.
* @return {boolean} The image is dirty.
* @private
*/
ol.source.Raster.prototype.isDirty_ = function(extent, resolution) {
var state = this.renderedState_;
return !state ||
this.getRevision() !== state.revision ||
resolution !== state.resolution ||
!ol.extent.equals(extent, state.extent);
};
/**
* @inheritDoc
*/
ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
if (!this.allSourcesReady_()) {
return null;
}
var currentExtent = extent.slice();
if (!this.isDirty_(currentExtent, resolution)) {
return this.renderedImageCanvas_;
}
var context = this.canvasContext_;
var canvas = context.canvas;
var width = Math.round(ol.extent.getWidth(currentExtent) / resolution);
var height = Math.round(ol.extent.getHeight(currentExtent) / resolution);
if (width !== canvas.width ||
height !== canvas.height) {
canvas.width = width;
canvas.height = height;
}
var frameState = this.updateFrameState_(currentExtent, resolution, projection);
var imageCanvas = new ol.ImageCanvas(
currentExtent, resolution, 1, this.getAttributions(), canvas,
this.composeFrame_.bind(this, frameState));
this.renderedImageCanvas_ = imageCanvas;
this.renderedState_ = {
extent: currentExtent,
resolution: resolution,
revision: this.getRevision()
};
return imageCanvas;
};
/**
* Determine if all sources are ready.
* @return {boolean} All sources are ready.
@@ -210,41 +272,13 @@ ol.source.Raster.prototype.allSourcesReady_ = function() {
/**
* @inheritDoc
*/
ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
if (!this.allSourcesReady_()) {
return null;
}
var frameState = this.updateFrameState_(extent, resolution, projection);
this.requestedFrameState_ = frameState;
frameState.tileQueue.loadMoreTiles(16, 16);
// check if we can't reuse the existing ol.ImageCanvas
if (this.renderedImageCanvas_) {
var renderedResolution = this.renderedImageCanvas_.getResolution();
var renderedExtent = this.renderedImageCanvas_.getExtent();
if (resolution !== renderedResolution || !ol.extent.equals(extent, renderedExtent)) {
this.renderedImageCanvas_ = null;
}
}
if (!this.renderedImageCanvas_ || this.getRevision() !== this.renderedRevision_) {
this.processSources_();
}
return this.renderedImageCanvas_;
};
/**
* Start processing source data.
* Compose the frame. This renders data from all sources, runs pixel-wise
* operations, and renders the result to the stored canvas context.
* @param {olx.FrameState} frameState The frame state.
* @param {function(Error)} callback Called when composition is complete.
* @private
*/
ol.source.Raster.prototype.processSources_ = function() {
var frameState = this.requestedFrameState_;
ol.source.Raster.prototype.composeFrame_ = function(frameState, callback) {
var len = this.renderers_.length;
var imageDatas = new Array(len);
for (var i = 0; i < len; ++i) {
@@ -253,56 +287,53 @@ ol.source.Raster.prototype.processSources_ = function() {
if (imageData) {
imageDatas[i] = imageData;
} else {
return;
// image not yet ready
imageDatas = null;
break;
}
}
var data = {};
this.dispatchEvent(new ol.source.Raster.Event(
ol.source.Raster.EventType_.BEFOREOPERATIONS, frameState, data));
this.worker_.process(imageDatas, data,
this.onWorkerComplete_.bind(this, frameState));
if (imageDatas) {
var data = {};
this.dispatchEvent(new ol.source.Raster.Event(
ol.source.Raster.EventType_.BEFOREOPERATIONS, frameState, data));
this.worker_.process(imageDatas, data,
this.onWorkerComplete_.bind(this, frameState, callback));
}
frameState.tileQueue.loadMoreTiles(16, 16);
};
/**
* Called when pixel processing is complete.
* @param {olx.FrameState} frameState The frame state.
* @param {function(Error)} callback Called when rendering is complete.
* @param {Error} err Any error during processing.
* @param {ImageData} output The output image data.
* @param {Object} data The user data.
* @private
*/
ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output, data) {
if (err || !output) {
ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, callback, err, output, data) {
if (err) {
callback(err);
return;
}
// do nothing if extent or resolution changed
var extent = frameState.extent;
var resolution = frameState.viewState.resolution;
if (resolution !== this.requestedFrameState_.viewState.resolution ||
!ol.extent.equals(extent, this.requestedFrameState_.extent)) {
if (!output) {
// job aborted
return;
}
var context;
if (this.renderedImageCanvas_) {
context = this.renderedImageCanvas_.getImage().getContext('2d');
} else {
var width = Math.round(ol.extent.getWidth(extent) / resolution);
var height = Math.round(ol.extent.getHeight(extent) / resolution);
context = ol.dom.createCanvasContext2D(width, height);
this.renderedImageCanvas_ = new ol.ImageCanvas(
extent, resolution, 1, this.getAttributions(), context.canvas);
}
context.putImageData(output, 0, 0);
this.changed();
this.renderedRevision_ = this.getRevision();
this.dispatchEvent(new ol.source.Raster.Event(
ol.source.Raster.EventType_.AFTEROPERATIONS, frameState, data));
var resolution = frameState.viewState.resolution / frameState.pixelRatio;
if (!this.isDirty_(frameState.extent, resolution)) {
this.canvasContext_.putImageData(output, 0, 0);
}
callback(null);
};

View File

@@ -194,7 +194,7 @@ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) {
} else {
var projKey = ol.getUid(projection).toString();
if (!(projKey in this.tileCacheForProjection)) {
this.tileCacheForProjection[projKey] = new ol.TileCache(this.tileCache.highWaterMark);
this.tileCacheForProjection[projKey] = new ol.TileCache();
}
return this.tileCacheForProjection[projKey];
}

View File

@@ -610,13 +610,11 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
*
* This method is not available when the source is configured with
* `useSpatialIndex` set to `false`.
* @param {ol.Extent=} opt_extent Destination extent. If provided, no new extent
* will be created. Instead, that extent's coordinates will be overwritten.
* @return {!ol.Extent} Extent.
* @api
*/
ol.source.Vector.prototype.getExtent = function(opt_extent) {
return this.featuresRtree_.getExtent(opt_extent);
ol.source.Vector.prototype.getExtent = function() {
return this.featuresRtree_.getExtent();
};

View File

@@ -292,8 +292,7 @@ ol.source.WMTS.prototype.updateDimensions = function(dimensions) {
* - style - {string} The name of the style
* - format - {string} Image format for the layer. Default is the first
* format returned in the GetCapabilities response.
* - crossOrigin - {string|null|undefined} Cross origin. Default is `undefined`.
* @return {?olx.source.WMTSOptions} WMTS source options object or `null` if the layer was not found.
* @return {olx.source.WMTSOptions} WMTS source options object.
* @api
*/
ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
@@ -301,9 +300,6 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var l = ol.array.find(layers, function(elt, index, array) {
return elt['Identifier'] == config['layer'];
});
if (l === null) {
return null;
}
var tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
var idx, matrixSet, matrixLimits;
if (l['TileMatrixSetLink'].length > 1) {
@@ -448,7 +444,6 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
tileGrid: tileGrid,
style: style,
dimensions: dimensions,
wrapX: wrapX,
crossOrigin: config['crossOrigin']
wrapX: wrapX
};
};

View File

@@ -3,7 +3,6 @@ goog.provide('ol.source.Zoomify');
goog.require('ol');
goog.require('ol.ImageTile');
goog.require('ol.TileState');
goog.require('ol.TileUrlFunction');
goog.require('ol.asserts');
goog.require('ol.dom');
goog.require('ol.extent');
@@ -84,51 +83,31 @@ ol.source.Zoomify = function(opt_options) {
});
var url = options.url;
if (url && url.indexOf('{TileGroup}') == -1) {
url += '{TileGroup}/{z}-{x}-{y}.jpg';
}
var urls = ol.TileUrlFunction.expandUrl(url);
/**
* @param {string} template Template.
* @return {ol.TileUrlFunctionType} Tile URL function.
* @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL.
*/
function createFromTemplate(template) {
return (
/**
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL.
*/
function(tileCoord, pixelRatio, projection) {
if (!tileCoord) {
return undefined;
} else {
var tileCoordZ = tileCoord[0];
var tileCoordX = tileCoord[1];
var tileCoordY = -tileCoord[2] - 1;
var tileIndex =
tileCoordX +
tileCoordY * tierSizeInTiles[tileCoordZ][0] +
tileCountUpToTier[tileCoordZ];
var tileGroup = (tileIndex / ol.DEFAULT_TILE_SIZE) | 0;
var localContext = {
'z': tileCoordZ,
'x': tileCoordX,
'y': tileCoordY,
'TileGroup': 'TileGroup' + tileGroup
};
return template.replace(/\{(\w+?)\}/g, function(m, p) {
return localContext[p];
});
}
});
function tileUrlFunction(tileCoord, pixelRatio, projection) {
if (!tileCoord) {
return undefined;
} else {
var tileCoordZ = tileCoord[0];
var tileCoordX = tileCoord[1];
var tileCoordY = -tileCoord[2] - 1;
var tileIndex =
tileCoordX +
tileCoordY * tierSizeInTiles[tileCoordZ][0] +
tileCountUpToTier[tileCoordZ];
var tileGroup = (tileIndex / ol.DEFAULT_TILE_SIZE) | 0;
return url + 'TileGroup' + tileGroup + '/' +
tileCoordZ + '-' + tileCoordX + '-' + tileCoordY + '.jpg';
}
}
var tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(createFromTemplate));
ol.source.TileImage.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,

View File

@@ -213,5 +213,5 @@ ol.structs.RBush.prototype.clear = function() {
ol.structs.RBush.prototype.getExtent = function(opt_extent) {
// FIXME add getExtent() to rbush
var data = this.rbush_.data;
return ol.extent.createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
return [data.minX, data.minY, data.maxX, data.maxY];
};

View File

@@ -322,11 +322,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
var strokeWidth = 0;
if (this.stroke_) {
strokeStyle = this.stroke_.getColor();
if (strokeStyle === null) {
strokeStyle = ol.render.canvas.defaultStrokeStyle;
}
strokeStyle = ol.colorlike.asColorLike(strokeStyle);
strokeStyle = ol.colorlike.asColorLike(this.stroke_.getColor());
strokeWidth = this.stroke_.getWidth();
if (strokeWidth === undefined) {
strokeWidth = ol.render.canvas.defaultLineWidth;
@@ -446,11 +442,7 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
if (this.fill_) {
var color = this.fill_.getColor();
if (color === null) {
color = ol.render.canvas.defaultFillStyle;
}
context.fillStyle = ol.colorlike.asColorLike(color);
context.fillStyle = ol.colorlike.asColorLike(this.fill_.getColor());
context.fill();
}
if (this.stroke_) {

View File

@@ -15,9 +15,10 @@ ol.TileCache = function(opt_highWaterMark) {
ol.structs.LRUCache.call(this);
/**
* @private
* @type {number}
*/
this.highWaterMark = opt_highWaterMark !== undefined ? opt_highWaterMark : 2048;
this.highWaterMark_ = opt_highWaterMark !== undefined ? opt_highWaterMark : 2048;
};
ol.inherits(ol.TileCache, ol.structs.LRUCache);
@@ -27,7 +28,7 @@ ol.inherits(ol.TileCache, ol.structs.LRUCache);
* @return {boolean} Can expire cache.
*/
ol.TileCache.prototype.canExpireCache = function() {
return this.getCount() > this.highWaterMark;
return this.getCount() > this.highWaterMark_;
};

View File

@@ -442,15 +442,6 @@ ol.RasterOperation;
ol.RegularShapeRenderOptions;
/**
* A function to be used when sorting features before rendering.
* It takes two instances of {@link ol.Feature} and returns a `{number}`.
*
* @typedef {function(ol.Feature, ol.Feature):number}
*/
ol.RenderOrderFunction;
/**
* @typedef {function(ol.Extent, number, number) : ol.ImageBase}
*/
@@ -640,7 +631,7 @@ ol.TilePriorityFunction;
/**
* @typedef {{
* dirty: boolean,
* renderedRenderOrder: (null|ol.RenderOrderFunction),
* renderedRenderOrder: (null|function(ol.Feature, ol.Feature):number),
* renderedTileRevision: number,
* renderedRevision: number,
* replayGroup: ol.render.ReplayGroup}}

View File

@@ -24,7 +24,7 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction) {
* @private
* @type {CanvasRenderingContext2D}
*/
this.context_ = null;
this.context_ = ol.dom.createCanvasContext2D();
/**
* @private
@@ -83,9 +83,6 @@ ol.inherits(ol.VectorTile, ol.Tile);
* @return {CanvasRenderingContext2D} The rendering context.
*/
ol.VectorTile.prototype.getContext = function() {
if (!this.context_) {
this.context_ = ol.dom.createCanvasContext2D();
}
return this.context_;
};

View File

@@ -16,7 +16,6 @@ goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Polygon');
goog.require('ol.geom.SimpleGeometry');
goog.require('ol.obj');
goog.require('ol.proj');
goog.require('ol.proj.Units');
@@ -80,8 +79,7 @@ goog.require('ol.proj.Units');
*/
ol.View = function(opt_options) {
ol.Object.call(this);
var options = ol.obj.assign({}, opt_options);
var options = opt_options || {};
/**
* @private
@@ -103,24 +101,6 @@ ol.View = function(opt_options) {
this.updateAnimations_ = this.updateAnimations_.bind(this);
/**
* @private
* @const
* @type {ol.proj.Projection}
*/
this.projection_ = ol.proj.createProjection(options.projection, 'EPSG:3857');
this.applyOptions_(options);
};
ol.inherits(ol.View, ol.Object);
/**
* Set up the view with the given options.
* @param {olx.ViewOptions} options View options.
*/
ol.View.prototype.applyOptions_ = function(options) {
/**
* @type {Object.<string, *>}
*/
@@ -128,6 +108,13 @@ ol.View.prototype.applyOptions_ = function(options) {
properties[ol.ViewProperty.CENTER] = options.center !== undefined ?
options.center : null;
/**
* @private
* @const
* @type {ol.proj.Projection}
*/
this.projection_ = ol.proj.createProjection(options.projection, 'EPSG:3857');
var resolutionConstraintInfo = ol.View.createResolutionConstraint_(
options);
@@ -181,41 +168,8 @@ ol.View.prototype.applyOptions_ = function(options) {
properties[ol.ViewProperty.ROTATION] =
options.rotation !== undefined ? options.rotation : 0;
this.setProperties(properties);
/**
* @private
* @type {olx.ViewOptions}
*/
this.options_ = options;
};
/**
* Get an updated version of the view options used to construct the view. The
* current resolution (or zoom), center, and rotation are applied to any stored
* options. The provided options can be uesd to apply new min/max zoom or
* resolution limits.
* @param {olx.ViewOptions} newOptions New options to be applied.
* @return {olx.ViewOptions} New options updated with the current view state.
*/
ol.View.prototype.getUpdatedOptions_ = function(newOptions) {
var options = ol.obj.assign({}, this.options_);
// preserve resolution (or zoom)
if (options.resolution !== undefined) {
options.resolution = this.getResolution();
} else {
options.zoom = this.getZoom();
}
// preserve center
options.center = this.getCenter();
// preserve rotation
options.rotation = this.getRotation();
return ol.obj.assign({}, options, newOptions);
};
ol.inherits(ol.View, ol.Object);
/**
@@ -310,7 +264,6 @@ ol.View.prototype.animate = function(var_args) {
/**
* Determine if the view is being animated.
* @return {boolean} The view is being animated.
* @api
*/
ol.View.prototype.getAnimating = function() {
return this.getHints()[ol.ViewHint.ANIMATING] > 0;
@@ -319,7 +272,6 @@ ol.View.prototype.getAnimating = function() {
/**
* Cancel any ongoing animations.
* @api
*/
ol.View.prototype.cancelAnimations = function() {
this.setHint(ol.ViewHint.ANIMATING, -this.getHints()[ol.ViewHint.ANIMATING]);
@@ -371,20 +323,18 @@ ol.View.prototype.updateAnimations_ = function() {
var y = y0 + progress * (y1 - y0);
this.set(ol.ViewProperty.CENTER, [x, y]);
}
if (animation.sourceResolution && animation.targetResolution) {
var resolution = progress === 1 ?
animation.targetResolution :
animation.sourceResolution + progress * (animation.targetResolution - animation.sourceResolution);
if (animation.sourceResolution) {
var resolution = animation.sourceResolution +
progress * (animation.targetResolution - animation.sourceResolution);
if (animation.anchor) {
this.set(ol.ViewProperty.CENTER,
this.calculateCenterZoom(resolution, animation.anchor));
}
this.set(ol.ViewProperty.RESOLUTION, resolution);
}
if (animation.sourceRotation !== undefined && animation.targetRotation !== undefined) {
var rotation = progress === 1 ?
animation.targetRotation :
animation.sourceRotation + progress * (animation.targetRotation - animation.sourceRotation);
if (animation.sourceRotation !== undefined) {
var rotation = animation.sourceRotation +
progress * (animation.targetRotation - animation.sourceRotation);
if (animation.anchor) {
this.set(ol.ViewProperty.CENTER,
this.calculateCenterRotate(rotation, animation.anchor));
@@ -576,46 +526,6 @@ ol.View.prototype.getMinResolution = function() {
};
/**
* Get the maximum zoom level for the view.
* @return {number} The maximum zoom level.
* @api
*/
ol.View.prototype.getMaxZoom = function() {
return /** @type {number} */ (this.getZoomForResolution(this.minResolution_));
};
/**
* Set a new maximum zoom level for the view.
* @param {number} zoom The maximum zoom level.
* @api
*/
ol.View.prototype.setMaxZoom = function(zoom) {
this.applyOptions_(this.getUpdatedOptions_({maxZoom: zoom}));
};
/**
* Get the minimum zoom level for the view.
* @return {number} The minimum zoom level.
* @api
*/
ol.View.prototype.getMinZoom = function() {
return /** @type {number} */ (this.getZoomForResolution(this.maxResolution_));
};
/**
* Set a new minimum zoom level for the view.
* @param {number} zoom The minimum zoom level.
* @api
*/
ol.View.prototype.setMinZoom = function(zoom) {
this.applyOptions_(this.getUpdatedOptions_({minZoom: zoom}));
};
/**
* Get the view projection.
* @return {ol.proj.Projection} The projection of the view.
@@ -747,22 +657,8 @@ ol.View.prototype.getState = function() {
ol.View.prototype.getZoom = function() {
var zoom;
var resolution = this.getResolution();
if (resolution !== undefined) {
zoom = this.getZoomForResolution(resolution);
}
return zoom;
};
/**
* Get the zoom level for a resolution.
* @param {number} resolution The resolution.
* @return {number|undefined} The zoom level for the provided resolution.
* @api
*/
ol.View.prototype.getZoomForResolution = function(resolution) {
var zoom;
if (resolution >= this.minResolution_ && resolution <= this.maxResolution_) {
if (resolution !== undefined &&
resolution >= this.minResolution_ && resolution <= this.maxResolution_) {
var offset = this.minZoom_ || 0;
var max, zoomFactor;
if (this.resolutions_) {

View File

@@ -56,7 +56,7 @@ function getLinkToApiHtml(requires) {
* example HTML file, this adds metadata for related js and css resources. When
* these files are run through the example template, the extra metadata is used
* to show the complete example source in the textarea and submit the parts to
* CodePen.
* jsFiddle.
*
* @param {Object} files The file lookup provided by Metalsmith. Property names
* are file paths relative to the source directory. The file objects
@@ -111,13 +111,13 @@ function augmentExamples(files, metalsmith, done) {
if (file.resources) {
var resources = [];
var remoteResources = [];
var codePenResources = [];
var fiddleResources = [];
for (var i = 0, ii = file.resources.length; i < ii; ++i) {
var resource = file.resources[i];
var remoteResource = resource.indexOf('//') === -1 ?
'https://openlayers.org/en/v' + pkg.version + '/examples/' +
resource : resource;
codePenResources[i] = remoteResource;
fiddleResources[i] = remoteResource;
if (isJsRegEx.test(resource)) {
resources[i] = '<script src="' + resource + '"></script>';
remoteResources[i] = '<script src="' + remoteResource +
@@ -138,7 +138,7 @@ function augmentExamples(files, metalsmith, done) {
remote: remoteResources.join('\n')
};
file.extraResources = file.resources.length ?
',' + codePenResources.join(',') : '';
',' + fiddleResources.join(',') : '';
}
}
}

Some files were not shown because too many files have changed in this diff Show More