Compare commits
306 Commits
v4.0.1
...
v4.1.2-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
646c9fb177 | ||
|
|
366bf46ca1 | ||
|
|
50615557d9 | ||
|
|
1c0f891427 | ||
|
|
0c6c0ef6d5 | ||
|
|
735ab45480 | ||
|
|
55c2adc503 | ||
|
|
2486b25e5e | ||
|
|
020a8da9bb | ||
|
|
d559037f31 | ||
|
|
cce81bcefb | ||
|
|
fc73c4b1fd | ||
|
|
588efb1427 | ||
|
|
e7afe2cb9c | ||
|
|
5e3ba9b7d1 | ||
|
|
51230aa3fb | ||
|
|
069ae0aff4 | ||
|
|
ec336e1d0e | ||
|
|
d2e571e3d1 | ||
|
|
1a9c41ae4e | ||
|
|
10aebb58d2 | ||
|
|
2d46c83149 | ||
|
|
3c62396533 | ||
|
|
22f55a7aeb | ||
|
|
3d7bd00abf | ||
|
|
7b1ed14e4e | ||
|
|
3c88e04d4c | ||
|
|
9adab910f4 | ||
|
|
d7969931e8 | ||
|
|
94b6f27937 | ||
|
|
8690bb7c12 | ||
|
|
49b5bbc964 | ||
|
|
479d98212b | ||
|
|
3f973e6fa3 | ||
|
|
584d4f67bd | ||
|
|
642ed5f46e | ||
|
|
9a9e6e94ff | ||
|
|
88b028e4a5 | ||
|
|
fb07d2dad6 | ||
|
|
b4f68ef021 | ||
|
|
403214f569 | ||
|
|
944f0df981 | ||
|
|
97b3ff0499 | ||
|
|
4507fb9368 | ||
|
|
cdd44c4db8 | ||
|
|
983fe5e086 | ||
|
|
f4686adced | ||
|
|
16f97a74d7 | ||
|
|
242c55dcff | ||
|
|
1f87dcc6b8 | ||
|
|
dafe3a0811 | ||
|
|
9ac4d137ff | ||
|
|
3cb3113705 | ||
|
|
239f9e817d | ||
|
|
b9f42ddc0f | ||
|
|
c437afc15b | ||
|
|
41812172a7 | ||
|
|
11e682e061 | ||
|
|
821cf24c5b | ||
|
|
14f29e95a7 | ||
|
|
8aa30ee8f6 | ||
|
|
c9303f5889 | ||
|
|
b1f38ea0e8 | ||
|
|
3e9cbade45 | ||
|
|
52af66e0f9 | ||
|
|
c1911994ea | ||
|
|
af62ef736d | ||
|
|
4a6f427df7 | ||
|
|
00a2d7b1cb | ||
|
|
e2af6b9d04 | ||
|
|
4955097a52 | ||
|
|
870bc51ad9 | ||
|
|
ea54543602 | ||
|
|
bb278df881 | ||
|
|
46fde0e439 | ||
|
|
e3d895be4c | ||
|
|
dd8d4b5ad8 | ||
|
|
d956a3bdb3 | ||
|
|
66930ab303 | ||
|
|
0f032a1388 | ||
|
|
5ce54c9e0d | ||
|
|
b86950da6f | ||
|
|
f7c71bdaac | ||
|
|
ee2aa91d97 | ||
|
|
c353455b83 | ||
|
|
530419a839 | ||
|
|
2b5d6536ca | ||
|
|
8116d8c11f | ||
|
|
04a1871ae3 | ||
|
|
41ebe62852 | ||
|
|
51da8ed830 | ||
|
|
515de3f6ad | ||
|
|
6604172c1c | ||
|
|
4a9114cd4e | ||
|
|
525fba6405 | ||
|
|
dff5cc63e7 | ||
|
|
3b83f666c1 | ||
|
|
9c8a3ba688 | ||
|
|
64b3302883 | ||
|
|
d28f50465b | ||
|
|
de057ac505 | ||
|
|
8b0e1b638b | ||
|
|
65103d5bd0 | ||
|
|
5d038d9d9b | ||
|
|
45e8f7d0c9 | ||
|
|
2b6e71ff46 | ||
|
|
f206fab268 | ||
|
|
4d30781673 | ||
|
|
5b162ce2b9 | ||
|
|
f12e0e3ed6 | ||
|
|
8a0e7439a7 | ||
|
|
15e6fa454d | ||
|
|
72bb310386 | ||
|
|
55f8a2775e | ||
|
|
051d5651a5 | ||
|
|
5c23123b6d | ||
|
|
80b51d083e | ||
|
|
b301760976 | ||
|
|
76ddcd405d | ||
|
|
d97d5e5164 | ||
|
|
55ace18509 | ||
|
|
cf6cd968ec | ||
|
|
9a230fcacf | ||
|
|
aaf3256279 | ||
|
|
3285c11e9c | ||
|
|
5e84d806d7 | ||
|
|
fc1a0c6c3d | ||
|
|
07b8d97751 | ||
|
|
639f40cb94 | ||
|
|
a6a0b2c158 | ||
|
|
5c6c555b62 | ||
|
|
d767f8545f | ||
|
|
e7f91cd526 | ||
|
|
c1a5a44dfc | ||
|
|
f0506211e2 | ||
|
|
5ca349d0f8 | ||
|
|
c1adde6a13 | ||
|
|
22ed575325 | ||
|
|
f7c392342e | ||
|
|
350b42ad91 | ||
|
|
c74f2a526f | ||
|
|
b62c4ec4a2 | ||
|
|
d409e5ac18 | ||
|
|
a9adaf2052 | ||
|
|
ce088d5919 | ||
|
|
3a5de5483c | ||
|
|
a65e30fe41 | ||
|
|
f806670c85 | ||
|
|
b51cca4a57 | ||
|
|
7f74f238fd | ||
|
|
3bb5179e2d | ||
|
|
57d39109e3 | ||
|
|
b4642903fd | ||
|
|
b1f4e14281 | ||
|
|
e9c340b957 | ||
|
|
a4fabef86c | ||
|
|
4c1bf075c4 | ||
|
|
9415899a03 | ||
|
|
03700c0f01 | ||
|
|
1316513a1e | ||
|
|
db6a5f34cd | ||
|
|
e5ef1aa5a1 | ||
|
|
166ef525f0 | ||
|
|
2305b18b18 | ||
|
|
28fd5147ae | ||
|
|
9d58b006e7 | ||
|
|
e5f2e284ba | ||
|
|
c4029fb9b6 | ||
|
|
3bf74f4a33 | ||
|
|
28fb57ebeb | ||
|
|
59ba146463 | ||
|
|
eef0b8869f | ||
|
|
c24ca7966a | ||
|
|
e731ff8118 | ||
|
|
07d4492ece | ||
|
|
5721e27161 | ||
|
|
f96a415e80 | ||
|
|
1843698daf | ||
|
|
57e67e62bb | ||
|
|
615f1333d3 | ||
|
|
630d9c5200 | ||
|
|
f4bf92a488 | ||
|
|
2dcecb9d59 | ||
|
|
d65d816ac8 | ||
|
|
827fabc849 | ||
|
|
7aa6d6350a | ||
|
|
ef1033dffc | ||
|
|
8a5fb286b6 | ||
|
|
14c78a138a | ||
|
|
ecafa44196 | ||
|
|
d216962b64 | ||
|
|
1320168cca | ||
|
|
f681302409 | ||
|
|
6df077be77 | ||
|
|
93ef22759a | ||
|
|
802c5ee30f | ||
|
|
f5c1908058 | ||
|
|
5cc6565078 | ||
|
|
6202c1736f | ||
|
|
35ef65e6b9 | ||
|
|
d931a92a9f | ||
|
|
576b646f36 | ||
|
|
b7fcc3ec46 | ||
|
|
9ae7df918f | ||
|
|
75e27cef98 | ||
|
|
518d433d64 | ||
|
|
48a9270fad | ||
|
|
686c3e1128 | ||
|
|
fb26c11dfb | ||
|
|
4e7202c9ae | ||
|
|
5ec294fd7f | ||
|
|
33ccb6619c | ||
|
|
0608c91587 | ||
|
|
76b917bf36 | ||
|
|
52e5bdbc9b | ||
|
|
121b2457e7 | ||
|
|
f1b7306eb6 | ||
|
|
7d39ccb0e3 | ||
|
|
0c11024fd7 | ||
|
|
b4eb3eb8ba | ||
|
|
793bf2f154 | ||
|
|
99de8b2eb1 | ||
|
|
2dc656c098 | ||
|
|
ebde179ab2 | ||
|
|
1e3462d476 | ||
|
|
80c5b90dea | ||
|
|
3e95c424ab | ||
|
|
2e22fce718 | ||
|
|
cc13ca68fa | ||
|
|
915b83a068 | ||
|
|
c54bf85dfc | ||
|
|
1d3eb2eb6e | ||
|
|
49af45c8b7 | ||
|
|
9c20a5eec8 | ||
|
|
c215a1c50f | ||
|
|
e3664dbf64 | ||
|
|
72b6a5c392 | ||
|
|
192e3a3197 | ||
|
|
5b020cc00b | ||
|
|
6679faf1e3 | ||
|
|
a519d83316 | ||
|
|
c027b4d127 | ||
|
|
a078f01f7b | ||
|
|
16d62f8d9b | ||
|
|
f06d1740e0 | ||
|
|
0ed864383d | ||
|
|
3d18b54978 | ||
|
|
b456250cbe | ||
|
|
a561300e9d | ||
|
|
c1be62e6c3 | ||
|
|
59a4bbf91e | ||
|
|
08a251103b | ||
|
|
9fe42fdcd6 | ||
|
|
aa2dd57f36 | ||
|
|
f2e834cd32 | ||
|
|
16b6bf1743 | ||
|
|
e3f11e9d8c | ||
|
|
1d47fc923f | ||
|
|
bc1c948950 | ||
|
|
fc9ed73ff4 | ||
|
|
6d8fed6edc | ||
|
|
7c45a0dc4f | ||
|
|
b383e0ecb2 | ||
|
|
719fa6e004 | ||
|
|
a10926ac74 | ||
|
|
ca5bf96cb9 | ||
|
|
6269b907c3 | ||
|
|
9bd48d06c3 | ||
|
|
1834c11f48 | ||
|
|
e77aabdf1b | ||
|
|
61404d5bd8 | ||
|
|
5f5c906129 | ||
|
|
fec279c460 | ||
|
|
579ec3955e | ||
|
|
650837b207 | ||
|
|
f8c6863fa7 | ||
|
|
dd90c90819 | ||
|
|
21394826b6 | ||
|
|
7f0ed44828 | ||
|
|
8d7eb0e372 | ||
|
|
3161e435b8 | ||
|
|
4bf0365d85 | ||
|
|
109d3149f4 | ||
|
|
a3f40b2057 | ||
|
|
08a118cc94 | ||
|
|
b05136ea53 | ||
|
|
9bf6dcbdcb | ||
|
|
6020c147ed | ||
|
|
1f2f8f06dc | ||
|
|
3829d883a7 | ||
|
|
cf12639749 | ||
|
|
0764be77c4 | ||
|
|
7db5eea56b | ||
|
|
302087b4ec | ||
|
|
db58db396f | ||
|
|
6906046e9f | ||
|
|
1705a2ca5f | ||
|
|
88be906ad5 | ||
|
|
f2a7ed5ef1 | ||
|
|
73ef345a2d | ||
|
|
4575c4ab6f | ||
|
|
7037ca211d | ||
|
|
b152f06973 | ||
|
|
328862172d | ||
|
|
ac99b5011a | ||
|
|
2b7ed7381f |
@@ -1,2 +1,3 @@
|
||||
examples/Jugl.js
|
||||
examples/resources/
|
||||
build/package/**/*webgl*
|
||||
|
||||
@@ -3,7 +3,10 @@ sudo: false
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "6"
|
||||
- "6.1"
|
||||
|
||||
addons:
|
||||
firefox: "52.0"
|
||||
|
||||
cache:
|
||||
directories:
|
||||
@@ -17,7 +20,7 @@ before_install:
|
||||
before_script:
|
||||
- "rm src/ol/renderer/webgl/*shader.js"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
||||
- "npm ls"
|
||||
- "npm ls || true"
|
||||
|
||||
script: "make ci"
|
||||
|
||||
|
||||
6
Makefile
6
Makefile
@@ -86,7 +86,7 @@ check-deps:
|
||||
done ;\
|
||||
|
||||
.PHONY: ci
|
||||
ci: lint build test test-rendering compile-examples check-examples apidoc
|
||||
ci: lint build test test-rendering package compile-examples check-examples apidoc
|
||||
|
||||
.PHONY: compile-examples
|
||||
compile-examples: build/compiled-examples/all.combined.js
|
||||
@@ -253,7 +253,7 @@ build/timestamps/eslint-timestamp: $(SRC_JS) $(SPEC_JS) $(SPEC_RENDERING_JS) \
|
||||
build/timestamps/node-modules-timestamp
|
||||
@mkdir -p $(@D)
|
||||
@echo "Running eslint..."
|
||||
@./node_modules/.bin/eslint --quiet tasks test test_rendering src examples
|
||||
@./node_modules/.bin/eslint tasks test test_rendering src examples
|
||||
@touch $@
|
||||
|
||||
build/timestamps/node-modules-timestamp: package.json
|
||||
@@ -308,4 +308,6 @@ 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
|
||||
npm run lint-package
|
||||
|
||||
@@ -2,6 +2,30 @@
|
||||
|
||||
### 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
|
||||
|
||||
127
changelog/v4.1.0.md
Normal file
127
changelog/v4.1.0.md
Normal file
@@ -0,0 +1,127 @@
|
||||
# 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) - Don’t 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))
|
||||
13
changelog/v4.1.1.md
Normal file
13
changelog/v4.1.1.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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))
|
||||
15
css/ol.css
15
css/ol.css
@@ -34,16 +34,21 @@
|
||||
.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);
|
||||
@@ -239,3 +244,7 @@
|
||||
.ol-overviewmap-box {
|
||||
border: 2px dotted rgba(0,60,136,0.7);
|
||||
}
|
||||
|
||||
.ol-overviewmap .ol-overviewmap-box:hover {
|
||||
cursor: move;
|
||||
}
|
||||
@@ -220,3 +220,7 @@ 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.
|
||||
|
||||
@@ -172,6 +172,7 @@ 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"
|
||||
],
|
||||
@@ -223,6 +224,7 @@ 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"
|
||||
],
|
||||
|
||||
@@ -51,7 +51,9 @@ 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",
|
||||
@@ -201,9 +203,16 @@ 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/oli.js",
|
||||
"externs/proj4js.js",
|
||||
"externs/tilejson.js",
|
||||
"externs/topojson.js"
|
||||
],
|
||||
"define": [
|
||||
"ol.ENABLE_WEBGL=false",
|
||||
|
||||
@@ -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.3.14/proj4.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js"></script>
|
||||
```
|
||||
|
||||
``` javascript
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Clustered Features
|
||||
shortdesc: Example of using <code>ol.source.Cluster</code>.
|
||||
shortdesc: Example of using ol.source.Cluster.
|
||||
docs: >
|
||||
This example shows how to do clustering on point features.
|
||||
tags: "cluster, vector"
|
||||
|
||||
@@ -11,7 +11,8 @@ var layers = [
|
||||
source: new ol.source.TileWMS({
|
||||
url: 'https://ahocevar.com/geoserver/wms',
|
||||
params: {
|
||||
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
|
||||
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
|
||||
'TILED': true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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'},
|
||||
params: {'LAYERS': 'ne:ne', 'TILED': true},
|
||||
serverType: 'geoserver',
|
||||
crossOrigin: 'anonymous'
|
||||
});
|
||||
|
||||
@@ -27,6 +27,8 @@ var graticule = new ol.Graticule({
|
||||
color: 'rgba(255,120,0,0.9)',
|
||||
width: 2,
|
||||
lineDash: [0.5, 4]
|
||||
})
|
||||
}),
|
||||
showLabels: true
|
||||
});
|
||||
|
||||
graticule.setMap(map);
|
||||
|
||||
@@ -26,6 +26,7 @@ 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'
|
||||
}))
|
||||
}));
|
||||
@@ -33,6 +34,7 @@ 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'
|
||||
}))
|
||||
}));
|
||||
@@ -40,6 +42,7 @@ 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'
|
||||
}))
|
||||
}));
|
||||
|
||||
@@ -15,6 +15,7 @@ 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
|
||||
|
||||
@@ -51,6 +51,7 @@ for (i = 0; i < iconCount; ++i) {
|
||||
rotation: info.rotation,
|
||||
scale: info.scale,
|
||||
size: info.size,
|
||||
crossOrigin: 'anonymous',
|
||||
src: 'data/Butterfly.png'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ layout: example.html
|
||||
title: Advanced Mapbox Vector Tiles
|
||||
shortdesc: Example of a Mapbox vector tiles map with custom tile grid.
|
||||
docs: >
|
||||
A vector tiles map which reuses the same tiles for subsequent zoom levels to save bandwith on mobile devices. **Note**: No map will be visible when the access token has expired.
|
||||
A vector tiles map which reuses the same tiles for subsequent zoom levels to save bandwidth on mobile devices. **Note**: No map will be visible when the access token has expired.
|
||||
tags: "mapbox, vector, tiles, mobile"
|
||||
resources:
|
||||
- resources/mapbox-streets-v6-style.js
|
||||
|
||||
12
examples/min-zoom.html
Normal file
12
examples/min-zoom.html
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
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>
|
||||
36
examples/min-zoom.js
Normal file
36
examples/min-zoom.js
Normal file
@@ -0,0 +1,36 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
12
examples/mousewheel-zoom.html
Normal file
12
examples/mousewheel-zoom.html
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
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>
|
||||
25
examples/mousewheel-zoom.js
Normal file
25
examples/mousewheel-zoom.js
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
})
|
||||
});
|
||||
@@ -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.3.15/proj4.js
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<form class="form-inline">
|
||||
|
||||
@@ -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.3.15/proj4.js
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -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.3.15/proj4.js
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<form class="form-inline">
|
||||
|
||||
@@ -72,7 +72,8 @@ layers['wms4326'] = new ol.layer.Tile({
|
||||
url: 'https://ahocevar.com/geoserver/wms',
|
||||
crossOrigin: '',
|
||||
params: {
|
||||
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
|
||||
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
|
||||
'TILED': true
|
||||
},
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
@@ -99,13 +100,15 @@ 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(options)
|
||||
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
|
||||
});
|
||||
});
|
||||
|
||||
@@ -131,7 +134,7 @@ layers['states'] = new ol.layer.Tile({
|
||||
source: new ol.source.TileWMS({
|
||||
url: 'https://ahocevar.com/geoserver/wms',
|
||||
crossOrigin: '',
|
||||
params: {'LAYERS': 'topp:states', 'TILED': true},
|
||||
params: {'LAYERS': 'topp:states'},
|
||||
serverType: 'geoserver',
|
||||
tileGrid: new ol.tilegrid.TileGrid({
|
||||
extent: [-13884991, 2870341, -7455066, 6338219],
|
||||
@@ -174,7 +177,7 @@ function updateViewProjection() {
|
||||
});
|
||||
map.setView(newView);
|
||||
|
||||
// Example how to prevent double occurence of map by limiting layer extent
|
||||
// Example how to prevent double occurrence of map by limiting layer extent
|
||||
if (newProj == ol.proj.get('EPSG:3857')) {
|
||||
layers['bng'].setExtent([-1057216, 6405988, 404315, 8759696]);
|
||||
} else {
|
||||
|
||||
@@ -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.3.15/proj4.js
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -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.3.15/proj4.js
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -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)</a> maps. The map on the left is an EPSG:4326 map. The one on the right is EPSG:3857.
|
||||
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`.
|
||||
tags: "tissot, circle"
|
||||
---
|
||||
<h4>EPSG:4326</h4>
|
||||
|
||||
@@ -22,7 +22,8 @@ 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'
|
||||
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
|
||||
'TILED': true
|
||||
}
|
||||
})
|
||||
}),
|
||||
@@ -42,7 +43,8 @@ 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'
|
||||
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
|
||||
'TILED': true
|
||||
}
|
||||
})
|
||||
}),
|
||||
|
||||
@@ -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.3.15/proj4.js
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
||||
- https://epsg.io/21781-1753.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -15,6 +15,7 @@ var layers = [
|
||||
source: new ol.source.ImageWMS({
|
||||
url: 'https://ahocevar.com/geoserver/wms',
|
||||
params: {'LAYERS': 'topp:states'},
|
||||
ratio: 1,
|
||||
serverType: 'geoserver'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@ layout: example.html
|
||||
title: WMS Time
|
||||
shortdesc: Example of smooth tile transitions when changing the time dimension of a tiled WMS layer.
|
||||
docs: >
|
||||
Demonstrates smooth reloading of layers when changing the time dimension continously. Data shown: IEM generated CONUS composite of NWS NEXRAD WSR-88D level III base reflectivity.
|
||||
Demonstrates smooth reloading of layers when changing the time dimension continuously. Data shown: IEM generated CONUS composite of NWS NEXRAD WSR-88D level III base reflectivity.
|
||||
tags: "wms, time, dimensions, transition, nexrad"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -3,7 +3,7 @@ layout: example.html
|
||||
title: WMTS Tile Transitions
|
||||
shortdesc: Example of smooth tile transitions when changing the dimension of a WMTS layer.
|
||||
docs: >
|
||||
Demonstrates smooth reloading of layers when changing a dimension continously. The demonstration layer is a global sea-level computation (flooding computation from <a href="http://scalgo.com">SCALGO</a>, underlying data from <a href="http://www.cgiar-csi.org/data/srtm-90m-digital-elevation-database-v4-1">CGIAR-CSI SRTM</a>) where cells that are flooded if the sea-level rises to more than <em>x</em> m are colored blue. The user selects the sea-level dimension using a slider.
|
||||
Demonstrates smooth reloading of layers when changing a dimension continuously. The demonstration layer is a global sea-level computation (flooding computation from <a href="http://scalgo.com">SCALGO</a>, underlying data from <a href="http://www.cgiar-csi.org/data/srtm-90m-digital-elevation-database-v4-1">CGIAR-CSI SRTM</a>) where cells that are flooded if the sea-level rises to more than <em>x</em> m are colored blue. The user selects the sea-level dimension using a slider.
|
||||
tags: "wmts, parameter, transition"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -34,6 +34,6 @@ fetch(capabilitiesUrl).then(function(response) {
|
||||
});
|
||||
options.tilePixelRatio = tilePixelRatio;
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: new ol.source.WMTS(options)
|
||||
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -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
|
||||
<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).
|
||||
[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).
|
||||
tags: "french, ign, geoportail, wmts"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -12,8 +12,10 @@ 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: [
|
||||
@@ -23,7 +25,7 @@ fetch('data/WMTSCapabilities.xml').then(function(response) {
|
||||
}),
|
||||
new ol.layer.Tile({
|
||||
opacity: 1,
|
||||
source: new ol.source.WMTS(options)
|
||||
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
|
||||
253
externs/olx.js
253
externs/olx.js
@@ -8,6 +8,21 @@ 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)}}
|
||||
@@ -97,7 +112,14 @@ olx.LogoOptions.prototype.src;
|
||||
* @typedef {{map: (ol.Map|undefined),
|
||||
* maxLines: (number|undefined),
|
||||
* strokeStyle: (ol.style.Stroke|undefined),
|
||||
* targetSize: (number|undefined)}}
|
||||
* targetSize: (number|undefined),
|
||||
* showLabels: (boolean|undefined),
|
||||
* lonLabelFormatter: (undefined|function(number):string),
|
||||
* latLabelFormatter: (undefined|function(number):string),
|
||||
* lonLabelPosition: (number|undefined),
|
||||
* latLabelPosition: (number|undefined),
|
||||
* lonLabelStyle: (ol.style.Text|undefined),
|
||||
* latLabelStyle: (ol.style.Text|undefined)}}
|
||||
*/
|
||||
olx.GraticuleOptions;
|
||||
|
||||
@@ -142,6 +164,106 @@ olx.GraticuleOptions.prototype.strokeStyle;
|
||||
olx.GraticuleOptions.prototype.targetSize;
|
||||
|
||||
|
||||
/**
|
||||
* Render a label with the respective latitude/longitude for each graticule
|
||||
* line. Default is false.
|
||||
*
|
||||
* @type {boolean|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.GraticuleOptions.prototype.showLabels;
|
||||
|
||||
|
||||
/**
|
||||
* Label formatter for longitudes. This function is called with the longitude as
|
||||
* argument, and should return a formatted string representing the longitude.
|
||||
* By default, labels are formatted as degrees, minutes, seconds and hemisphere.
|
||||
*
|
||||
* @type {undefined|function(number):string}
|
||||
* @api
|
||||
*/
|
||||
olx.GraticuleOptions.prototype.lonLabelFormatter;
|
||||
|
||||
|
||||
/**
|
||||
* Label formatter for latitudes. This function is called with the latitude as
|
||||
* argument, and should return a formatted string representing the latitude.
|
||||
* By default, labels are formatted as degrees, minutes, seconds and hemisphere.
|
||||
*
|
||||
* @type {undefined|function(number):string}
|
||||
* @api
|
||||
*/
|
||||
olx.GraticuleOptions.prototype.latLabelFormatter;
|
||||
|
||||
|
||||
/**
|
||||
* Longitude label position in fractions (0..1) of view extent. 0 means at the
|
||||
* bottom of the viewport, 1 means at the top. Default is 0.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.GraticuleOptions.prototype.lonLabelPosition;
|
||||
|
||||
|
||||
/**
|
||||
* Latitude label position in fractions (0..1) of view extent. 0 means at the
|
||||
* left of the viewport, 1 means at the right. Default is 1.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.GraticuleOptions.prototype.latLabelPosition;
|
||||
|
||||
|
||||
/**
|
||||
* Longitude label text style. The default is
|
||||
* ```js
|
||||
* new ol.style.Text({
|
||||
* font: '12px Calibri,sans-serif',
|
||||
* textBaseline: 'bottom',
|
||||
* fill: new ol.style.Fill({
|
||||
* color: 'rgba(0,0,0,1)'
|
||||
* }),
|
||||
* stroke: new ol.style.Stroke({
|
||||
* color: 'rgba(255,255,255,1)',
|
||||
* width: 3
|
||||
* })
|
||||
* });
|
||||
* ```
|
||||
* Note that the default's `textBaseline` configuration will not work well for
|
||||
* `lonLabelPosition` configurations that position labels close to the top of
|
||||
* the viewport.
|
||||
*
|
||||
* @type {ol.style.Text|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.GraticuleOptions.prototype.lonLabelStyle;
|
||||
|
||||
|
||||
/**
|
||||
* Latitude label text style. The default is
|
||||
* ```js
|
||||
* new ol.style.Text({
|
||||
* font: '12px Calibri,sans-serif',
|
||||
* textAlign: 'end',
|
||||
* fill: new ol.style.Fill({
|
||||
* color: 'rgba(0,0,0,1)'
|
||||
* }),
|
||||
* stroke: new ol.style.Stroke({
|
||||
* color: 'rgba(255,255,255,1)',
|
||||
* width: 3
|
||||
* })
|
||||
* });
|
||||
* ```
|
||||
* Note that the default's `textAlign` configuration will not work well for
|
||||
* `latLabelPosition` configurations that position labels close to the left of
|
||||
* the viewport.
|
||||
*
|
||||
* @type {ol.style.Text|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.GraticuleOptions.prototype.latLabelStyle;
|
||||
|
||||
|
||||
/**
|
||||
* Object literal with config options for interactions.
|
||||
* @typedef {{handleEvent: function(ol.MapBrowserEvent):boolean}}
|
||||
@@ -2284,8 +2406,10 @@ olx.format.WFSWriteGetFeatureOptions.prototype.resultType;
|
||||
* featureType: string,
|
||||
* srsName: (string|undefined),
|
||||
* handle: (string|undefined),
|
||||
* hasZ: (boolean|undefined),
|
||||
* nativeElements: Array.<Object>,
|
||||
* gmlOptions: (olx.format.GMLOptions|undefined)}}
|
||||
* gmlOptions: (olx.format.GMLOptions|undefined),
|
||||
* version: (string|undefined)}}
|
||||
*/
|
||||
olx.format.WFSWriteTransactionOptions;
|
||||
|
||||
@@ -2331,6 +2455,15 @@ olx.format.WFSWriteTransactionOptions.prototype.srsName;
|
||||
olx.format.WFSWriteTransactionOptions.prototype.handle;
|
||||
|
||||
|
||||
/**
|
||||
* Must be set to true if the transaction is for a 3D layer. This will allow
|
||||
* the Z coordinate to be included in the transaction.
|
||||
* @type {boolean|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.format.WFSWriteTransactionOptions.prototype.hasZ;
|
||||
|
||||
|
||||
/**
|
||||
* Native elements. Currently not supported.
|
||||
* @type {Array.<Object>}
|
||||
@@ -2347,6 +2480,15 @@ 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)}}
|
||||
*/
|
||||
@@ -2388,7 +2530,9 @@ olx.interaction;
|
||||
|
||||
/**
|
||||
* Interactions for the map. Default is `true` for all options.
|
||||
* @typedef {{altShiftDragRotate: (boolean|undefined),
|
||||
* @typedef {{
|
||||
* altShiftDragRotate: (boolean|undefined),
|
||||
* constrainResolution: (boolean|undefined),
|
||||
* doubleClickZoom: (boolean|undefined),
|
||||
* keyboard: (boolean|undefined),
|
||||
* mouseWheelZoom: (boolean|undefined),
|
||||
@@ -2397,7 +2541,8 @@ olx.interaction;
|
||||
* pinchRotate: (boolean|undefined),
|
||||
* pinchZoom: (boolean|undefined),
|
||||
* zoomDelta: (number|undefined),
|
||||
* zoomDuration: (number|undefined)}}
|
||||
* zoomDuration: (number|undefined)
|
||||
* }}
|
||||
*/
|
||||
olx.interaction.DefaultsOptions;
|
||||
|
||||
@@ -2410,6 +2555,15 @@ 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}
|
||||
@@ -2540,6 +2694,7 @@ olx.interaction.DragAndDropOptions.prototype.target;
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* condition: (ol.EventsConditionType|undefined),
|
||||
* minArea: (number|undefined),
|
||||
* boxEndCondition: (ol.DragBoxEndConditionType|undefined)}}
|
||||
*/
|
||||
olx.interaction.DragBoxOptions;
|
||||
@@ -2563,19 +2718,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:
|
||||
* ```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;
|
||||
* }
|
||||
* ```
|
||||
* {@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.
|
||||
* @type {ol.DragBoxEndConditionType|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -2867,7 +3022,7 @@ olx.interaction.DrawOptions.prototype.wrapX;
|
||||
olx.interaction.ExtentOptions;
|
||||
|
||||
/**
|
||||
* Initial extent. Defaults to no inital extent
|
||||
* Initial extent. Defaults to no initial extent
|
||||
* @type {ol.Extent|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -2932,7 +3087,7 @@ olx.interaction.TranslateOptions.prototype.layers;
|
||||
/**
|
||||
* Hit-detection tolerance. Pixels inside the radius around the given position
|
||||
* will be checked for features. This only works for the canvas renderer and
|
||||
* not for WebGL.
|
||||
* not for WebGL. Default is `0`.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -3076,7 +3231,8 @@ olx.interaction.ModifyOptions.prototype.wrapX;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{duration: (number|undefined),
|
||||
* @typedef {{constrainResolution: (boolean|undefined),
|
||||
* duration: (number|undefined),
|
||||
* timeout: (number|undefined),
|
||||
* useAnchor: (boolean|undefined)}}
|
||||
*/
|
||||
@@ -3099,6 +3255,16 @@ 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
|
||||
@@ -3133,7 +3299,10 @@ olx.interaction.PinchRotateOptions.prototype.threshold;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{duration: (number|undefined)}}
|
||||
* @typedef {{
|
||||
* duration: (number|undefined),
|
||||
* constrainResolution: (boolean|undefined)
|
||||
* }}
|
||||
*/
|
||||
olx.interaction.PinchZoomOptions;
|
||||
|
||||
@@ -3339,7 +3508,7 @@ olx.interaction.SelectOptions.prototype.wrapX;
|
||||
/**
|
||||
* Hit-detection tolerance. Pixels inside the radius around the given position
|
||||
* will be checked for features. This only works for the canvas renderer and
|
||||
* not for WebGL.
|
||||
* not for WebGL. Default is `0`.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -3881,7 +4050,7 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{renderOrder: (function(ol.Feature, ol.Feature):number|null|undefined),
|
||||
* @typedef {{renderOrder: (ol.RenderOrderFunction|null|undefined),
|
||||
* minResolution: (number|undefined),
|
||||
* maxResolution: (number|undefined),
|
||||
* opacity: (number|undefined),
|
||||
@@ -3900,7 +4069,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 {function(ol.Feature, ol.Feature):number|null|undefined}
|
||||
* @type {ol.RenderOrderFunction|null|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.layer.VectorOptions.prototype.renderOrder;
|
||||
@@ -4015,7 +4184,7 @@ olx.layer.VectorOptions.prototype.visible;
|
||||
* preload: (number|undefined),
|
||||
* renderBuffer: (number|undefined),
|
||||
* renderMode: (ol.layer.VectorTileRenderType|string|undefined),
|
||||
* renderOrder: (function(ol.Feature, ol.Feature):number|undefined),
|
||||
* renderOrder: (ol.RenderOrderFunction|undefined),
|
||||
* source: (ol.source.VectorTile|undefined),
|
||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
||||
* updateWhileAnimating: (boolean|undefined),
|
||||
@@ -4058,7 +4227,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 {function(ol.Feature, ol.Feature):number|undefined}
|
||||
* @type {ol.RenderOrderFunction|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.layer.VectorTileOptions.prototype.renderOrder;
|
||||
@@ -5506,14 +5675,17 @@ olx.source.ImageWMSOptions.prototype.url;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{cacheSize: (number|undefined),
|
||||
* @typedef {{
|
||||
* cacheSize: (number|undefined),
|
||||
* layer: string,
|
||||
* minZoom: (number|undefined),
|
||||
* maxZoom: (number|undefined),
|
||||
* opaque: (boolean|undefined),
|
||||
* reprojectionErrorThreshold: (number|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* url: (string|undefined)}}
|
||||
* url: (string|undefined),
|
||||
* wrapX: (boolean|undefined)
|
||||
* }}
|
||||
*/
|
||||
olx.source.StamenOptions;
|
||||
|
||||
@@ -5587,6 +5759,14 @@ olx.source.StamenOptions.prototype.tileLoadFunction;
|
||||
olx.source.StamenOptions.prototype.url;
|
||||
|
||||
|
||||
/**
|
||||
* Whether to wrap the world horizontally. Default is `true`.
|
||||
* @type {boolean|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.source.StamenOptions.prototype.wrapX;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{attributions: (ol.AttributionLike|undefined),
|
||||
* crossOrigin: (null|string|undefined),
|
||||
@@ -6986,7 +7166,7 @@ olx.style.IconOptions.prototype.opacity;
|
||||
|
||||
|
||||
/**
|
||||
* Scale.
|
||||
* Scale. Default is `1`.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -7044,7 +7224,7 @@ olx.style.IconOptions.prototype.imgSize;
|
||||
|
||||
/**
|
||||
* Image source URI.
|
||||
* @type {string}
|
||||
* @type {string|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.style.IconOptions.prototype.src;
|
||||
@@ -7093,7 +7273,7 @@ olx.style.RegularShapeOptions.prototype.radius;
|
||||
|
||||
|
||||
/**
|
||||
* Inner radius of a star.
|
||||
* Outer radius of a star.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -7101,7 +7281,7 @@ olx.style.RegularShapeOptions.prototype.radius1;
|
||||
|
||||
|
||||
/**
|
||||
* Outer radius of a star.
|
||||
* Inner radius of a star.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -7669,7 +7849,8 @@ olx.view;
|
||||
* maxZoom: (number|undefined),
|
||||
* minResolution: (number|undefined),
|
||||
* duration: (number|undefined),
|
||||
* easing: (undefined|function(number):number)
|
||||
* easing: (undefined|function(number):number),
|
||||
* callback: (undefined|function(boolean))
|
||||
* }}
|
||||
*/
|
||||
olx.view.FitOptions;
|
||||
@@ -7747,6 +7928,16 @@ olx.view.FitOptions.prototype.duration;
|
||||
olx.view.FitOptions.prototype.easing;
|
||||
|
||||
|
||||
/**
|
||||
* Optional function called when the view is in it's final position. The callback will be
|
||||
* called with `true` if the animation series completed on its own or `false`
|
||||
* if it was cancelled.
|
||||
* @type {undefined|function(boolean)}
|
||||
* @api
|
||||
*/
|
||||
olx.view.FitOptions.prototype.callback;
|
||||
|
||||
|
||||
/* typedefs for object literals exposed by the library */
|
||||
|
||||
|
||||
|
||||
@@ -7,25 +7,31 @@
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
var proj4 = function() {};
|
||||
var Proj4 = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {function(Array.<number>): Array.<number>}
|
||||
* @param {ol.Coordinate} coordinates
|
||||
* @return {ol.Coordinate}
|
||||
*/
|
||||
proj4.prototype.forward;
|
||||
Proj4.prototype.forward = function(coordinates) {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {function(Array.<number>): Array.<number>}
|
||||
* @param {ol.Coordinate} coordinates
|
||||
* @return {ol.Coordinate}
|
||||
*/
|
||||
proj4.prototype.inverse;
|
||||
Proj4.prototype.inverse = function(coordinates) {};
|
||||
|
||||
|
||||
/**
|
||||
* @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.defs = function(name, opt_def) {};
|
||||
Proj4.prototype.defs = function(name, opt_def) {};
|
||||
|
||||
/**
|
||||
* @type {Proj4}
|
||||
*/
|
||||
var proj4;
|
||||
|
||||
52
package.json
52
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openlayers",
|
||||
"version": "4.0.1",
|
||||
"version": "4.1.2-beta.1",
|
||||
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
||||
"keywords": [
|
||||
"map",
|
||||
@@ -13,6 +13,7 @@
|
||||
"postinstall": "closure-util update",
|
||||
"start": "node tasks/serve.js",
|
||||
"pretest": "eslint tasks test test_rendering src examples",
|
||||
"lint-package": "eslint --fix build/package",
|
||||
"test": "node tasks/test.js",
|
||||
"debug-server": "node tasks/serve-lib.js"
|
||||
},
|
||||
@@ -30,47 +31,49 @@
|
||||
"css/ol.css"
|
||||
],
|
||||
"dependencies": {
|
||||
"async": "2.1.4",
|
||||
"browserify": "14.0.0",
|
||||
"closure-util": "1.17.0",
|
||||
"async": "2.4.0",
|
||||
"closure-util": "1.20.0",
|
||||
"derequire": "2.0.6",
|
||||
"fs-extra": "2.0.0",
|
||||
"fs-extra": "3.0.1",
|
||||
"glob": "7.1.1",
|
||||
"handlebars": "4.0.6",
|
||||
"handlebars": "4.0.8",
|
||||
"jsdoc": "3.4.3",
|
||||
"marked": "0.3.6",
|
||||
"metalsmith": "2.3.0",
|
||||
"metalsmith-layouts": "1.8.0",
|
||||
"metalsmith-layouts": "1.8.1",
|
||||
"nomnom": "1.8.1",
|
||||
"pbf": "3.0.5",
|
||||
"pixelworks": "1.1.0",
|
||||
"rbush": "2.0.1",
|
||||
"rollup": "^0.41.6",
|
||||
"rollup-plugin-cleanup": "^1.0.0",
|
||||
"rollup-plugin-commonjs": "^8.0.2",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"temp": "0.8.3",
|
||||
"vector-tile": "1.3.0",
|
||||
"@mapbox/vector-tile": "1.3.0",
|
||||
"walk": "2.3.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clean-css-cli": "4.0.6",
|
||||
"coveralls": "2.11.16",
|
||||
"clean-css-cli": "4.1.0",
|
||||
"coveralls": "2.13.1",
|
||||
"debounce": "^1.0.0",
|
||||
"eslint": "3.15.0",
|
||||
"eslint": "3.19.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.1.1",
|
||||
"jquery": "3.2.1",
|
||||
"jscodeshift": "^0.3.30",
|
||||
"mocha": "3.2.0",
|
||||
"mocha": "3.3.0",
|
||||
"mocha-phantomjs-core": "^2.1.0",
|
||||
"mustache": "2.3.0",
|
||||
"phantomjs-prebuilt": "2.1.14",
|
||||
"proj4": "2.3.17",
|
||||
"resemblejs": "2.2.3",
|
||||
"proj4": "2.4.3",
|
||||
"resemblejs": "2.2.4",
|
||||
"serve-files": "1.0.1",
|
||||
"sinon": "1.17.7",
|
||||
"slimerjs": "0.906.2"
|
||||
"sinon": "2.2.0",
|
||||
"slimerjs": "0.10.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "openlayers",
|
||||
@@ -92,7 +95,7 @@
|
||||
"no-constant-condition": 0,
|
||||
"openlayers-internal/enum": 2,
|
||||
"openlayers-internal/no-duplicate-requires": 2,
|
||||
"openlayers-internal/no-missing-requires": 1,
|
||||
"openlayers-internal/no-missing-requires": 2,
|
||||
"openlayers-internal/no-unused-requires": 2,
|
||||
"openlayers-internal/one-provide": 2,
|
||||
"openlayers-internal/requires-first": 2,
|
||||
@@ -102,21 +105,20 @@
|
||||
},
|
||||
"ext": [
|
||||
{
|
||||
"module": "rbush",
|
||||
"browserify": true
|
||||
"module": "rbush"
|
||||
},
|
||||
{
|
||||
"module": "pbf",
|
||||
"browserify": true
|
||||
"name": "PBF"
|
||||
},
|
||||
{
|
||||
"module": "pixelworks",
|
||||
"browserify": true
|
||||
"import": "Processor"
|
||||
},
|
||||
{
|
||||
"module": "vector-tile",
|
||||
"module": "@mapbox/vector-tile",
|
||||
"name": "vectortile",
|
||||
"browserify": true
|
||||
"import": "VectorTile"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
5
package/.eslintrc
Normal file
5
package/.eslintrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ol",
|
||||
"version": "4.0.1-beta.1",
|
||||
"version": "4.1.1",
|
||||
"description": "OpenLayers as ES2015 modules",
|
||||
"main": "index.js",
|
||||
"module": "index.js",
|
||||
@@ -9,6 +9,16 @@
|
||||
"pbf": "3.0.5",
|
||||
"pixelworks": "1.1.0",
|
||||
"rbush": "2.0.1",
|
||||
"vector-tile": "1.3.0"
|
||||
"@mapbox/vector-tile": "1.3.0"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
[
|
||||
"babelify",
|
||||
{
|
||||
"plugins": ["transform-es2015-modules-commonjs"]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
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.
|
||||
@@ -51,5 +49,4 @@ 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.
|
||||
|
||||
@@ -13,11 +13,12 @@ goog.require('ol');
|
||||
*/
|
||||
ol.AssertionError = function(code) {
|
||||
|
||||
var path = ol.VERSION ? ol.VERSION.split('-')[0] : 'latest';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
this.message = 'Assertion failed. See ' +
|
||||
(ol.VERSION ? 'https://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') +
|
||||
this.message = 'Assertion failed. See https://openlayers.org/en/' + path +
|
||||
'/doc/errors/#' + code + ' for details.';
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
goog.provide('ol.Collection');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.AssertionError');
|
||||
goog.require('ol.CollectionEventType');
|
||||
goog.require('ol.Object');
|
||||
goog.require('ol.events.Event');
|
||||
@@ -23,19 +24,34 @@ 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) {
|
||||
ol.Collection = function(opt_array, opt_options) {
|
||||
|
||||
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_();
|
||||
|
||||
};
|
||||
@@ -125,6 +141,9 @@ 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(
|
||||
@@ -150,6 +169,9 @@ 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();
|
||||
@@ -200,6 +222,9 @@ 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(
|
||||
@@ -224,6 +249,20 @@ 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
|
||||
|
||||
@@ -12,7 +12,7 @@ goog.require('ol.events.EventType');
|
||||
* @classdesc
|
||||
* Provides a button that when clicked fills up the full screen with the map.
|
||||
* The full screen source element is by default the element containing the map viewport unless
|
||||
* overriden by providing the `source` option. In which case, the dom
|
||||
* overridden by providing the `source` option. In which case, the dom
|
||||
* element introduced using this parameter will be displayed in full screen.
|
||||
*
|
||||
* When in full screen mode, a close button is shown to exit full screen mode.
|
||||
|
||||
@@ -148,6 +148,44 @@ 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);
|
||||
|
||||
|
||||
@@ -120,16 +120,8 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
|
||||
// upon it
|
||||
return;
|
||||
}
|
||||
var currentRotation = view.getRotation();
|
||||
if (currentRotation !== undefined) {
|
||||
if (view.getRotation() !== 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_,
|
||||
|
||||
@@ -203,7 +203,10 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
||||
pointResolution /= 1852;
|
||||
suffix = 'nm';
|
||||
} else if (units == ol.control.ScaleLineUnits.METRIC) {
|
||||
if (nominalCount < 1) {
|
||||
if (nominalCount < 0.001) {
|
||||
suffix = 'μm';
|
||||
pointResolution *= 1000000;
|
||||
} else if (nominalCount < 1) {
|
||||
suffix = 'mm';
|
||||
pointResolution *= 1000;
|
||||
} else if (nominalCount < 1000) {
|
||||
|
||||
@@ -101,14 +101,13 @@ ol.coordinate.createStringXY = function(opt_fractionDigits) {
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {number} degrees Degrees.
|
||||
* @param {string} hemispheres Hemispheres.
|
||||
* @param {number} degrees Degrees.
|
||||
* @param {number=} opt_fractionDigits The number of digits to include
|
||||
* after the decimal point. Default is `0`.
|
||||
* @return {string} String.
|
||||
*/
|
||||
ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres, opt_fractionDigits) {
|
||||
ol.coordinate.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionDigits) {
|
||||
var normalizedDegrees = ol.math.modulo(degrees + 180, 360) - 180;
|
||||
var x = Math.abs(3600 * normalizedDegrees);
|
||||
var dflPrecision = opt_fractionDigits || 0;
|
||||
@@ -130,8 +129,8 @@ ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres, opt_fraction
|
||||
}
|
||||
|
||||
return deg + '\u00b0 ' + ol.string.padNumber(min, 2) + '\u2032 ' +
|
||||
ol.string.padNumber(sec, 2, dflPrecision) + '\u2033 ' +
|
||||
hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);
|
||||
ol.string.padNumber(sec, 2, dflPrecision) + '\u2033' +
|
||||
(normalizedDegrees == 0 ? '' : ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0));
|
||||
};
|
||||
|
||||
|
||||
@@ -313,8 +312,8 @@ ol.coordinate.squaredDistanceToSegment = function(coordinate, segment) {
|
||||
*/
|
||||
ol.coordinate.toStringHDMS = function(coordinate, opt_fractionDigits) {
|
||||
if (coordinate) {
|
||||
return ol.coordinate.degreesToStringHDMS_(coordinate[1], 'NS', opt_fractionDigits) + ' ' +
|
||||
ol.coordinate.degreesToStringHDMS_(coordinate[0], 'EW', opt_fractionDigits);
|
||||
return ol.coordinate.degreesToStringHDMS('NS', coordinate[1], opt_fractionDigits) + ' ' +
|
||||
ol.coordinate.degreesToStringHDMS('EW', coordinate[0], opt_fractionDigits);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -10,6 +10,14 @@ 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.
|
||||
*
|
||||
|
||||
@@ -28,7 +28,7 @@ ol.dom.createCanvasContext2D = function(opt_width, opt_height) {
|
||||
*/
|
||||
ol.dom.outerWidth = function(element) {
|
||||
var width = element.offsetWidth;
|
||||
var style = element.currentStyle || getComputedStyle(element);
|
||||
var style = 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 = element.currentStyle || getComputedStyle(element);
|
||||
var style = getComputedStyle(element);
|
||||
height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
|
||||
|
||||
return height;
|
||||
|
||||
@@ -26,7 +26,7 @@ ol.events.EventType = {
|
||||
MOUSEOUT: 'mouseout',
|
||||
MOUSEUP: 'mouseup',
|
||||
MOUSEWHEEL: 'mousewheel',
|
||||
MSPOINTERDOWN: 'mspointerdown',
|
||||
MSPOINTERDOWN: 'MSPointerDown',
|
||||
RESIZE: 'resize',
|
||||
TOUCHSTART: 'touchstart',
|
||||
TOUCHMOVE: 'touchmove',
|
||||
|
||||
@@ -64,6 +64,12 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
failure.call(this);
|
||||
}
|
||||
}.bind(this);
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
xhr.onerror = function() {
|
||||
failure.call(this);
|
||||
}.bind(this);
|
||||
xhr.send();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,8 +2,11 @@ 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');
|
||||
|
||||
@@ -57,7 +60,6 @@ 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);
|
||||
@@ -65,24 +67,14 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
|
||||
axisOrientation = proj.getAxisOrientation();
|
||||
}
|
||||
}
|
||||
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 coordsGroups = s.trim().split(/\s+/);
|
||||
var x, y, z;
|
||||
var flatCoordinates = [];
|
||||
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;
|
||||
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;
|
||||
if (axisOrientation.substr(0, 2) === 'en') {
|
||||
flatCoordinates.push(x, y, z);
|
||||
} else {
|
||||
@@ -204,3 +196,583 @@ 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 hasZ = context['hasZ'];
|
||||
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, hasZ);
|
||||
}
|
||||
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 hasZ = context['hasZ'];
|
||||
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, hasZ: hasZ, 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
|
||||
* @param {boolean=} opt_hasZ whether the geometry has a Z coordinate (is 3D) or not.
|
||||
* @return {string} The coords string.
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
|
||||
var axisOrientation = 'enu';
|
||||
if (opt_srsName) {
|
||||
axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation();
|
||||
}
|
||||
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
||||
point[0] + ',' + point[1] :
|
||||
point[1] + ',' + point[0]);
|
||||
if (opt_hasZ) {
|
||||
// For newly created points, Z can be undefined.
|
||||
var z = point[2] || 0;
|
||||
coords += ',' + z;
|
||||
}
|
||||
|
||||
return coords;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @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 hasZ = context['hasZ'];
|
||||
var srsName = context['srsName'];
|
||||
var curve = context['curve'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
}
|
||||
var lines = geometry.getLineStrings();
|
||||
ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, 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 hasZ = context['hasZ'];
|
||||
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, hasZ);
|
||||
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 hasZ = context['hasZ'];
|
||||
var srsName = context['srsName'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
}
|
||||
var points = geometry.getPoints();
|
||||
ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, 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 hasZ = context['hasZ'];
|
||||
var srsName = context['srsName'];
|
||||
var surface = context['surface'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
}
|
||||
var polygons = geometry.getPolygons();
|
||||
ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, 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)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -565,6 +565,7 @@ ol.format.GML3.prototype.SEGMENTS_PARSERS_ = {
|
||||
*/
|
||||
ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
var hasZ = context['hasZ'];
|
||||
var srsName = context['srsName'];
|
||||
var axisOrientation = 'enu';
|
||||
if (srsName) {
|
||||
@@ -578,6 +579,11 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) {
|
||||
} else {
|
||||
coords = (point[1] + ' ' + point[0]);
|
||||
}
|
||||
if (hasZ) {
|
||||
// For newly created points, Z can be undefined.
|
||||
var z = point[2] || 0;
|
||||
coords += ' ' + z;
|
||||
}
|
||||
ol.format.XSD.writeStringTextNode(node, coords);
|
||||
};
|
||||
|
||||
@@ -585,17 +591,25 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) {
|
||||
/**
|
||||
* @param {Array.<number>} point Point geometry.
|
||||
* @param {string=} opt_srsName Optional srsName
|
||||
* @param {boolean=} opt_hasZ whether the geometry has a Z coordinate (is 3D) or not.
|
||||
* @return {string} The coords string.
|
||||
* @private
|
||||
*/
|
||||
ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName) {
|
||||
ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
|
||||
var axisOrientation = 'enu';
|
||||
if (opt_srsName) {
|
||||
axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation();
|
||||
}
|
||||
return ((axisOrientation.substr(0, 2) === 'en') ?
|
||||
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
||||
point[0] + ' ' + point[1] :
|
||||
point[1] + ' ' + point[0]);
|
||||
if (opt_hasZ) {
|
||||
// For newly created points, Z can be undefined.
|
||||
var z = point[2] || 0;
|
||||
coords += ' ' + z;
|
||||
}
|
||||
|
||||
return coords;
|
||||
};
|
||||
|
||||
|
||||
@@ -607,6 +621,7 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName) {
|
||||
*/
|
||||
ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
var hasZ = context['hasZ'];
|
||||
var srsName = context['srsName'];
|
||||
// only 2d for simple features profile
|
||||
var points = value.getCoordinates();
|
||||
@@ -615,7 +630,7 @@ ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
|
||||
var point;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
point = points[i];
|
||||
parts[i] = this.getCoords_(point, srsName);
|
||||
parts[i] = this.getCoords_(point, srsName, hasZ);
|
||||
}
|
||||
ol.format.XSD.writeStringTextNode(node, parts.join(' '));
|
||||
};
|
||||
@@ -717,6 +732,7 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_n
|
||||
*/
|
||||
ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
var hasZ = context['hasZ'];
|
||||
var srsName = context['srsName'];
|
||||
if (node.nodeName !== 'PolygonPatch' && srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
@@ -724,7 +740,7 @@ ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec
|
||||
if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') {
|
||||
var rings = geometry.getLinearRings();
|
||||
ol.xml.pushSerializeAndPop(
|
||||
{node: node, srsName: srsName},
|
||||
{node: node, hasZ: hasZ, srsName: srsName},
|
||||
ol.format.GML3.RING_SERIALIZERS_,
|
||||
this.RING_NODE_FACTORY_,
|
||||
rings, objectStack, undefined, this);
|
||||
@@ -771,13 +787,14 @@ ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, obje
|
||||
*/
|
||||
ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
var hasZ = context['hasZ'];
|
||||
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.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface},
|
||||
ol.format.GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_,
|
||||
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons,
|
||||
objectStack, undefined, this);
|
||||
@@ -794,11 +811,12 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry,
|
||||
objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
var srsName = context['srsName'];
|
||||
var hasZ = context['hasZ'];
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
}
|
||||
var points = geometry.getPoints();
|
||||
ol.xml.pushSerializeAndPop({node: node, srsName: srsName},
|
||||
ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName},
|
||||
ol.format.GML3.POINTMEMBER_SERIALIZERS_,
|
||||
ol.xml.makeSimpleNodeFactory('pointMember'), points,
|
||||
objectStack, undefined, this);
|
||||
@@ -813,13 +831,14 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry,
|
||||
*/
|
||||
ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) {
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
var hasZ = context['hasZ'];
|
||||
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.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve},
|
||||
ol.format.GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_,
|
||||
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines,
|
||||
objectStack, undefined, this);
|
||||
@@ -1168,7 +1187,7 @@ ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, o
|
||||
ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) {
|
||||
opt_options = this.adaptOptions(opt_options);
|
||||
var geom = ol.xml.createElementNS('http://www.opengis.net/gml', 'geom');
|
||||
var context = {node: geom, srsName: this.srsName,
|
||||
var context = {node: geom, hasZ: this.hasZ, srsName: this.srsName,
|
||||
curve: this.curve_, surface: this.surface_,
|
||||
multiSurface: this.multiSurface_, multiCurve: this.multiCurve_};
|
||||
if (opt_options) {
|
||||
@@ -1208,6 +1227,7 @@ ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) {
|
||||
'xsi:schemaLocation', this.schemaLocation);
|
||||
var context = {
|
||||
srsName: this.srsName,
|
||||
hasZ: this.hasZ,
|
||||
curve: this.curve_,
|
||||
surface: this.surface_,
|
||||
multiSurface: this.multiSurface_,
|
||||
|
||||
@@ -285,7 +285,8 @@ ol.format.KML.createStyleDefaults_ = function() {
|
||||
*/
|
||||
ol.format.KML.ICON_ANCHOR_UNITS_MAP_ = {
|
||||
'fraction': ol.style.IconAnchorUnits.FRACTION,
|
||||
'pixels': ol.style.IconAnchorUnits.PIXELS
|
||||
'pixels': ol.style.IconAnchorUnits.PIXELS,
|
||||
'insetPixels': ol.style.IconAnchorUnits.PIXELS
|
||||
};
|
||||
|
||||
|
||||
@@ -504,11 +505,26 @@ ol.format.KML.readURI_ = function(node) {
|
||||
ol.format.KML.readVec2_ = function(node) {
|
||||
var xunits = node.getAttribute('xunits');
|
||||
var yunits = node.getAttribute('yunits');
|
||||
var origin;
|
||||
if (xunits !== 'insetPixels') {
|
||||
if (yunits !== 'insetPixels') {
|
||||
origin = ol.style.IconOrigin.BOTTOM_LEFT;
|
||||
} else {
|
||||
origin = ol.style.IconOrigin.TOP_LEFT;
|
||||
}
|
||||
} else {
|
||||
if (yunits !== 'insetPixels') {
|
||||
origin = ol.style.IconOrigin.BOTTOM_RIGHT;
|
||||
} else {
|
||||
origin = ol.style.IconOrigin.TOP_RIGHT;
|
||||
}
|
||||
}
|
||||
return {
|
||||
x: parseFloat(node.getAttribute('x')),
|
||||
xunits: ol.format.KML.ICON_ANCHOR_UNITS_MAP_[xunits],
|
||||
y: parseFloat(node.getAttribute('y')),
|
||||
yunits: ol.format.KML.ICON_ANCHOR_UNITS_MAP_[yunits]
|
||||
yunits: ol.format.KML.ICON_ANCHOR_UNITS_MAP_[yunits],
|
||||
origin: origin
|
||||
};
|
||||
};
|
||||
|
||||
@@ -562,12 +578,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
src = ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_;
|
||||
}
|
||||
var anchor, anchorXUnits, anchorYUnits;
|
||||
var anchorOrigin = ol.style.IconOrigin.BOTTOM_LEFT;
|
||||
var hotSpot = /** @type {ol.KMLVec2_|undefined} */
|
||||
(object['hotSpot']);
|
||||
if (hotSpot) {
|
||||
anchor = [hotSpot.x, hotSpot.y];
|
||||
anchorXUnits = hotSpot.xunits;
|
||||
anchorYUnits = hotSpot.yunits;
|
||||
anchorOrigin = hotSpot.origin;
|
||||
} else if (src === ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_) {
|
||||
anchor = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_;
|
||||
anchorXUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_;
|
||||
@@ -616,7 +634,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
|
||||
var imageStyle = new ol.style.Icon({
|
||||
anchor: anchor,
|
||||
anchorOrigin: ol.style.IconOrigin.BOTTOM_LEFT,
|
||||
anchorOrigin: anchorOrigin,
|
||||
anchorXUnits: anchorXUnits,
|
||||
anchorYUnits: anchorYUnits,
|
||||
crossOrigin: 'anonymous', // FIXME should this be configurable?
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
goog.provide('ol.format.MVT');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.ext.pbf');
|
||||
goog.require('ol.ext.vectortile');
|
||||
goog.require('ol.ext.PBF');
|
||||
goog.require('ol.ext.vectortile.VectorTile');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.FormatType');
|
||||
goog.require('ol.geom.GeometryLayout');
|
||||
@@ -149,7 +149,7 @@ ol.format.MVT.prototype.readRenderFeature_ = function(rawFeature, layer) {
|
||||
ol.format.MVT.prototype.readFeatures = function(source, opt_options) {
|
||||
var layers = this.layers_;
|
||||
|
||||
var pbf = new ol.ext.pbf(/** @type {ArrayBuffer} */ (source));
|
||||
var pbf = new ol.ext.PBF(/** @type {ArrayBuffer} */ (source));
|
||||
var tile = new ol.ext.vectortile.VectorTile(pbf);
|
||||
var features = [];
|
||||
var featureClass = this.featureClass_;
|
||||
|
||||
@@ -2,6 +2,7 @@ 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');
|
||||
@@ -53,7 +54,8 @@ ol.format.WFS = function(opt_options) {
|
||||
* @type {string}
|
||||
*/
|
||||
this.schemaLocation_ = options.schemaLocation ?
|
||||
options.schemaLocation : ol.format.WFS.SCHEMA_LOCATION;
|
||||
options.schemaLocation :
|
||||
ol.format.WFS.SCHEMA_LOCATIONS[ol.format.WFS.DEFAULT_VERSION];
|
||||
|
||||
ol.format.XMLFeature.call(this);
|
||||
};
|
||||
@@ -88,12 +90,23 @@ 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.SCHEMA_LOCATION = 'http://www.opengis.net/wfs ' +
|
||||
'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd';
|
||||
ol.format.WFS.DEFAULT_VERSION = '1.1.0';
|
||||
|
||||
|
||||
/**
|
||||
@@ -360,9 +373,14 @@ 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);
|
||||
ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack);
|
||||
if (gmlVersion === 2) {
|
||||
ol.format.GML2.prototype.writeFeatureElement(child, feature, objectStack);
|
||||
} else {
|
||||
ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -381,6 +399,25 @@ ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|undefined} featurePrefix The prefix of the feature.
|
||||
* @param {string} featureType The type of the feature.
|
||||
* @returns {string} The value of the typeName property.
|
||||
* @private
|
||||
*/
|
||||
ol.format.WFS.getTypeName_ = function(featurePrefix, featureType) {
|
||||
featurePrefix = featurePrefix ? featurePrefix :
|
||||
ol.format.WFS.FEATURE_PREFIX;
|
||||
var prefix = featurePrefix + ':';
|
||||
// The featureType already contains the prefix.
|
||||
if (featureType.indexOf(prefix) === 0) {
|
||||
return featureType;
|
||||
} else {
|
||||
return prefix + featureType;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {ol.Feature} feature Feature.
|
||||
@@ -392,10 +429,9 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
|
||||
ol.asserts.assert(feature.getId() !== undefined, 26); // Features must have an id set
|
||||
var featureType = context['featureType'];
|
||||
var featurePrefix = context['featurePrefix'];
|
||||
featurePrefix = featurePrefix ? featurePrefix :
|
||||
ol.format.WFS.FEATURE_PREFIX;
|
||||
var featureNS = context['featureNS'];
|
||||
node.setAttribute('typeName', featurePrefix + ':' + featureType);
|
||||
var typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType);
|
||||
node.setAttribute('typeName', typeName);
|
||||
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
|
||||
featureNS);
|
||||
var fid = feature.getId();
|
||||
@@ -416,10 +452,9 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
||||
ol.asserts.assert(feature.getId() !== undefined, 27); // Features must have an id set
|
||||
var featureType = context['featureType'];
|
||||
var featurePrefix = context['featurePrefix'];
|
||||
featurePrefix = featurePrefix ? featurePrefix :
|
||||
ol.format.WFS.FEATURE_PREFIX;
|
||||
var featureNS = context['featureNS'];
|
||||
node.setAttribute('typeName', featurePrefix + ':' + featureType);
|
||||
var typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType);
|
||||
node.setAttribute('typeName', typeName);
|
||||
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
|
||||
featureNS);
|
||||
var fid = feature.getId();
|
||||
@@ -433,7 +468,8 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
||||
}
|
||||
}
|
||||
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (
|
||||
{node: node, 'srsName': context['srsName']}),
|
||||
{'gmlVersion': context['gmlVersion'], node: node,
|
||||
'hasZ': context['hasZ'], 'srsName': context['srsName']}),
|
||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||
ol.xml.makeSimpleNodeFactory('Property'), values,
|
||||
objectStack);
|
||||
@@ -450,14 +486,21 @@ 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) {
|
||||
ol.format.GML3.prototype.writeGeometryElement(value,
|
||||
pair.value, objectStack);
|
||||
if (gmlVersion === 2) {
|
||||
ol.format.GML2.prototype.writeGeometryElement(value,
|
||||
pair.value, objectStack);
|
||||
} else {
|
||||
ol.format.GML3.prototype.writeGeometryElement(value,
|
||||
pair.value, objectStack);
|
||||
}
|
||||
} else {
|
||||
ol.format.XSD.writeStringTextNode(value, pair.value);
|
||||
}
|
||||
@@ -512,8 +555,14 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
|
||||
var featureNS = context['featureNS'];
|
||||
var propertyNames = context['propertyNames'];
|
||||
var srsName = context['srsName'];
|
||||
var prefix = featurePrefix ? featurePrefix + ':' : '';
|
||||
node.setAttribute('typeName', prefix + featureType);
|
||||
var typeName;
|
||||
// If feature prefix is not defined, we must not use the default prefix.
|
||||
if (featurePrefix) {
|
||||
typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType);
|
||||
} else {
|
||||
typeName = featureType;
|
||||
}
|
||||
node.setAttribute('typeName', typeName);
|
||||
if (srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
}
|
||||
@@ -756,6 +805,20 @@ 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.
|
||||
@@ -851,8 +914,11 @@ 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', '1.1.0');
|
||||
node.setAttribute('version', version);
|
||||
var baseObj;
|
||||
/** @type {ol.XmlNodeStackItem} */
|
||||
var obj;
|
||||
@@ -862,12 +928,13 @@ 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', this.schemaLocation_);
|
||||
'xsi:schemaLocation', schemaLocation);
|
||||
if (inserts) {
|
||||
obj = {node: node, 'featureNS': options.featureNS,
|
||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
||||
'srsName': options.srsName};
|
||||
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
||||
ol.obj.assign(obj, baseObj);
|
||||
ol.xml.pushSerializeAndPop(obj,
|
||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||
@@ -877,7 +944,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
||||
if (updates) {
|
||||
obj = {node: node, 'featureNS': options.featureNS,
|
||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
||||
'srsName': options.srsName};
|
||||
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
||||
ol.obj.assign(obj, baseObj);
|
||||
ol.xml.pushSerializeAndPop(obj,
|
||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||
@@ -887,7 +954,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,
|
||||
'srsName': options.srsName},
|
||||
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
|
||||
objectStack);
|
||||
@@ -895,7 +962,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,
|
||||
'srsName': options.srsName},
|
||||
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||
ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements,
|
||||
objectStack);
|
||||
|
||||
@@ -192,12 +192,12 @@ ol.Geolocation.prototype.getAccuracy = function() {
|
||||
|
||||
/**
|
||||
* Get a geometry of the position accuracy.
|
||||
* @return {?ol.geom.Geometry} A geometry of the position accuracy.
|
||||
* @return {?ol.geom.Polygon} A geometry of the position accuracy.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
ol.Geolocation.prototype.getAccuracyGeometry = function() {
|
||||
return /** @type {?ol.geom.Geometry} */ (
|
||||
return /** @type {?ol.geom.Polygon} */ (
|
||||
this.get(ol.GeolocationProperty.ACCURACY_GEOMETRY) || null);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
goog.provide('ol.Graticule');
|
||||
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.GeometryLayout');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.flat.geodesic');
|
||||
goog.require('ol.math');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.render.EventType');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Text');
|
||||
|
||||
|
||||
/**
|
||||
@@ -104,31 +108,116 @@ ol.Graticule = function(opt_options) {
|
||||
*/
|
||||
this.parallels_ = [];
|
||||
|
||||
/**
|
||||
* @type {ol.style.Stroke}
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* @type {ol.style.Stroke}
|
||||
* @private
|
||||
*/
|
||||
this.strokeStyle_ = options.strokeStyle !== undefined ?
|
||||
options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_;
|
||||
|
||||
/**
|
||||
* @type {ol.TransformFunction|undefined}
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* @type {ol.TransformFunction|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.fromLonLatTransform_ = undefined;
|
||||
|
||||
/**
|
||||
* @type {ol.TransformFunction|undefined}
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* @type {ol.TransformFunction|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.toLonLatTransform_ = undefined;
|
||||
|
||||
/**
|
||||
* @type {ol.Coordinate}
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* @type {ol.Coordinate}
|
||||
* @private
|
||||
*/
|
||||
this.projectionCenterLonLat_ = null;
|
||||
|
||||
/**
|
||||
* @type {Array.<ol.GraticuleLabelDataType>}
|
||||
* @private
|
||||
*/
|
||||
this.meridiansLabels_ = null;
|
||||
|
||||
/**
|
||||
* @type {Array.<ol.GraticuleLabelDataType>}
|
||||
* @private
|
||||
*/
|
||||
this.parallelsLabels_ = null;
|
||||
|
||||
if (options.showLabels == true) {
|
||||
var degreesToString = ol.coordinate.degreesToStringHDMS;
|
||||
|
||||
/**
|
||||
* @type {null|function(number):string}
|
||||
* @private
|
||||
*/
|
||||
this.lonLabelFormatter_ = options.lonLabelFormatter == undefined ?
|
||||
degreesToString.bind(this, 'EW') : options.lonLabelFormatter;
|
||||
|
||||
/**
|
||||
* @type {function(number):string}
|
||||
* @private
|
||||
*/
|
||||
this.latLabelFormatter_ = options.latLabelFormatter == undefined ?
|
||||
degreesToString.bind(this, 'NS') : options.latLabelFormatter;
|
||||
|
||||
/**
|
||||
* Longitude label position in fractions (0..1) of view extent. 0 means
|
||||
* bottom, 1 means top.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.lonLabelPosition_ = options.lonLabelPosition == undefined ? 0 :
|
||||
options.lonLabelPosition;
|
||||
|
||||
/**
|
||||
* Latitude Label position in fractions (0..1) of view extent. 0 means left, 1
|
||||
* means right.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.latLabelPosition_ = options.latLabelPosition == undefined ? 1 :
|
||||
options.latLabelPosition;
|
||||
|
||||
/**
|
||||
* @type {ol.style.Text}
|
||||
* @private
|
||||
*/
|
||||
this.lonLabelStyle_ = options.lonLabelStyle !== undefined ? options.lonLabelStyle :
|
||||
new ol.style.Text({
|
||||
font: '12px Calibri,sans-serif',
|
||||
textBaseline: 'bottom',
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(0,0,0,1)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: 'rgba(255,255,255,1)',
|
||||
width: 3
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {ol.style.Text}
|
||||
* @private
|
||||
*/
|
||||
this.latLabelStyle_ = options.latLabelStyle !== undefined ? options.latLabelStyle :
|
||||
new ol.style.Text({
|
||||
font: '12px Calibri,sans-serif',
|
||||
textAlign: 'end',
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(0,0,0,1)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: 'rgba(255,255,255,1)',
|
||||
width: 3
|
||||
})
|
||||
});
|
||||
|
||||
this.meridiansLabels_ = [];
|
||||
this.parallelsLabels_ = [];
|
||||
}
|
||||
|
||||
this.setMap(options.map !== undefined ? options.map : null);
|
||||
};
|
||||
|
||||
@@ -166,11 +255,39 @@ ol.Graticule.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredToler
|
||||
var lineString = this.getMeridian_(lon, minLat, maxLat,
|
||||
squaredTolerance, index);
|
||||
if (ol.extent.intersects(lineString.getExtent(), extent)) {
|
||||
if (this.meridiansLabels_) {
|
||||
var textPoint = this.getMeridianPoint_(lineString, extent, index);
|
||||
this.meridiansLabels_[index] = {
|
||||
geom: textPoint,
|
||||
text: this.lonLabelFormatter_(lon)
|
||||
};
|
||||
}
|
||||
this.meridians_[index++] = lineString;
|
||||
}
|
||||
return index;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ol.geom.LineString} lineString Meridian
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {number} index Index.
|
||||
* @return {ol.geom.Point} Meridian point.
|
||||
* @private
|
||||
*/
|
||||
ol.Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) {
|
||||
var flatCoordinates = lineString.getFlatCoordinates();
|
||||
var clampedBottom = Math.max(extent[1], flatCoordinates[1]);
|
||||
var clampedTop = Math.min(extent[3], flatCoordinates[flatCoordinates.length - 1]);
|
||||
var lat = ol.math.clamp(
|
||||
extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_,
|
||||
clampedBottom, clampedTop);
|
||||
var coordinate = [flatCoordinates[0], lat];
|
||||
var point = this.meridiansLabels_[index] !== undefined ?
|
||||
this.meridiansLabels_[index].geom : new ol.geom.Point(null);
|
||||
point.setCoordinates(coordinate);
|
||||
return point;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} lat Latitude.
|
||||
@@ -186,12 +303,41 @@ ol.Graticule.prototype.addParallel_ = function(lat, minLon, maxLon, squaredToler
|
||||
var lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance,
|
||||
index);
|
||||
if (ol.extent.intersects(lineString.getExtent(), extent)) {
|
||||
if (this.parallelsLabels_) {
|
||||
var textPoint = this.getParallelPoint_(lineString, extent, index);
|
||||
this.parallelsLabels_[index] = {
|
||||
geom: textPoint,
|
||||
text: this.latLabelFormatter_(lat)
|
||||
};
|
||||
}
|
||||
this.parallels_[index++] = lineString;
|
||||
}
|
||||
return index;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.LineString} lineString Parallels.
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {number} index Index.
|
||||
* @return {ol.geom.Point} Parallel point.
|
||||
* @private
|
||||
*/
|
||||
ol.Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) {
|
||||
var flatCoordinates = lineString.getFlatCoordinates();
|
||||
var clampedLeft = Math.max(extent[0], flatCoordinates[0]);
|
||||
var clampedRight = Math.min(extent[2], flatCoordinates[flatCoordinates.length - 2]);
|
||||
var lon = ol.math.clamp(
|
||||
extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_,
|
||||
clampedLeft, clampedRight);
|
||||
var coordinate = [lon, flatCoordinates[1]];
|
||||
var point = this.parallelsLabels_[index] !== undefined ?
|
||||
this.parallelsLabels_[index].geom : new ol.geom.Point(null);
|
||||
point.setCoordinates(coordinate);
|
||||
return point;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {ol.Coordinate} center Center.
|
||||
@@ -204,6 +350,12 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s
|
||||
var interval = this.getInterval_(resolution);
|
||||
if (interval == -1) {
|
||||
this.meridians_.length = this.parallels_.length = 0;
|
||||
if (this.meridiansLabels_) {
|
||||
this.meridiansLabels_.length = 0;
|
||||
}
|
||||
if (this.parallelsLabels_) {
|
||||
this.parallelsLabels_.length = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -249,6 +401,9 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s
|
||||
}
|
||||
|
||||
this.meridians_.length = idx;
|
||||
if (this.meridiansLabels_) {
|
||||
this.meridiansLabels_.length = idx;
|
||||
}
|
||||
|
||||
// Create parallels
|
||||
|
||||
@@ -272,6 +427,9 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s
|
||||
}
|
||||
|
||||
this.parallels_.length = idx;
|
||||
if (this.parallelsLabels_) {
|
||||
this.parallelsLabels_.length = idx;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -426,11 +584,28 @@ ol.Graticule.prototype.handlePostCompose_ = function(e) {
|
||||
var i, l, line;
|
||||
for (i = 0, l = this.meridians_.length; i < l; ++i) {
|
||||
line = this.meridians_[i];
|
||||
vectorContext.drawLineString(line, null);
|
||||
vectorContext.drawGeometry(line);
|
||||
}
|
||||
for (i = 0, l = this.parallels_.length; i < l; ++i) {
|
||||
line = this.parallels_[i];
|
||||
vectorContext.drawLineString(line, null);
|
||||
vectorContext.drawGeometry(line);
|
||||
}
|
||||
var labelData;
|
||||
if (this.meridiansLabels_) {
|
||||
for (i = 0, l = this.meridiansLabels_.length; i < l; ++i) {
|
||||
labelData = this.meridiansLabels_[i];
|
||||
this.lonLabelStyle_.setText(labelData.text);
|
||||
vectorContext.setTextStyle(this.lonLabelStyle_);
|
||||
vectorContext.drawGeometry(labelData.geom);
|
||||
}
|
||||
}
|
||||
if (this.parallelsLabels_) {
|
||||
for (i = 0, l = this.parallelsLabels_.length; i < l; ++i) {
|
||||
labelData = this.parallelsLabels_[i];
|
||||
this.latLabelStyle_.setText(labelData.text);
|
||||
vectorContext.setTextStyle(this.latLabelStyle_);
|
||||
vectorContext.drawGeometry(labelData.geom);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -47,12 +47,6 @@ 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
|
||||
|
||||
@@ -75,6 +75,7 @@ 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
|
||||
}));
|
||||
}
|
||||
@@ -92,6 +93,7 @@ ol.interaction.defaults = function(opt_options) {
|
||||
options.mouseWheelZoom : true;
|
||||
if (mouseWheelZoom) {
|
||||
interactions.push(new ol.interaction.MouseWheelZoom({
|
||||
constrainResolution: options.constrainResolution,
|
||||
duration: options.zoomDuration
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -8,15 +8,6 @@ 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,
|
||||
@@ -50,6 +41,12 @@ 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
|
||||
@@ -76,18 +73,17 @@ 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 >=
|
||||
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED;
|
||||
return width * width + height * height >= this.minArea_;
|
||||
};
|
||||
|
||||
|
||||
@@ -119,8 +115,8 @@ ol.interaction.DragBox.prototype.getGeometry = function() {
|
||||
|
||||
|
||||
/**
|
||||
* To be overriden by child classes.
|
||||
* FIXME: use constructor option instead of relying on overridding.
|
||||
* To be overridden by child classes.
|
||||
* FIXME: use constructor option instead of relying on overriding.
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @protected
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,12 @@ ol.interaction.Draw = function(options) {
|
||||
handleUpEvent: ol.interaction.Draw.handleUpEvent_
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.shouldHandle_ = false;
|
||||
|
||||
/**
|
||||
* @type {ol.Pixel}
|
||||
* @private
|
||||
@@ -111,7 +117,7 @@ ol.interaction.Draw = function(options) {
|
||||
this.maxPoints_ = options.maxPoints ? options.maxPoints : Infinity;
|
||||
|
||||
/**
|
||||
* A function to decide if a potential finish coordinate is permissable
|
||||
* A function to decide if a potential finish coordinate is permissible
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
@@ -325,6 +331,8 @@ 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_) {
|
||||
@@ -347,18 +355,13 @@ 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;
|
||||
var shouldHandle = this.freehand_ ?
|
||||
squaredDistance > this.squaredClickTolerance_ :
|
||||
squaredDistance <= this.squaredClickTolerance_;
|
||||
|
||||
this.handlePointerMove_(event);
|
||||
|
||||
var circleMode = this.mode_ === ol.interaction.Draw.Mode_.CIRCLE;
|
||||
if (shouldHandle) {
|
||||
this.handlePointerMove_(event);
|
||||
|
||||
if (this.shouldHandle_) {
|
||||
if (!this.finishCoordinate_) {
|
||||
this.startDrawing_(event);
|
||||
if (this.mode_ === ol.interaction.Draw.Mode_.POINT) {
|
||||
@@ -374,8 +377,9 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
|
||||
this.addToDrawing_(event);
|
||||
}
|
||||
pass = false;
|
||||
} else if (circleMode) {
|
||||
} else if (this.freehand_) {
|
||||
this.finishCoordinate_ = null;
|
||||
this.abortDrawing_();
|
||||
}
|
||||
return pass;
|
||||
};
|
||||
@@ -388,6 +392,19 @@ 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 {
|
||||
@@ -586,12 +603,18 @@ 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);
|
||||
|
||||
@@ -550,6 +550,7 @@ 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_;
|
||||
@@ -575,7 +576,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_(vertex, segmentDataMatch);
|
||||
var closestVertex = ol.interaction.Modify.closestOnSegmentData_(pixelCoordinate, segmentDataMatch);
|
||||
if (ol.coordinate.equals(closestVertex, vertex) && !componentSegments[uid][0]) {
|
||||
this.dragSegments_.push([segmentDataMatch, 0]);
|
||||
componentSegments[uid][0] = segmentDataMatch;
|
||||
@@ -1087,6 +1088,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
|
||||
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
||||
this.vertexFeature_ = null;
|
||||
}
|
||||
dragSegments.length = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,12 @@ 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}
|
||||
@@ -186,6 +192,16 @@ 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,
|
||||
|
||||
@@ -418,8 +418,10 @@ ol.interaction.Snap.prototype.updateFeature_ = function(feature) {
|
||||
ol.interaction.Snap.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) {
|
||||
var i, geometries = geometry.getGeometriesArray();
|
||||
for (i = 0; i < geometries.length; ++i) {
|
||||
this.SEGMENT_WRITERS_[geometries[i].getType()].call(
|
||||
this, feature, geometries[i]);
|
||||
var segmentWriter = this.SEGMENT_WRITERS_[geometries[i].getType()];
|
||||
if (segmentWriter) {
|
||||
segmentWriter.call(this, feature, geometries[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@ 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');
|
||||
|
||||
|
||||
@@ -82,6 +85,11 @@ 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);
|
||||
|
||||
@@ -233,6 +241,43 @@ 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
|
||||
|
||||
@@ -54,14 +54,14 @@ ol.layer.Group = function(opt_options) {
|
||||
|
||||
if (layers) {
|
||||
if (Array.isArray(layers)) {
|
||||
layers = new ol.Collection(layers.slice());
|
||||
layers = new ol.Collection(layers.slice(), {unique: true});
|
||||
} 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();
|
||||
layers = new ol.Collection(undefined, {unique: true});
|
||||
}
|
||||
|
||||
this.setLayers(layers);
|
||||
|
||||
@@ -102,7 +102,7 @@ ol.layer.Vector.prototype.getRenderBuffer = function() {
|
||||
* order.
|
||||
*/
|
||||
ol.layer.Vector.prototype.getRenderOrder = function() {
|
||||
return /** @type {function(ol.Feature, ol.Feature):number|null|undefined} */ (
|
||||
return /** @type {ol.RenderOrderFunction|null|undefined} */ (
|
||||
this.get(ol.layer.Vector.Property_.RENDER_ORDER));
|
||||
};
|
||||
|
||||
@@ -157,7 +157,7 @@ ol.layer.Vector.prototype.getUpdateWhileInteracting = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @param {function(ol.Feature, ol.Feature):number|null|undefined} renderOrder
|
||||
* @param {ol.RenderOrderFunction|null|undefined} renderOrder
|
||||
* Render order.
|
||||
*/
|
||||
ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
|
||||
|
||||
@@ -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.VectorTile.Property_.PRELOAD));
|
||||
return /** @type {number} */ (this.get(ol.layer.TileProperty.PRELOAD));
|
||||
};
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ ol.layer.VectorTile.prototype.getRenderMode = function() {
|
||||
*/
|
||||
ol.layer.VectorTile.prototype.getUseInterimTilesOnError = function() {
|
||||
return /** @type {boolean} */ (
|
||||
this.get(ol.layer.VectorTile.Property_.USE_INTERIM_TILES_ON_ERROR));
|
||||
this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR));
|
||||
};
|
||||
|
||||
|
||||
@@ -116,13 +116,3 @@ 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'
|
||||
};
|
||||
|
||||
@@ -30,7 +30,6 @@ 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');
|
||||
@@ -580,7 +579,7 @@ ol.Map.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_options)
|
||||
* detection can be configured through `opt_layerFilter`.
|
||||
* @param {ol.Pixel} pixel Pixel.
|
||||
* @param {function(this: S, ol.layer.Layer, (Uint8ClampedArray|Uint8Array)): T} callback
|
||||
* Layer callback. This callback will recieve two arguments: first is the
|
||||
* Layer callback. This callback will receive two arguments: first is the
|
||||
* {@link ol.layer.Layer layer}, second argument is an array representing
|
||||
* [R, G, B, A] pixel values (0 - 255) and will be `null` for layer types
|
||||
* that do not currently support this argument. To stop detection, callback
|
||||
@@ -1501,5 +1500,3 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
ol.proj.common.add();
|
||||
|
||||
@@ -4,6 +4,7 @@ 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');
|
||||
@@ -58,7 +59,7 @@ ol.Overlay = function(options) {
|
||||
* @type {Element}
|
||||
*/
|
||||
this.element_ = document.createElement('DIV');
|
||||
this.element_.className = 'ol-overlay-container';
|
||||
this.element_.className = 'ol-overlay-container ' + ol.css.CLASS_SELECTABLE;
|
||||
this.element_.style.position = 'absolute';
|
||||
|
||||
/**
|
||||
@@ -464,6 +465,8 @@ 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 ||
|
||||
@@ -514,8 +517,6 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
||||
this.rendered_.top_ = style.top = top;
|
||||
}
|
||||
}
|
||||
|
||||
this.setVisible(true);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ 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');
|
||||
@@ -29,7 +31,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) {
|
||||
@@ -467,3 +469,24 @@ 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();
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
goog.provide('ol.proj.common');
|
||||
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.EPSG3857');
|
||||
goog.require('ol.proj.EPSG4326');
|
||||
|
||||
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
* 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.
|
||||
* @api
|
||||
*/
|
||||
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);
|
||||
};
|
||||
ol.proj.common.add = ol.proj.addCommon;
|
||||
|
||||
@@ -2,7 +2,6 @@ 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');
|
||||
|
||||
@@ -16,7 +15,7 @@ goog.require('ol.proj.Units');
|
||||
* @param {string} code Code.
|
||||
* @private
|
||||
*/
|
||||
ol.proj.EPSG3857_ = function(code) {
|
||||
ol.proj.EPSG3857.Projection_ = function(code) {
|
||||
ol.proj.Projection.call(this, {
|
||||
code: code,
|
||||
units: ol.proj.Units.METERS,
|
||||
@@ -28,7 +27,7 @@ ol.proj.EPSG3857_ = function(code) {
|
||||
}
|
||||
});
|
||||
};
|
||||
ol.inherits(ol.proj.EPSG3857_, ol.proj.Projection);
|
||||
ol.inherits(ol.proj.EPSG3857.Projection_, ol.proj.Projection);
|
||||
|
||||
|
||||
/**
|
||||
@@ -85,7 +84,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_(code);
|
||||
return new ol.proj.EPSG3857.Projection_(code);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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');
|
||||
@@ -21,7 +20,7 @@ goog.require('ol.sphere.WGS84');
|
||||
* @param {string=} opt_axisOrientation Axis orientation.
|
||||
* @private
|
||||
*/
|
||||
ol.proj.EPSG4326_ = function(code, opt_axisOrientation) {
|
||||
ol.proj.EPSG4326.Projection_ = function(code, opt_axisOrientation) {
|
||||
ol.proj.Projection.call(this, {
|
||||
code: code,
|
||||
units: ol.proj.Units.DEGREES,
|
||||
@@ -32,7 +31,7 @@ ol.proj.EPSG4326_ = function(code, opt_axisOrientation) {
|
||||
worldExtent: ol.proj.EPSG4326.EXTENT
|
||||
});
|
||||
};
|
||||
ol.inherits(ol.proj.EPSG4326_, ol.proj.Projection);
|
||||
ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection);
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,12 +57,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_('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')
|
||||
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')
|
||||
];
|
||||
|
||||
@@ -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'];
|
||||
|
||||
@@ -204,8 +204,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations =
|
||||
new ol.render.webgl.circlereplay.defaultshader.Locations(gl, program);
|
||||
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
||||
locations = new ol.render.webgl.circlereplay.defaultshader.Locations(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This file is automatically generated, do not edit
|
||||
/* eslint openlayers-internal/no-missing-requires: 0 */
|
||||
goog.provide('ol.render.webgl.circlereplay.defaultshader');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
@@ -377,8 +377,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations =
|
||||
new ol.render.webgl.imagereplay.defaultshader.Locations(gl, program);
|
||||
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
||||
locations = new ol.render.webgl.imagereplay.defaultshader.Locations(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This file is automatically generated, do not edit
|
||||
/* eslint openlayers-internal/no-missing-requires: 0 */
|
||||
goog.provide('ol.render.webgl.imagereplay.defaultshader');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
@@ -446,8 +446,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations =
|
||||
new ol.render.webgl.linestringreplay.defaultshader.Locations(gl, program);
|
||||
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
||||
locations = new ol.render.webgl.linestringreplay.defaultshader.Locations(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This file is automatically generated, do not edit
|
||||
/* eslint openlayers-internal/no-missing-requires: 0 */
|
||||
goog.provide('ol.render.webgl.linestringreplay.defaultshader');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
@@ -833,8 +833,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations =
|
||||
new ol.render.webgl.polygonreplay.defaultshader.Locations(gl, program);
|
||||
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
||||
locations = new ol.render.webgl.polygonreplay.defaultshader.Locations(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This file is automatically generated, do not edit
|
||||
/* eslint openlayers-internal/no-missing-requires: 0 */
|
||||
goog.provide('ol.render.webgl.polygonreplay.defaultshader');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
@@ -3,6 +3,7 @@ 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');
|
||||
|
||||
@@ -29,12 +30,6 @@ ol.renderer.canvas.IntermediateCanvas = function(layer) {
|
||||
*/
|
||||
this.hitCanvasContext_ = null;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this.renderedResolution;
|
||||
|
||||
};
|
||||
ol.inherits(ol.renderer.canvas.IntermediateCanvas, ol.renderer.canvas.Layer);
|
||||
|
||||
@@ -51,7 +46,9 @@ ol.renderer.canvas.IntermediateCanvas.prototype.composeFrame = function(frameSta
|
||||
|
||||
// clipped rendering if layer extent is set
|
||||
var extent = layerState.extent;
|
||||
var clipped = extent !== undefined;
|
||||
var clipped = extent !== undefined &&
|
||||
!ol.extent.containsExtent(extent, frameState.extent) &&
|
||||
ol.extent.intersects(extent, frameState.extent);
|
||||
if (clipped) {
|
||||
this.clip(context, frameState, /** @type {ol.Extent} */ (extent));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ ol.renderer.canvas.TileLayer = function(tileLayer) {
|
||||
* @protected
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
this.context = ol.dom.createCanvasContext2D();
|
||||
this.context = this.context === null ? null : ol.dom.createCanvasContext2D();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -170,27 +170,31 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
|
||||
}
|
||||
}
|
||||
|
||||
var renderedResolution = tileResolution * pixelRatio / tilePixelRatio * oversampling;
|
||||
var hints = frameState.viewHints;
|
||||
if (!(this.renderedResolution && Date.now() - frameState.time > 16 &&
|
||||
(hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING])) &&
|
||||
(newTiles || !(this.renderedExtent_ &&
|
||||
ol.extent.containsExtent(this.renderedExtent_, extent)) ||
|
||||
this.renderedRevision != sourceRevision) ||
|
||||
oversampling != this.oversampling_) {
|
||||
var animatingOrInteracting = hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING];
|
||||
if (!(Date.now() - frameState.time > 16 && animatingOrInteracting) && (
|
||||
newTiles ||
|
||||
!(this.renderedExtent_ && ol.extent.containsExtent(this.renderedExtent_, extent)) ||
|
||||
this.renderedRevision != sourceRevision ||
|
||||
oversampling != this.oversampling_ ||
|
||||
!animatingOrInteracting && renderedResolution != this.renderedResolution
|
||||
)) {
|
||||
|
||||
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;
|
||||
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_;
|
||||
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_;
|
||||
}
|
||||
}
|
||||
|
||||
this.renderedTiles.length = 0;
|
||||
@@ -213,9 +217,6 @@ 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);
|
||||
}
|
||||
@@ -261,6 +262,9 @@ 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,
|
||||
@@ -273,7 +277,8 @@ ol.renderer.canvas.TileLayer.prototype.drawTileImage = function(tile, frameState
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.canvas.TileLayer.prototype.getImage = function() {
|
||||
return this.context.canvas;
|
||||
var context = this.context;
|
||||
return context ? context.canvas : null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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');
|
||||
@@ -22,6 +23,8 @@ goog.require('ol.transform');
|
||||
*/
|
||||
ol.renderer.canvas.VectorTileLayer = function(layer) {
|
||||
|
||||
this.context = null;
|
||||
|
||||
ol.renderer.canvas.TileLayer.call(this, layer);
|
||||
|
||||
/**
|
||||
@@ -74,9 +77,17 @@ ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS = {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame = function(frameState, layerState) {
|
||||
var layerRevision = this.getLayer().getRevision();
|
||||
var layer = this.getLayer();
|
||||
var layerRevision = layer.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);
|
||||
@@ -184,11 +195,10 @@ 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);
|
||||
var layer = this.getLayer();
|
||||
if (layer.getRenderMode() != ol.layer.VectorTileRenderType.VECTOR) {
|
||||
if (this.context) {
|
||||
this.renderTileImage_(vectorTile, frameState, layerState);
|
||||
ol.renderer.canvas.TileLayer.prototype.drawTileImage.apply(this, arguments);
|
||||
}
|
||||
ol.renderer.canvas.TileLayer.prototype.drawTileImage.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This file is automatically generated, do not edit
|
||||
/* eslint openlayers-internal/no-missing-requires: 0 */
|
||||
goog.provide('ol.renderer.webgl.defaultmapshader');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
@@ -156,8 +156,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations =
|
||||
new ol.renderer.webgl.defaultmapshader.Locations(gl, program);
|
||||
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
||||
locations = new ol.renderer.webgl.defaultmapshader.Locations(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
|
||||
@@ -196,8 +196,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
var program = context.getProgram(this.fragmentShader_, this.vertexShader_);
|
||||
context.useProgram(program);
|
||||
if (!this.locations_) {
|
||||
this.locations_ =
|
||||
new ol.renderer.webgl.tilelayershader.Locations(gl, program);
|
||||
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
||||
this.locations_ = new ol.renderer.webgl.tilelayershader.Locations(gl, program);
|
||||
}
|
||||
|
||||
context.bindBuffer(ol.webgl.ARRAY_BUFFER, this.renderArrayBuffer_);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This file is automatically generated, do not edit
|
||||
/* eslint openlayers-internal/no-missing-requires: 0 */
|
||||
goog.provide('ol.renderer.webgl.tilelayershader');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
@@ -74,6 +74,16 @@ 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.
|
||||
|
||||
@@ -79,10 +79,8 @@ ol.source.ImageStatic.prototype.handleImageChange = function(evt) {
|
||||
imageWidth = this.imageSize_[0];
|
||||
imageHeight = this.imageSize_[1];
|
||||
} else {
|
||||
// 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);
|
||||
imageWidth = image.width;
|
||||
imageHeight = image.height;
|
||||
}
|
||||
var resolution = ol.extent.getHeight(imageExtent) / imageHeight;
|
||||
var targetWidth = Math.ceil(ol.extent.getWidth(imageExtent) / resolution);
|
||||
|
||||
@@ -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, resolution, 0,
|
||||
var viewExtent = ol.extent.getForViewAndSize(center, imageResolution, 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, resolution, 0,
|
||||
var requestExtent = ol.extent.getForViewAndSize(center, imageResolution, 0,
|
||||
[requestWidth, requestHeight]);
|
||||
|
||||
var image = this.image_;
|
||||
|
||||
@@ -7,7 +7,7 @@ goog.require('ol.dom');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.ext.pixelworks');
|
||||
goog.require('ol.ext.pixelworks.Processor');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.Image');
|
||||
goog.require('ol.layer.Tile');
|
||||
@@ -65,12 +65,6 @@ ol.source.Raster = function(options) {
|
||||
this.changed, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
this.canvasContext_ = ol.dom.createCanvasContext2D();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.TileQueue}
|
||||
@@ -88,11 +82,11 @@ ol.source.Raster = function(options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The most recently rendered state.
|
||||
* @type {?ol.SourceRasterRenderedState}
|
||||
* The most recently requested frame state.
|
||||
* @type {olx.FrameState}
|
||||
* @private
|
||||
*/
|
||||
this.renderedState_ = null;
|
||||
this.requestedFrameState_;
|
||||
|
||||
/**
|
||||
* The most recently rendered image canvas.
|
||||
@@ -101,6 +95,12 @@ ol.source.Raster = function(options) {
|
||||
*/
|
||||
this.renderedImageCanvas_ = null;
|
||||
|
||||
/**
|
||||
* The most recently rendered revision.
|
||||
* @type {number}
|
||||
*/
|
||||
this.renderedRevision_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {olx.FrameState}
|
||||
@@ -176,13 +176,11 @@ 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;
|
||||
frameState.focus = ol.extent.getCenter(extent);
|
||||
frameState.size[0] = width;
|
||||
frameState.size[1] = height;
|
||||
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);
|
||||
|
||||
var viewState = frameState.viewState;
|
||||
viewState.center = center;
|
||||
@@ -192,66 +190,6 @@ 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.
|
||||
@@ -272,13 +210,41 @@ ol.source.Raster.prototype.allSourcesReady_ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @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.
|
||||
* @private
|
||||
*/
|
||||
ol.source.Raster.prototype.composeFrame_ = function(frameState, callback) {
|
||||
ol.source.Raster.prototype.processSources_ = function() {
|
||||
var frameState = this.requestedFrameState_;
|
||||
var len = this.renderers_.length;
|
||||
var imageDatas = new Array(len);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
@@ -287,53 +253,56 @@ ol.source.Raster.prototype.composeFrame_ = function(frameState, callback) {
|
||||
if (imageData) {
|
||||
imageDatas[i] = imageData;
|
||||
} else {
|
||||
// image not yet ready
|
||||
imageDatas = null;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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, callback, err, output, data) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output, data) {
|
||||
if (err || !output) {
|
||||
return;
|
||||
}
|
||||
if (!output) {
|
||||
// job aborted
|
||||
|
||||
// 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)) {
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ ol.source.Stamen = function(options) {
|
||||
opaque: layerConfig.opaque,
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
url: url
|
||||
url: url,
|
||||
wrapX: options.wrapX
|
||||
});
|
||||
};
|
||||
ol.inherits(ol.source.Stamen, ol.source.XYZ);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user