Compare commits
230 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1249b46e5d | ||
|
|
4733a5d0f9 | ||
|
|
dfe51e6195 | ||
|
|
24d1f4eac3 | ||
|
|
95bf18f6bd | ||
|
|
8b0ee6023e | ||
|
|
29fcf5f1c2 | ||
|
|
952a2cfba3 | ||
|
|
3b444978a7 | ||
|
|
13a761b7e7 | ||
|
|
89080cf8dd | ||
|
|
bfd94445f1 | ||
|
|
7c5a208e07 | ||
|
|
b38336b17f | ||
|
|
1af4d35713 | ||
|
|
f2c51cb39e | ||
|
|
5f794ab562 | ||
|
|
f4752cee59 | ||
|
|
3629a66917 | ||
|
|
35f79f401b | ||
|
|
a58f162ed9 | ||
|
|
f3ebbf4b7c | ||
|
|
94fb7ca5a6 | ||
|
|
92c62e5432 | ||
|
|
445c157ee3 | ||
|
|
15ddab7d0a | ||
|
|
3d72cc73b8 | ||
|
|
1b20f89c93 | ||
|
|
17b6088a79 | ||
|
|
23405b80a2 | ||
|
|
5b75666755 | ||
|
|
1c8734b150 | ||
|
|
ff9ef481db | ||
|
|
02cc7d643a | ||
|
|
efee061251 | ||
|
|
3551679a7c | ||
|
|
86eacefe19 | ||
|
|
7d260c54d3 | ||
|
|
25dca1ea3b | ||
|
|
6fd844d24c | ||
|
|
9f6839c87b | ||
|
|
e9611e6a6b | ||
|
|
b9089c00e3 | ||
|
|
388e2a93cb | ||
|
|
ac13dbccf1 | ||
|
|
1795a86f7f | ||
|
|
66da6fc150 | ||
|
|
e0eec51eb3 | ||
|
|
4b4d711dbc | ||
|
|
bb405e2919 | ||
|
|
f133f4fc3c | ||
|
|
35f22fb52c | ||
|
|
617151c8ff | ||
|
|
25e1e11550 | ||
|
|
67aa1a6dc9 | ||
|
|
3290039b32 | ||
|
|
e52ca96dc3 | ||
|
|
25b851e7cb | ||
|
|
9cbbc30ce1 | ||
|
|
2392f87113 | ||
|
|
63b14f5f32 | ||
|
|
ee7795e31d | ||
|
|
aba1045304 | ||
|
|
83c35758c8 | ||
|
|
d4d371a4c2 | ||
|
|
b3be7e7ba9 | ||
|
|
60f9c4be2d | ||
|
|
22dfe93f8b | ||
|
|
1bbcdea9bd | ||
|
|
e91ad26ac9 | ||
|
|
0fc3b0f58e | ||
|
|
afe0c10f45 | ||
|
|
d5fd215632 | ||
|
|
d9c49092e4 | ||
|
|
9fdce0f2b1 | ||
|
|
007d8c2d5e | ||
|
|
68f6b61217 | ||
|
|
1b46f38696 | ||
|
|
c6b942f185 | ||
|
|
2258c00fca | ||
|
|
f01e5d3eaf | ||
|
|
52a9ca6518 | ||
|
|
0d0f3cadc8 | ||
|
|
e454d3220e | ||
|
|
9b90ec099c | ||
|
|
fad485069b | ||
|
|
9ee1f6df98 | ||
|
|
b0b68983f7 | ||
|
|
8dbbe3ba5d | ||
|
|
e94b660b04 | ||
|
|
6cf3a3ca28 | ||
|
|
7782870522 | ||
|
|
648cd0ca61 | ||
|
|
b9b70ea3ec | ||
|
|
2f1bfc42ca | ||
|
|
2c358387a2 | ||
|
|
70af444b98 | ||
|
|
707bc4a708 | ||
|
|
ac48af204e | ||
|
|
fd7272ab1e | ||
|
|
ecadb6b685 | ||
|
|
fa41c0bad6 | ||
|
|
dd878e2a4c | ||
|
|
8666c8fee8 | ||
|
|
dd914ef635 | ||
|
|
719abf7265 | ||
|
|
c86d13f032 | ||
|
|
1b34dd945e | ||
|
|
cc13641216 | ||
|
|
13a0ca5ca1 | ||
|
|
704cd03d96 | ||
|
|
e79a4dd006 | ||
|
|
4bb2f6c1f5 | ||
|
|
89ec2dacad | ||
|
|
b97439cf8e | ||
|
|
f61bd6352d | ||
|
|
b7b2ee0c57 | ||
|
|
fe39b5da1b | ||
|
|
bc0bc3f8a9 | ||
|
|
9c0d0c5681 | ||
|
|
b97daf844b | ||
|
|
f8237c9cd2 | ||
|
|
b317a4474e | ||
|
|
b1772dae44 | ||
|
|
c33383d248 | ||
|
|
645e359cde | ||
|
|
fa71593a2a | ||
|
|
2e903c0293 | ||
|
|
aced192bcd | ||
|
|
19b0b956f7 | ||
|
|
9f9355ac46 | ||
|
|
f28e6c2d95 | ||
|
|
e633380221 | ||
|
|
5f6f757bd0 | ||
|
|
b29fc52842 | ||
|
|
791ffaabeb | ||
|
|
c31d67fe57 | ||
|
|
a1710be335 | ||
|
|
2260d92436 | ||
|
|
4d0e106d98 | ||
|
|
2be40953a8 | ||
|
|
8bc4bde5c3 | ||
|
|
429e2982d0 | ||
|
|
23f8540b4c | ||
|
|
59d8d749e3 | ||
|
|
cff9ef5e63 | ||
|
|
e6e0109a1b | ||
|
|
7739239e89 | ||
|
|
eb8d5bcade | ||
|
|
ff242ef28c | ||
|
|
4a0f97ac6a | ||
|
|
a0e0e76995 | ||
|
|
b5f9b88d0e | ||
|
|
339f048826 | ||
|
|
8db49fa981 | ||
|
|
4f0bfbc1db | ||
|
|
77273321b7 | ||
|
|
db63cc1b23 | ||
|
|
f88d8b8a7d | ||
|
|
991328904d | ||
|
|
9d3539b3cb | ||
|
|
bd143c0ad1 | ||
|
|
970265acb0 | ||
|
|
36c80f61bc | ||
|
|
d86c7c22dc | ||
|
|
71b334d49c | ||
|
|
ee0eb8b1a0 | ||
|
|
cd4ed759ed | ||
|
|
c0e4da6d8c | ||
|
|
72f5ff917f | ||
|
|
4c9c9fa719 | ||
|
|
163e01a2dc | ||
|
|
79862ca8c2 | ||
|
|
aa8d7b0b36 | ||
|
|
8d0857fd7a | ||
|
|
67f69a32bb | ||
|
|
382674975e | ||
|
|
eaaa895b0a | ||
|
|
70b971d3a4 | ||
|
|
3ddb8712a3 | ||
|
|
533ca8b9fe | ||
|
|
0fc710bc48 | ||
|
|
fe18636ff9 | ||
|
|
c299bfcd0f | ||
|
|
3f5a6bca26 | ||
|
|
a6b35e7d8a | ||
|
|
619e85e737 | ||
|
|
b3407b0554 | ||
|
|
a4c421e699 | ||
|
|
a3a443324d | ||
|
|
7b9833fdce | ||
|
|
bd87ec7c83 | ||
|
|
26bfa7a172 | ||
|
|
f82bc15013 | ||
|
|
da60b96445 | ||
|
|
2ed5abed07 | ||
|
|
49dcda7794 | ||
|
|
9fc0fb5e74 | ||
|
|
d32006b324 | ||
|
|
feabb6440d | ||
|
|
87e9c9ad46 | ||
|
|
7d6929c710 | ||
|
|
887642e69c | ||
|
|
b9e6619b2d | ||
|
|
78b5fe5f8c | ||
|
|
72e9b74b3e | ||
|
|
c6aeda1511 | ||
|
|
eb501e1244 | ||
|
|
1f51c14e7e | ||
|
|
dee3ebdc54 | ||
|
|
d0ef05977b | ||
|
|
a17db4f45c | ||
|
|
20974fea55 | ||
|
|
416df98505 | ||
|
|
fb5891cd48 | ||
|
|
1d4a482c1a | ||
|
|
8d57a879ce | ||
|
|
3e7aecd094 | ||
|
|
c46bc1f02a | ||
|
|
0d0ed6c130 | ||
|
|
0045bed6e7 | ||
|
|
0982dc0551 | ||
|
|
e38efc7cbe | ||
|
|
ea4e5f2293 | ||
|
|
29d1590bc6 | ||
|
|
e14ee2ea72 | ||
|
|
68ca4b3c2a | ||
|
|
4ad85e52e2 | ||
|
|
ca90157e9f | ||
|
|
132634f10c |
7
.github/ISSUE_TEMPLATE.md
vendored
Normal file
7
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
This issue tracker is for reporting bugs or feature requests, not for asking questions. For usage questions, refer to the (documentation)[http://openlayers.org/en/latest/doc/].
|
||||||
|
|
||||||
|
Ready to submit your bug or feature request? Make sure these boxes are checked before submitting your issue. Thank you!
|
||||||
|
|
||||||
|
- [ ] I have searched GitHub to see if a similar bug or feature request has already been reported.
|
||||||
|
- [ ] If reporting a bug, I have tried with the latest version of OpenLayers (see 'LATEST' on https://openlayers.org/)
|
||||||
|
- [ ] If reporting a bug, I have created a [CodePen](https://codepen.io) or prepared a stack trace (using the latest version and unminified code, so e.g. `ol-debug.js`, not `ol.js`) that shows the issue.
|
||||||
5
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
5
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Make sure these boxes are checked before submitting your pull request. Thank you!
|
||||||
|
|
||||||
|
- [ ] This pull request addresses an issue that has been marked with the 'Pull request accepted' label.
|
||||||
|
- [ ] It contains one or more small, incremental, logically separate commits, with no merge commits.
|
||||||
|
- [ ] I have used clear commit messages.
|
||||||
14
README.md
14
README.md
@@ -9,9 +9,16 @@
|
|||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
- Download the [latest release](https://openlayers.org/download/)
|
Use one of the following methods to use OpenLayers in your project:
|
||||||
- Install with npm: `npm install openlayers`
|
|
||||||
- Clone the repo: `git clone git@github.com:openlayers/openlayers.git`
|
* For use with webpack, Rollup, Browserify, or other module bundlers, install the [`ol` package](https://www.npmjs.com/package/ol):
|
||||||
|
```
|
||||||
|
npm install ol
|
||||||
|
```
|
||||||
|
|
||||||
|
* If you just want to add a `<script>` tag to test things out, you can link directly to one of the full builds from [cdnjs](https://cdnjs.com/libraries/openlayers) (not recommended for production)
|
||||||
|
|
||||||
|
* For use with Closure Library (rare), install the [`openlayers` package](https://npmjs.com/package/openlayers) and read the [tutorial](http://openlayers.org/en/latest/doc/tutorials/closure.html).
|
||||||
|
|
||||||
## Supported Browsers
|
## Supported Browsers
|
||||||
|
|
||||||
@@ -33,4 +40,3 @@ Please see our guide on [contributing](CONTRIBUTING.md) if you're interested in
|
|||||||
|
|
||||||
- Need help? Find it on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers)
|
- Need help? Find it on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers)
|
||||||
- Follow [@openlayers](https://twitter.com/openlayers) on Twitter
|
- Follow [@openlayers](https://twitter.com/openlayers) on Twitter
|
||||||
- Discuss with openlayers users on IRC in `#openlayers` at `chat.freenode`
|
|
||||||
|
|||||||
@@ -1,6 +1,73 @@
|
|||||||
## Upgrade notes
|
## Upgrade notes
|
||||||
|
|
||||||
### Next release
|
### Next Release
|
||||||
|
|
||||||
|
### v4.3.0
|
||||||
|
|
||||||
|
#### `ol.source.VectorTile` no longer requires a `tileGrid` option
|
||||||
|
|
||||||
|
By default, the `ol.source.VectorTile` constructor creates an XYZ tile grid (in Web Mercator) for 512 pixel tiles and assumes a max zoom level of 22. If you were creating a vector tile source with an explicit `tileGrid` option, you can now remove this.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
```js
|
||||||
|
var source = new ol.source.VectorTile({
|
||||||
|
tileGrid: ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22}),
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
```js
|
||||||
|
var source = new ol.source.VectorTile({
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need to change the max zoom level, you can pass the source a `maxZoom` option. If you need to change the tile size, you can pass the source a `tileSize` option. If you need a completely custom tile grid, you can still pass the source a `tileGrid` option.
|
||||||
|
|
||||||
|
#### `ol.interaction.Modify` deletes with `alt` key only
|
||||||
|
|
||||||
|
To delete features with the modify interaction, press the `alt` key while clicking on an existing vertex. If you want to configure the modify interaction with a different delete condition, use the `deleteCondition` option. For example, to allow deletion on a single click with no modifier keys, configure the interaction like this:
|
||||||
|
```js
|
||||||
|
var interaction = new ol.interaction.Modify({
|
||||||
|
source: source,
|
||||||
|
deleteCondition: function(event) {
|
||||||
|
return ol.events.condition.noModifierKeys(event) && ol.events.condition.singleClick(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
The motivation for this change is to make the modify, draw, and snap interactions all work well together. Previously, the use of these interactions with the default configuration would make it so you couldn't reliably add new vertices (click with no modifier) and delete existing vertices (click with no modifier).
|
||||||
|
|
||||||
|
#### `ol.source.VectorTile` no longer has a `tilePixelRatio` option
|
||||||
|
|
||||||
|
The `tilePixelRatio` option was only used for tiles in projections with `tile-pixels` as units. For tiles read with `ol.format.MVT` and the default tile loader, or tiles with the default pixel size of 4096 pixels, no changes are necessary. For the very rare cases that do not fall under these categories, a custom `tileLoadFunction` now needs to be configured on the `ol.source.VectorTile`. In addition to calling `tile.setFeatures()` and `tile.setProjection()`, it also needs to contain code like the following:
|
||||||
|
```js
|
||||||
|
var extent = tile.getFormat() instanceof ol.format.MVT ?
|
||||||
|
tile.getLastExtent() :
|
||||||
|
[0, 0, tilePixelRatio * tileSize, tilePixelRatio * tileSize];
|
||||||
|
tile.setExtent(extent);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `ol.animate` now takes the shortest arc for rotation animation
|
||||||
|
|
||||||
|
Usually rotation animations should animate along the shortest arc. There are rare occasions where a spinning animation effect is desired. So if you previously had something like
|
||||||
|
```js
|
||||||
|
map.getView().animate({
|
||||||
|
rotation: 2 * Math.PI,
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
```
|
||||||
|
we recommend to split the animation into two parts and use different easing functions. The code below results in the same effect as the snippet above did with previous versions:
|
||||||
|
```js
|
||||||
|
map.getView().animate({
|
||||||
|
rotation: Math.PI,
|
||||||
|
easing: ol.easing.easeIn
|
||||||
|
}, {
|
||||||
|
rotation: 2 * Math.PI,
|
||||||
|
easing: ol.easing.easeOut
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### v4.2.0
|
### v4.2.0
|
||||||
|
|
||||||
|
|||||||
216
changelog/v4.3.0.md
Normal file
216
changelog/v4.3.0.md
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
# 4.3.0
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
The v4.3.0 release includes features and fixes from 92 pull requests.
|
||||||
|
|
||||||
|
#### New `map.getFeaturesAtPixel()` method
|
||||||
|
|
||||||
|
When you want to get all features at a given pixel, use the new `map.getFeaturesAtPixel()` method.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
```js
|
||||||
|
var features = [];
|
||||||
|
map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||||
|
features.push(feature);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
```js
|
||||||
|
var features = map.getFeaturesAtPixel(pixel);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `ol.Sphere` functions for spherical measures
|
||||||
|
|
||||||
|
The new `ol.Sphere.getArea()` and `ol.Sphere.getLength()` methods can be used to calculate spherical measures on geometries. This is the recommended over using the `geometry.getArea()` or `geometry.getLength()` methods.
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
```js
|
||||||
|
geometry.getArea();
|
||||||
|
```
|
||||||
|
|
||||||
|
Good:
|
||||||
|
```js
|
||||||
|
ol.Sphere.getArea(geometry);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `ol.interaction.DragAndDrop` can be configured with a vector source
|
||||||
|
|
||||||
|
It is now possible to configure the drag and drop interaction with a vector source:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var dragAndDrop = new ol.interaction.DragAndDrop({source: source});
|
||||||
|
```
|
||||||
|
|
||||||
|
Any dropped features will replace all existing features on the source.
|
||||||
|
|
||||||
|
#### `ol.interaction.Modify` can be configured with a vector source
|
||||||
|
|
||||||
|
It is now possible to configure the modify interaction with a vector source (in addition to a feature collection):
|
||||||
|
|
||||||
|
```js
|
||||||
|
var modify = new ol.interaction.Modify({source: source});
|
||||||
|
```
|
||||||
|
|
||||||
|
With this configuration, all features on the source are eligible for modification while the interaction is active.
|
||||||
|
|
||||||
|
#### `ol.interaction.Modify` deletes with `alt` key only
|
||||||
|
|
||||||
|
To delete features with the modify interaction, press the `alt` key while clicking on an existing vertex. If you want to configure the modify interaction with a different delete condition, use the `deleteCondition` option. For example, to allow deletion on a single click with no modifier keys, configure the interaction like this:
|
||||||
|
```js
|
||||||
|
var interaction = new ol.interaction.Modify({
|
||||||
|
source: source,
|
||||||
|
deleteCondition: function(event) {
|
||||||
|
return ol.events.condition.noModifierKeys(event) && ol.events.condition.singleClick(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
The motivation for this change is to make the modify, draw, and snap interactions all work well together. Previously, the use of these interactions with the default configuration would make it so you couldn't reliably add new vertices (click with no modifier) and delete existing vertices (click with no modifier).
|
||||||
|
|
||||||
|
#### `ol.source.VectorTile` no longer requires a `tileGrid` option
|
||||||
|
|
||||||
|
By default, the `ol.source.VectorTile` constructor creates an XYZ tile grid (in Web Mercator) for 512 pixel tiles and assumes a max zoom level of 22. If you were creating a vector tile source with an explicit `tileGrid` option, you can now remove this.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
```js
|
||||||
|
var source = new ol.source.VectorTile({
|
||||||
|
tileGrid: ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22}),
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
```js
|
||||||
|
var source = new ol.source.VectorTile({
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need to change the max zoom level, you can pass the source a `maxZoom` option. If you need to change the tile size, you can pass the source a `tileSize` option. If you need a completely custom tile grid, you can still pass the source a `tileGrid` option.
|
||||||
|
|
||||||
|
#### `ol.source.VectorTile` no longer has a `tilePixelRatio` option
|
||||||
|
|
||||||
|
The `tilePixelRatio` option was only used for tiles in projections with `tile-pixels` as units. For tiles read with `ol.format.MVT` and the default tile loader, or tiles with the default pixel size of 4096 pixels, no changes are necessary. For the very rare cases that do not fall under these categories, a custom `tileLoadFunction` now needs to be configured on the `ol.source.VectorTile`. In addition to calling `tile.setFeatures()` and `tile.setProjection()`, it also needs to contain code like the following:
|
||||||
|
```js
|
||||||
|
var extent = tile.getFormat() instanceof ol.format.MVT ?
|
||||||
|
tile.getLastExtent() :
|
||||||
|
[0, 0, tilePixelRatio * tileSize, tilePixelRatio * tileSize];
|
||||||
|
tile.setExtent(extent);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `ol.animate` now takes the shortest arc for rotation animation
|
||||||
|
|
||||||
|
Usually rotation animations should animate along the shortest arc. There are rare occasions where a spinning animation effect is desired. So if you previously had something like
|
||||||
|
```js
|
||||||
|
map.getView().animate({
|
||||||
|
rotation: 2 * Math.PI,
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
```
|
||||||
|
we recommend to split the animation into two parts and use different easing functions. The code below results in the same effect as the snippet above did with previous versions:
|
||||||
|
```js
|
||||||
|
map.getView().animate({
|
||||||
|
rotation: Math.PI,
|
||||||
|
easing: ol.easing.easeIn
|
||||||
|
}, {
|
||||||
|
rotation: 2 * Math.PI,
|
||||||
|
easing: ol.easing.easeOut
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Full List of Changes
|
||||||
|
|
||||||
|
* [#7117](https://github.com/openlayers/openlayers/pull/7117) - Sensible default tilegrid for vector tiles ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#7116](https://github.com/openlayers/openlayers/pull/7116) - fix(package): update rollup to version 0.47.2 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7111](https://github.com/openlayers/openlayers/pull/7111) - Remove broken wrapX handling from ol.Graticule ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7107](https://github.com/openlayers/openlayers/pull/7107) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7106](https://github.com/openlayers/openlayers/pull/7106) - Update proj4 to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7105](https://github.com/openlayers/openlayers/pull/7105) - Functions for spherical calculations ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#7104](https://github.com/openlayers/openlayers/pull/7104) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6807](https://github.com/openlayers/openlayers/pull/6807) - Initialize hasZ in the constructor of GML3 ([@Jenselme](https://github.com/Jenselme))
|
||||||
|
* [#7102](https://github.com/openlayers/openlayers/pull/7102) - Allow drag and drop interaction to be configured with a source ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#6825](https://github.com/openlayers/openlayers/pull/6825) - Read/write Tessellate tag in KML format ([@oterral](https://github.com/oterral))
|
||||||
|
* [#7098](https://github.com/openlayers/openlayers/pull/7098) - Use fractional coordinates for CSS positioning ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7064](https://github.com/openlayers/openlayers/pull/7064) - Do not use Array.prototype.forEach when dealing with potentially large arrays ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7093](https://github.com/openlayers/openlayers/pull/7093) - Allow modify interaction to be configured with a source ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#7096](https://github.com/openlayers/openlayers/pull/7096) - Add new Map#getFeaturesAtPixel method ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7094](https://github.com/openlayers/openlayers/pull/7094) - Add missing zIndex options ([@icholy](https://github.com/icholy))
|
||||||
|
* [#7087](https://github.com/openlayers/openlayers/pull/7087) - Fix scale line for EPSG:4326 maps ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7088](https://github.com/openlayers/openlayers/pull/7088) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7085](https://github.com/openlayers/openlayers/pull/7085) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7084](https://github.com/openlayers/openlayers/pull/7084) - Fix a typo in the street-labels example ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7082](https://github.com/openlayers/openlayers/pull/7082) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7079](https://github.com/openlayers/openlayers/pull/7079) - Optimize custom renderer code, examples and API ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7080](https://github.com/openlayers/openlayers/pull/7080) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7078](https://github.com/openlayers/openlayers/pull/7078) - Fix return type annotation of ol.layer.VectorTile.getSource ([@geosense](https://github.com/geosense))
|
||||||
|
* [#7073](https://github.com/openlayers/openlayers/pull/7073) - Make ol.layer.Group change handling consistent ([@gberaudo](https://github.com/gberaudo))
|
||||||
|
* [#7075](https://github.com/openlayers/openlayers/pull/7075) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7072](https://github.com/openlayers/openlayers/pull/7072) - Improve API docs for ol.VectorTile ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7070](https://github.com/openlayers/openlayers/pull/7070) - Get tilePixelRatio from MVT tiles ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7069](https://github.com/openlayers/openlayers/pull/7069) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7068](https://github.com/openlayers/openlayers/pull/7068) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7066](https://github.com/openlayers/openlayers/pull/7066) - Fix ol.interaction.Extent event type and documentation ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7032](https://github.com/openlayers/openlayers/pull/7032) - Fix KML Export Icon Anchor ([@raiyni](https://github.com/raiyni))
|
||||||
|
* [#7065](https://github.com/openlayers/openlayers/pull/7065) - Only use API functions in example ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7022](https://github.com/openlayers/openlayers/pull/7022) - Allow styles to configure a custom renderer ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7061](https://github.com/openlayers/openlayers/pull/7061) - Update docs and issue and pull request instructions ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7059](https://github.com/openlayers/openlayers/pull/7059) - Allow to configure Extent interaction with an extent ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7060](https://github.com/openlayers/openlayers/pull/7060) - Removing invalid urn ([@wnordmann](https://github.com/wnordmann))
|
||||||
|
* [#7051](https://github.com/openlayers/openlayers/pull/7051) - Changing the EPSG3857.PROJECTION array assignment and adding urn:ogc:… ([@wnordmann](https://github.com/wnordmann))
|
||||||
|
* [#7045](https://github.com/openlayers/openlayers/pull/7045) - Respect pixelRatio when scaling images ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7023](https://github.com/openlayers/openlayers/pull/7023) - Update tile size and resolutions of vector tile examples ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#7005](https://github.com/openlayers/openlayers/pull/7005) - Add spatial reference inside geometry in EsriFormat ([@Sol1du2](https://github.com/Sol1du2))
|
||||||
|
* [#7034](https://github.com/openlayers/openlayers/pull/7034) - Move non-build dependencies to devDependencies ([@probins](https://github.com/probins))
|
||||||
|
* [#7050](https://github.com/openlayers/openlayers/pull/7050) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6976](https://github.com/openlayers/openlayers/pull/6976) - Example - Earthquake Clusters - Change evt.type of interaction ([@ehanoj](https://github.com/ehanoj))
|
||||||
|
* [#7048](https://github.com/openlayers/openlayers/pull/7048) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7041](https://github.com/openlayers/openlayers/pull/7041) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7042](https://github.com/openlayers/openlayers/pull/7042) - Line dash offset ([@gkresic](https://github.com/gkresic))
|
||||||
|
* [#6980](https://github.com/openlayers/openlayers/pull/6980) - Added tileClass to TileWMS ([@ZachTRice](https://github.com/ZachTRice))
|
||||||
|
* [#7028](https://github.com/openlayers/openlayers/pull/7028) - Fix Graticule use of incorrect min/maxLon values ([@greggian](https://github.com/greggian))
|
||||||
|
* [#7021](https://github.com/openlayers/openlayers/pull/7021) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7018](https://github.com/openlayers/openlayers/pull/7018) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7015](https://github.com/openlayers/openlayers/pull/7015) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7014](https://github.com/openlayers/openlayers/pull/7014) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7013](https://github.com/openlayers/openlayers/pull/7013) - Remove ol.sphere.WGS84 and ol.sphere.NORMAL ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#6981](https://github.com/openlayers/openlayers/pull/6981) - Render transparent vector layers to an intermediate canvas ([@gberaudo](https://github.com/gberaudo))
|
||||||
|
* [#6899](https://github.com/openlayers/openlayers/pull/6899) - Use number literal for sphere radius ([@probins](https://github.com/probins))
|
||||||
|
* [#7011](https://github.com/openlayers/openlayers/pull/7011) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7008](https://github.com/openlayers/openlayers/pull/7008) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7007](https://github.com/openlayers/openlayers/pull/7007) - fix(package): update rollup to version 0.45.0 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6996](https://github.com/openlayers/openlayers/pull/6996) - 6987: Memory leak with WMS time source with reprojection ([@ch08532](https://github.com/ch08532))
|
||||||
|
* [#7003](https://github.com/openlayers/openlayers/pull/7003) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#7004](https://github.com/openlayers/openlayers/pull/7004) - Use https for bing and stamen attributions ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6998](https://github.com/openlayers/openlayers/pull/6998) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6999](https://github.com/openlayers/openlayers/pull/6999) - Make VectorTile source work with multiple layers ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6988](https://github.com/openlayers/openlayers/pull/6988) - Add missing type annotations ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6984](https://github.com/openlayers/openlayers/pull/6984) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6970](https://github.com/openlayers/openlayers/pull/6970) - Fix Bug when adding/removing layer with no cache ([@cmortazavi](https://github.com/cmortazavi))
|
||||||
|
* [#6972](https://github.com/openlayers/openlayers/pull/6972) - Handle error tiles properly ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6973](https://github.com/openlayers/openlayers/pull/6973) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6971](https://github.com/openlayers/openlayers/pull/6971) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6968](https://github.com/openlayers/openlayers/pull/6968) - Shortest arc rotation animation improvements and upgrade notes ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6966](https://github.com/openlayers/openlayers/pull/6966) - Add getResolutionForZoom method for ol.View ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6965](https://github.com/openlayers/openlayers/pull/6965) - Use shortest rotation delta for animation ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6967](https://github.com/openlayers/openlayers/pull/6967) - Add RoadOnDemand imagery set to Bing example ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6964](https://github.com/openlayers/openlayers/pull/6964) - Fix KML ExtendedData reading ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6958](https://github.com/openlayers/openlayers/pull/6958) - Remove error tiles after loading is finished ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6793](https://github.com/openlayers/openlayers/pull/6793) - Webgl text ([@GaborFarkas](https://github.com/GaborFarkas))
|
||||||
|
* [#6960](https://github.com/openlayers/openlayers/pull/6960) - Queue tiles before loading ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#6957](https://github.com/openlayers/openlayers/pull/6957) - Greenkeeper/eslint 4.1.1 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6955](https://github.com/openlayers/openlayers/pull/6955) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6916](https://github.com/openlayers/openlayers/pull/6916) - Upgrade eslint to v4.0.0 ([@marcjansen](https://github.com/marcjansen))
|
||||||
|
* [#6943](https://github.com/openlayers/openlayers/pull/6943) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6939](https://github.com/openlayers/openlayers/pull/6939) - Abort loading when tile is disposed ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6930](https://github.com/openlayers/openlayers/pull/6930) - Handle setActive(false) on an interaction without map ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6936](https://github.com/openlayers/openlayers/pull/6936) - Do not stop the render loop when all wanted tiles are aborted ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6920](https://github.com/openlayers/openlayers/pull/6920) - Fix minor type strength inconsistency ([@klokantech](https://github.com/klokantech))
|
||||||
|
* [#6935](https://github.com/openlayers/openlayers/pull/6935) - Use transparent image from canvas context ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6933](https://github.com/openlayers/openlayers/pull/6933) - Improve proj.get() logic ([@probins](https://github.com/probins))
|
||||||
|
* [#6931](https://github.com/openlayers/openlayers/pull/6931) - Make sure we use the default featurePrefix ([@bartvde](https://github.com/bartvde))
|
||||||
|
* [#6928](https://github.com/openlayers/openlayers/pull/6928) - Only adjust resolution when center within projection extent ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6923](https://github.com/openlayers/openlayers/pull/6923) - Load tasks/build-ext.js in strict mode ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6918](https://github.com/openlayers/openlayers/pull/6918) - Remove unnecessary pixelRatio check ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6917](https://github.com/openlayers/openlayers/pull/6917) - Correct typo in graticule docs ([@probins](https://github.com/probins))
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"opts": {
|
"opts": {
|
||||||
"recurse": true,
|
"recurse": true,
|
||||||
"template": "config/jsdoc/api/template"
|
"template": "../../config/jsdoc/api/template"
|
||||||
},
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"allowUnknownTags": true
|
"allowUnknownTags": true
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"node_modules/jsdoc/plugins/markdown",
|
"plugins/markdown",
|
||||||
"config/jsdoc/api/plugins/inheritdoc",
|
"../../config/jsdoc/api/plugins/inheritdoc",
|
||||||
"config/jsdoc/api/plugins/typedefs",
|
"../../config/jsdoc/api/plugins/typedefs",
|
||||||
"config/jsdoc/api/plugins/events",
|
"../../config/jsdoc/api/plugins/events",
|
||||||
"config/jsdoc/api/plugins/observable",
|
"../../config/jsdoc/api/plugins/observable",
|
||||||
"config/jsdoc/api/plugins/api"
|
"../../config/jsdoc/api/plugins/api"
|
||||||
],
|
],
|
||||||
"markdown": {
|
"markdown": {
|
||||||
"parser": "gfm"
|
"parser": "gfm"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"opts": {
|
"opts": {
|
||||||
"recurse": true,
|
"recurse": true,
|
||||||
"template": "config/jsdoc/info"
|
"template": "../../config/jsdoc/info"
|
||||||
},
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"allowUnknownTags": true
|
"allowUnknownTags": true
|
||||||
@@ -10,8 +10,8 @@
|
|||||||
"includePattern": "\\.js$"
|
"includePattern": "\\.js$"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"config/jsdoc/info/api-plugin",
|
"../../config/jsdoc/info/api-plugin",
|
||||||
"config/jsdoc/info/define-plugin",
|
"../../config/jsdoc/info/define-plugin",
|
||||||
"config/jsdoc/info/virtual-plugin"
|
"../../config/jsdoc/info/virtual-plugin"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* an api tag) and boolean defines (with a define tag and a default value).
|
* an api tag) and boolean defines (with a define tag and a default value).
|
||||||
*/
|
*/
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var fs = require('fs');
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +88,6 @@ exports.publish = function(data, opts) {
|
|||||||
types: getTypes(doc.type.names)
|
types: getTypes(doc.type.names)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var types;
|
|
||||||
var symbol = {
|
var symbol = {
|
||||||
name: doc.longname,
|
name: doc.longname,
|
||||||
kind: doc.kind,
|
kind: doc.kind,
|
||||||
@@ -169,13 +167,15 @@ exports.publish = function(data, opts) {
|
|||||||
return (symbol.name in augments || symbol.virtual);
|
return (symbol.name in augments || symbol.virtual);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.stdout.write(
|
return new Promise(function(resolve, reject) {
|
||||||
JSON.stringify({
|
process.stdout.write(
|
||||||
symbols: symbols,
|
JSON.stringify({
|
||||||
defines: defines,
|
symbols: symbols,
|
||||||
typedefs: typedefs,
|
defines: defines,
|
||||||
externs: externs,
|
typedefs: typedefs,
|
||||||
base: base
|
externs: externs,
|
||||||
}, null, 2));
|
base: base
|
||||||
|
}, null, 2));
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ For a more in-depth overview of OpenLayers core concepts, check out the [tutoria
|
|||||||
|
|
||||||
Make sure to also check out the [OpenLayers workshop](/workshop/).
|
Make sure to also check out the [OpenLayers workshop](/workshop/).
|
||||||
|
|
||||||
Find additional reference material in the [API docs](../apidoc).
|
Find additional reference material in the [API docs](../apidoc) and [examples](../examples).
|
||||||
|
|
||||||
# Frequently Asked Questions (FAQ)
|
# Frequently Asked Questions (FAQ)
|
||||||
|
|
||||||
@@ -19,4 +19,4 @@ We have put together a document that lists [Frequently Asked Questions (FAQ)](fa
|
|||||||
|
|
||||||
# More questions?
|
# More questions?
|
||||||
|
|
||||||
If you cannot find an answer in the documentation or the FAQ, you can ask your question on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers).
|
If you cannot find an answer in the documentation or the FAQ, you can search [Stack Overflow](http://stackoverflow.com/questions/tagged/openlayers). If you cannot find an answer there, ask a new question there, using the tag 'openlayers'.
|
||||||
|
|||||||
@@ -5,57 +5,56 @@ layout: doc.hbs
|
|||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
When going beyond modifying existing examples you might be looking for a
|
When going beyond modifying existing examples you might be looking for a way to setup your own code with dependency management together with external dependencies like OpenLayers.
|
||||||
way to setup your own code with dependency management together with external
|
|
||||||
dependencies like OpenLayers.
|
|
||||||
|
|
||||||
This tutorial serves as a suggested project setup using NPM and Browserify
|
This tutorial serves as a suggested project setup using NPM and Browserify for the most basic needs. There are several other options, and in particular you might be interested in a more modern one (ES2015) [using Webpack with OpenLayers](https://gist.github.com/tschaub/79025aef325cd2837364400a105405b8).
|
||||||
for the most basic needs. There are several other options and in particular
|
|
||||||
you might be interested in
|
|
||||||
[compiling your own code together with OpenLayers](closure.html).
|
|
||||||
|
|
||||||
## Initial steps
|
## Initial steps
|
||||||
|
|
||||||
Create a new empty directory for your project and navigate to it by running
|
Create a new empty directory for your project and navigate to it by running `mkdir new-project && cd new-project`. Initialize your project using `npm init` and answer the questions asked.
|
||||||
`mkdir new-project && cd new-project`. Initialize your project using `npm init`
|
|
||||||
and answer the questions asked.
|
|
||||||
|
|
||||||
At this point you can ask NPM to add required dependencies by running
|
Add OpenLayers as dependency to your application with `npm install --save ol`.
|
||||||
`npm install --save-dev openlayers browserify watchify uglify-js`. Watchify and
|
|
||||||
Uglify will be used to monitor for changes and to build into a minified
|
At this point you can ask NPM to add required development dependencies by running
|
||||||
bundle.
|
```
|
||||||
|
npm install --save-dev cssify browserify cssify http-server uglify-js watchify
|
||||||
|
npm install --save-dev babelify babel-plugin-transform-es2015-modules-commonjs
|
||||||
|
```
|
||||||
|
We will be using `cssify` to include the css definitions required by OpenLayers in our bundle. `watchify`, `http-server` and `uglify-js` are used to monitor for changes and to build into a minified bundle. `babelify` and `babel-plugin-transform-es2015-modules-commonjs` are used to make the `ol` package, which was created using ES2015 modules, work with CommonJS.
|
||||||
|
|
||||||
## Application code and index.html
|
## Application code and index.html
|
||||||
|
|
||||||
Place your application code in `index.js`. Here is a simple starting point:
|
Place your application code in `index.js`. Here is a simple starting point:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var ol = require('openlayers');
|
require('ol/ol.css');
|
||||||
|
var ol_Map = require('ol/map').default;
|
||||||
var map = new ol.Map({
|
var ol_layer_Tile = require('ol/layer/tile').default;
|
||||||
|
var ol_source_OSM = require('ol/source/osm').default;
|
||||||
|
var ol_View = require('ol/view').default;
|
||||||
|
|
||||||
|
var map = new ol_Map({
|
||||||
target: 'map',
|
target: 'map',
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Tile({
|
new ol_layer_Tile({
|
||||||
source: new ol.source.OSM()
|
source: new ol_source_OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
view: new ol.View({
|
view: new ol_View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 0
|
zoom: 0
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also need an `ìndex.html` file that will use your bundle. Here is a simple
|
You will also need an `ìndex.html` file that will use your bundle. Here is a simple example:
|
||||||
example:
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Using Browserify with OpenLayers</title>
|
<title>Using Browserify with OpenLayers</title>
|
||||||
<link rel="stylesheet" href="node_modules/openlayers/dist/ol.css" type="text/css">
|
|
||||||
<style>
|
<style>
|
||||||
#map {
|
#map {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
@@ -72,18 +71,17 @@ example:
|
|||||||
|
|
||||||
## Creating a bundle
|
## Creating a bundle
|
||||||
|
|
||||||
With simple scripts you can introduce the commands `npm run build` and `npm start` to
|
With simple scripts you can introduce the commands `npm run build` and `npm start` to manually build your bundle and watch for changes, respectively. Add the following to the script section in `package.json`:
|
||||||
manually build your bundle and watch for changes, respectively. Add the following
|
|
||||||
to the script section in `package.json`:
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "watchify index.js --outfile bundle.js",
|
"start": "watchify index.js -g cssify --outfile bundle.js & http-server",
|
||||||
"build": "browserify index.js | uglifyjs --compress --output bundle.js"
|
"build": "browserify -g cssify index.js | uglifyjs --compress --output bundle.js"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Now to test your application open http://localhost:8080/ in your browser. `watchify` will update `bundle.js` whenever you change something. You simply need to reload the page in your browser to see the changes.
|
||||||
|
```
|
||||||
|
$ npm start
|
||||||
|
```
|
||||||
|
|
||||||
Note that `bundle.js` will contain your application code and all dependencies
|
Note that `bundle.js` will contain your application code and all dependencies used in your application. From OpenLayers, it only contains the required components.
|
||||||
used in your application, in this case the official full build of OpenLayers.
|
|
||||||
If you only need parts of OpenLayers you can create
|
|
||||||
[custom builds](../../builder).
|
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ layout: doc.hbs
|
|||||||
|
|
||||||
# Compiling Application with Closure Compiler
|
# Compiling Application with Closure Compiler
|
||||||
|
|
||||||
|
**Note**: When building an application with dependencies that are available as [npm](https://npmjs.com/) packages, it will probably be easier to use the [ol](https://npmjs.com/package/ol) package and follow the instructions there.
|
||||||
|
|
||||||
The OpenLayers code uses the Closure Library, and it is compiled with the
|
The OpenLayers code uses the Closure Library, and it is compiled with the
|
||||||
Closure Compiler. Using OpenLayers in an application does not require using
|
Closure Compiler. Using OpenLayers in an application does not require using
|
||||||
Closure. But using Closure in an OpenLayers application is possible. And this
|
Closure. But using Closure in an OpenLayers application is possible. And this
|
||||||
is what this tutorial is about.
|
is what this tutorial is about.
|
||||||
|
|
||||||
|
When you want to include OpenLayers as separate script without bundling with your application, follow the [Creating custom builds](./custom-builds.html) tutorial instead.
|
||||||
|
|
||||||
This tutorial will teach you how to set up an OpenLayers application based on
|
This tutorial will teach you how to set up an OpenLayers application based on
|
||||||
the [`closure-util`](https://github.com/openlayers/closure-util) node package,
|
the [`closure-util`](https://github.com/openlayers/closure-util) node package,
|
||||||
which provides utilities for working with Closure. Using `closure-util` is one
|
which provides utilities for working with Closure. Using `closure-util` is one
|
||||||
|
|||||||
@@ -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):
|
Following example shows definition of a [British National Grid](https://epsg.io/27700):
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.easing');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
@@ -73,9 +74,16 @@ onClick('rotate-right', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onClick('rotate-around-rome', function() {
|
onClick('rotate-around-rome', function() {
|
||||||
|
// Rotation animation takes the shortest arc, so animate in two parts
|
||||||
|
var rotation = view.getRotation();
|
||||||
view.animate({
|
view.animate({
|
||||||
rotation: view.getRotation() + 2 * Math.PI,
|
rotation: rotation + Math.PI,
|
||||||
anchor: rome
|
anchor: rome,
|
||||||
|
easing: ol.easing.easeIn
|
||||||
|
}, {
|
||||||
|
rotation: rotation + 2 * Math.PI,
|
||||||
|
anchor: rome,
|
||||||
|
easing: ol.easing.easeOut
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,10 +111,19 @@ onClick('bounce-to-istanbul', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onClick('spin-to-rome', function() {
|
onClick('spin-to-rome', function() {
|
||||||
|
// Rotation animation takes the shortest arc, so animate in two parts
|
||||||
|
var center = view.getCenter();
|
||||||
view.animate({
|
view.animate({
|
||||||
|
center: [
|
||||||
|
center[0] + (rome[0] - center[0]) / 2,
|
||||||
|
center[1] + (rome[1] - center[1]) / 2
|
||||||
|
],
|
||||||
|
rotation: Math.PI,
|
||||||
|
easing: ol.easing.easeIn
|
||||||
|
}, {
|
||||||
center: rome,
|
center: rome,
|
||||||
rotation: 2 * Math.PI,
|
rotation: 2 * Math.PI,
|
||||||
duration: 2000
|
easing: ol.easing.easeOut
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ cloak:
|
|||||||
<select id="layer-select">
|
<select id="layer-select">
|
||||||
<option value="Aerial">Aerial</option>
|
<option value="Aerial">Aerial</option>
|
||||||
<option value="AerialWithLabels" selected>Aerial with labels</option>
|
<option value="AerialWithLabels" selected>Aerial with labels</option>
|
||||||
<option value="Road">Road</option>
|
<option value="Road">Road (static)</option>
|
||||||
|
<option value="RoadOnDemand">Road (dynamic)</option>
|
||||||
<option value="collinsBart">Collins Bart</option>
|
<option value="collinsBart">Collins Bart</option>
|
||||||
<option value="ordnanceSurvey">Ordnance Survey</option>
|
<option value="ordnanceSurvey">Ordnance Survey</option>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ goog.require('ol.source.BingMaps');
|
|||||||
|
|
||||||
var styles = [
|
var styles = [
|
||||||
'Road',
|
'Road',
|
||||||
|
'RoadOnDemand',
|
||||||
'Aerial',
|
'Aerial',
|
||||||
'AerialWithLabels',
|
'AerialWithLabels',
|
||||||
'collinsBart',
|
'collinsBart',
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ function rgb2xyz(x) {
|
|||||||
|
|
||||||
function xyz2rgb(x) {
|
function xyz2rgb(x) {
|
||||||
return 255 * (x <= 0.0031308 ?
|
return 255 * (x <= 0.0031308 ?
|
||||||
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
||||||
}
|
}
|
||||||
|
|
||||||
var raster = new ol.source.Raster({
|
var raster = new ol.source.Raster({
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ var lineFeature = new ol.Feature(
|
|||||||
|
|
||||||
var polygonFeature = new ol.Feature(
|
var polygonFeature = new ol.Feature(
|
||||||
new ol.geom.Polygon([[[-3e6, -1e6], [-3e6, 1e6],
|
new ol.geom.Polygon([[[-3e6, -1e6], [-3e6, 1e6],
|
||||||
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
|
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
|
||||||
|
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
goog.require('ol.Collection');
|
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
goog.require('ol.events.condition');
|
|
||||||
goog.require('ol.interaction.Draw');
|
goog.require('ol.interaction.Draw');
|
||||||
goog.require('ol.interaction.Modify');
|
goog.require('ol.interaction.Modify');
|
||||||
|
goog.require('ol.interaction.Snap');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
@@ -17,18 +16,9 @@ var raster = new ol.layer.Tile({
|
|||||||
source: new ol.source.OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
|
|
||||||
var map = new ol.Map({
|
var source = new ol.source.Vector();
|
||||||
layers: [raster],
|
var vector = new ol.layer.Vector({
|
||||||
target: 'map',
|
source: source,
|
||||||
view: new ol.View({
|
|
||||||
center: [-11000000, 4600000],
|
|
||||||
zoom: 4
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
var features = new ol.Collection();
|
|
||||||
var featureOverlay = new ol.layer.Vector({
|
|
||||||
source: new ol.source.Vector({features: features}),
|
|
||||||
style: new ol.style.Style({
|
style: new ol.style.Style({
|
||||||
fill: new ol.style.Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255, 255, 255, 0.2)'
|
color: 'rgba(255, 255, 255, 0.2)'
|
||||||
@@ -45,38 +35,40 @@ var featureOverlay = new ol.layer.Vector({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
featureOverlay.setMap(map);
|
|
||||||
|
|
||||||
var modify = new ol.interaction.Modify({
|
var map = new ol.Map({
|
||||||
features: features,
|
layers: [raster, vector],
|
||||||
// the SHIFT key must be pressed to delete vertices, so
|
target: 'map',
|
||||||
// that new vertices can be drawn at the same position
|
view: new ol.View({
|
||||||
// of existing vertices
|
center: [-11000000, 4600000],
|
||||||
deleteCondition: function(event) {
|
zoom: 4
|
||||||
return ol.events.condition.shiftKeyOnly(event) &&
|
})
|
||||||
ol.events.condition.singleClick(event);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var modify = new ol.interaction.Modify({source: source});
|
||||||
map.addInteraction(modify);
|
map.addInteraction(modify);
|
||||||
|
|
||||||
var draw; // global so we can remove it later
|
var draw, snap; // global so we can remove them later
|
||||||
var typeSelect = document.getElementById('type');
|
var typeSelect = document.getElementById('type');
|
||||||
|
|
||||||
function addInteraction() {
|
function addInteractions() {
|
||||||
draw = new ol.interaction.Draw({
|
draw = new ol.interaction.Draw({
|
||||||
features: features,
|
source: source,
|
||||||
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
|
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
|
||||||
});
|
});
|
||||||
map.addInteraction(draw);
|
map.addInteraction(draw);
|
||||||
}
|
snap = new ol.interaction.Snap({source: source});
|
||||||
|
map.addInteraction(snap);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle change event.
|
* Handle change event.
|
||||||
*/
|
*/
|
||||||
typeSelect.onchange = function() {
|
typeSelect.onchange = function() {
|
||||||
map.removeInteraction(draw);
|
map.removeInteraction(draw);
|
||||||
addInteraction();
|
map.removeInteraction(snap);
|
||||||
|
addInteractions();
|
||||||
};
|
};
|
||||||
|
|
||||||
addInteraction();
|
addInteractions();
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ var map = new ol.Map({
|
|||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
interactions: ol.interaction.defaults().extend([new ol.interaction.Select({
|
interactions: ol.interaction.defaults().extend([new ol.interaction.Select({
|
||||||
condition: function(evt) {
|
condition: function(evt) {
|
||||||
return evt.originalEvent.type == 'mousemove' ||
|
return evt.type == 'pointermove' ||
|
||||||
evt.type == 'singleclick';
|
evt.type == 'singleclick';
|
||||||
},
|
},
|
||||||
style: selectStyleFunction
|
style: selectStyleFunction
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ function stopAnimation(ended) {
|
|||||||
// if animation cancelled set the marker at the beginning
|
// if animation cancelled set the marker at the beginning
|
||||||
var coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
|
var coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
|
||||||
/** @type {ol.geom.Point} */ (geoMarker.getGeometry())
|
/** @type {ol.geom.Point} */ (geoMarker.getGeometry())
|
||||||
.setCoordinates(coord);
|
.setCoordinates(coord);
|
||||||
//remove listener
|
//remove listener
|
||||||
map.un('postcompose', moveFeature);
|
map.un('postcompose', moveFeature);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ goog.require('ol.source.OSM');
|
|||||||
goog.require('ol.source.VectorTile');
|
goog.require('ol.source.VectorTile');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.VectorTile');
|
goog.require('ol.layer.VectorTile');
|
||||||
goog.require('ol.tilegrid');
|
|
||||||
goog.require('ol.proj.Projection');
|
goog.require('ol.proj.Projection');
|
||||||
|
|
||||||
|
|
||||||
@@ -77,18 +76,16 @@ fetch(url).then(function(response) {
|
|||||||
});
|
});
|
||||||
var vectorSource = new ol.source.VectorTile({
|
var vectorSource = new ol.source.VectorTile({
|
||||||
format: new ol.format.GeoJSON(),
|
format: new ol.format.GeoJSON(),
|
||||||
tileGrid: ol.tilegrid.createXYZ(),
|
|
||||||
tilePixelRatio: 16,
|
|
||||||
tileLoadFunction: function(tile) {
|
tileLoadFunction: function(tile) {
|
||||||
var format = tile.getFormat();
|
var format = tile.getFormat();
|
||||||
var tileCoord = tile.getTileCoord();
|
var tileCoord = tile.getTileCoord();
|
||||||
var data = tileIndex.getTile(tileCoord[0], tileCoord[1], -tileCoord[2] - 1);
|
var data = tileIndex.getTile(tileCoord[0], tileCoord[1], -tileCoord[2] - 1);
|
||||||
|
|
||||||
var features = format.readFeatures(
|
var features = format.readFeatures(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: data ? data.features : []
|
features: data ? data.features : []
|
||||||
}, replacer));
|
}, replacer));
|
||||||
tile.setLoader(function() {
|
tile.setLoader(function() {
|
||||||
tile.setFeatures(features);
|
tile.setFeatures(features);
|
||||||
tile.setProjection(tilePixels);
|
tile.setProjection(tilePixels);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ positionFeature.setStyle(new ol.style.Style({
|
|||||||
geolocation.on('change:position', function() {
|
geolocation.on('change:position', function() {
|
||||||
var coordinates = geolocation.getPosition();
|
var coordinates = geolocation.getPosition();
|
||||||
positionFeature.setGeometry(coordinates ?
|
positionFeature.setGeometry(coordinates ?
|
||||||
new ol.geom.Point(coordinates) : null);
|
new ol.geom.Point(coordinates) : null);
|
||||||
});
|
});
|
||||||
|
|
||||||
new ol.layer.Vector({
|
new ol.layer.Vector({
|
||||||
|
|||||||
@@ -10,12 +10,15 @@ goog.require('ol.style.Stroke');
|
|||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
source: new ol.source.OSM()
|
source: new ol.source.OSM({
|
||||||
|
wrapX: false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: ol.proj.fromLonLat([4.8, 47.75]),
|
center: ol.proj.fromLonLat([4.8, 47.75]),
|
||||||
|
extent: ol.proj.get('EPSG:3857').getExtent(),
|
||||||
zoom: 5
|
zoom: 5
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ var map = new ol.Map({
|
|||||||
|
|
||||||
function createUrl(tpl, layerDesc) {
|
function createUrl(tpl, layerDesc) {
|
||||||
return tpl
|
return tpl
|
||||||
.replace('{base}', layerDesc.base)
|
.replace('{base}', layerDesc.base)
|
||||||
.replace('{type}', layerDesc.type)
|
.replace('{type}', layerDesc.type)
|
||||||
.replace('{scheme}', layerDesc.scheme)
|
.replace('{scheme}', layerDesc.scheme)
|
||||||
.replace('{app_id}', layerDesc.app_id)
|
.replace('{app_id}', layerDesc.app_id)
|
||||||
.replace('{app_code}', layerDesc.app_code);
|
.replace('{app_code}', layerDesc.app_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
var select = document.getElementById('layer-select');
|
var select = document.getElementById('layer-select');
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
|
|||||||
|
|
||||||
// Calculation of resolutions that match zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
// Calculation of resolutions that match zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
||||||
var resolutions = [];
|
var resolutions = [];
|
||||||
for (var i = 0; i <= 7; ++i) {
|
for (var i = 0; i <= 8; ++i) {
|
||||||
resolutions.push(156543.03392804097 / Math.pow(2, i * 2));
|
resolutions.push(156543.03392804097 / Math.pow(2, i * 2));
|
||||||
}
|
}
|
||||||
// Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
// Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
||||||
@@ -44,7 +44,6 @@ var map = new ol.Map({
|
|||||||
resolutions: resolutions,
|
resolutions: resolutions,
|
||||||
tileSize: 512
|
tileSize: 512
|
||||||
}),
|
}),
|
||||||
tilePixelRatio: 8,
|
|
||||||
tileUrlFunction: tileUrlFunction
|
tileUrlFunction: tileUrlFunction
|
||||||
}),
|
}),
|
||||||
style: createMapboxStreetsV6Style()
|
style: createMapboxStreetsV6Style()
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ goog.require('ol.style.Icon');
|
|||||||
goog.require('ol.style.Stroke');
|
goog.require('ol.style.Stroke');
|
||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
goog.require('ol.style.Text');
|
goog.require('ol.style.Text');
|
||||||
goog.require('ol.tilegrid');
|
|
||||||
|
|
||||||
|
|
||||||
var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
|
var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
|
||||||
@@ -23,8 +22,6 @@ var map = new ol.Map({
|
|||||||
'© <a href="https://www.openstreetmap.org/copyright">' +
|
'© <a href="https://www.openstreetmap.org/copyright">' +
|
||||||
'OpenStreetMap contributors</a>',
|
'OpenStreetMap contributors</a>',
|
||||||
format: new ol.format.MVT(),
|
format: new ol.format.MVT(),
|
||||||
tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),
|
|
||||||
tilePixelRatio: 16,
|
|
||||||
url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
||||||
'{z}/{x}/{y}.vector.pbf?access_token=' + key
|
'{z}/{x}/{y}.vector.pbf?access_token=' + key
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
---
|
---
|
||||||
layout: example.html
|
layout: example.html
|
||||||
title: Measure
|
title: Measure
|
||||||
shortdesc: Example of using the ol.interaction.Draw interaction to create a simple measuring application.
|
shortdesc: Using a draw interaction to measure lengths and areas.
|
||||||
docs: >
|
docs: >
|
||||||
<p><i>NOTE: By default, length and area are calculated using the projected coordinates. This is not accurate for projections like Mercator where the projected meters do not correspond to meters on the ground. To get a standarized measurement across all projections, use the geodesic measures.</i></p>
|
<p>The <code>ol.Sphere.getLength()</code> and <code>ol.Sphere.getArea()</code>
|
||||||
|
functions calculate spherical lengths and areas for geometries. Lengths are
|
||||||
|
calculated by assuming great circle segments between geometry coordinates.
|
||||||
|
Areas are calculated as if edges of polygons were great circle segments.</p>
|
||||||
|
<p>Note that the <code>geometry.getLength()</code> and <code>geometry.getArea()</code>
|
||||||
|
methods return measures of projected (planar) geometries. These can be very
|
||||||
|
different than on-the-ground measures in certain situations — in northern
|
||||||
|
and southern latitudes using Web Mercator for example. For better results,
|
||||||
|
use the functions on <code>ol.Sphere</code>.</p>
|
||||||
tags: "draw, edit, measure, vector"
|
tags: "draw, edit, measure, vector"
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<form class="form-inline">
|
<form class="form-inline">
|
||||||
<label>Measurement type </label>
|
<label>Measurement type </label>
|
||||||
<select id="type">
|
<select id="type">
|
||||||
<option value="length">Length (LineString)</option>
|
<option value="length">Length (LineString)</option>
|
||||||
<option value="area">Area (Polygon)</option>
|
<option value="area">Area (Polygon)</option>
|
||||||
</select>
|
</select>
|
||||||
<label class="checkbox">
|
|
||||||
<input type="checkbox" id="geodesic">
|
|
||||||
use geodesic measures
|
|
||||||
</label>
|
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ goog.require('ol.geom.Polygon');
|
|||||||
goog.require('ol.interaction.Draw');
|
goog.require('ol.interaction.Draw');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
goog.require('ol.proj');
|
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
goog.require('ol.source.Vector');
|
goog.require('ol.source.Vector');
|
||||||
goog.require('ol.style.Circle');
|
goog.require('ol.style.Circle');
|
||||||
@@ -17,8 +16,6 @@ goog.require('ol.style.Stroke');
|
|||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
var wgs84Sphere = new ol.Sphere(6378137);
|
|
||||||
|
|
||||||
var raster = new ol.layer.Tile({
|
var raster = new ol.layer.Tile({
|
||||||
source: new ol.source.OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
@@ -137,7 +134,6 @@ map.getViewport().addEventListener('mouseout', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var typeSelect = document.getElementById('type');
|
var typeSelect = document.getElementById('type');
|
||||||
var geodesicCheckbox = document.getElementById('geodesic');
|
|
||||||
|
|
||||||
var draw; // global so we can remove it later
|
var draw; // global so we can remove it later
|
||||||
|
|
||||||
@@ -148,19 +144,7 @@ var draw; // global so we can remove it later
|
|||||||
* @return {string} The formatted length.
|
* @return {string} The formatted length.
|
||||||
*/
|
*/
|
||||||
var formatLength = function(line) {
|
var formatLength = function(line) {
|
||||||
var length;
|
var length = ol.Sphere.getLength(line);
|
||||||
if (geodesicCheckbox.checked) {
|
|
||||||
var coordinates = line.getCoordinates();
|
|
||||||
length = 0;
|
|
||||||
var sourceProj = map.getView().getProjection();
|
|
||||||
for (var i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
|
||||||
var c1 = ol.proj.transform(coordinates[i], sourceProj, 'EPSG:4326');
|
|
||||||
var c2 = ol.proj.transform(coordinates[i + 1], sourceProj, 'EPSG:4326');
|
|
||||||
length += wgs84Sphere.haversineDistance(c1, c2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
length = Math.round(line.getLength() * 100) / 100;
|
|
||||||
}
|
|
||||||
var output;
|
var output;
|
||||||
if (length > 100) {
|
if (length > 100) {
|
||||||
output = (Math.round(length / 1000 * 100) / 100) +
|
output = (Math.round(length / 1000 * 100) / 100) +
|
||||||
@@ -179,16 +163,7 @@ var formatLength = function(line) {
|
|||||||
* @return {string} Formatted area.
|
* @return {string} Formatted area.
|
||||||
*/
|
*/
|
||||||
var formatArea = function(polygon) {
|
var formatArea = function(polygon) {
|
||||||
var area;
|
var area = ol.Sphere.getArea(polygon);
|
||||||
if (geodesicCheckbox.checked) {
|
|
||||||
var sourceProj = map.getView().getProjection();
|
|
||||||
var geom = /** @type {ol.geom.Polygon} */(polygon.clone().transform(
|
|
||||||
sourceProj, 'EPSG:4326'));
|
|
||||||
var coordinates = geom.getLinearRing(0).getCoordinates();
|
|
||||||
area = Math.abs(wgs84Sphere.geodesicArea(coordinates));
|
|
||||||
} else {
|
|
||||||
area = polygon.getArea();
|
|
||||||
}
|
|
||||||
var output;
|
var output;
|
||||||
if (area > 10000) {
|
if (area > 10000) {
|
||||||
output = (Math.round(area / 1000000 * 100) / 100) +
|
output = (Math.round(area / 1000000 * 100) / 100) +
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ var geojsonObject = {
|
|||||||
'geometry': {
|
'geometry': {
|
||||||
'type': 'Polygon',
|
'type': 'Polygon',
|
||||||
'coordinates': [[[-5e6, -1e6], [-4e6, 1e6],
|
'coordinates': [[[-5e6, -1e6], [-4e6, 1e6],
|
||||||
[-3e6, -1e6], [-5e6, -1e6]], [[-4.5e6, -0.5e6],
|
[-3e6, -1e6], [-5e6, -1e6]], [[-4.5e6, -0.5e6],
|
||||||
[-3.5e6, -0.5e6], [-4e6, 0.5e6], [-4.5e6, -0.5e6]]]
|
[-3.5e6, -0.5e6], [-4e6, 0.5e6], [-4.5e6, -0.5e6]]]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'type': 'Feature',
|
'type': 'Feature',
|
||||||
@@ -117,11 +117,11 @@ var geojsonObject = {
|
|||||||
'type': 'MultiPolygon',
|
'type': 'MultiPolygon',
|
||||||
'coordinates': [
|
'coordinates': [
|
||||||
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
|
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
|
||||||
[-3e6, 6e6], [-5e6, 6e6]]],
|
[-3e6, 6e6], [-5e6, 6e6]]],
|
||||||
[[[-3e6, 6e6], [-2e6, 8e6], [0, 8e6],
|
[[[-3e6, 6e6], [-2e6, 8e6], [0, 8e6],
|
||||||
[0, 6e6], [-3e6, 6e6]]],
|
[0, 6e6], [-3e6, 6e6]]],
|
||||||
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
|
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
|
||||||
[3e6, 6e6], [1e6, 6e6]]]
|
[3e6, 6e6], [1e6, 6e6]]]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ goog.require('ol.source.VectorTile');
|
|||||||
goog.require('ol.style.Fill');
|
goog.require('ol.style.Fill');
|
||||||
goog.require('ol.style.Stroke');
|
goog.require('ol.style.Stroke');
|
||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
goog.require('ol.tilegrid');
|
|
||||||
|
|
||||||
|
|
||||||
var key = 'vector-tiles-5eJz6JX';
|
var key = 'vector-tiles-5eJz6JX';
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ var map = new ol.Map({
|
|||||||
layerName: 'layer',
|
layerName: 'layer',
|
||||||
layers: ['water', 'roads', 'buildings']
|
layers: ['water', 'roads', 'buildings']
|
||||||
}),
|
}),
|
||||||
tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
|
maxZoom: 19,
|
||||||
url: 'https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.topojson?api_key=' + key
|
url: 'https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.topojson?api_key=' + key
|
||||||
}),
|
}),
|
||||||
style: function(feature, resolution) {
|
style: function(feature, resolution) {
|
||||||
|
|||||||
@@ -54,28 +54,28 @@ var geojsonObject = {
|
|||||||
'geometry': {
|
'geometry': {
|
||||||
'type': 'Polygon',
|
'type': 'Polygon',
|
||||||
'coordinates': [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
|
'coordinates': [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
|
||||||
[-3e6, 6e6], [-5e6, 6e6]]]
|
[-3e6, 6e6], [-5e6, 6e6]]]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'type': 'Feature',
|
'type': 'Feature',
|
||||||
'geometry': {
|
'geometry': {
|
||||||
'type': 'Polygon',
|
'type': 'Polygon',
|
||||||
'coordinates': [[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6],
|
'coordinates': [[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6],
|
||||||
[0, 6e6], [-2e6, 6e6]]]
|
[0, 6e6], [-2e6, 6e6]]]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'type': 'Feature',
|
'type': 'Feature',
|
||||||
'geometry': {
|
'geometry': {
|
||||||
'type': 'Polygon',
|
'type': 'Polygon',
|
||||||
'coordinates': [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
|
'coordinates': [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
|
||||||
[3e6, 6e6], [1e6, 6e6]]]
|
[3e6, 6e6], [1e6, 6e6]]]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'type': 'Feature',
|
'type': 'Feature',
|
||||||
'geometry': {
|
'geometry': {
|
||||||
'type': 'Polygon',
|
'type': 'Polygon',
|
||||||
'coordinates': [[[-2e6, -1e6], [-1e6, 1e6],
|
'coordinates': [[[-2e6, -1e6], [-1e6, 1e6],
|
||||||
[0, -1e6], [-2e6, -1e6]]]
|
[0, -1e6], [-2e6, -1e6]]]
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -162,13 +162,13 @@ function plot(resolution, counts, threshold) {
|
|||||||
var value = counts.min + (index * counts.delta);
|
var value = counts.min + (index * counts.delta);
|
||||||
return 'bar' + (value >= threshold ? ' selected' : '');
|
return 'bar' + (value >= threshold ? ' selected' : '');
|
||||||
})
|
})
|
||||||
.attr('width', barWidth - 2);
|
.attr('width', barWidth - 2);
|
||||||
|
|
||||||
bar.transition().attr('transform', function(value, index) {
|
bar.transition().attr('transform', function(value, index) {
|
||||||
return 'translate(' + (index * barWidth) + ', ' +
|
return 'translate(' + (index * barWidth) + ', ' +
|
||||||
(plotHeight - yScale(value)) + ')';
|
(plotHeight - yScale(value)) + ')';
|
||||||
})
|
})
|
||||||
.attr('height', yScale);
|
.attr('height', yScale);
|
||||||
|
|
||||||
bar.on('mousemove', function(count, index) {
|
bar.on('mousemove', function(count, index) {
|
||||||
var threshold = counts.min + (index * counts.delta);
|
var threshold = counts.min + (index * counts.delta);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ docs: >
|
|||||||
in <a href="https://epsg.io/">EPSG.io</a> database.
|
in <a href="https://epsg.io/">EPSG.io</a> database.
|
||||||
tags: "reprojection, projection, proj4js, epsg.io"
|
tags: "reprojection, projection, proj4js, epsg.io"
|
||||||
resources:
|
resources:
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<form class="form-inline">
|
<form class="form-inline">
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ docs: >
|
|||||||
This example shows client-side reprojection of single image source.
|
This example shows client-side reprojection of single image source.
|
||||||
tags: "reprojection, projection, proj4js, image, imagestatic"
|
tags: "reprojection, projection, proj4js, image, imagestatic"
|
||||||
resources:
|
resources:
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ docs: >
|
|||||||
This example shows client-side raster reprojection between various projections.
|
This example shows client-side raster reprojection between various projections.
|
||||||
tags: "reprojection, projection, proj4js, osm, wms, wmts, hidpi"
|
tags: "reprojection, projection, proj4js, osm, wms, wmts, hidpi"
|
||||||
resources:
|
resources:
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<form class="form-inline">
|
<form class="form-inline">
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ docs: >
|
|||||||
This example shows client-side reprojection of OpenStreetMap to NAD83 Indiana East, including a ScaleLine control with US units.
|
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"
|
tags: "reprojection, projection, openstreetmap, nad83, tile, scaleline"
|
||||||
resources:
|
resources:
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ docs: >
|
|||||||
Example of a Sphere Mollweide map with a Graticule component.
|
Example of a Sphere Mollweide map with a Graticule component.
|
||||||
tags: "graticule, Mollweide, projection, proj4js"
|
tags: "graticule, Mollweide, projection, proj4js"
|
||||||
resources:
|
resources:
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
17
examples/street-labels.html
Normal file
17
examples/street-labels.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
layout: example.html
|
||||||
|
title: Street Labels
|
||||||
|
shortdesc: Render street names with a custom render.
|
||||||
|
docs: >
|
||||||
|
Example showing the use of a custom renderer to render text along a path. [Labelgun](https://github.com/Geovation/labelgun) is used to avoid label collisions. [label-segment](https://github.com/ahocevar/label-segment) makes sure that labels are placed on suitable street segments. [textpath](https://github.com/ahocevar/textpath) arranges the letters of a label along the geometry. The data is fetched from OSM using the [Overpass API](https://overpass-api.de).
|
||||||
|
tags: "vector, label, collision detection, labelgun, linelabel, overpass"
|
||||||
|
resources:
|
||||||
|
- https://cdn.polyfill.io/v2/polyfill.min.js?features=Set"
|
||||||
|
- https://unpkg.com/rbush@2.0.1/rbush.min.js
|
||||||
|
- https://unpkg.com/labelgun@0.1.1/lib/labelgun.min.js
|
||||||
|
- https://unpkg.com/textpath@1.0.1/dist/textpath.js
|
||||||
|
- https://unpkg.com/label-segment@1.0.0/dist/label-segment.js
|
||||||
|
cloak:
|
||||||
|
As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5: Your Bing Maps Key from http://www.bingmapsportal.com/ here
|
||||||
|
---
|
||||||
|
<div id="map" class="map"></div>
|
||||||
115
examples/street-labels.js
Normal file
115
examples/street-labels.js
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
// NOCOMPILE
|
||||||
|
/* global labelgun, labelSegment, textPath */
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.format.OSMXML');
|
||||||
|
goog.require('ol.layer.Tile');
|
||||||
|
goog.require('ol.layer.Vector');
|
||||||
|
goog.require('ol.source.BingMaps');
|
||||||
|
goog.require('ol.source.Vector');
|
||||||
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
var emptyFn = function() {};
|
||||||
|
var labelEngine = new labelgun['default'](emptyFn, emptyFn);
|
||||||
|
|
||||||
|
var context, pixelRatio; // Will be set in the map's postcompose listener
|
||||||
|
function measureText(text) {
|
||||||
|
return context.measureText(text).width * pixelRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
var extent, letters; // Will be set in the style's renderer function
|
||||||
|
function collectDrawData(letter, x, y, angle) {
|
||||||
|
ol.extent.extend(extent, [x, y, x, y]);
|
||||||
|
letters.push([x, y, angle, letter]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var style = new ol.style.Style({
|
||||||
|
renderer: function(coords, context) {
|
||||||
|
var feature = context.feature;
|
||||||
|
var text = feature.get('name');
|
||||||
|
// Only create label when geometry has a long and straight segment
|
||||||
|
var path = labelSegment(coords, Math.PI / 8, measureText(text));
|
||||||
|
if (path) {
|
||||||
|
extent = ol.extent.createEmpty();
|
||||||
|
letters = [];
|
||||||
|
textPath(text, path, measureText, collectDrawData);
|
||||||
|
ol.extent.buffer(extent, 5 * pixelRatio, extent);
|
||||||
|
var bounds = {
|
||||||
|
bottomLeft: ol.extent.getBottomLeft(extent),
|
||||||
|
topRight: ol.extent.getTopRight(extent)
|
||||||
|
};
|
||||||
|
labelEngine.ingestLabel(bounds, feature.getId(), 1, letters, text, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var rasterLayer = new ol.layer.Tile({
|
||||||
|
source: new ol.source.BingMaps({
|
||||||
|
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
|
||||||
|
imagerySet: 'Aerial'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
var source = new ol.source.Vector();
|
||||||
|
// Request streets from OSM, using the Overpass API
|
||||||
|
fetch('https://overpass-api.de/api/interpreter', {
|
||||||
|
method: 'POST',
|
||||||
|
body: '(way["highway"](48.19642,16.32580,48.22050,16.41986));(._;>;);out meta;'
|
||||||
|
}).then(function(response) {
|
||||||
|
return response.text();
|
||||||
|
}).then(function(responseText) {
|
||||||
|
var features = new ol.format.OSMXML().readFeatures(responseText, {
|
||||||
|
featureProjection: 'EPSG:3857'
|
||||||
|
});
|
||||||
|
source.addFeatures(features);
|
||||||
|
});
|
||||||
|
|
||||||
|
var vectorLayer = new ol.layer.Vector({
|
||||||
|
source: source,
|
||||||
|
style: function(feature) {
|
||||||
|
if (feature.getGeometry().getType() == 'LineString' && feature.get('name')) {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var viewExtent = [1817379, 6139595, 1827851, 6143616];
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [rasterLayer, vectorLayer],
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View({
|
||||||
|
extent: viewExtent,
|
||||||
|
center: ol.extent.getCenter(viewExtent),
|
||||||
|
zoom: 17,
|
||||||
|
minZoom: 14
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
vectorLayer.on('precompose', function() {
|
||||||
|
labelEngine.destroy();
|
||||||
|
});
|
||||||
|
vectorLayer.on('postcompose', function(e) {
|
||||||
|
context = e.context;
|
||||||
|
pixelRatio = e.frameState.pixelRatio;
|
||||||
|
context.save();
|
||||||
|
context.font = 'normal 11px "Open Sans", "Arial Unicode MS"';
|
||||||
|
context.fillStyle = 'white';
|
||||||
|
context.textBaseline = 'middle';
|
||||||
|
context.textAlign = 'center';
|
||||||
|
var labels = labelEngine.getShown();
|
||||||
|
for (var i = 0, ii = labels.length; i < ii; ++i) {
|
||||||
|
// Render label letter by letter
|
||||||
|
var letters = labels[i].labelObject;
|
||||||
|
for (var j = 0, jj = letters.length; j < jj; ++j) {
|
||||||
|
var labelData = letters[j];
|
||||||
|
context.save();
|
||||||
|
context.translate(labelData[0], labelData[1]);
|
||||||
|
context.rotate(labelData[2]);
|
||||||
|
context.scale(pixelRatio, pixelRatio);
|
||||||
|
context.fillText(labelData[3], 0, 0);
|
||||||
|
context.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.restore();
|
||||||
|
});
|
||||||
13
examples/vector-label-decluttering.html
Normal file
13
examples/vector-label-decluttering.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
layout: example.html
|
||||||
|
title: Vector Label Decluttering
|
||||||
|
shortdesc: Label decluttering with a custom renderer.
|
||||||
|
resources:
|
||||||
|
- https://cdn.polyfill.io/v2/polyfill.min.js?features=Set"
|
||||||
|
- https://unpkg.com/rbush@2.0.1/rbush.min.js
|
||||||
|
- https://unpkg.com/labelgun@0.1.1/lib/labelgun.min.js
|
||||||
|
docs: >
|
||||||
|
A custom `renderer` function is used instead of an `ol.style.Text` to label the countries of the world. Only texts that are not wider than their country's bounding box are considered and handed over to [Labelgun](https://github.com/Geovation/labelgun) for decluttering.
|
||||||
|
tags: "vector, renderer, labelgun, label"
|
||||||
|
---
|
||||||
|
<div id="map" class="map"></div>
|
||||||
125
examples/vector-label-decluttering.js
Normal file
125
examples/vector-label-decluttering.js
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
// NOCOMPILE
|
||||||
|
/* global labelgun */
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.format.GeoJSON');
|
||||||
|
goog.require('ol.layer.Vector');
|
||||||
|
goog.require('ol.source.Vector');
|
||||||
|
goog.require('ol.style.Fill');
|
||||||
|
goog.require('ol.style.Stroke');
|
||||||
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
// Style for labels
|
||||||
|
function setStyle(context) {
|
||||||
|
context.font = '12px Calibri,sans-serif';
|
||||||
|
context.fillStyle = '#000';
|
||||||
|
context.strokeStyle = '#fff';
|
||||||
|
context.lineWidth = 3;
|
||||||
|
context.textBaseline = 'hanging';
|
||||||
|
context.textAlign = 'start';
|
||||||
|
}
|
||||||
|
|
||||||
|
// A separate canvas context for measuring label width and height.
|
||||||
|
var textMeasureContext = document.createElement('CANVAS').getContext('2d');
|
||||||
|
setStyle(textMeasureContext);
|
||||||
|
|
||||||
|
// The label height is approximated by the width of the text 'WI'.
|
||||||
|
var height = textMeasureContext.measureText('WI').width;
|
||||||
|
|
||||||
|
// A cache for reusing label images once they have been created.
|
||||||
|
var textCache = {};
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 1
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
var emptyFn = function() {};
|
||||||
|
var labelEngine = new labelgun['default'](emptyFn, emptyFn);
|
||||||
|
|
||||||
|
function createLabel(canvas, text, coord) {
|
||||||
|
var halfWidth = canvas.width / 2;
|
||||||
|
var halfHeight = canvas.height / 2;
|
||||||
|
var bounds = {
|
||||||
|
bottomLeft: [Math.round(coord[0] - halfWidth), Math.round(coord[1] - halfHeight)],
|
||||||
|
topRight: [Math.round(coord[0] + halfWidth), Math.round(coord[1] + halfHeight)]
|
||||||
|
};
|
||||||
|
labelEngine.ingestLabel(bounds, coord.toString(), 1, canvas, text, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// For multi-polygons, we only label the widest polygon. This is done by sorting
|
||||||
|
// by extent width in descending order, and take the first from the array.
|
||||||
|
function sortByWidth(a, b) {
|
||||||
|
return ol.extent.getWidth(b.getExtent()) - ol.extent.getWidth(a.getExtent());
|
||||||
|
}
|
||||||
|
|
||||||
|
var labelStyle = new ol.style.Style({
|
||||||
|
renderer: function(coords, state) {
|
||||||
|
var text = state.feature.get('name');
|
||||||
|
createLabel(textCache[text], text, coords);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var countryStyle = new ol.style.Style({
|
||||||
|
fill: new ol.style.Fill({
|
||||||
|
color: 'rgba(255, 255, 255, 0.6)'
|
||||||
|
}),
|
||||||
|
stroke: new ol.style.Stroke({
|
||||||
|
color: '#319FD3',
|
||||||
|
width: 1
|
||||||
|
})
|
||||||
|
});
|
||||||
|
var styleWithLabel = [countryStyle, labelStyle];
|
||||||
|
var styleWithoutLabel = [countryStyle];
|
||||||
|
|
||||||
|
var pixelRatio; // This is set by the map's precompose listener
|
||||||
|
var vectorLayer = new ol.layer.Vector({
|
||||||
|
source: new ol.source.Vector({
|
||||||
|
url: 'data/geojson/countries.geojson',
|
||||||
|
format: new ol.format.GeoJSON()
|
||||||
|
}),
|
||||||
|
style: function(feature, resolution) {
|
||||||
|
var text = feature.get('name');
|
||||||
|
var width = textMeasureContext.measureText(text).width;
|
||||||
|
var geometry = feature.getGeometry();
|
||||||
|
if (geometry.getType() == 'MultiPolygon') {
|
||||||
|
geometry = geometry.getPolygons().sort(sortByWidth)[0];
|
||||||
|
}
|
||||||
|
var extentWidth = ol.extent.getWidth(geometry.getExtent());
|
||||||
|
if (extentWidth / resolution > width) {
|
||||||
|
// Only consider label when it fits its geometry's extent
|
||||||
|
if (!(text in textCache)) {
|
||||||
|
// Draw the label to its own canvas and cache it.
|
||||||
|
var canvas = textCache[text] = document.createElement('CANVAS');
|
||||||
|
canvas.width = width * pixelRatio;
|
||||||
|
canvas.height = height * pixelRatio;
|
||||||
|
var context = canvas.getContext('2d');
|
||||||
|
context.scale(pixelRatio, pixelRatio);
|
||||||
|
setStyle(context);
|
||||||
|
context.strokeText(text, 0, 0);
|
||||||
|
context.fillText(text, 0, 0);
|
||||||
|
}
|
||||||
|
labelStyle.setGeometry(geometry.getInteriorPoint());
|
||||||
|
return styleWithLabel;
|
||||||
|
} else {
|
||||||
|
return styleWithoutLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
vectorLayer.on('precompose', function(e) {
|
||||||
|
pixelRatio = e.frameState.pixelRatio;
|
||||||
|
labelEngine.destroy();
|
||||||
|
});
|
||||||
|
vectorLayer.on('postcompose', function(e) {
|
||||||
|
var labels = labelEngine.getShown();
|
||||||
|
for (var i = 0, ii = labels.length; i < ii; ++i) {
|
||||||
|
var label = labels[i];
|
||||||
|
// Draw label to the map canvas
|
||||||
|
e.context.drawImage(label.labelObject, label.minX, label.minY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
map.addLayer(vectorLayer);
|
||||||
@@ -47,8 +47,8 @@ var featureRequest = new ol.format.WFS().writeGetFeature({
|
|||||||
featureTypes: ['water_areas'],
|
featureTypes: ['water_areas'],
|
||||||
outputFormat: 'application/json',
|
outputFormat: 'application/json',
|
||||||
filter: ol.format.filter.and(
|
filter: ol.format.filter.and(
|
||||||
ol.format.filter.like('name', 'Mississippi*'),
|
ol.format.filter.like('name', 'Mississippi*'),
|
||||||
ol.format.filter.equalTo('waterway', 'riverbank')
|
ol.format.filter.equalTo('waterway', 'riverbank')
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ docs: >
|
|||||||
With [Proj4js](http://proj4js.org/) integration, OpenLayers can transform coordinates between arbitrary projections.
|
With [Proj4js](http://proj4js.org/) integration, OpenLayers can transform coordinates between arbitrary projections.
|
||||||
tags: "wms, single image, proj4js, projection"
|
tags: "wms, single image, proj4js, projection"
|
||||||
resources:
|
resources:
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js
|
- https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js
|
||||||
- https://epsg.io/21781-1753.js
|
- https://epsg.io/21781-1753.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ var map = new ol.Map({
|
|||||||
tileSize: tileSize,
|
tileSize: tileSize,
|
||||||
tileUrlFunction: function(tileCoord) {
|
tileUrlFunction: function(tileCoord) {
|
||||||
return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString())
|
return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString())
|
||||||
.replace('{x}', tileCoord[1].toString())
|
.replace('{x}', tileCoord[1].toString())
|
||||||
.replace('{y}', (-tileCoord[2] - 1).toString());
|
.replace('{y}', (-tileCoord[2] - 1).toString());
|
||||||
},
|
},
|
||||||
wrapX: true
|
wrapX: true
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -91,6 +91,17 @@ oli.DrawEvent = function() {};
|
|||||||
oli.DrawEvent.prototype.feature;
|
oli.DrawEvent.prototype.feature;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @interface
|
||||||
|
*/
|
||||||
|
oli.ExtentEvent = function() {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol.Extent}
|
||||||
|
*/
|
||||||
|
oli.ExtentEvent.prototype.extent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
*/
|
*/
|
||||||
|
|||||||
199
externs/olx.js
199
externs/olx.js
@@ -436,6 +436,33 @@ olx.MapOptions.prototype.target;
|
|||||||
olx.MapOptions.prototype.view;
|
olx.MapOptions.prototype.view;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object literal with options for the {@link ol.Sphere.getLength} or
|
||||||
|
* {@link ol.Sphere.getArea} functions.
|
||||||
|
* @typedef {{projection: (ol.ProjectionLike|undefined),
|
||||||
|
* radius: (number|undefined)}}
|
||||||
|
*/
|
||||||
|
olx.SphereMetricOptions;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Projection of the geometry. By default, the geometry is assumed to be in
|
||||||
|
* EPSG:3857 (Web Mercator).
|
||||||
|
* @type {(ol.ProjectionLike|undefined)}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.SphereMetricOptions.prototype.projection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sphere radius. By default, the radius of the earth is used (Clarke 1866
|
||||||
|
* Authalic Sphere).
|
||||||
|
* @type {(number|undefined)}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.SphereMetricOptions.prototype.radius;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object literal with options for the {@link ol.Map#forEachFeatureAtPixel} and
|
* Object literal with options for the {@link ol.Map#forEachFeatureAtPixel} and
|
||||||
* {@link ol.Map#hasFeatureAtPixel} methods.
|
* {@link ol.Map#hasFeatureAtPixel} methods.
|
||||||
@@ -2710,6 +2737,7 @@ olx.interaction.DoubleClickZoomOptions.prototype.delta;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{formatConstructors: (Array.<function(new: ol.format.Feature)>|undefined),
|
* @typedef {{formatConstructors: (Array.<function(new: ol.format.Feature)>|undefined),
|
||||||
|
* source: (ol.source.Vector|undefined),
|
||||||
* projection: ol.ProjectionLike,
|
* projection: ol.ProjectionLike,
|
||||||
* target: (Element|undefined)}}
|
* target: (Element|undefined)}}
|
||||||
*/
|
*/
|
||||||
@@ -2724,6 +2752,18 @@ olx.interaction.DragAndDropOptions;
|
|||||||
olx.interaction.DragAndDropOptions.prototype.formatConstructors;
|
olx.interaction.DragAndDropOptions.prototype.formatConstructors;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional vector source where features will be added. If a source is provided
|
||||||
|
* all existing features will be removed and new features will be added when
|
||||||
|
* they are dropped on the target. If you want to add features to a vector
|
||||||
|
* source without removing the existing features (append only), instead of
|
||||||
|
* providing the source option listen for the "addfeatures" event.
|
||||||
|
* @type {ol.source.Vector|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.interaction.DragAndDropOptions.prototype.source;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target projection. By default, the map's view's projection is used.
|
* Target projection. By default, the map's view's projection is used.
|
||||||
* @type {ol.ProjectionLike}
|
* @type {ol.ProjectionLike}
|
||||||
@@ -3219,7 +3259,8 @@ olx.interaction.KeyboardZoomOptions.prototype.delta;
|
|||||||
* insertVertexCondition: (ol.EventsConditionType|undefined),
|
* insertVertexCondition: (ol.EventsConditionType|undefined),
|
||||||
* pixelTolerance: (number|undefined),
|
* pixelTolerance: (number|undefined),
|
||||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
||||||
* features: ol.Collection.<ol.Feature>,
|
* source: (ol.source.Vector|undefined),
|
||||||
|
* features: (ol.Collection.<ol.Feature>|undefined),
|
||||||
* wrapX: (boolean|undefined)
|
* wrapX: (boolean|undefined)
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
@@ -3277,8 +3318,18 @@ olx.interaction.ModifyOptions.prototype.style;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The features the interaction works on.
|
* The vector source with features to modify. If a vector source is not
|
||||||
* @type {ol.Collection.<ol.Feature>}
|
* provided, a feature collection must be provided with the features option.
|
||||||
|
* @type {ol.source.Vector|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.interaction.ModifyOptions.prototype.source;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The features the interaction works on. If a feature collection is not
|
||||||
|
* provided, a vector source must be provided with the source option.
|
||||||
|
* @type {ol.Collection.<ol.Feature>|undefined}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.interaction.ModifyOptions.prototype.features;
|
olx.interaction.ModifyOptions.prototype.features;
|
||||||
@@ -3851,7 +3902,8 @@ olx.layer.GroupOptions.prototype.layers;
|
|||||||
* maxResolution: (number|undefined),
|
* maxResolution: (number|undefined),
|
||||||
* opacity: (number|undefined),
|
* opacity: (number|undefined),
|
||||||
* source: (ol.source.Vector|undefined),
|
* source: (ol.source.Vector|undefined),
|
||||||
* visible: (boolean|undefined)}}
|
* visible: (boolean|undefined),
|
||||||
|
* zIndex: (number|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.layer.HeatmapOptions;
|
olx.layer.HeatmapOptions;
|
||||||
|
|
||||||
@@ -3948,6 +4000,15 @@ olx.layer.HeatmapOptions.prototype.source;
|
|||||||
olx.layer.HeatmapOptions.prototype.visible;
|
olx.layer.HeatmapOptions.prototype.visible;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The z-index for layer rendering. At rendering time, the layers will be
|
||||||
|
* ordered, first by Z-index and then by position. The default Z-index is 0.
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.layer.HeatmapOptions.prototype.zIndex;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{opacity: (number|undefined),
|
* @typedef {{opacity: (number|undefined),
|
||||||
* map: (ol.Map|undefined),
|
* map: (ol.Map|undefined),
|
||||||
@@ -3955,7 +4016,8 @@ olx.layer.HeatmapOptions.prototype.visible;
|
|||||||
* visible: (boolean|undefined),
|
* visible: (boolean|undefined),
|
||||||
* extent: (ol.Extent|undefined),
|
* extent: (ol.Extent|undefined),
|
||||||
* minResolution: (number|undefined),
|
* minResolution: (number|undefined),
|
||||||
* maxResolution: (number|undefined)}}
|
* maxResolution: (number|undefined),
|
||||||
|
* zIndex: (number|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.layer.ImageOptions;
|
olx.layer.ImageOptions;
|
||||||
|
|
||||||
@@ -4020,6 +4082,15 @@ olx.layer.ImageOptions.prototype.minResolution;
|
|||||||
olx.layer.ImageOptions.prototype.maxResolution;
|
olx.layer.ImageOptions.prototype.maxResolution;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The z-index for layer rendering. At rendering time, the layers will be
|
||||||
|
* ordered, first by Z-index and then by position. The default Z-index is 0.
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.layer.ImageOptions.prototype.zIndex;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{opacity: (number|undefined),
|
* @typedef {{opacity: (number|undefined),
|
||||||
* preload: (number|undefined),
|
* preload: (number|undefined),
|
||||||
@@ -4029,7 +4100,8 @@ olx.layer.ImageOptions.prototype.maxResolution;
|
|||||||
* extent: (ol.Extent|undefined),
|
* extent: (ol.Extent|undefined),
|
||||||
* minResolution: (number|undefined),
|
* minResolution: (number|undefined),
|
||||||
* maxResolution: (number|undefined),
|
* maxResolution: (number|undefined),
|
||||||
* useInterimTilesOnError: (boolean|undefined)}}
|
* useInterimTilesOnError: (boolean|undefined),
|
||||||
|
* zIndex: (number|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.layer.TileOptions;
|
olx.layer.TileOptions;
|
||||||
|
|
||||||
@@ -4111,6 +4183,15 @@ olx.layer.TileOptions.prototype.maxResolution;
|
|||||||
olx.layer.TileOptions.prototype.useInterimTilesOnError;
|
olx.layer.TileOptions.prototype.useInterimTilesOnError;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The z-index for layer rendering. At rendering time, the layers will be
|
||||||
|
* ordered, first by Z-index and then by position. The default Z-index is 0.
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.layer.TileOptions.prototype.zIndex;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{renderOrder: (ol.RenderOrderFunction|null|undefined),
|
* @typedef {{renderOrder: (ol.RenderOrderFunction|null|undefined),
|
||||||
* minResolution: (number|undefined),
|
* minResolution: (number|undefined),
|
||||||
@@ -4122,7 +4203,8 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError;
|
|||||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
||||||
* updateWhileAnimating: (boolean|undefined),
|
* updateWhileAnimating: (boolean|undefined),
|
||||||
* updateWhileInteracting: (boolean|undefined),
|
* updateWhileInteracting: (boolean|undefined),
|
||||||
* visible: (boolean|undefined)}}
|
* visible: (boolean|undefined),
|
||||||
|
* zIndex: (number|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.layer.VectorOptions;
|
olx.layer.VectorOptions;
|
||||||
|
|
||||||
@@ -4237,6 +4319,15 @@ olx.layer.VectorOptions.prototype.updateWhileInteracting;
|
|||||||
olx.layer.VectorOptions.prototype.visible;
|
olx.layer.VectorOptions.prototype.visible;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The z-index for layer rendering. At rendering time, the layers will be
|
||||||
|
* ordered, first by Z-index and then by position. The default Z-index is 0.
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.layer.VectorOptions.prototype.zIndex;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{extent: (ol.Extent|undefined),
|
* @typedef {{extent: (ol.Extent|undefined),
|
||||||
* map: (ol.Map|undefined),
|
* map: (ol.Map|undefined),
|
||||||
@@ -4251,7 +4342,8 @@ olx.layer.VectorOptions.prototype.visible;
|
|||||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
||||||
* updateWhileAnimating: (boolean|undefined),
|
* updateWhileAnimating: (boolean|undefined),
|
||||||
* updateWhileInteracting: (boolean|undefined),
|
* updateWhileInteracting: (boolean|undefined),
|
||||||
* visible: (boolean|undefined)}}
|
* visible: (boolean|undefined),
|
||||||
|
* zIndex: (number|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.layer.VectorTileOptions;
|
olx.layer.VectorTileOptions;
|
||||||
|
|
||||||
@@ -4393,6 +4485,15 @@ olx.layer.VectorTileOptions.prototype.updateWhileInteracting;
|
|||||||
olx.layer.VectorTileOptions.prototype.visible;
|
olx.layer.VectorTileOptions.prototype.visible;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The z-index for layer rendering. At rendering time, the layers will be
|
||||||
|
* ordered, first by Z-index and then by position. The default Z-index is 0.
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.layer.VectorOptions.prototype.zIndex;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Namespace.
|
* Namespace.
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
@@ -4400,6 +4501,50 @@ olx.layer.VectorTileOptions.prototype.visible;
|
|||||||
olx.render;
|
olx.render;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {{context: CanvasRenderingContext2D,
|
||||||
|
* feature: (ol.Feature|ol.render.Feature),
|
||||||
|
* geometry: ol.geom.SimpleGeometry,
|
||||||
|
* pixelRatio: number,
|
||||||
|
* resolution: number,
|
||||||
|
* rotation: number}}
|
||||||
|
*/
|
||||||
|
olx.render.State;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Canvas context that the layer is being rendered to.
|
||||||
|
* @type {CanvasRenderingContext2D}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.render.State.prototype.context;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pixel ratio used by the layer renderer.
|
||||||
|
* @type {number}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.render.State.prototype.pixelRatio;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolution that the render batch was created and optimized for. This is
|
||||||
|
* not the view's resolution that is being rendered.
|
||||||
|
* @type {number}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.render.State.prototype.resolution;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotation of the rendered layer in radians.
|
||||||
|
* @type {number}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.render.State.prototype.rotation;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{size: (ol.Size|undefined),
|
* @typedef {{size: (ol.Size|undefined),
|
||||||
* pixelRatio: (number|undefined)}}
|
* pixelRatio: (number|undefined)}}
|
||||||
@@ -4856,7 +5001,6 @@ olx.source.TileImageOptions.prototype.wrapX;
|
|||||||
* ol.TileLoadFunctionType)|undefined),
|
* ol.TileLoadFunctionType)|undefined),
|
||||||
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
||||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||||
* tilePixelRatio: (number|undefined),
|
|
||||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined),
|
* tileUrlFunction: (ol.TileUrlFunctionType|undefined),
|
||||||
* url: (string|undefined),
|
* url: (string|undefined),
|
||||||
* urls: (Array.<string>|undefined),
|
* urls: (Array.<string>|undefined),
|
||||||
@@ -4952,6 +5096,8 @@ olx.source.VectorTileOptions.prototype.tileGrid;
|
|||||||
* var format = tile.getFormat();
|
* var format = tile.getFormat();
|
||||||
* tile.setFeatures(format.readFeatures(data));
|
* tile.setFeatures(format.readFeatures(data));
|
||||||
* tile.setProjection(format.readProjection(data));
|
* tile.setProjection(format.readProjection(data));
|
||||||
|
* // uncomment the line below for ol.format.MVT only
|
||||||
|
* //tile.setExtent(format.getLastExtent());
|
||||||
* };
|
* };
|
||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
@@ -4961,17 +5107,6 @@ olx.source.VectorTileOptions.prototype.tileGrid;
|
|||||||
olx.source.VectorTileOptions.prototype.tileLoadFunction;
|
olx.source.VectorTileOptions.prototype.tileLoadFunction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The pixel ratio used by the tile service. For example, if the tile
|
|
||||||
* service advertizes 256px by 256px tiles but actually sends 512px
|
|
||||||
* by 512px tiles (for retina/hidpi devices) then `tilePixelRatio`
|
|
||||||
* should be set to `2`. Default is `1`.
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
olx.source.VectorTileOptions.prototype.tilePixelRatio;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional function to get tile URL given a tile coordinate and the projection.
|
* Optional function to get tile URL given a tile coordinate and the projection.
|
||||||
* @type {ol.TileUrlFunctionType|undefined}
|
* @type {ol.TileUrlFunctionType|undefined}
|
||||||
@@ -6155,6 +6290,9 @@ olx.source.TileJSONOptions.prototype.wrapX;
|
|||||||
* gutter: (number|undefined),
|
* gutter: (number|undefined),
|
||||||
* hidpi: (boolean|undefined),
|
* hidpi: (boolean|undefined),
|
||||||
* logo: (string|olx.LogoOptions|undefined),
|
* logo: (string|olx.LogoOptions|undefined),
|
||||||
|
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
|
||||||
|
* ol.TileState, string, ?string,
|
||||||
|
* ol.TileLoadFunctionType)|undefined),
|
||||||
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
||||||
* projection: ol.ProjectionLike,
|
* projection: ol.ProjectionLike,
|
||||||
* reprojectionErrorThreshold: (number|undefined),
|
* reprojectionErrorThreshold: (number|undefined),
|
||||||
@@ -6237,6 +6375,16 @@ olx.source.TileWMSOptions.prototype.hidpi;
|
|||||||
olx.source.TileWMSOptions.prototype.logo;
|
olx.source.TileWMSOptions.prototype.logo;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class used to instantiate image tiles. Default is {@link ol.ImageTile}.
|
||||||
|
* @type {function(new: ol.ImageTile, ol.TileCoord,
|
||||||
|
* ol.TileState, string, ?string,
|
||||||
|
* ol.TileLoadFunctionType)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.source.TileWMSOptions.prototype.tileClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tile grid. Base this on the resolutions, tilesize and extent supported by the
|
* Tile grid. Base this on the resolutions, tilesize and extent supported by the
|
||||||
* server.
|
* server.
|
||||||
@@ -7608,6 +7756,7 @@ olx.style.TextOptions.prototype.stroke;
|
|||||||
* @typedef {{geometry: (undefined|string|ol.geom.Geometry|ol.StyleGeometryFunction),
|
* @typedef {{geometry: (undefined|string|ol.geom.Geometry|ol.StyleGeometryFunction),
|
||||||
* fill: (ol.style.Fill|undefined),
|
* fill: (ol.style.Fill|undefined),
|
||||||
* image: (ol.style.Image|undefined),
|
* image: (ol.style.Image|undefined),
|
||||||
|
* renderer: (ol.StyleRenderFunction|undefined),
|
||||||
* stroke: (ol.style.Stroke|undefined),
|
* stroke: (ol.style.Stroke|undefined),
|
||||||
* text: (ol.style.Text|undefined),
|
* text: (ol.style.Text|undefined),
|
||||||
* zIndex: (number|undefined)}}
|
* zIndex: (number|undefined)}}
|
||||||
@@ -7640,6 +7789,16 @@ olx.style.StyleOptions.prototype.fill;
|
|||||||
olx.style.StyleOptions.prototype.image;
|
olx.style.StyleOptions.prototype.image;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom renderer. When configured, `fill`, `stroke` and `image` will be
|
||||||
|
* ignored, and the provided function will be called with each render frame for
|
||||||
|
* each geometry.
|
||||||
|
*
|
||||||
|
* @type {ol.StyleRenderFunction|undefined}
|
||||||
|
*/
|
||||||
|
olx.style.StyleOptions.prototype.renderer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stroke style.
|
* Stroke style.
|
||||||
* @type {ol.style.Stroke|undefined}
|
* @type {ol.style.Stroke|undefined}
|
||||||
|
|||||||
55
package.json
55
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openlayers",
|
"name": "openlayers",
|
||||||
"version": "4.2.0",
|
"version": "4.3.0",
|
||||||
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"map",
|
"map",
|
||||||
@@ -31,21 +31,15 @@
|
|||||||
"css/ol.css"
|
"css/ol.css"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "2.4.1",
|
"async": "2.5.0",
|
||||||
"closure-util": "1.21.0",
|
"closure-util": "1.22.0",
|
||||||
"derequire": "2.0.6",
|
"fs-extra": "4.0.1",
|
||||||
"fs-extra": "3.0.1",
|
"jsdoc": "3.5.4",
|
||||||
"glob": "7.1.1",
|
|
||||||
"handlebars": "4.0.10",
|
|
||||||
"jsdoc": "3.4.3",
|
|
||||||
"marked": "0.3.6",
|
|
||||||
"metalsmith": "2.3.0",
|
|
||||||
"metalsmith-layouts": "1.8.1",
|
|
||||||
"nomnom": "1.8.1",
|
"nomnom": "1.8.1",
|
||||||
"pbf": "3.0.5",
|
"pbf": "3.0.5",
|
||||||
"pixelworks": "1.1.0",
|
"pixelworks": "1.1.0",
|
||||||
"rbush": "2.0.1",
|
"rbush": "2.0.1",
|
||||||
"rollup": "^0.42.0",
|
"rollup": "^0.47.2",
|
||||||
"rollup-plugin-cleanup": "^1.0.0",
|
"rollup-plugin-cleanup": "^1.0.0",
|
||||||
"rollup-plugin-commonjs": "^8.0.2",
|
"rollup-plugin-commonjs": "^8.0.2",
|
||||||
"rollup-plugin-node-resolve": "^3.0.0",
|
"rollup-plugin-node-resolve": "^3.0.0",
|
||||||
@@ -54,25 +48,30 @@
|
|||||||
"walk": "2.3.9"
|
"walk": "2.3.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"clean-css-cli": "4.1.4",
|
"clean-css-cli": "4.1.6",
|
||||||
"coveralls": "2.13.1",
|
"coveralls": "2.13.1",
|
||||||
"debounce": "^1.0.0",
|
"debounce": "^1.0.0",
|
||||||
"eslint": "3.19.0",
|
"eslint": "4.4.1",
|
||||||
"eslint-config-openlayers": "7.0.0",
|
"eslint-config-openlayers": "7.0.0",
|
||||||
"eslint-plugin-openlayers-internal": "^3.1.0",
|
"eslint-plugin-openlayers-internal": "^3.1.0",
|
||||||
"expect.js": "0.3.1",
|
"expect.js": "0.3.1",
|
||||||
"gaze": "^1.0.0",
|
"gaze": "^1.0.0",
|
||||||
|
"glob": "7.1.1",
|
||||||
|
"handlebars": "4.0.10",
|
||||||
"istanbul": "0.4.5",
|
"istanbul": "0.4.5",
|
||||||
"jquery": "3.2.1",
|
"jquery": "3.2.1",
|
||||||
"jscodeshift": "^0.3.30",
|
"jscodeshift": "^0.3.30",
|
||||||
"mocha": "3.4.2",
|
"marked": "0.3.6",
|
||||||
|
"metalsmith": "2.3.0",
|
||||||
|
"metalsmith-layouts": "1.8.1",
|
||||||
|
"mocha": "3.5.0",
|
||||||
"mocha-phantomjs-core": "^2.1.0",
|
"mocha-phantomjs-core": "^2.1.0",
|
||||||
"mustache": "2.3.0",
|
"mustache": "2.3.0",
|
||||||
"phantomjs-prebuilt": "2.1.14",
|
"phantomjs-prebuilt": "2.1.14",
|
||||||
"proj4": "2.4.3",
|
"proj4": "2.4.4",
|
||||||
"resemblejs": "2.2.4",
|
"resemblejs": "2.2.4",
|
||||||
"serve-files": "1.0.1",
|
"serve-files": "1.0.1",
|
||||||
"sinon": "2.3.4",
|
"sinon": "3.2.0",
|
||||||
"slimerjs": "0.10.3"
|
"slimerjs": "0.10.3"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
@@ -100,7 +99,27 @@
|
|||||||
"openlayers-internal/one-provide": 2,
|
"openlayers-internal/one-provide": 2,
|
||||||
"openlayers-internal/requires-first": 2,
|
"openlayers-internal/requires-first": 2,
|
||||||
"openlayers-internal/valid-provide": 2,
|
"openlayers-internal/valid-provide": 2,
|
||||||
"openlayers-internal/valid-requires": 2
|
"openlayers-internal/valid-requires": 2,
|
||||||
|
"indent": [
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"VariableDeclarator": 2,
|
||||||
|
"SwitchCase": 1,
|
||||||
|
"MemberExpression": 2,
|
||||||
|
"FunctionDeclaration": {
|
||||||
|
"parameters": 2,
|
||||||
|
"body": 1
|
||||||
|
},
|
||||||
|
"FunctionExpression": {
|
||||||
|
"parameters": 2,
|
||||||
|
"body": 1
|
||||||
|
},
|
||||||
|
"CallExpression": {
|
||||||
|
"arguments": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ext": [
|
"ext": [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ol",
|
"name": "ol",
|
||||||
"version": "4.2.0",
|
"version": "4.3.0",
|
||||||
"description": "OpenLayers as ES2015 modules",
|
"description": "OpenLayers as ES2015 modules",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.js",
|
"module": "index.js",
|
||||||
|
|||||||
@@ -9,20 +9,20 @@ goog.require('ol.math');
|
|||||||
*/
|
*/
|
||||||
ol.CenterConstraint.createExtent = function(extent) {
|
ol.CenterConstraint.createExtent = function(extent) {
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate|undefined} center Center.
|
* @param {ol.Coordinate|undefined} center Center.
|
||||||
* @return {ol.Coordinate|undefined} Center.
|
* @return {ol.Coordinate|undefined} Center.
|
||||||
*/
|
*/
|
||||||
function(center) {
|
function(center) {
|
||||||
if (center) {
|
if (center) {
|
||||||
return [
|
return [
|
||||||
ol.math.clamp(center[0], extent[0], extent[2]),
|
ol.math.clamp(center[0], extent[0], extent[2]),
|
||||||
ol.math.clamp(center[1], extent[1], extent[3])
|
ol.math.clamp(center[1], extent[1], extent[3])
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ goog.require('ol.events.Event');
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Object}
|
* @extends {ol.Object}
|
||||||
* @fires ol.Collection.Event
|
* @fires ol.Collection.Event
|
||||||
* @param {!Array.<T>=} opt_array Array.
|
* @param {Array.<T>=} opt_array Array.
|
||||||
* @param {olx.CollectionOptions=} opt_options Collection options.
|
* @param {olx.CollectionOptions=} opt_options Collection options.
|
||||||
* @template T
|
* @template T
|
||||||
* @api
|
* @api
|
||||||
@@ -95,7 +95,11 @@ ol.Collection.prototype.extend = function(arr) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.forEach = function(f, opt_this) {
|
ol.Collection.prototype.forEach = function(f, opt_this) {
|
||||||
this.array_.forEach(f, opt_this);
|
var fn = (opt_this) ? f.bind(opt_this) : f;
|
||||||
|
var array = this.array_;
|
||||||
|
for (var i = 0, ii = array.length; i < ii; ++i) {
|
||||||
|
fn(array[i], i, array);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,56 +72,56 @@ ol.color.fromNamed = function(color) {
|
|||||||
* @return {ol.Color} Color.
|
* @return {ol.Color} Color.
|
||||||
*/
|
*/
|
||||||
ol.color.fromString = (
|
ol.color.fromString = (
|
||||||
function() {
|
function() {
|
||||||
|
|
||||||
// We maintain a small cache of parsed strings. To provide cheap LRU-like
|
// We maintain a small cache of parsed strings. To provide cheap LRU-like
|
||||||
// semantics, whenever the cache grows too large we simply delete an
|
// semantics, whenever the cache grows too large we simply delete an
|
||||||
// arbitrary 25% of the entries.
|
// arbitrary 25% of the entries.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
var MAX_CACHE_SIZE = 1024;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object.<string, ol.Color>}
|
||||||
|
*/
|
||||||
|
var cache = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
var cacheSize = 0;
|
||||||
|
|
||||||
|
return (
|
||||||
/**
|
/**
|
||||||
* @const
|
* @param {string} s String.
|
||||||
* @type {number}
|
* @return {ol.Color} Color.
|
||||||
*/
|
*/
|
||||||
var MAX_CACHE_SIZE = 1024;
|
function(s) {
|
||||||
|
var color;
|
||||||
/**
|
if (cache.hasOwnProperty(s)) {
|
||||||
* @type {Object.<string, ol.Color>}
|
color = cache[s];
|
||||||
*/
|
} else {
|
||||||
var cache = {};
|
if (cacheSize >= MAX_CACHE_SIZE) {
|
||||||
|
var i = 0;
|
||||||
/**
|
var key;
|
||||||
* @type {number}
|
for (key in cache) {
|
||||||
*/
|
if ((i++ & 3) === 0) {
|
||||||
var cacheSize = 0;
|
delete cache[key];
|
||||||
|
--cacheSize;
|
||||||
return (
|
|
||||||
/**
|
|
||||||
* @param {string} s String.
|
|
||||||
* @return {ol.Color} Color.
|
|
||||||
*/
|
|
||||||
function(s) {
|
|
||||||
var color;
|
|
||||||
if (cache.hasOwnProperty(s)) {
|
|
||||||
color = cache[s];
|
|
||||||
} else {
|
|
||||||
if (cacheSize >= MAX_CACHE_SIZE) {
|
|
||||||
var i = 0;
|
|
||||||
var key;
|
|
||||||
for (key in cache) {
|
|
||||||
if ((i++ & 3) === 0) {
|
|
||||||
delete cache[key];
|
|
||||||
--cacheSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
color = ol.color.fromStringInternal_(s);
|
|
||||||
cache[s] = color;
|
|
||||||
++cacheSize;
|
|
||||||
}
|
}
|
||||||
return color;
|
}
|
||||||
});
|
color = ol.color.fromStringInternal_(s);
|
||||||
|
cache[s] = color;
|
||||||
|
++cacheSize;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ ol.colorlike.asColorLike = function(color) {
|
|||||||
*/
|
*/
|
||||||
ol.colorlike.isColorLike = function(color) {
|
ol.colorlike.isColorLike = function(color) {
|
||||||
return (
|
return (
|
||||||
typeof color === 'string' ||
|
typeof color === 'string' ||
|
||||||
color instanceof CanvasPattern ||
|
color instanceof CanvasPattern ||
|
||||||
color instanceof CanvasGradient
|
color instanceof CanvasGradient
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ ol.control.defaults = function(opt_options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var attributionControl = options.attribution !== undefined ?
|
var attributionControl = options.attribution !== undefined ?
|
||||||
options.attribution : true;
|
options.attribution : true;
|
||||||
if (attributionControl) {
|
if (attributionControl) {
|
||||||
controls.push(new ol.control.Attribution(options.attributionOptions));
|
controls.push(new ol.control.Attribution(options.attributionOptions));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ ol.control.Attribution = function(opt_options) {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.collapsible_ = options.collapsible !== undefined ?
|
this.collapsible_ = options.collapsible !== undefined ?
|
||||||
options.collapsible : true;
|
options.collapsible : true;
|
||||||
|
|
||||||
if (!this.collapsible_) {
|
if (!this.collapsible_) {
|
||||||
this.collapsed_ = false;
|
this.collapsed_ = false;
|
||||||
@@ -91,7 +91,7 @@ ol.control.Attribution = function(opt_options) {
|
|||||||
|
|
||||||
|
|
||||||
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||||
this.collapseLabel_ : this.label_;
|
this.collapseLabel_ : this.label_;
|
||||||
var button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
button.setAttribute('type', 'button');
|
button.setAttribute('type', 'button');
|
||||||
button.title = tipLabel;
|
button.title = tipLabel;
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ ol.control.Control.prototype.setMap = function(map) {
|
|||||||
this.map_ = map;
|
this.map_ = map;
|
||||||
if (this.map_) {
|
if (this.map_) {
|
||||||
var target = this.target_ ?
|
var target = this.target_ ?
|
||||||
this.target_ : map.getOverlayContainerStopEvent();
|
this.target_ : map.getOverlayContainerStopEvent();
|
||||||
target.appendChild(this.element);
|
target.appendChild(this.element);
|
||||||
if (this.render !== ol.nullFunction) {
|
if (this.render !== ol.nullFunction) {
|
||||||
this.listenerKeys.push(ol.events.listen(map,
|
this.listenerKeys.push(ol.events.listen(map,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ ol.control.FullScreen = function(opt_options) {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.cssClassName_ = options.className !== undefined ? options.className :
|
this.cssClassName_ = options.className !== undefined ? options.className :
|
||||||
'ol-full-screen';
|
'ol-full-screen';
|
||||||
|
|
||||||
var label = options.label !== undefined ? options.label : '\u2922';
|
var label = options.label !== undefined ? options.label : '\u2922';
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ ol.control.FullScreen = function(opt_options) {
|
|||||||
* @type {Node}
|
* @type {Node}
|
||||||
*/
|
*/
|
||||||
this.labelNode_ = typeof label === 'string' ?
|
this.labelNode_ = typeof label === 'string' ?
|
||||||
document.createTextNode(label) : label;
|
document.createTextNode(label) : label;
|
||||||
|
|
||||||
var labelActive = options.labelActive !== undefined ? options.labelActive : '\u00d7';
|
var labelActive = options.labelActive !== undefined ? options.labelActive : '\u00d7';
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ ol.control.FullScreen = function(opt_options) {
|
|||||||
* @type {Node}
|
* @type {Node}
|
||||||
*/
|
*/
|
||||||
this.labelActiveNode_ = typeof labelActive === 'string' ?
|
this.labelActiveNode_ = typeof labelActive === 'string' ?
|
||||||
document.createTextNode(labelActive) : labelActive;
|
document.createTextNode(labelActive) : labelActive;
|
||||||
|
|
||||||
var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
|
var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
|
||||||
var button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ ol.control.MousePosition = function(opt_options) {
|
|||||||
element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
|
element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
|
||||||
|
|
||||||
var render = options.render ?
|
var render = options.render ?
|
||||||
options.render : ol.control.MousePosition.render;
|
options.render : ol.control.MousePosition.render;
|
||||||
|
|
||||||
ol.control.Control.call(this, {
|
ol.control.Control.call(this, {
|
||||||
element: element,
|
element: element,
|
||||||
@@ -122,7 +122,7 @@ ol.control.MousePosition.prototype.handleProjectionChanged_ = function() {
|
|||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.getCoordinateFormat = function() {
|
ol.control.MousePosition.prototype.getCoordinateFormat = function() {
|
||||||
return /** @type {ol.CoordinateFormatType|undefined} */ (
|
return /** @type {ol.CoordinateFormatType|undefined} */ (
|
||||||
this.get(ol.control.MousePosition.Property_.COORDINATE_FORMAT));
|
this.get(ol.control.MousePosition.Property_.COORDINATE_FORMAT));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ ol.control.MousePosition.prototype.getCoordinateFormat = function() {
|
|||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.getProjection = function() {
|
ol.control.MousePosition.prototype.getProjection = function() {
|
||||||
return /** @type {ol.proj.Projection|undefined} */ (
|
return /** @type {ol.proj.Projection|undefined} */ (
|
||||||
this.get(ol.control.MousePosition.Property_.PROJECTION));
|
this.get(ol.control.MousePosition.Property_.PROJECTION));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ ol.control.OverviewMap = function(opt_options) {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.collapsible_ = options.collapsible !== undefined ?
|
this.collapsible_ = options.collapsible !== undefined ?
|
||||||
options.collapsible : true;
|
options.collapsible : true;
|
||||||
|
|
||||||
if (!this.collapsible_) {
|
if (!this.collapsible_) {
|
||||||
this.collapsed_ = false;
|
this.collapsed_ = false;
|
||||||
@@ -80,7 +80,7 @@ ol.control.OverviewMap = function(opt_options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||||
this.collapseLabel_ : this.label_;
|
this.collapseLabel_ : this.label_;
|
||||||
var button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
button.setAttribute('type', 'button');
|
button.setAttribute('type', 'button');
|
||||||
button.title = tipLabel;
|
button.title = tipLabel;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ ol.control.ScaleLine.LEADING_DIGITS = [1, 2, 5];
|
|||||||
*/
|
*/
|
||||||
ol.control.ScaleLine.prototype.getUnits = function() {
|
ol.control.ScaleLine.prototype.getUnits = function() {
|
||||||
return /** @type {ol.control.ScaleLineUnits|undefined} */ (
|
return /** @type {ol.control.ScaleLineUnits|undefined} */ (
|
||||||
this.get(ol.control.ScaleLine.Property_.UNITS));
|
this.get(ol.control.ScaleLine.Property_.UNITS));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -168,17 +168,22 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
|||||||
|
|
||||||
var center = viewState.center;
|
var center = viewState.center;
|
||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
var metersPerUnit = projection.getMetersPerUnit();
|
var units = this.getUnits();
|
||||||
|
var pointResolutionUnits = units == ol.control.ScaleLineUnits.DEGREES ?
|
||||||
|
ol.proj.Units.DEGREES :
|
||||||
|
ol.proj.Units.METERS;
|
||||||
var pointResolution =
|
var pointResolution =
|
||||||
ol.proj.getPointResolution(projection, viewState.resolution, center) *
|
ol.proj.getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
|
||||||
metersPerUnit;
|
|
||||||
|
|
||||||
var nominalCount = this.minWidth_ * pointResolution;
|
var nominalCount = this.minWidth_ * pointResolution;
|
||||||
var suffix = '';
|
var suffix = '';
|
||||||
var units = this.getUnits();
|
|
||||||
if (units == ol.control.ScaleLineUnits.DEGREES) {
|
if (units == ol.control.ScaleLineUnits.DEGREES) {
|
||||||
var metersPerDegree = ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES];
|
var metersPerDegree = ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES];
|
||||||
pointResolution /= metersPerDegree;
|
if (projection.getUnits() == ol.proj.Units.DEGREES) {
|
||||||
|
nominalCount *= metersPerDegree;
|
||||||
|
} else {
|
||||||
|
pointResolution /= metersPerDegree;
|
||||||
|
}
|
||||||
if (nominalCount < metersPerDegree / 60) {
|
if (nominalCount < metersPerDegree / 60) {
|
||||||
suffix = '\u2033'; // seconds
|
suffix = '\u2033'; // seconds
|
||||||
pointResolution *= 3600;
|
pointResolution *= 3600;
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ ol.control.Zoom = function(opt_options) {
|
|||||||
var zoomOutLabel = options.zoomOutLabel !== undefined ? options.zoomOutLabel : '\u2212';
|
var zoomOutLabel = options.zoomOutLabel !== undefined ? options.zoomOutLabel : '\u2212';
|
||||||
|
|
||||||
var zoomInTipLabel = options.zoomInTipLabel !== undefined ?
|
var zoomInTipLabel = options.zoomInTipLabel !== undefined ?
|
||||||
options.zoomInTipLabel : 'Zoom in';
|
options.zoomInTipLabel : 'Zoom in';
|
||||||
var zoomOutTipLabel = options.zoomOutTipLabel !== undefined ?
|
var zoomOutTipLabel = options.zoomOutTipLabel !== undefined ?
|
||||||
options.zoomOutTipLabel : 'Zoom out';
|
options.zoomOutTipLabel : 'Zoom out';
|
||||||
|
|
||||||
var inElement = document.createElement('button');
|
var inElement = document.createElement('button');
|
||||||
inElement.className = className + '-in';
|
inElement.className = className + '-in';
|
||||||
inElement.setAttribute('type', 'button');
|
inElement.setAttribute('type', 'button');
|
||||||
inElement.title = zoomInTipLabel;
|
inElement.title = zoomInTipLabel;
|
||||||
inElement.appendChild(
|
inElement.appendChild(
|
||||||
typeof zoomInLabel === 'string' ? document.createTextNode(zoomInLabel) : zoomInLabel
|
typeof zoomInLabel === 'string' ? document.createTextNode(zoomInLabel) : zoomInLabel
|
||||||
);
|
);
|
||||||
|
|
||||||
ol.events.listen(inElement, ol.events.EventType.CLICK,
|
ol.events.listen(inElement, ol.events.EventType.CLICK,
|
||||||
@@ -51,7 +51,7 @@ ol.control.Zoom = function(opt_options) {
|
|||||||
outElement.setAttribute('type', 'button');
|
outElement.setAttribute('type', 'button');
|
||||||
outElement.title = zoomOutTipLabel;
|
outElement.title = zoomOutTipLabel;
|
||||||
outElement.appendChild(
|
outElement.appendChild(
|
||||||
typeof zoomOutLabel === 'string' ? document.createTextNode(zoomOutLabel) : zoomOutLabel
|
typeof zoomOutLabel === 'string' ? document.createTextNode(zoomOutLabel) : zoomOutLabel
|
||||||
);
|
);
|
||||||
|
|
||||||
ol.events.listen(outElement, ol.events.EventType.CLICK,
|
ol.events.listen(outElement, ol.events.EventType.CLICK,
|
||||||
|
|||||||
@@ -27,16 +27,16 @@ ol.control.ZoomToExtent = function(opt_options) {
|
|||||||
this.extent_ = options.extent ? options.extent : null;
|
this.extent_ = options.extent ? options.extent : null;
|
||||||
|
|
||||||
var className = options.className !== undefined ? options.className :
|
var className = options.className !== undefined ? options.className :
|
||||||
'ol-zoom-extent';
|
'ol-zoom-extent';
|
||||||
|
|
||||||
var label = options.label !== undefined ? options.label : 'E';
|
var label = options.label !== undefined ? options.label : 'E';
|
||||||
var tipLabel = options.tipLabel !== undefined ?
|
var tipLabel = options.tipLabel !== undefined ?
|
||||||
options.tipLabel : 'Fit to extent';
|
options.tipLabel : 'Fit to extent';
|
||||||
var button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
button.setAttribute('type', 'button');
|
button.setAttribute('type', 'button');
|
||||||
button.title = tipLabel;
|
button.title = tipLabel;
|
||||||
button.appendChild(
|
button.appendChild(
|
||||||
typeof label === 'string' ? document.createTextNode(label) : label
|
typeof label === 'string' ? document.createTextNode(label) : label
|
||||||
);
|
);
|
||||||
|
|
||||||
ol.events.listen(button, ol.events.EventType.CLICK,
|
ol.events.listen(button, ol.events.EventType.CLICK,
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ ol.coordinate.closestOnSegment = function(coordinate, segment) {
|
|||||||
var dx = x2 - x1;
|
var dx = x2 - x1;
|
||||||
var dy = y2 - y1;
|
var dy = y2 - y1;
|
||||||
var along = (dx === 0 && dy === 0) ? 0 :
|
var along = (dx === 0 && dy === 0) ? 0 :
|
||||||
((dx * (x0 - x1)) + (dy * (y0 - y1))) / ((dx * dx + dy * dy) || 0);
|
((dx * (x0 - x1)) + (dy * (y0 - y1))) / ((dx * dx + dy * dy) || 0);
|
||||||
var x, y;
|
var x, y;
|
||||||
if (along <= 0) {
|
if (along <= 0) {
|
||||||
x = x1;
|
x = x1;
|
||||||
@@ -121,13 +121,13 @@ ol.coordinate.closestOnSegment = function(coordinate, segment) {
|
|||||||
*/
|
*/
|
||||||
ol.coordinate.createStringXY = function(opt_fractionDigits) {
|
ol.coordinate.createStringXY = function(opt_fractionDigits) {
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate|undefined} coordinate Coordinate.
|
* @param {ol.Coordinate|undefined} coordinate Coordinate.
|
||||||
* @return {string} String XY.
|
* @return {string} String XY.
|
||||||
*/
|
*/
|
||||||
function(coordinate) {
|
function(coordinate) {
|
||||||
return ol.coordinate.toStringXY(coordinate, opt_fractionDigits);
|
return ol.coordinate.toStringXY(coordinate, opt_fractionDigits);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -195,8 +195,8 @@ ol.coordinate.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionD
|
|||||||
ol.coordinate.format = function(coordinate, template, opt_fractionDigits) {
|
ol.coordinate.format = function(coordinate, template, opt_fractionDigits) {
|
||||||
if (coordinate) {
|
if (coordinate) {
|
||||||
return template
|
return template
|
||||||
.replace('{x}', coordinate[0].toFixed(opt_fractionDigits))
|
.replace('{x}', coordinate[0].toFixed(opt_fractionDigits))
|
||||||
.replace('{y}', coordinate[1].toFixed(opt_fractionDigits));
|
.replace('{y}', coordinate[1].toFixed(opt_fractionDigits));
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) {
|
|||||||
*/
|
*/
|
||||||
ol.DeviceOrientation.prototype.getAlpha = function() {
|
ol.DeviceOrientation.prototype.getAlpha = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.DeviceOrientation.Property_.ALPHA));
|
this.get(ol.DeviceOrientation.Property_.ALPHA));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ ol.DeviceOrientation.prototype.getAlpha = function() {
|
|||||||
*/
|
*/
|
||||||
ol.DeviceOrientation.prototype.getBeta = function() {
|
ol.DeviceOrientation.prototype.getBeta = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.DeviceOrientation.Property_.BETA));
|
this.get(ol.DeviceOrientation.Property_.BETA));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ ol.DeviceOrientation.prototype.getBeta = function() {
|
|||||||
*/
|
*/
|
||||||
ol.DeviceOrientation.prototype.getGamma = function() {
|
ol.DeviceOrientation.prototype.getGamma = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.DeviceOrientation.Property_.GAMMA));
|
this.get(ol.DeviceOrientation.Property_.GAMMA));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ ol.DeviceOrientation.prototype.getGamma = function() {
|
|||||||
*/
|
*/
|
||||||
ol.DeviceOrientation.prototype.getHeading = function() {
|
ol.DeviceOrientation.prototype.getHeading = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.DeviceOrientation.Property_.HEADING));
|
this.get(ol.DeviceOrientation.Property_.HEADING));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ ol.DeviceOrientation.prototype.getHeading = function() {
|
|||||||
*/
|
*/
|
||||||
ol.DeviceOrientation.prototype.getTracking = function() {
|
ol.DeviceOrientation.prototype.getTracking = function() {
|
||||||
return /** @type {boolean} */ (
|
return /** @type {boolean} */ (
|
||||||
this.get(ol.DeviceOrientation.Property_.TRACKING));
|
this.get(ol.DeviceOrientation.Property_.TRACKING));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ goog.require('ol.has');
|
|||||||
ol.events.condition.altKeyOnly = function(mapBrowserEvent) {
|
ol.events.condition.altKeyOnly = function(mapBrowserEvent) {
|
||||||
var originalEvent = mapBrowserEvent.originalEvent;
|
var originalEvent = mapBrowserEvent.originalEvent;
|
||||||
return (
|
return (
|
||||||
originalEvent.altKey &&
|
originalEvent.altKey &&
|
||||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||||
!originalEvent.shiftKey);
|
!originalEvent.shiftKey);
|
||||||
};
|
};
|
||||||
@@ -34,7 +34,7 @@ ol.events.condition.altKeyOnly = function(mapBrowserEvent) {
|
|||||||
ol.events.condition.altShiftKeysOnly = function(mapBrowserEvent) {
|
ol.events.condition.altShiftKeysOnly = function(mapBrowserEvent) {
|
||||||
var originalEvent = mapBrowserEvent.originalEvent;
|
var originalEvent = mapBrowserEvent.originalEvent;
|
||||||
return (
|
return (
|
||||||
originalEvent.altKey &&
|
originalEvent.altKey &&
|
||||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||||
originalEvent.shiftKey);
|
originalEvent.shiftKey);
|
||||||
};
|
};
|
||||||
@@ -138,7 +138,7 @@ ol.events.condition.doubleClick = function(mapBrowserEvent) {
|
|||||||
ol.events.condition.noModifierKeys = function(mapBrowserEvent) {
|
ol.events.condition.noModifierKeys = function(mapBrowserEvent) {
|
||||||
var originalEvent = mapBrowserEvent.originalEvent;
|
var originalEvent = mapBrowserEvent.originalEvent;
|
||||||
return (
|
return (
|
||||||
!originalEvent.altKey &&
|
!originalEvent.altKey &&
|
||||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||||
!originalEvent.shiftKey);
|
!originalEvent.shiftKey);
|
||||||
};
|
};
|
||||||
@@ -156,7 +156,7 @@ ol.events.condition.noModifierKeys = function(mapBrowserEvent) {
|
|||||||
ol.events.condition.platformModifierKeyOnly = function(mapBrowserEvent) {
|
ol.events.condition.platformModifierKeyOnly = function(mapBrowserEvent) {
|
||||||
var originalEvent = mapBrowserEvent.originalEvent;
|
var originalEvent = mapBrowserEvent.originalEvent;
|
||||||
return (
|
return (
|
||||||
!originalEvent.altKey &&
|
!originalEvent.altKey &&
|
||||||
(ol.has.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
|
(ol.has.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
|
||||||
!originalEvent.shiftKey);
|
!originalEvent.shiftKey);
|
||||||
};
|
};
|
||||||
@@ -173,7 +173,7 @@ ol.events.condition.platformModifierKeyOnly = function(mapBrowserEvent) {
|
|||||||
ol.events.condition.shiftKeyOnly = function(mapBrowserEvent) {
|
ol.events.condition.shiftKeyOnly = function(mapBrowserEvent) {
|
||||||
var originalEvent = mapBrowserEvent.originalEvent;
|
var originalEvent = mapBrowserEvent.originalEvent;
|
||||||
return (
|
return (
|
||||||
!originalEvent.altKey &&
|
!originalEvent.altKey &&
|
||||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||||
originalEvent.shiftKey);
|
originalEvent.shiftKey);
|
||||||
};
|
};
|
||||||
@@ -191,7 +191,7 @@ ol.events.condition.targetNotEditable = function(mapBrowserEvent) {
|
|||||||
var target = mapBrowserEvent.originalEvent.target;
|
var target = mapBrowserEvent.originalEvent.target;
|
||||||
var tagName = target.tagName;
|
var tagName = target.tagName;
|
||||||
return (
|
return (
|
||||||
tagName !== 'INPUT' &&
|
tagName !== 'INPUT' &&
|
||||||
tagName !== 'SELECT' &&
|
tagName !== 'SELECT' &&
|
||||||
tagName !== 'TEXTAREA');
|
tagName !== 'TEXTAREA');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ ol.events.Event = function(type) {
|
|||||||
*/
|
*/
|
||||||
ol.events.Event.prototype.preventDefault =
|
ol.events.Event.prototype.preventDefault =
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop event propagation.
|
* Stop event propagation.
|
||||||
* @function
|
* @function
|
||||||
* @override
|
* @override
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.events.Event.prototype.stopPropagation = function() {
|
ol.events.Event.prototype.stopPropagation = function() {
|
||||||
this.propagationStopped = true;
|
this.propagationStopped = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ ol.events.EventTarget.prototype.getListeners = function(type) {
|
|||||||
*/
|
*/
|
||||||
ol.events.EventTarget.prototype.hasListener = function(opt_type) {
|
ol.events.EventTarget.prototype.hasListener = function(opt_type) {
|
||||||
return opt_type ?
|
return opt_type ?
|
||||||
opt_type in this.listeners_ :
|
opt_type in this.listeners_ :
|
||||||
Object.keys(this.listeners_).length > 0;
|
Object.keys(this.listeners_).length > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ ol.Feature.prototype.clone = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Feature.prototype.getGeometry = function() {
|
ol.Feature.prototype.getGeometry = function() {
|
||||||
return /** @type {ol.geom.Geometry|undefined} */ (
|
return /** @type {ol.geom.Geometry|undefined} */ (
|
||||||
this.get(this.geometryName_));
|
this.get(this.geometryName_));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ ol.Feature.prototype.setGeometry = function(geometry) {
|
|||||||
ol.Feature.prototype.setStyle = function(style) {
|
ol.Feature.prototype.setStyle = function(style) {
|
||||||
this.style_ = style;
|
this.style_ = style;
|
||||||
this.styleFunction_ = !style ?
|
this.styleFunction_ = !style ?
|
||||||
undefined : ol.Feature.createStyleFunction(style);
|
undefined : ol.Feature.createStyleFunction(style);
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ goog.require('ol.xml');
|
|||||||
/**
|
/**
|
||||||
* @param {string|ol.FeatureUrlFunction} url Feature URL service.
|
* @param {string|ol.FeatureUrlFunction} url Feature URL service.
|
||||||
* @param {ol.format.Feature} format Feature format.
|
* @param {ol.format.Feature} format Feature format.
|
||||||
* @param {function(this:ol.VectorTile, Array.<ol.Feature>, ol.proj.Projection)|function(this:ol.source.Vector, Array.<ol.Feature>)} success
|
* @param {function(this:ol.VectorTile, Array.<ol.Feature>, ol.proj.Projection, ol.Extent)|function(this:ol.source.Vector, Array.<ol.Feature>)} success
|
||||||
* Function called with the loaded features and optionally with the data
|
* Function called with the loaded features and optionally with the data
|
||||||
* projection. Called with the vector tile or source as `this`.
|
* projection. Called with the vector tile or source as `this`.
|
||||||
* @param {function(this:ol.VectorTile)|function(this:ol.source.Vector)} failure
|
* @param {function(this:ol.VectorTile)|function(this:ol.source.Vector)} failure
|
||||||
@@ -18,60 +18,60 @@ goog.require('ol.xml');
|
|||||||
*/
|
*/
|
||||||
ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||||
return (
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.Extent} extent Extent.
|
||||||
|
* @param {number} resolution Resolution.
|
||||||
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
|
* @this {ol.source.Vector|ol.VectorTile}
|
||||||
|
*/
|
||||||
|
function(extent, resolution, projection) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET',
|
||||||
|
typeof url === 'function' ? url(extent, resolution, projection) : url,
|
||||||
|
true);
|
||||||
|
if (format.getType() == ol.format.FormatType.ARRAY_BUFFER) {
|
||||||
|
xhr.responseType = 'arraybuffer';
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {Event} event Event.
|
||||||
* @param {number} resolution Resolution.
|
* @private
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
|
||||||
* @this {ol.source.Vector|ol.VectorTile}
|
|
||||||
*/
|
*/
|
||||||
function(extent, resolution, projection) {
|
xhr.onload = function(event) {
|
||||||
var xhr = new XMLHttpRequest();
|
// status will be 0 for file:// urls
|
||||||
xhr.open('GET',
|
if (!xhr.status || xhr.status >= 200 && xhr.status < 300) {
|
||||||
typeof url === 'function' ? url(extent, resolution, projection) : url,
|
var type = format.getType();
|
||||||
true);
|
/** @type {Document|Node|Object|string|undefined} */
|
||||||
if (format.getType() == ol.format.FormatType.ARRAY_BUFFER) {
|
var source;
|
||||||
xhr.responseType = 'arraybuffer';
|
if (type == ol.format.FormatType.JSON ||
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param {Event} event Event.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
xhr.onload = function(event) {
|
|
||||||
// status will be 0 for file:// urls
|
|
||||||
if (!xhr.status || xhr.status >= 200 && xhr.status < 300) {
|
|
||||||
var type = format.getType();
|
|
||||||
/** @type {Document|Node|Object|string|undefined} */
|
|
||||||
var source;
|
|
||||||
if (type == ol.format.FormatType.JSON ||
|
|
||||||
type == ol.format.FormatType.TEXT) {
|
type == ol.format.FormatType.TEXT) {
|
||||||
source = xhr.responseText;
|
source = xhr.responseText;
|
||||||
} else if (type == ol.format.FormatType.XML) {
|
} else if (type == ol.format.FormatType.XML) {
|
||||||
source = xhr.responseXML;
|
source = xhr.responseXML;
|
||||||
if (!source) {
|
if (!source) {
|
||||||
source = ol.xml.parse(xhr.responseText);
|
source = ol.xml.parse(xhr.responseText);
|
||||||
}
|
|
||||||
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
|
||||||
source = /** @type {ArrayBuffer} */ (xhr.response);
|
|
||||||
}
|
|
||||||
if (source) {
|
|
||||||
success.call(this, format.readFeatures(source,
|
|
||||||
{featureProjection: projection}),
|
|
||||||
format.readProjection(source));
|
|
||||||
} else {
|
|
||||||
failure.call(this);
|
|
||||||
}
|
}
|
||||||
|
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
||||||
|
source = /** @type {ArrayBuffer} */ (xhr.response);
|
||||||
|
}
|
||||||
|
if (source) {
|
||||||
|
success.call(this, format.readFeatures(source,
|
||||||
|
{featureProjection: projection}),
|
||||||
|
format.readProjection(source), format.getLastExtent());
|
||||||
} else {
|
} else {
|
||||||
failure.call(this);
|
failure.call(this);
|
||||||
}
|
}
|
||||||
}.bind(this);
|
} else {
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
xhr.onerror = function() {
|
|
||||||
failure.call(this);
|
failure.call(this);
|
||||||
}.bind(this);
|
}
|
||||||
xhr.send();
|
}.bind(this);
|
||||||
});
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
xhr.onerror = function() {
|
||||||
|
failure.call(this);
|
||||||
|
}.bind(this);
|
||||||
|
xhr.send();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
|
|||||||
}
|
}
|
||||||
var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type];
|
var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type];
|
||||||
return /** @type {ol.geom.Geometry} */ (
|
return /** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(
|
ol.format.Feature.transformWithOptions(
|
||||||
geometryReader(object), false, opt_options));
|
geometryReader(object), false, opt_options));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -121,9 +121,11 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) {
|
|||||||
// loop over all outer rings and see if they contain our hole.
|
// loop over all outer rings and see if they contain our hole.
|
||||||
for (i = outerRings.length - 1; i >= 0; i--) {
|
for (i = outerRings.length - 1; i >= 0; i--) {
|
||||||
var outerRing = outerRings[i][0];
|
var outerRing = outerRings[i][0];
|
||||||
if (ol.extent.containsExtent(new ol.geom.LinearRing(
|
var containsHole = ol.extent.containsExtent(
|
||||||
outerRing).getExtent(),
|
new ol.geom.LinearRing(outerRing).getExtent(),
|
||||||
new ol.geom.LinearRing(hole).getExtent())) {
|
new ol.geom.LinearRing(hole).getExtent()
|
||||||
|
);
|
||||||
|
if (containsHole) {
|
||||||
// the hole is contained push it into our polygon
|
// the hole is contained push it into our polygon
|
||||||
outerRings[i].push(hole);
|
outerRings[i].push(hole);
|
||||||
matched = true;
|
matched = true;
|
||||||
@@ -288,9 +290,9 @@ ol.format.EsriJSON.getHasZM_ = function(geometry) {
|
|||||||
var layout = geometry.getLayout();
|
var layout = geometry.getLayout();
|
||||||
return {
|
return {
|
||||||
hasZ: (layout === ol.geom.GeometryLayout.XYZ ||
|
hasZ: (layout === ol.geom.GeometryLayout.XYZ ||
|
||||||
layout === ol.geom.GeometryLayout.XYZM),
|
layout === ol.geom.GeometryLayout.XYZM),
|
||||||
hasM: (layout === ol.geom.GeometryLayout.XYM ||
|
hasM: (layout === ol.geom.GeometryLayout.XYM ||
|
||||||
layout === ol.geom.GeometryLayout.XYZM)
|
layout === ol.geom.GeometryLayout.XYZM)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -302,7 +304,7 @@ ol.format.EsriJSON.getHasZM_ = function(geometry) {
|
|||||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */ (geometry));
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */(geometry));
|
||||||
return /** @type {EsriJSONPolyline} */ ({
|
return /** @type {EsriJSONPolyline} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
hasM: hasZM.hasM,
|
||||||
@@ -321,7 +323,7 @@ ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
|
|||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
||||||
// Esri geometries use the left-hand rule
|
// Esri geometries use the left-hand rule
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */ (geometry));
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */(geometry));
|
||||||
return /** @type {EsriJSONPolygon} */ ({
|
return /** @type {EsriJSONPolygon} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
hasM: hasZM.hasM,
|
||||||
@@ -337,7 +339,7 @@ ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
|
|||||||
* @return {EsriJSONPolyline} EsriJSON geometry.
|
* @return {EsriJSONPolyline} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */ (geometry));
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */(geometry));
|
||||||
return /** @type {EsriJSONPolyline} */ ({
|
return /** @type {EsriJSONPolyline} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
hasM: hasZM.hasM,
|
||||||
@@ -353,7 +355,7 @@ ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_option
|
|||||||
* @return {EsriJSONMultipoint} EsriJSON geometry.
|
* @return {EsriJSONMultipoint} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */ (geometry));
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */(geometry));
|
||||||
return /** @type {EsriJSONMultipoint} */ ({
|
return /** @type {EsriJSONMultipoint} */ ({
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
hasM: hasZM.hasM,
|
||||||
@@ -370,7 +372,7 @@ ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
|
|||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
|
ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
|
||||||
opt_options) {
|
opt_options) {
|
||||||
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */ (geometry));
|
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */(geometry));
|
||||||
var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false);
|
var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false);
|
||||||
var output = [];
|
var output = [];
|
||||||
for (var i = 0; i < coordinates.length; i++) {
|
for (var i = 0; i < coordinates.length; i++) {
|
||||||
@@ -393,17 +395,17 @@ ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
|
|||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.GEOMETRY_READERS_ = {};
|
ol.format.EsriJSON.GEOMETRY_READERS_ = {};
|
||||||
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POINT] =
|
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POINT] =
|
||||||
ol.format.EsriJSON.readPointGeometry_;
|
ol.format.EsriJSON.readPointGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.LINE_STRING] =
|
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.LINE_STRING] =
|
||||||
ol.format.EsriJSON.readLineStringGeometry_;
|
ol.format.EsriJSON.readLineStringGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POLYGON] =
|
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POLYGON] =
|
||||||
ol.format.EsriJSON.readPolygonGeometry_;
|
ol.format.EsriJSON.readPolygonGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POINT] =
|
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POINT] =
|
||||||
ol.format.EsriJSON.readMultiPointGeometry_;
|
ol.format.EsriJSON.readMultiPointGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_LINE_STRING] =
|
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_LINE_STRING] =
|
||||||
ol.format.EsriJSON.readMultiLineStringGeometry_;
|
ol.format.EsriJSON.readMultiLineStringGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] =
|
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] =
|
||||||
ol.format.EsriJSON.readMultiPolygonGeometry_;
|
ol.format.EsriJSON.readMultiPolygonGeometry_;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -413,17 +415,17 @@ ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] =
|
|||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.GEOMETRY_WRITERS_ = {};
|
ol.format.EsriJSON.GEOMETRY_WRITERS_ = {};
|
||||||
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POINT] =
|
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POINT] =
|
||||||
ol.format.EsriJSON.writePointGeometry_;
|
ol.format.EsriJSON.writePointGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.LINE_STRING] =
|
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.LINE_STRING] =
|
||||||
ol.format.EsriJSON.writeLineStringGeometry_;
|
ol.format.EsriJSON.writeLineStringGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POLYGON] =
|
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POLYGON] =
|
||||||
ol.format.EsriJSON.writePolygonGeometry_;
|
ol.format.EsriJSON.writePolygonGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POINT] =
|
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POINT] =
|
||||||
ol.format.EsriJSON.writeMultiPointGeometry_;
|
ol.format.EsriJSON.writeMultiPointGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_LINE_STRING] =
|
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_LINE_STRING] =
|
||||||
ol.format.EsriJSON.writeMultiLineStringGeometry_;
|
ol.format.EsriJSON.writeMultiLineStringGeometry_;
|
||||||
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POLYGON] =
|
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POLYGON] =
|
||||||
ol.format.EsriJSON.writeMultiPolygonGeometry_;
|
ol.format.EsriJSON.writeMultiPolygonGeometry_;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -466,9 +468,9 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function(
|
|||||||
}
|
}
|
||||||
feature.setGeometry(geometry);
|
feature.setGeometry(geometry);
|
||||||
if (opt_options && opt_options.idField &&
|
if (opt_options && opt_options.idField &&
|
||||||
esriJSONFeature.attributes[opt_options.idField]) {
|
esriJSONFeature.attributes[opt_options.idField]) {
|
||||||
feature.setId(/** @type {number} */(
|
feature.setId(/** @type {number} */(
|
||||||
esriJSONFeature.attributes[opt_options.idField]));
|
esriJSONFeature.attributes[opt_options.idField]));
|
||||||
}
|
}
|
||||||
if (esriJSONFeature.attributes) {
|
if (esriJSONFeature.attributes) {
|
||||||
feature.setProperties(esriJSONFeature.attributes);
|
feature.setProperties(esriJSONFeature.attributes);
|
||||||
@@ -486,7 +488,7 @@ ol.format.EsriJSON.prototype.readFeaturesFromObject = function(
|
|||||||
var options = opt_options ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
if (esriJSONObject.features) {
|
if (esriJSONObject.features) {
|
||||||
var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
|
var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
|
||||||
(object);
|
(object);
|
||||||
/** @type {Array.<ol.Feature>} */
|
/** @type {Array.<ol.Feature>} */
|
||||||
var features = [];
|
var features = [];
|
||||||
var esriJSONFeatures = esriJSONFeatureCollection.features;
|
var esriJSONFeatures = esriJSONFeatureCollection.features;
|
||||||
@@ -521,7 +523,7 @@ ol.format.EsriJSON.prototype.readGeometry;
|
|||||||
ol.format.EsriJSON.prototype.readGeometryFromObject = function(
|
ol.format.EsriJSON.prototype.readGeometryFromObject = function(
|
||||||
object, opt_options) {
|
object, opt_options) {
|
||||||
return ol.format.EsriJSON.readGeometry_(
|
return ol.format.EsriJSON.readGeometry_(
|
||||||
/** @type {EsriJSONGeometry} */ (object), opt_options);
|
/** @type {EsriJSONGeometry} */(object), opt_options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -558,9 +560,9 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) {
|
|||||||
*/
|
*/
|
||||||
ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) {
|
ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) {
|
||||||
var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
||||||
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
return geometryWriter(/** @type {ol.geom.Geometry} */(
|
||||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
||||||
opt_options);
|
opt_options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -620,7 +622,13 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function(
|
|||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
object['geometry'] =
|
object['geometry'] =
|
||||||
ol.format.EsriJSON.writeGeometry_(geometry, opt_options);
|
ol.format.EsriJSON.writeGeometry_(geometry, opt_options);
|
||||||
|
if (opt_options && opt_options.featureProjection) {
|
||||||
|
object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({
|
||||||
|
wkid: ol.proj.get(
|
||||||
|
opt_options.featureProjection).getCode().split(':').pop()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var properties = feature.getProperties();
|
var properties = feature.getProperties();
|
||||||
delete properties[feature.getGeometryName()];
|
delete properties[feature.getGeometryName()];
|
||||||
@@ -629,12 +637,6 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function(
|
|||||||
} else {
|
} else {
|
||||||
object['attributes'] = {};
|
object['attributes'] = {};
|
||||||
}
|
}
|
||||||
if (opt_options && opt_options.featureProjection) {
|
|
||||||
object['spatialReference'] = /** @type {EsriJSONCRS} */({
|
|
||||||
wkid: ol.proj.get(
|
|
||||||
opt_options.featureProjection).getCode().split(':').pop()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return object;
|
return object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ ol.format.Feature.prototype.getReadOptions = function(source, opt_options) {
|
|||||||
if (opt_options) {
|
if (opt_options) {
|
||||||
options = {
|
options = {
|
||||||
dataProjection: opt_options.dataProjection ?
|
dataProjection: opt_options.dataProjection ?
|
||||||
opt_options.dataProjection : this.readProjection(source),
|
opt_options.dataProjection : this.readProjection(source),
|
||||||
featureProjection: opt_options.featureProjection
|
featureProjection: opt_options.featureProjection
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -72,6 +72,15 @@ ol.format.Feature.prototype.adaptOptions = function(options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the extent from the source of the last {@link readFeatures} call.
|
||||||
|
* @return {ol.Extent} Tile extent.
|
||||||
|
*/
|
||||||
|
ol.format.Feature.prototype.getLastExtent = function() {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @return {ol.format.FormatType} Format.
|
* @return {ol.format.FormatType} Format.
|
||||||
@@ -166,9 +175,9 @@ ol.format.Feature.prototype.writeGeometry = function(geometry, opt_options) {};
|
|||||||
ol.format.Feature.transformWithOptions = function(
|
ol.format.Feature.transformWithOptions = function(
|
||||||
geometry, write, opt_options) {
|
geometry, write, opt_options) {
|
||||||
var featureProjection = opt_options ?
|
var featureProjection = opt_options ?
|
||||||
ol.proj.get(opt_options.featureProjection) : null;
|
ol.proj.get(opt_options.featureProjection) : null;
|
||||||
var dataProjection = opt_options ?
|
var dataProjection = opt_options ?
|
||||||
ol.proj.get(opt_options.dataProjection) : null;
|
ol.proj.get(opt_options.dataProjection) : null;
|
||||||
/**
|
/**
|
||||||
* @type {ol.geom.Geometry|ol.Extent}
|
* @type {ol.geom.Geometry|ol.Extent}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ ol.format.filter.between = function(propertyName, lowerBoundary, upperBoundary)
|
|||||||
ol.format.filter.like = function(propertyName, pattern,
|
ol.format.filter.like = function(propertyName, pattern,
|
||||||
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
|
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
|
||||||
return new ol.format.filter.IsLike(propertyName, pattern,
|
return new ol.format.filter.IsLike(propertyName, pattern,
|
||||||
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
|
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ ol.format.GeoJSON = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.defaultDataProjection = ol.proj.get(
|
this.defaultDataProjection = ol.proj.get(
|
||||||
options.defaultDataProjection ?
|
options.defaultDataProjection ?
|
||||||
options.defaultDataProjection : 'EPSG:4326');
|
options.defaultDataProjection : 'EPSG:4326');
|
||||||
|
|
||||||
|
|
||||||
if (options.featureProjection) {
|
if (options.featureProjection) {
|
||||||
@@ -69,8 +69,8 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
|
|||||||
}
|
}
|
||||||
var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type];
|
var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type];
|
||||||
return /** @type {ol.geom.Geometry} */ (
|
return /** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(
|
ol.format.Feature.transformWithOptions(
|
||||||
geometryReader(object), false, opt_options));
|
geometryReader(object), false, opt_options));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -163,8 +163,8 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
|
|||||||
ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) {
|
ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) {
|
||||||
var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
||||||
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
|
||||||
opt_options);
|
opt_options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ ol.format.GML2 = function(opt_options) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
this.schemaLocation = options.schemaLocation ?
|
this.schemaLocation = options.schemaLocation ?
|
||||||
options.schemaLocation : ol.format.GML2.schemaLocation_;
|
options.schemaLocation : ol.format.GML2.schemaLocation_;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.GML2, ol.format.GMLBase);
|
ol.inherits(ol.format.GML2, ol.format.GMLBase);
|
||||||
@@ -469,8 +469,8 @@ ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
|
|||||||
axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation();
|
axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation();
|
||||||
}
|
}
|
||||||
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
||||||
point[0] + ',' + point[1] :
|
point[0] + ',' + point[1] :
|
||||||
point[1] + ',' + point[0]);
|
point[1] + ',' + point[0]);
|
||||||
if (opt_hasZ) {
|
if (opt_hasZ) {
|
||||||
// For newly created points, Z can be undefined.
|
// For newly created points, Z can be undefined.
|
||||||
var z = point[2] || 0;
|
var z = point[2] || 0;
|
||||||
|
|||||||
@@ -52,20 +52,27 @@ ol.format.GML3 = function(opt_options) {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.multiCurve_ = options.multiCurve !== undefined ?
|
this.multiCurve_ = options.multiCurve !== undefined ?
|
||||||
options.multiCurve : true;
|
options.multiCurve : true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.multiSurface_ = options.multiSurface !== undefined ?
|
this.multiSurface_ = options.multiSurface !== undefined ?
|
||||||
options.multiSurface : true;
|
options.multiSurface : true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
this.schemaLocation = options.schemaLocation ?
|
this.schemaLocation = options.schemaLocation ?
|
||||||
options.schemaLocation : ol.format.GML3.schemaLocation_;
|
options.schemaLocation : ol.format.GML3.schemaLocation_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.hasZ = options.hasZ !== undefined ?
|
||||||
|
options.hasZ : false;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.GML3, ol.format.GMLBase);
|
ol.inherits(ol.format.GML3, ol.format.GMLBase);
|
||||||
@@ -601,8 +608,8 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
|
|||||||
axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation();
|
axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation();
|
||||||
}
|
}
|
||||||
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
||||||
point[0] + ' ' + point[1] :
|
point[0] + ' ' + point[1] :
|
||||||
point[1] + ' ' + point[0]);
|
point[1] + ' ' + point[0]);
|
||||||
if (opt_hasZ) {
|
if (opt_hasZ) {
|
||||||
// For newly created points, Z can be undefined.
|
// For newly created points, Z can be undefined.
|
||||||
var z = point[2] || 0;
|
var z = point[2] || 0;
|
||||||
|
|||||||
@@ -167,12 +167,12 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
|||||||
var parsers = {};
|
var parsers = {};
|
||||||
for (i = 0, ii = featureTypes.length; i < ii; ++i) {
|
for (i = 0, ii = featureTypes.length; i < ii; ++i) {
|
||||||
var featurePrefix = featureTypes[i].indexOf(':') === -1 ?
|
var featurePrefix = featureTypes[i].indexOf(':') === -1 ?
|
||||||
defaultPrefix : featureTypes[i].split(':')[0];
|
defaultPrefix : featureTypes[i].split(':')[0];
|
||||||
if (featurePrefix === p) {
|
if (featurePrefix === p) {
|
||||||
parsers[featureTypes[i].split(':').pop()] =
|
parsers[featureTypes[i].split(':').pop()] =
|
||||||
(localName == 'featureMembers') ?
|
(localName == 'featureMembers') ?
|
||||||
ol.xml.makeArrayPusher(this.readFeatureElement, this) :
|
ol.xml.makeArrayPusher(this.readFeatureElement, this) :
|
||||||
ol.xml.makeReplacer(this.readFeatureElement, this);
|
ol.xml.makeReplacer(this.readFeatureElement, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parsersNS[featureNS[p]] = parsers;
|
parsersNS[featureNS[p]] = parsers;
|
||||||
@@ -203,7 +203,7 @@ ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
|
|||||||
this.GEOMETRY_PARSERS_, node, objectStack, this);
|
this.GEOMETRY_PARSERS_, node, objectStack, this);
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
return /** @type {ol.geom.Geometry} */ (
|
return /** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(geometry, false, context));
|
ol.format.Feature.transformWithOptions(geometry, false, context));
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -590,5 +590,5 @@ ol.format.GMLBase.prototype.readFeaturesFromNode = function(node, opt_options) {
|
|||||||
*/
|
*/
|
||||||
ol.format.GMLBase.prototype.readProjectionFromNode = function(node) {
|
ol.format.GMLBase.prototype.readProjectionFromNode = function(node) {
|
||||||
return ol.proj.get(this.srsName ? this.srsName :
|
return ol.proj.get(this.srsName ? this.srsName :
|
||||||
node.firstElementChild.getAttribute('srsName'));
|
node.firstElementChild.getAttribute('srsName'));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -606,8 +606,8 @@ ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) {
|
|||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
var orderedKeys = (node.nodeName == 'rtept') ?
|
var orderedKeys = (node.nodeName == 'rtept') ?
|
||||||
ol.format.GPX.RTEPT_TYPE_SEQUENCE_[namespaceURI] :
|
ol.format.GPX.RTEPT_TYPE_SEQUENCE_[namespaceURI] :
|
||||||
ol.format.GPX.WPT_TYPE_SEQUENCE_[namespaceURI];
|
ol.format.GPX.WPT_TYPE_SEQUENCE_[namespaceURI];
|
||||||
var values = ol.xml.makeSequence(properties, orderedKeys);
|
var values = ol.xml.makeSequence(properties, orderedKeys);
|
||||||
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
|
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
|
||||||
({node: node, 'properties': properties}),
|
({node: node, 'properties': properties}),
|
||||||
@@ -629,7 +629,7 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) {
|
|||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
geometry = /** @type {ol.geom.LineString} */
|
geometry = /** @type {ol.geom.LineString} */
|
||||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||||
context['geometryLayout'] = geometry.getLayout();
|
context['geometryLayout'] = geometry.getLayout();
|
||||||
properties['rtept'] = geometry.getCoordinates();
|
properties['rtept'] = geometry.getCoordinates();
|
||||||
}
|
}
|
||||||
@@ -656,7 +656,7 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) {
|
|||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
geometry = /** @type {ol.geom.MultiLineString} */
|
geometry = /** @type {ol.geom.MultiLineString} */
|
||||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||||
properties['trkseg'] = geometry.getLineStrings();
|
properties['trkseg'] = geometry.getLineStrings();
|
||||||
}
|
}
|
||||||
var parentNode = objectStack[objectStack.length - 1].node;
|
var parentNode = objectStack[objectStack.length - 1].node;
|
||||||
@@ -697,7 +697,7 @@ ol.format.GPX.writeWpt_ = function(node, feature, objectStack) {
|
|||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
geometry = /** @type {ol.geom.Point} */
|
geometry = /** @type {ol.geom.Point} */
|
||||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||||
context['geometryLayout'] = geometry.getLayout();
|
context['geometryLayout'] = geometry.getLayout();
|
||||||
ol.format.GPX.writeWptType_(node, geometry.getCoordinates(), objectStack);
|
ol.format.GPX.writeWptType_(node, geometry.getCoordinates(), objectStack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ ol.format.IGC = function(opt_options) {
|
|||||||
* @type {ol.format.IGCZ}
|
* @type {ol.format.IGCZ}
|
||||||
*/
|
*/
|
||||||
this.altitudeMode_ = options.altitudeMode ?
|
this.altitudeMode_ = options.altitudeMode ?
|
||||||
options.altitudeMode : ol.format.IGCZ.NONE;
|
options.altitudeMode : ol.format.IGCZ.NONE;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.IGC, ol.format.TextFeature);
|
ol.inherits(ol.format.IGC, ol.format.TextFeature);
|
||||||
@@ -158,7 +158,7 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
|||||||
}
|
}
|
||||||
var lineString = new ol.geom.LineString(null);
|
var lineString = new ol.geom.LineString(null);
|
||||||
var layout = altitudeMode == ol.format.IGCZ.NONE ?
|
var layout = altitudeMode == ol.format.IGCZ.NONE ?
|
||||||
ol.geom.GeometryLayout.XYM : ol.geom.GeometryLayout.XYZM;
|
ol.geom.GeometryLayout.XYM : ol.geom.GeometryLayout.XYZM;
|
||||||
lineString.setFlatCoordinates(layout, flatCoordinates);
|
lineString.setFlatCoordinates(layout, flatCoordinates);
|
||||||
var feature = new ol.Feature(ol.format.Feature.transformWithOptions(
|
var feature = new ol.Feature(ol.format.Feature.transformWithOptions(
|
||||||
lineString, false, opt_options));
|
lineString, false, opt_options));
|
||||||
|
|||||||
@@ -66,21 +66,21 @@ ol.format.KML = function(opt_options) {
|
|||||||
* @type {Array.<ol.style.Style>}
|
* @type {Array.<ol.style.Style>}
|
||||||
*/
|
*/
|
||||||
this.defaultStyle_ = options.defaultStyle ?
|
this.defaultStyle_ = options.defaultStyle ?
|
||||||
options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_;
|
options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.extractStyles_ = options.extractStyles !== undefined ?
|
this.extractStyles_ = options.extractStyles !== undefined ?
|
||||||
options.extractStyles : true;
|
options.extractStyles : true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.writeStyles_ = options.writeStyles !== undefined ?
|
this.writeStyles_ = options.writeStyles !== undefined ?
|
||||||
options.writeStyles : true;
|
options.writeStyles : true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -93,7 +93,7 @@ ol.format.KML = function(opt_options) {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.showPointNames_ = options.showPointNames !== undefined ?
|
this.showPointNames_ = options.showPointNames !== undefined ?
|
||||||
options.showPointNames : true;
|
options.showPointNames : true;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.KML, ol.format.XMLFeature);
|
ol.inherits(ol.format.KML, ol.format.XMLFeature);
|
||||||
@@ -353,53 +353,53 @@ ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl,
|
|||||||
defaultStyle, sharedStyles, showPointNames) {
|
defaultStyle, sharedStyles, showPointNames) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @return {Array.<ol.style.Style>} Style.
|
* @return {Array.<ol.style.Style>} Style.
|
||||||
* @this {ol.Feature}
|
* @this {ol.Feature}
|
||||||
*/
|
*/
|
||||||
function(resolution) {
|
function(resolution) {
|
||||||
var drawName = showPointNames;
|
var drawName = showPointNames;
|
||||||
/** @type {ol.style.Style|undefined} */
|
/** @type {ol.style.Style|undefined} */
|
||||||
var nameStyle;
|
var nameStyle;
|
||||||
var name = '';
|
var name = '';
|
||||||
if (drawName) {
|
if (drawName) {
|
||||||
if (this.getGeometry()) {
|
if (this.getGeometry()) {
|
||||||
drawName = (this.getGeometry().getType() ===
|
drawName = (this.getGeometry().getType() ===
|
||||||
ol.geom.GeometryType.POINT);
|
ol.geom.GeometryType.POINT);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (drawName) {
|
if (drawName) {
|
||||||
name = /** @type {string} */ (this.get('name'));
|
name = /** @type {string} */ (this.get('name'));
|
||||||
drawName = drawName && name;
|
drawName = drawName && name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style) {
|
if (style) {
|
||||||
if (drawName) {
|
|
||||||
nameStyle = ol.format.KML.createNameStyleFunction_(style[0],
|
|
||||||
name);
|
|
||||||
return style.concat(nameStyle);
|
|
||||||
}
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
if (styleUrl) {
|
|
||||||
var foundStyle = ol.format.KML.findStyle_(styleUrl, defaultStyle,
|
|
||||||
sharedStyles);
|
|
||||||
if (drawName) {
|
|
||||||
nameStyle = ol.format.KML.createNameStyleFunction_(foundStyle[0],
|
|
||||||
name);
|
|
||||||
return foundStyle.concat(nameStyle);
|
|
||||||
}
|
|
||||||
return foundStyle;
|
|
||||||
}
|
|
||||||
if (drawName) {
|
if (drawName) {
|
||||||
nameStyle = ol.format.KML.createNameStyleFunction_(defaultStyle[0],
|
nameStyle = ol.format.KML.createNameStyleFunction_(style[0],
|
||||||
name);
|
name);
|
||||||
return defaultStyle.concat(nameStyle);
|
return style.concat(nameStyle);
|
||||||
}
|
}
|
||||||
return defaultStyle;
|
return style;
|
||||||
});
|
}
|
||||||
|
if (styleUrl) {
|
||||||
|
var foundStyle = ol.format.KML.findStyle_(styleUrl, defaultStyle,
|
||||||
|
sharedStyles);
|
||||||
|
if (drawName) {
|
||||||
|
nameStyle = ol.format.KML.createNameStyleFunction_(foundStyle[0],
|
||||||
|
name);
|
||||||
|
return foundStyle.concat(nameStyle);
|
||||||
|
}
|
||||||
|
return foundStyle;
|
||||||
|
}
|
||||||
|
if (drawName) {
|
||||||
|
nameStyle = ol.format.KML.createNameStyleFunction_(defaultStyle[0],
|
||||||
|
name);
|
||||||
|
return defaultStyle.concat(nameStyle);
|
||||||
|
}
|
||||||
|
return defaultStyle;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ ol.format.KML.readStyleMapValue_ = function(node, objectStack) {
|
|||||||
return ol.xml.pushParseAndPop(undefined,
|
return ol.xml.pushParseAndPop(undefined,
|
||||||
ol.format.KML.STYLE_MAP_PARSERS_, node, objectStack);
|
ol.format.KML.STYLE_MAP_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @param {Node} node Node.
|
||||||
* @param {Array.<*>} objectStack Object stack.
|
* @param {Array.<*>} objectStack Object stack.
|
||||||
* @private
|
* @private
|
||||||
@@ -807,7 +807,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
|
|||||||
var whens = gxTrackObject.whens;
|
var whens = gxTrackObject.whens;
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = Math.min(flatCoordinates.length, whens.length); i < ii;
|
for (i = 0, ii = Math.min(flatCoordinates.length, whens.length); i < ii;
|
||||||
++i) {
|
++i) {
|
||||||
flatCoordinates[4 * i + 3] = whens[i];
|
flatCoordinates[4 * i + 3] = whens[i];
|
||||||
}
|
}
|
||||||
var lineString = new ol.geom.LineString(null);
|
var lineString = new ol.geom.LineString(null);
|
||||||
@@ -1021,23 +1021,23 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
|
|||||||
}
|
}
|
||||||
var fillStyle = /** @type {ol.style.Fill} */
|
var fillStyle = /** @type {ol.style.Fill} */
|
||||||
('fillStyle' in styleObject ?
|
('fillStyle' in styleObject ?
|
||||||
styleObject['fillStyle'] : ol.format.KML.DEFAULT_FILL_STYLE_);
|
styleObject['fillStyle'] : ol.format.KML.DEFAULT_FILL_STYLE_);
|
||||||
var fill = /** @type {boolean|undefined} */ (styleObject['fill']);
|
var fill = /** @type {boolean|undefined} */ (styleObject['fill']);
|
||||||
if (fill !== undefined && !fill) {
|
if (fill !== undefined && !fill) {
|
||||||
fillStyle = null;
|
fillStyle = null;
|
||||||
}
|
}
|
||||||
var imageStyle = /** @type {ol.style.Image} */
|
var imageStyle = /** @type {ol.style.Image} */
|
||||||
('imageStyle' in styleObject ?
|
('imageStyle' in styleObject ?
|
||||||
styleObject['imageStyle'] : ol.format.KML.DEFAULT_IMAGE_STYLE_);
|
styleObject['imageStyle'] : ol.format.KML.DEFAULT_IMAGE_STYLE_);
|
||||||
if (imageStyle == ol.format.KML.DEFAULT_NO_IMAGE_STYLE_) {
|
if (imageStyle == ol.format.KML.DEFAULT_NO_IMAGE_STYLE_) {
|
||||||
imageStyle = undefined;
|
imageStyle = undefined;
|
||||||
}
|
}
|
||||||
var textStyle = /** @type {ol.style.Text} */
|
var textStyle = /** @type {ol.style.Text} */
|
||||||
('textStyle' in styleObject ?
|
('textStyle' in styleObject ?
|
||||||
styleObject['textStyle'] : ol.format.KML.DEFAULT_TEXT_STYLE_);
|
styleObject['textStyle'] : ol.format.KML.DEFAULT_TEXT_STYLE_);
|
||||||
var strokeStyle = /** @type {ol.style.Stroke} */
|
var strokeStyle = /** @type {ol.style.Stroke} */
|
||||||
('strokeStyle' in styleObject ?
|
('strokeStyle' in styleObject ?
|
||||||
styleObject['strokeStyle'] : ol.format.KML.DEFAULT_STROKE_STYLE_);
|
styleObject['strokeStyle'] : ol.format.KML.DEFAULT_STROKE_STYLE_);
|
||||||
var outline = /** @type {boolean|undefined} */
|
var outline = /** @type {boolean|undefined} */
|
||||||
(styleObject['outline']);
|
(styleObject['outline']);
|
||||||
if (outline !== undefined && !outline) {
|
if (outline !== undefined && !outline) {
|
||||||
@@ -1065,19 +1065,25 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
|
|||||||
geometries) {
|
geometries) {
|
||||||
var ii = geometries.length;
|
var ii = geometries.length;
|
||||||
var extrudes = new Array(geometries.length);
|
var extrudes = new Array(geometries.length);
|
||||||
|
var tessellates = new Array(geometries.length);
|
||||||
var altitudeModes = new Array(geometries.length);
|
var altitudeModes = new Array(geometries.length);
|
||||||
var geometry, i, hasExtrude, hasAltitudeMode;
|
var geometry, i, hasExtrude, hasTessellate, hasAltitudeMode;
|
||||||
hasExtrude = hasAltitudeMode = false;
|
hasExtrude = hasTessellate = hasAltitudeMode = false;
|
||||||
for (i = 0; i < ii; ++i) {
|
for (i = 0; i < ii; ++i) {
|
||||||
geometry = geometries[i];
|
geometry = geometries[i];
|
||||||
extrudes[i] = geometry.get('extrude');
|
extrudes[i] = geometry.get('extrude');
|
||||||
|
tessellates[i] = geometry.get('tessellate');
|
||||||
altitudeModes[i] = geometry.get('altitudeMode');
|
altitudeModes[i] = geometry.get('altitudeMode');
|
||||||
hasExtrude = hasExtrude || extrudes[i] !== undefined;
|
hasExtrude = hasExtrude || extrudes[i] !== undefined;
|
||||||
|
hasTessellate = hasTessellate || tessellates[i] !== undefined;
|
||||||
hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
|
hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
|
||||||
}
|
}
|
||||||
if (hasExtrude) {
|
if (hasExtrude) {
|
||||||
multiGeometry.set('extrude', extrudes);
|
multiGeometry.set('extrude', extrudes);
|
||||||
}
|
}
|
||||||
|
if (hasTessellate) {
|
||||||
|
multiGeometry.set('tessellate', tessellates);
|
||||||
|
}
|
||||||
if (hasAltitudeMode) {
|
if (hasAltitudeMode) {
|
||||||
multiGeometry.set('altitudeMode', altitudeModes);
|
multiGeometry.set('altitudeMode', altitudeModes);
|
||||||
}
|
}
|
||||||
@@ -1092,13 +1098,13 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
|
|||||||
ol.format.KML.DataParser_ = function(node, objectStack) {
|
ol.format.KML.DataParser_ = function(node, objectStack) {
|
||||||
var name = node.getAttribute('name');
|
var name = node.getAttribute('name');
|
||||||
ol.xml.parseNode(ol.format.KML.DATA_PARSERS_, node, objectStack);
|
ol.xml.parseNode(ol.format.KML.DATA_PARSERS_, node, objectStack);
|
||||||
var featureObject =
|
var featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
/** @type {Object} */ (objectStack[objectStack.length - 1]);
|
|
||||||
if (name !== null) {
|
if (name !== null) {
|
||||||
featureObject[name] = featureObject.value;
|
featureObject[name] = featureObject.value;
|
||||||
} else if (featureObject.displayName !== null) {
|
} else if (featureObject.displayName !== null) {
|
||||||
featureObject[featureObject.displayName] = featureObject.value;
|
featureObject[featureObject.displayName] = featureObject.value;
|
||||||
}
|
}
|
||||||
|
delete featureObject['value'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1371,6 +1377,7 @@ ol.format.KML.LOD_PARSERS_ = ol.xml.makeStructureNS(
|
|||||||
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_ = ol.xml.makeStructureNS(
|
ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_ = ol.xml.makeStructureNS(
|
||||||
ol.format.KML.NAMESPACE_URIS_, {
|
ol.format.KML.NAMESPACE_URIS_, {
|
||||||
'extrude': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean),
|
'extrude': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean),
|
||||||
|
'tessellate': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean),
|
||||||
'altitudeMode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
|
'altitudeMode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2144,16 +2151,16 @@ ol.format.KML.writeDataNode_ = function(node, pair, objectStack) {
|
|||||||
if (typeof value == 'object') {
|
if (typeof value == 'object') {
|
||||||
if (value !== null && value.displayName) {
|
if (value !== null && value.displayName) {
|
||||||
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
||||||
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value.displayName], objectStack, ['displayName']);
|
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value.displayName], objectStack, ['displayName']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value !== null && value.value) {
|
if (value !== null && value.value) {
|
||||||
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
||||||
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value.value], objectStack, ['value']);
|
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value.value], objectStack, ['value']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
||||||
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value], objectStack, ['value']);
|
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value], objectStack, ['value']);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2206,7 +2213,7 @@ ol.format.KML.writeExtendedData_ = function(node, namesAndValues, objectStack) {
|
|||||||
|
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_,
|
||||||
ol.format.KML.DATA_NODE_FACTORY_, [{name: names[i], value: values[i]}], objectStack);
|
ol.format.KML.DATA_NODE_FACTORY_, [{name: names[i], value: values[i]}], objectStack);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2260,7 +2267,7 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) {
|
|||||||
iconProperties['y'] = iconImageSize[1] - (origin[1] + size[1]);
|
iconProperties['y'] = iconImageSize[1] - (origin[1] + size[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anchor && anchor[0] !== 0 && anchor[1] !== size[1]) {
|
if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) {
|
||||||
var /** @type {ol.KMLVec2_} */ hotSpot = {
|
var /** @type {ol.KMLVec2_} */ hotSpot = {
|
||||||
x: anchor[0],
|
x: anchor[0],
|
||||||
xunits: ol.style.IconAnchorUnits.PIXELS,
|
xunits: ol.style.IconAnchorUnits.PIXELS,
|
||||||
@@ -2420,7 +2427,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
|
|||||||
var sequence = ol.xml.makeSequence(properties, keys);
|
var sequence = ol.xml.makeSequence(properties, keys);
|
||||||
var namesAndValues = {names: keys, values: sequence};
|
var namesAndValues = {names: keys, values: sequence};
|
||||||
ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_,
|
ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_,
|
||||||
ol.format.KML.EXTENDEDDATA_NODE_FACTORY_, [namesAndValues], objectStack);
|
ol.format.KML.EXTENDEDDATA_NODE_FACTORY_, [namesAndValues], objectStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
var styleFunction = feature.getStyleFunction();
|
var styleFunction = feature.getStyleFunction();
|
||||||
@@ -2468,10 +2475,16 @@ ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
|
|||||||
var /** @type {ol.XmlNodeStackItem} */ context = {node: node};
|
var /** @type {ol.XmlNodeStackItem} */ context = {node: node};
|
||||||
context['layout'] = geometry.getLayout();
|
context['layout'] = geometry.getLayout();
|
||||||
context['stride'] = geometry.getStride();
|
context['stride'] = geometry.getStride();
|
||||||
ol.xml.pushSerializeAndPop(context,
|
|
||||||
ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_,
|
// serialize properties (properties unknown to KML are not serialized)
|
||||||
ol.format.KML.COORDINATES_NODE_FACTORY_,
|
var properties = geometry.getProperties();
|
||||||
[flatCoordinates], objectStack);
|
properties.coordinates = flatCoordinates;
|
||||||
|
|
||||||
|
var parentNode = objectStack[objectStack.length - 1].node;
|
||||||
|
var orderedKeys = ol.format.KML.PRIMITIVE_GEOMETRY_SEQUENCE_[parentNode.namespaceURI];
|
||||||
|
var values = ol.xml.makeSequence(properties, orderedKeys);
|
||||||
|
ol.xml.pushSerializeAndPop(context, ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_,
|
||||||
|
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -2632,7 +2645,6 @@ ol.format.KML.GEOMETRY_TYPE_TO_NODENAME_ = {
|
|||||||
'GeometryCollection': 'MultiGeometry'
|
'GeometryCollection': 'MultiGeometry'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Object.<string, Array.<string>>}
|
* @type {Object.<string, Array.<string>>}
|
||||||
@@ -2808,6 +2820,17 @@ ol.format.KML.PLACEMARK_SERIALIZERS_ = ol.xml.makeStructureNS(
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {Object.<string, Array.<string>>}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.format.KML.PRIMITIVE_GEOMETRY_SEQUENCE_ = ol.xml.makeStructureNS(
|
||||||
|
ol.format.KML.NAMESPACE_URIS_, [
|
||||||
|
'extrude', 'tessellate', 'altitudeMode', 'coordinates'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
|
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
|
||||||
@@ -2815,6 +2838,9 @@ ol.format.KML.PLACEMARK_SERIALIZERS_ = ol.xml.makeStructureNS(
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS(
|
ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS(
|
||||||
ol.format.KML.NAMESPACE_URIS_, {
|
ol.format.KML.NAMESPACE_URIS_, {
|
||||||
|
'extrude': ol.xml.makeChildAppender(ol.format.XSD.writeBooleanTextNode),
|
||||||
|
'tessellate': ol.xml.makeChildAppender(ol.format.XSD.writeBooleanTextNode),
|
||||||
|
'altitudeMode': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode),
|
||||||
'coordinates': ol.xml.makeChildAppender(
|
'coordinates': ol.xml.makeChildAppender(
|
||||||
ol.format.KML.writeCoordinatesTextNode_)
|
ol.format.KML.writeCoordinatesTextNode_)
|
||||||
});
|
});
|
||||||
@@ -2926,16 +2952,6 @@ ol.format.KML.GEOMETRY_NODE_FACTORY_ = function(value, objectStack,
|
|||||||
ol.format.KML.COLOR_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('color');
|
ol.format.KML.COLOR_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('color');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A factory for creating coordinates nodes.
|
|
||||||
* @const
|
|
||||||
* @type {function(*, Array.<*>, string=): (Node|undefined)}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.format.KML.COORDINATES_NODE_FACTORY_ =
|
|
||||||
ol.xml.makeSimpleNodeFactory('coordinates');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory for creating Data nodes.
|
* A factory for creating Data nodes.
|
||||||
* @const
|
* @const
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ ol.format.MVT = function(opt_options) {
|
|||||||
* (Array.<number>|Array.<Array.<number>>),Object.<string,*>,number)}
|
* (Array.<number>|Array.<Array.<number>>),Object.<string,*>,number)}
|
||||||
*/
|
*/
|
||||||
this.featureClass_ = options.featureClass ?
|
this.featureClass_ = options.featureClass ?
|
||||||
options.featureClass : ol.render.Feature;
|
options.featureClass : ol.render.Feature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -69,10 +69,25 @@ ol.format.MVT = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.layers_ = options.layers ? options.layers : null;
|
this.layers_ = options.layers ? options.layers : null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Extent}
|
||||||
|
*/
|
||||||
|
this.extent_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.MVT, ol.format.Feature);
|
ol.inherits(ol.format.MVT, ol.format.Feature);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.format.MVT.prototype.getLastExtent = function() {
|
||||||
|
return this.extent_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -124,7 +139,7 @@ ol.format.MVT.prototype.readRenderFeature_ = function(rawFeature, layer) {
|
|||||||
var geometryType;
|
var geometryType;
|
||||||
if (type === 1) {
|
if (type === 1) {
|
||||||
geometryType = coords.length === 1 ?
|
geometryType = coords.length === 1 ?
|
||||||
ol.geom.GeometryType.POINT : ol.geom.GeometryType.MULTI_POINT;
|
ol.geom.GeometryType.POINT : ol.geom.GeometryType.MULTI_POINT;
|
||||||
} else if (type === 2) {
|
} else if (type === 2) {
|
||||||
if (coords.length === 1) {
|
if (coords.length === 1) {
|
||||||
geometryType = ol.geom.GeometryType.LINE_STRING;
|
geometryType = ol.geom.GeometryType.LINE_STRING;
|
||||||
@@ -161,14 +176,17 @@ ol.format.MVT.prototype.readFeatures = function(source, opt_options) {
|
|||||||
}
|
}
|
||||||
layer = tile.layers[name];
|
layer = tile.layers[name];
|
||||||
|
|
||||||
|
var rawFeature;
|
||||||
for (var i = 0, ii = layer.length; i < ii; ++i) {
|
for (var i = 0, ii = layer.length; i < ii; ++i) {
|
||||||
|
rawFeature = layer.feature(i);
|
||||||
if (featureClass === ol.render.Feature) {
|
if (featureClass === ol.render.Feature) {
|
||||||
feature = this.readRenderFeature_(layer.feature(i), name);
|
feature = this.readRenderFeature_(rawFeature, name);
|
||||||
} else {
|
} else {
|
||||||
feature = this.readFeature_(layer.feature(i), name, opt_options);
|
feature = this.readFeature_(rawFeature, name, opt_options);
|
||||||
}
|
}
|
||||||
features.push(feature);
|
features.push(feature);
|
||||||
}
|
}
|
||||||
|
this.extent_ = layer ? [0, 0, layer.extent, layer.extent] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return features;
|
return features;
|
||||||
@@ -238,7 +256,7 @@ ol.format.MVT.readGeometry_ = function(rawFeature) {
|
|||||||
var geom;
|
var geom;
|
||||||
if (type === 1) {
|
if (type === 1) {
|
||||||
geom = coords.length === 1 ?
|
geom = coords.length === 1 ?
|
||||||
new ol.geom.Point(null) : new ol.geom.MultiPoint(null);
|
new ol.geom.Point(null) : new ol.geom.MultiPoint(null);
|
||||||
} else if (type === 2) {
|
} else if (type === 2) {
|
||||||
if (coords.length === 1) {
|
if (coords.length === 1) {
|
||||||
geom = new ol.geom.LineString(null);
|
geom = new ol.geom.LineString(null);
|
||||||
|
|||||||
@@ -386,13 +386,13 @@ ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeStructureNS(
|
|||||||
*/
|
*/
|
||||||
ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
|
ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
|
||||||
ol.xml.makeStructureNS(
|
ol.xml.makeStructureNS(
|
||||||
ol.format.OWS.NAMESPACE_URIS_, {
|
ol.format.OWS.NAMESPACE_URIS_, {
|
||||||
'IndividualName': ol.xml.makeObjectPropertySetter(
|
'IndividualName': ol.xml.makeObjectPropertySetter(
|
||||||
ol.format.XSD.readString),
|
ol.format.XSD.readString),
|
||||||
'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||||
'ContactInfo': ol.xml.makeObjectPropertySetter(
|
'ContactInfo': ol.xml.makeObjectPropertySetter(
|
||||||
ol.format.OWS.readContactInfo_)
|
ol.format.OWS.readContactInfo_)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -402,12 +402,12 @@ ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
|
|||||||
*/
|
*/
|
||||||
ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
|
ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
|
||||||
ol.xml.makeStructureNS(
|
ol.xml.makeStructureNS(
|
||||||
ol.format.OWS.NAMESPACE_URIS_, {
|
ol.format.OWS.NAMESPACE_URIS_, {
|
||||||
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||||
'ServiceTypeVersion': ol.xml.makeObjectPropertySetter(
|
'ServiceTypeVersion': ol.xml.makeObjectPropertySetter(
|
||||||
ol.format.XSD.readString),
|
ol.format.XSD.readString),
|
||||||
'ServiceType': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
|
'ServiceType': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -417,9 +417,9 @@ ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
|
|||||||
*/
|
*/
|
||||||
ol.format.OWS.SERVICE_PROVIDER_PARSERS_ =
|
ol.format.OWS.SERVICE_PROVIDER_PARSERS_ =
|
||||||
ol.xml.makeStructureNS(
|
ol.xml.makeStructureNS(
|
||||||
ol.format.OWS.NAMESPACE_URIS_, {
|
ol.format.OWS.NAMESPACE_URIS_, {
|
||||||
'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||||
'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref),
|
'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref),
|
||||||
'ServiceContact': ol.xml.makeObjectPropertySetter(
|
'ServiceContact': ol.xml.makeObjectPropertySetter(
|
||||||
ol.format.OWS.readServiceContact_)
|
ol.format.OWS.readServiceContact_)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ ol.format.Polyline = function(opt_options) {
|
|||||||
* @type {ol.geom.GeometryLayout}
|
* @type {ol.geom.GeometryLayout}
|
||||||
*/
|
*/
|
||||||
this.geometryLayout_ = options.geometryLayout ?
|
this.geometryLayout_ = options.geometryLayout ?
|
||||||
options.geometryLayout : ol.geom.GeometryLayout.XY;
|
options.geometryLayout : ol.geom.GeometryLayout.XY;
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.Polyline, ol.format.TextFeature);
|
ol.inherits(ol.format.Polyline, ol.format.TextFeature);
|
||||||
|
|
||||||
@@ -332,9 +332,9 @@ ol.format.Polyline.prototype.readGeometryFromText = function(text, opt_options)
|
|||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
|
|
||||||
return /** @type {ol.geom.Geometry} */ (
|
return /** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(
|
ol.format.Feature.transformWithOptions(
|
||||||
new ol.geom.LineString(coordinates, this.geometryLayout_), false,
|
new ol.geom.LineString(coordinates, this.geometryLayout_), false,
|
||||||
this.adaptOptions(opt_options)));
|
this.adaptOptions(opt_options)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -388,8 +388,8 @@ ol.format.Polyline.prototype.writeGeometry;
|
|||||||
*/
|
*/
|
||||||
ol.format.Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
|
ol.format.Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
|
||||||
geometry = /** @type {ol.geom.LineString} */
|
geometry = /** @type {ol.geom.LineString} */
|
||||||
(ol.format.Feature.transformWithOptions(
|
(ol.format.Feature.transformWithOptions(
|
||||||
geometry, true, this.adaptOptions(opt_options)));
|
geometry, true, this.adaptOptions(opt_options)));
|
||||||
var flatCoordinates = geometry.getFlatCoordinates();
|
var flatCoordinates = geometry.getFlatCoordinates();
|
||||||
var stride = geometry.getStride();
|
var stride = geometry.getStride();
|
||||||
ol.geom.flat.flip.flipXY(
|
ol.geom.flat.flip.flipXY(
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ ol.format.TopoJSON = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.defaultDataProjection = ol.proj.get(
|
this.defaultDataProjection = ol.proj.get(
|
||||||
options.defaultDataProjection ?
|
options.defaultDataProjection ?
|
||||||
options.defaultDataProjection : 'EPSG:4326');
|
options.defaultDataProjection : 'EPSG:4326');
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.TopoJSON, ol.format.JSONFeature);
|
ol.inherits(ol.format.TopoJSON, ol.format.JSONFeature);
|
||||||
@@ -259,7 +259,7 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
|||||||
}
|
}
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.setGeometry(/** @type {ol.geom.Geometry} */ (
|
feature.setGeometry(/** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(geometry, false, opt_options)));
|
ol.format.Feature.transformWithOptions(geometry, false, opt_options)));
|
||||||
if (object.id !== undefined) {
|
if (object.id !== undefined) {
|
||||||
feature.setId(object.id);
|
feature.setId(object.id);
|
||||||
}
|
}
|
||||||
@@ -316,13 +316,13 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function(
|
|||||||
}
|
}
|
||||||
if (topoJSONFeatures[objectName].type === 'GeometryCollection') {
|
if (topoJSONFeatures[objectName].type === 'GeometryCollection') {
|
||||||
feature = /** @type {TopoJSONGeometryCollection} */
|
feature = /** @type {TopoJSONGeometryCollection} */
|
||||||
(topoJSONFeatures[objectName]);
|
(topoJSONFeatures[objectName]);
|
||||||
features.push.apply(features,
|
features.push.apply(features,
|
||||||
ol.format.TopoJSON.readFeaturesFromGeometryCollection_(
|
ol.format.TopoJSON.readFeaturesFromGeometryCollection_(
|
||||||
feature, arcs, scale, translate, property, objectName, opt_options));
|
feature, arcs, scale, translate, property, objectName, opt_options));
|
||||||
} else {
|
} else {
|
||||||
feature = /** @type {TopoJSONGeometry} */
|
feature = /** @type {TopoJSONGeometry} */
|
||||||
(topoJSONFeatures[objectName]);
|
(topoJSONFeatures[objectName]);
|
||||||
features.push(ol.format.TopoJSON.readFeatureFromGeometry_(
|
features.push(ol.format.TopoJSON.readFeatureFromGeometry_(
|
||||||
feature, arcs, scale, translate, property, objectName, opt_options));
|
feature, arcs, scale, translate, property, objectName, opt_options));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ ol.format.WFS = function(opt_options) {
|
|||||||
* @type {ol.format.GMLBase}
|
* @type {ol.format.GMLBase}
|
||||||
*/
|
*/
|
||||||
this.gmlFormat_ = options.gmlFormat ?
|
this.gmlFormat_ = options.gmlFormat ?
|
||||||
options.gmlFormat : new ol.format.GML3();
|
options.gmlFormat : new ol.format.GML3();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.schemaLocation_ = options.schemaLocation ?
|
this.schemaLocation_ = options.schemaLocation ?
|
||||||
options.schemaLocation :
|
options.schemaLocation :
|
||||||
ol.format.WFS.SCHEMA_LOCATIONS[ol.format.WFS.DEFAULT_VERSION];
|
ol.format.WFS.SCHEMA_LOCATIONS[ol.format.WFS.DEFAULT_VERSION];
|
||||||
|
|
||||||
ol.format.XMLFeature.call(this);
|
ol.format.XMLFeature.call(this);
|
||||||
};
|
};
|
||||||
@@ -414,7 +414,7 @@ ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WFS.getTypeName_ = function(featurePrefix, featureType) {
|
ol.format.WFS.getTypeName_ = function(featurePrefix, featureType) {
|
||||||
featurePrefix = featurePrefix ? featurePrefix :
|
featurePrefix = featurePrefix ? featurePrefix :
|
||||||
ol.format.WFS.FEATURE_PREFIX;
|
ol.format.WFS.FEATURE_PREFIX;
|
||||||
var prefix = featurePrefix + ':';
|
var prefix = featurePrefix + ':';
|
||||||
// The featureType already contains the prefix.
|
// The featureType already contains the prefix.
|
||||||
if (featureType.indexOf(prefix) === 0) {
|
if (featureType.indexOf(prefix) === 0) {
|
||||||
@@ -477,9 +477,9 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
|||||||
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (
|
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (
|
||||||
{'gmlVersion': context['gmlVersion'], node: node,
|
{'gmlVersion': context['gmlVersion'], node: node,
|
||||||
'hasZ': context['hasZ'], 'srsName': context['srsName']}),
|
'hasZ': context['hasZ'], 'srsName': context['srsName']}),
|
||||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||||
ol.xml.makeSimpleNodeFactory('Property'), values,
|
ol.xml.makeSimpleNodeFactory('Property'), values,
|
||||||
objectStack);
|
objectStack);
|
||||||
ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack);
|
ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -688,12 +688,14 @@ ol.format.WFS.writeDuringFilter_ = function(node, filter, objectStack) {
|
|||||||
ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
|
ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
|
||||||
/** @type {ol.XmlNodeStackItem} */
|
/** @type {ol.XmlNodeStackItem} */
|
||||||
var item = {node: node};
|
var item = {node: node};
|
||||||
filter.conditions.forEach(function(condition) {
|
var conditions = filter.conditions;
|
||||||
|
for (var i = 0, ii = conditions.length; i < ii; ++i) {
|
||||||
|
var condition = conditions[i];
|
||||||
ol.xml.pushSerializeAndPop(item,
|
ol.xml.pushSerializeAndPop(item,
|
||||||
ol.format.WFS.GETFEATURE_SERIALIZERS_,
|
ol.format.WFS.GETFEATURE_SERIALIZERS_,
|
||||||
ol.xml.makeSimpleNodeFactory(condition.getTagName()),
|
ol.xml.makeSimpleNodeFactory(condition.getTagName()),
|
||||||
[condition], objectStack);
|
[condition], objectStack);
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -964,7 +966,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
var objectStack = [];
|
var objectStack = [];
|
||||||
var node = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Transaction');
|
var node = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Transaction');
|
||||||
var version = options.version ?
|
var version = options.version ?
|
||||||
options.version : ol.format.WFS.DEFAULT_VERSION;
|
options.version : ol.format.WFS.DEFAULT_VERSION;
|
||||||
var gmlVersion = version === '1.0.0' ? 2 : 3;
|
var gmlVersion = version === '1.0.0' ? 2 : 3;
|
||||||
node.setAttribute('service', 'WFS');
|
node.setAttribute('service', 'WFS');
|
||||||
node.setAttribute('version', version);
|
node.setAttribute('version', version);
|
||||||
@@ -980,9 +982,10 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
var schemaLocation = ol.format.WFS.SCHEMA_LOCATIONS[version];
|
var schemaLocation = ol.format.WFS.SCHEMA_LOCATIONS[version];
|
||||||
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'xsi:schemaLocation', schemaLocation);
|
'xsi:schemaLocation', schemaLocation);
|
||||||
|
var featurePrefix = options.featurePrefix ? options.featurePrefix : ol.format.WFS.FEATURE_PREFIX;
|
||||||
if (inserts) {
|
if (inserts) {
|
||||||
obj = {node: node, 'featureNS': options.featureNS,
|
obj = {node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
||||||
ol.obj.assign(obj, baseObj);
|
ol.obj.assign(obj, baseObj);
|
||||||
ol.xml.pushSerializeAndPop(obj,
|
ol.xml.pushSerializeAndPop(obj,
|
||||||
@@ -992,7 +995,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
}
|
}
|
||||||
if (updates) {
|
if (updates) {
|
||||||
obj = {node: node, 'featureNS': options.featureNS,
|
obj = {node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
||||||
ol.obj.assign(obj, baseObj);
|
ol.obj.assign(obj, baseObj);
|
||||||
ol.xml.pushSerializeAndPop(obj,
|
ol.xml.pushSerializeAndPop(obj,
|
||||||
@@ -1002,7 +1005,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
}
|
}
|
||||||
if (deletes) {
|
if (deletes) {
|
||||||
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
||||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||||
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
|
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
|
||||||
@@ -1010,7 +1013,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
}
|
}
|
||||||
if (options.nativeElements) {
|
if (options.nativeElements) {
|
||||||
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
||||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||||
ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements,
|
ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ ol.format.WKT = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.splitCollection_ = options.splitCollection !== undefined ?
|
this.splitCollection_ = options.splitCollection !== undefined ?
|
||||||
options.splitCollection : false;
|
options.splitCollection : false;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.WKT, ol.format.TextFeature);
|
ol.inherits(ol.format.WKT, ol.format.TextFeature);
|
||||||
@@ -330,7 +330,7 @@ ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) {
|
|||||||
var geometry = this.parse_(text);
|
var geometry = this.parse_(text);
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
return /** @type {ol.geom.Geometry} */ (
|
return /** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(geometry, false, opt_options));
|
ol.format.Feature.transformWithOptions(geometry, false, opt_options));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ ol.format.WKT.prototype.writeGeometry;
|
|||||||
*/
|
*/
|
||||||
ol.format.WKT.prototype.writeGeometryText = function(geometry, opt_options) {
|
ol.format.WKT.prototype.writeGeometryText = function(geometry, opt_options) {
|
||||||
return ol.format.WKT.encode_(/** @type {ol.geom.Geometry} */ (
|
return ol.format.WKT.encode_(/** @type {ol.geom.Geometry} */ (
|
||||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)));
|
ol.format.Feature.transformWithOptions(geometry, true, opt_options)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ ol.format.WKT.Lexer.prototype.readNumber_ = function() {
|
|||||||
}
|
}
|
||||||
c = this.nextChar_();
|
c = this.nextChar_();
|
||||||
} while (
|
} while (
|
||||||
this.isNumeric_(c, decimal) ||
|
this.isNumeric_(c, decimal) ||
|
||||||
// if we haven't detected a scientific number before, 'e' or 'E'
|
// if we haven't detected a scientific number before, 'e' or 'E'
|
||||||
// hint that we should continue to read
|
// hint that we should continue to read
|
||||||
!scientificNotation && (c == 'e' || c == 'E') ||
|
!scientificNotation && (c == 'e' || c == 'E') ||
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -110,9 +110,9 @@ ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectStack) {
|
||||||
var geographicBoundingBox = ol.xml.pushParseAndPop(
|
var geographicBoundingBox = ol.xml.pushParseAndPop(
|
||||||
{},
|
{},
|
||||||
ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_,
|
ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_,
|
||||||
node, objectStack);
|
node, objectStack);
|
||||||
if (!geographicBoundingBox) {
|
if (!geographicBoundingBox) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectSt
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -167,8 +167,8 @@ ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
|
{}, ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
|
||||||
node, objectStack);
|
node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -180,8 +180,8 @@ ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack)
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_,
|
{}, ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_,
|
||||||
node, objectStack);
|
node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -193,8 +193,8 @@ ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
|
{}, ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
|
||||||
node, objectStack);
|
node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
[], ol.format.WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
|
[], ol.format.WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
|||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
|
|
||||||
var layerObject = ol.xml.pushParseAndPop(
|
var layerObject = ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||||
|
|
||||||
if (!layerObject) {
|
if (!layerObject) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -246,7 +246,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
|||||||
layerObject['queryable'] = queryable !== undefined ? queryable : false;
|
layerObject['queryable'] = queryable !== undefined ? queryable : false;
|
||||||
|
|
||||||
var cascaded = ol.format.XSD.readNonNegativeIntegerString(
|
var cascaded = ol.format.XSD.readNonNegativeIntegerString(
|
||||||
node.getAttribute('cascaded'));
|
node.getAttribute('cascaded'));
|
||||||
if (cascaded === undefined) {
|
if (cascaded === undefined) {
|
||||||
cascaded = parentLayerObject['cascaded'];
|
cascaded = parentLayerObject['cascaded'];
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
|||||||
}
|
}
|
||||||
layerObject['fixedHeight'] = fixedHeight;
|
layerObject['fixedHeight'] = fixedHeight;
|
||||||
|
|
||||||
// See 7.2.4.8
|
// See 7.2.4.8
|
||||||
var addKeys = ['Style', 'CRS', 'AuthorityURL'];
|
var addKeys = ['Style', 'CRS', 'AuthorityURL'];
|
||||||
addKeys.forEach(function(key) {
|
addKeys.forEach(function(key) {
|
||||||
if (key in parentLayerObject) {
|
if (key in parentLayerObject) {
|
||||||
@@ -314,9 +314,9 @@ ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) {
|
|||||||
'unitSymbol': node.getAttribute('unitSymbol'),
|
'unitSymbol': node.getAttribute('unitSymbol'),
|
||||||
'default': node.getAttribute('default'),
|
'default': node.getAttribute('default'),
|
||||||
'multipleValues': ol.format.XSD.readBooleanString(
|
'multipleValues': ol.format.XSD.readBooleanString(
|
||||||
node.getAttribute('multipleValues')),
|
node.getAttribute('multipleValues')),
|
||||||
'nearestValue': ol.format.XSD.readBooleanString(
|
'nearestValue': ol.format.XSD.readBooleanString(
|
||||||
node.getAttribute('nearestValue')),
|
node.getAttribute('nearestValue')),
|
||||||
'current': ol.format.XSD.readBooleanString(node.getAttribute('current')),
|
'current': ol.format.XSD.readBooleanString(node.getAttribute('current')),
|
||||||
'values': ol.format.XSD.readString(node)
|
'values': ol.format.XSD.readString(node)
|
||||||
};
|
};
|
||||||
@@ -332,8 +332,8 @@ ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
|
{}, ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
|
||||||
node, objectStack);
|
node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.HTTP_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.HTTP_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -448,7 +448,7 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
{}, ol.format.WMSCapabilities.STYLE_PARSERS_, node, objectStack);
|
{}, ol.format.WMSCapabilities.STYLE_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMSCapabilities.readKeywordList_ = function(node, objectStack) {
|
ol.format.WMSCapabilities.readKeywordList_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop(
|
return ol.xml.pushParseAndPop(
|
||||||
[], ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
|
[], ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
|
|||||||
}
|
}
|
||||||
WMTSCapabilityObject['version'] = version;
|
WMTSCapabilityObject['version'] = version;
|
||||||
WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject,
|
WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject,
|
||||||
ol.format.WMTSCapabilities.PARSERS_, node, []);
|
ol.format.WMTSCapabilities.PARSERS_, node, []);
|
||||||
return WMTSCapabilityObject ? WMTSCapabilityObject : null;
|
return WMTSCapabilityObject ? WMTSCapabilityObject : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.WMTSCapabilities.CONTENTS_PARSERS_, node, objectStack);
|
ol.format.WMTSCapabilities.CONTENTS_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
|||||||
*/
|
*/
|
||||||
ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) {
|
ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) {
|
||||||
return ol.xml.pushParseAndPop({},
|
return ol.xml.pushParseAndPop({},
|
||||||
ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack);
|
ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,16 @@
|
|||||||
goog.provide('ol.Geolocation');
|
goog.provide('ol.Geolocation');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
|
||||||
goog.require('ol.GeolocationProperty');
|
goog.require('ol.GeolocationProperty');
|
||||||
|
goog.require('ol.Object');
|
||||||
|
goog.require('ol.Sphere');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.has');
|
goog.require('ol.has');
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.sphere.WGS84');
|
goog.require('ol.proj.EPSG4326');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,6 +60,12 @@ ol.Geolocation = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.transform_ = ol.proj.identityTransform;
|
this.transform_ = ol.proj.identityTransform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Sphere}
|
||||||
|
*/
|
||||||
|
this.sphere_ = new ol.Sphere(ol.proj.EPSG4326.RADIUS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
@@ -140,9 +147,9 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
|
|||||||
coords.altitude === null ? undefined : coords.altitude);
|
coords.altitude === null ? undefined : coords.altitude);
|
||||||
this.set(ol.GeolocationProperty.ALTITUDE_ACCURACY,
|
this.set(ol.GeolocationProperty.ALTITUDE_ACCURACY,
|
||||||
coords.altitudeAccuracy === null ?
|
coords.altitudeAccuracy === null ?
|
||||||
undefined : coords.altitudeAccuracy);
|
undefined : coords.altitudeAccuracy);
|
||||||
this.set(ol.GeolocationProperty.HEADING, coords.heading === null ?
|
this.set(ol.GeolocationProperty.HEADING, coords.heading === null ?
|
||||||
undefined : ol.math.toRadians(coords.heading));
|
undefined : ol.math.toRadians(coords.heading));
|
||||||
if (!this.position_) {
|
if (!this.position_) {
|
||||||
this.position_ = [coords.longitude, coords.latitude];
|
this.position_ = [coords.longitude, coords.latitude];
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +161,7 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
|
|||||||
this.set(ol.GeolocationProperty.SPEED,
|
this.set(ol.GeolocationProperty.SPEED,
|
||||||
coords.speed === null ? undefined : coords.speed);
|
coords.speed === null ? undefined : coords.speed);
|
||||||
var geometry = ol.geom.Polygon.circular(
|
var geometry = ol.geom.Polygon.circular(
|
||||||
ol.sphere.WGS84, this.position_, coords.accuracy);
|
this.sphere_, this.position_, coords.accuracy);
|
||||||
geometry.applyTransform(this.transform_);
|
geometry.applyTransform(this.transform_);
|
||||||
this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry);
|
this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry);
|
||||||
this.changed();
|
this.changed();
|
||||||
@@ -186,7 +193,7 @@ ol.Geolocation.prototype.positionError_ = function(error) {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getAccuracy = function() {
|
ol.Geolocation.prototype.getAccuracy = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.ACCURACY));
|
this.get(ol.GeolocationProperty.ACCURACY));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -198,7 +205,7 @@ ol.Geolocation.prototype.getAccuracy = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getAccuracyGeometry = function() {
|
ol.Geolocation.prototype.getAccuracyGeometry = function() {
|
||||||
return /** @type {?ol.geom.Polygon} */ (
|
return /** @type {?ol.geom.Polygon} */ (
|
||||||
this.get(ol.GeolocationProperty.ACCURACY_GEOMETRY) || null);
|
this.get(ol.GeolocationProperty.ACCURACY_GEOMETRY) || null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -211,7 +218,7 @@ ol.Geolocation.prototype.getAccuracyGeometry = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getAltitude = function() {
|
ol.Geolocation.prototype.getAltitude = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.ALTITUDE));
|
this.get(ol.GeolocationProperty.ALTITUDE));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -224,7 +231,7 @@ ol.Geolocation.prototype.getAltitude = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getAltitudeAccuracy = function() {
|
ol.Geolocation.prototype.getAltitudeAccuracy = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.ALTITUDE_ACCURACY));
|
this.get(ol.GeolocationProperty.ALTITUDE_ACCURACY));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -236,7 +243,7 @@ ol.Geolocation.prototype.getAltitudeAccuracy = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getHeading = function() {
|
ol.Geolocation.prototype.getHeading = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.HEADING));
|
this.get(ol.GeolocationProperty.HEADING));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -249,7 +256,7 @@ ol.Geolocation.prototype.getHeading = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getPosition = function() {
|
ol.Geolocation.prototype.getPosition = function() {
|
||||||
return /** @type {ol.Coordinate|undefined} */ (
|
return /** @type {ol.Coordinate|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.POSITION));
|
this.get(ol.GeolocationProperty.POSITION));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -262,7 +269,7 @@ ol.Geolocation.prototype.getPosition = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getProjection = function() {
|
ol.Geolocation.prototype.getProjection = function() {
|
||||||
return /** @type {ol.proj.Projection|undefined} */ (
|
return /** @type {ol.proj.Projection|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.PROJECTION));
|
this.get(ol.GeolocationProperty.PROJECTION));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -275,7 +282,7 @@ ol.Geolocation.prototype.getProjection = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getSpeed = function() {
|
ol.Geolocation.prototype.getSpeed = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.SPEED));
|
this.get(ol.GeolocationProperty.SPEED));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -287,7 +294,7 @@ ol.Geolocation.prototype.getSpeed = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getTracking = function() {
|
ol.Geolocation.prototype.getTracking = function() {
|
||||||
return /** @type {boolean} */ (
|
return /** @type {boolean} */ (
|
||||||
this.get(ol.GeolocationProperty.TRACKING));
|
this.get(ol.GeolocationProperty.TRACKING));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -302,7 +309,7 @@ ol.Geolocation.prototype.getTracking = function() {
|
|||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.getTrackingOptions = function() {
|
ol.Geolocation.prototype.getTrackingOptions = function() {
|
||||||
return /** @type {GeolocationPositionOptions|undefined} */ (
|
return /** @type {GeolocationPositionOptions|undefined} */ (
|
||||||
this.get(ol.GeolocationProperty.TRACKING_OPTIONS));
|
this.get(ol.GeolocationProperty.TRACKING_OPTIONS));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ ol.geom.flat.geodesic.greatCircleArc = function(
|
|||||||
var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
|
var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
|
||||||
var lon = ol.math.toRadians(lon1) +
|
var lon = ol.math.toRadians(lon1) +
|
||||||
Math.atan2(Math.sin(theta) * sinD * cosLat1,
|
Math.atan2(Math.sin(theta) * sinD * cosLat1,
|
||||||
cosD - sinLat1 * Math.sin(lat));
|
cosD - sinLat1 * Math.sin(lat));
|
||||||
return [ol.math.toDegrees(lon), ol.math.toDegrees(lat)];
|
return [ol.math.toDegrees(lon), ol.math.toDegrees(lat)];
|
||||||
}, ol.proj.getTransform(geoProjection, projection), squaredTolerance);
|
}, ol.proj.getTransform(geoProjection, projection), squaredTolerance);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ ol.geom.flat.orient.orientLinearRings = function(flatCoordinates, offset, ends,
|
|||||||
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(
|
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(
|
||||||
flatCoordinates, offset, end, stride);
|
flatCoordinates, offset, end, stride);
|
||||||
var reverse = i === 0 ?
|
var reverse = i === 0 ?
|
||||||
(right && isClockwise) || (!right && !isClockwise) :
|
(right && isClockwise) || (!right && !isClockwise) :
|
||||||
(right && !isClockwise) || (!right && isClockwise);
|
(right && !isClockwise) || (!right && isClockwise);
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
ol.geom.flat.reverse.coordinates(flatCoordinates, offset, end, stride);
|
ol.geom.flat.reverse.coordinates(flatCoordinates, offset, end, stride);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ goog.require('ol.math');
|
|||||||
ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end,
|
ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
||||||
var simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ?
|
var simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ?
|
||||||
opt_simplifiedFlatCoordinates : [];
|
opt_simplifiedFlatCoordinates : [];
|
||||||
if (!highQuality) {
|
if (!highQuality) {
|
||||||
end = ol.geom.flat.simplify.radialDistance(flatCoordinates, offset, end,
|
end = ol.geom.flat.simplify.radialDistance(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance,
|
stride, squaredTolerance,
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ ol.geom.MultiPoint.prototype.getCoordinates = function() {
|
|||||||
*/
|
*/
|
||||||
ol.geom.MultiPoint.prototype.getPoint = function(index) {
|
ol.geom.MultiPoint.prototype.getPoint = function(index) {
|
||||||
var n = !this.flatCoordinates ?
|
var n = !this.flatCoordinates ?
|
||||||
0 : this.flatCoordinates.length / this.stride;
|
0 : this.flatCoordinates.length / this.stride;
|
||||||
if (index < 0 || n <= index) {
|
if (index < 0 || n <= index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ ol.geom.MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout
|
|||||||
} else {
|
} else {
|
||||||
var lastEnds = endss[endss.length - 1];
|
var lastEnds = endss[endss.length - 1];
|
||||||
this.flatCoordinates.length = lastEnds.length === 0 ?
|
this.flatCoordinates.length = lastEnds.length === 0 ?
|
||||||
0 : lastEnds[lastEnds.length - 1];
|
0 : lastEnds[lastEnds.length - 1];
|
||||||
}
|
}
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,89 +23,89 @@ goog.require('ol.style.Text');
|
|||||||
ol.Graticule = function(opt_options) {
|
ol.Graticule = function(opt_options) {
|
||||||
var options = opt_options || {};
|
var options = opt_options || {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Map}
|
* @type {ol.Map}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.map_ = null;
|
this.map_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.proj.Projection}
|
* @type {ol.proj.Projection}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.projection_ = null;
|
this.projection_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.maxLat_ = Infinity;
|
this.maxLat_ = Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.maxLon_ = Infinity;
|
this.maxLon_ = Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.minLat_ = -Infinity;
|
this.minLat_ = -Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.minLon_ = -Infinity;
|
this.minLon_ = -Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.maxLatP_ = Infinity;
|
this.maxLatP_ = Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.maxLonP_ = Infinity;
|
this.maxLonP_ = Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.minLatP_ = -Infinity;
|
this.minLatP_ = -Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.minLonP_ = -Infinity;
|
this.minLonP_ = -Infinity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.targetSize_ = options.targetSize !== undefined ?
|
this.targetSize_ = options.targetSize !== undefined ?
|
||||||
options.targetSize : 100;
|
options.targetSize : 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
|
this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array.<ol.geom.LineString>}
|
* @type {Array.<ol.geom.LineString>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.meridians_ = [];
|
this.meridians_ = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array.<ol.geom.LineString>}
|
* @type {Array.<ol.geom.LineString>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.parallels_ = [];
|
this.parallels_ = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +113,7 @@ ol.Graticule = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.strokeStyle_ = options.strokeStyle !== undefined ?
|
this.strokeStyle_ = options.strokeStyle !== undefined ?
|
||||||
options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_;
|
options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.TransformFunction|undefined}
|
* @type {ol.TransformFunction|undefined}
|
||||||
@@ -153,14 +153,14 @@ ol.Graticule = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.lonLabelFormatter_ = options.lonLabelFormatter == undefined ?
|
this.lonLabelFormatter_ = options.lonLabelFormatter == undefined ?
|
||||||
degreesToString.bind(this, 'EW') : options.lonLabelFormatter;
|
degreesToString.bind(this, 'EW') : options.lonLabelFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {function(number):string}
|
* @type {function(number):string}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.latLabelFormatter_ = options.latLabelFormatter == undefined ?
|
this.latLabelFormatter_ = options.latLabelFormatter == undefined ?
|
||||||
degreesToString.bind(this, 'NS') : options.latLabelFormatter;
|
degreesToString.bind(this, 'NS') : options.latLabelFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Longitude label position in fractions (0..1) of view extent. 0 means
|
* Longitude label position in fractions (0..1) of view extent. 0 means
|
||||||
@@ -169,7 +169,7 @@ ol.Graticule = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.lonLabelPosition_ = options.lonLabelPosition == undefined ? 0 :
|
this.lonLabelPosition_ = options.lonLabelPosition == undefined ? 0 :
|
||||||
options.lonLabelPosition;
|
options.lonLabelPosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Latitude Label position in fractions (0..1) of view extent. 0 means left, 1
|
* Latitude Label position in fractions (0..1) of view extent. 0 means left, 1
|
||||||
@@ -178,41 +178,41 @@ ol.Graticule = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.latLabelPosition_ = options.latLabelPosition == undefined ? 1 :
|
this.latLabelPosition_ = options.latLabelPosition == undefined ? 1 :
|
||||||
options.latLabelPosition;
|
options.latLabelPosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.style.Text}
|
* @type {ol.style.Text}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.lonLabelStyle_ = options.lonLabelStyle !== undefined ? options.lonLabelStyle :
|
this.lonLabelStyle_ = options.lonLabelStyle !== undefined ? options.lonLabelStyle :
|
||||||
new ol.style.Text({
|
new ol.style.Text({
|
||||||
font: '12px Calibri,sans-serif',
|
font: '12px Calibri,sans-serif',
|
||||||
textBaseline: 'bottom',
|
textBaseline: 'bottom',
|
||||||
fill: new ol.style.Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,0,0,1)'
|
color: 'rgba(0,0,0,1)'
|
||||||
}),
|
}),
|
||||||
stroke: new ol.style.Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgba(255,255,255,1)',
|
color: 'rgba(255,255,255,1)',
|
||||||
width: 3
|
width: 3
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.style.Text}
|
* @type {ol.style.Text}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.latLabelStyle_ = options.latLabelStyle !== undefined ? options.latLabelStyle :
|
this.latLabelStyle_ = options.latLabelStyle !== undefined ? options.latLabelStyle :
|
||||||
new ol.style.Text({
|
new ol.style.Text({
|
||||||
font: '12px Calibri,sans-serif',
|
font: '12px Calibri,sans-serif',
|
||||||
textAlign: 'end',
|
textAlign: 'end',
|
||||||
fill: new ol.style.Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,0,0,1)'
|
color: 'rgba(0,0,0,1)'
|
||||||
}),
|
}),
|
||||||
stroke: new ol.style.Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgba(255,255,255,1)',
|
color: 'rgba(255,255,255,1)',
|
||||||
width: 3
|
width: 3
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
this.meridiansLabels_ = [];
|
this.meridiansLabels_ = [];
|
||||||
this.parallelsLabels_ = [];
|
this.parallelsLabels_ = [];
|
||||||
@@ -283,7 +283,7 @@ ol.Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) {
|
|||||||
clampedBottom, clampedTop);
|
clampedBottom, clampedTop);
|
||||||
var coordinate = [flatCoordinates[0], lat];
|
var coordinate = [flatCoordinates[0], lat];
|
||||||
var point = this.meridiansLabels_[index] !== undefined ?
|
var point = this.meridiansLabels_[index] !== undefined ?
|
||||||
this.meridiansLabels_[index].geom : new ol.geom.Point(null);
|
this.meridiansLabels_[index].geom : new ol.geom.Point(null);
|
||||||
point.setCoordinates(coordinate);
|
point.setCoordinates(coordinate);
|
||||||
return point;
|
return point;
|
||||||
};
|
};
|
||||||
@@ -332,7 +332,7 @@ ol.Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) {
|
|||||||
clampedLeft, clampedRight);
|
clampedLeft, clampedRight);
|
||||||
var coordinate = [lon, flatCoordinates[1]];
|
var coordinate = [lon, flatCoordinates[1]];
|
||||||
var point = this.parallelsLabels_[index] !== undefined ?
|
var point = this.parallelsLabels_[index] !== undefined ?
|
||||||
this.parallelsLabels_[index].geom : new ol.geom.Point(null);
|
this.parallelsLabels_[index].geom : new ol.geom.Point(null);
|
||||||
point.setCoordinates(coordinate);
|
point.setCoordinates(coordinate);
|
||||||
return point;
|
return point;
|
||||||
};
|
};
|
||||||
@@ -487,11 +487,11 @@ ol.Graticule.prototype.getMap = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
|
ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
|
||||||
squaredTolerance, index) {
|
squaredTolerance, index) {
|
||||||
var flatCoordinates = ol.geom.flat.geodesic.meridian(lon,
|
var flatCoordinates = ol.geom.flat.geodesic.meridian(lon,
|
||||||
minLat, maxLat, this.projection_, squaredTolerance);
|
minLat, maxLat, this.projection_, squaredTolerance);
|
||||||
var lineString = this.meridians_[index] !== undefined ?
|
var lineString = this.meridians_[index] !== undefined ?
|
||||||
this.meridians_[index] : new ol.geom.LineString(null);
|
this.meridians_[index] : new ol.geom.LineString(null);
|
||||||
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
|
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
|
||||||
return lineString;
|
return lineString;
|
||||||
};
|
};
|
||||||
@@ -517,18 +517,18 @@ ol.Graticule.prototype.getMeridians = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
||||||
squaredTolerance, index) {
|
squaredTolerance, index) {
|
||||||
var flatCoordinates = ol.geom.flat.geodesic.parallel(lat,
|
var flatCoordinates = ol.geom.flat.geodesic.parallel(lat,
|
||||||
this.minLon_, this.maxLon_, this.projection_, squaredTolerance);
|
minLon, maxLon, this.projection_, squaredTolerance);
|
||||||
var lineString = this.parallels_[index] !== undefined ?
|
var lineString = this.parallels_[index] !== undefined ?
|
||||||
this.parallels_[index] : new ol.geom.LineString(null);
|
this.parallels_[index] : new ol.geom.LineString(null);
|
||||||
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
|
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
|
||||||
return lineString;
|
return lineString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of parallels. Pallels are lines of equal latitude.
|
* Get the list of parallels. Parallels are lines of equal latitude.
|
||||||
* @return {Array.<ol.geom.LineString>} The parallels.
|
* @return {Array.<ol.geom.LineString>} The parallels.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -560,23 +560,6 @@ ol.Graticule.prototype.handlePostCompose_ = function(e) {
|
|||||||
this.updateProjectionInfo_(projection);
|
this.updateProjectionInfo_(projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fix the extent if wrapped.
|
|
||||||
//(note: this is the same extent as vectorContext.extent_)
|
|
||||||
var offsetX = 0;
|
|
||||||
if (projection.canWrapX()) {
|
|
||||||
var projectionExtent = projection.getExtent();
|
|
||||||
var worldWidth = ol.extent.getWidth(projectionExtent);
|
|
||||||
var x = frameState.focus[0];
|
|
||||||
if (x < projectionExtent[0] || x > projectionExtent[2]) {
|
|
||||||
var worldsAway = Math.ceil((projectionExtent[0] - x) / worldWidth);
|
|
||||||
offsetX = worldWidth * worldsAway;
|
|
||||||
extent = [
|
|
||||||
extent[0] + offsetX, extent[1],
|
|
||||||
extent[2] + offsetX, extent[3]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.createGraticule_(extent, center, resolution, squaredTolerance);
|
this.createGraticule_(extent, center, resolution, squaredTolerance);
|
||||||
|
|
||||||
// Draw the lines
|
// Draw the lines
|
||||||
@@ -620,7 +603,7 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
|
|||||||
var extent = projection.getExtent();
|
var extent = projection.getExtent();
|
||||||
var worldExtent = projection.getWorldExtent();
|
var worldExtent = projection.getWorldExtent();
|
||||||
var worldExtentP = ol.proj.transformExtent(worldExtent,
|
var worldExtentP = ol.proj.transformExtent(worldExtent,
|
||||||
epsg4326Projection, projection);
|
epsg4326Projection, projection);
|
||||||
|
|
||||||
var maxLat = worldExtent[3];
|
var maxLat = worldExtent[3];
|
||||||
var maxLon = worldExtent[2];
|
var maxLon = worldExtent[2];
|
||||||
@@ -644,13 +627,13 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
|
|||||||
|
|
||||||
|
|
||||||
this.fromLonLatTransform_ = ol.proj.getTransform(
|
this.fromLonLatTransform_ = ol.proj.getTransform(
|
||||||
epsg4326Projection, projection);
|
epsg4326Projection, projection);
|
||||||
|
|
||||||
this.toLonLatTransform_ = ol.proj.getTransform(
|
this.toLonLatTransform_ = ol.proj.getTransform(
|
||||||
projection, epsg4326Projection);
|
projection, epsg4326Projection);
|
||||||
|
|
||||||
this.projectionCenterLonLat_ = this.toLonLatTransform_(
|
this.projectionCenterLonLat_ = this.toLonLatTransform_(
|
||||||
ol.extent.getCenter(extent));
|
ol.extent.getCenter(extent));
|
||||||
|
|
||||||
this.projection_ = projection;
|
this.projection_ = projection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl');
|
goog.require('ol.webgl');
|
||||||
|
|
||||||
var ua = typeof navigator !== 'undefined' ?
|
var ua = typeof navigator !== 'undefined' ?
|
||||||
navigator.userAgent.toLowerCase() : '';
|
navigator.userAgent.toLowerCase() : '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User agent string says we are dealing with Firefox as browser.
|
* User agent string says we are dealing with Firefox as browser.
|
||||||
@@ -56,27 +56,27 @@ ol.has.CANVAS_LINE_DASH = false;
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.has.CANVAS = ol.ENABLE_CANVAS && (
|
ol.has.CANVAS = ol.ENABLE_CANVAS && (
|
||||||
/**
|
/**
|
||||||
* @return {boolean} Canvas supported.
|
* @return {boolean} Canvas supported.
|
||||||
*/
|
*/
|
||||||
function() {
|
function() {
|
||||||
if (!('HTMLCanvasElement' in window)) {
|
if (!('HTMLCanvasElement' in window)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var context = document.createElement('CANVAS').getContext('2d');
|
||||||
|
if (!context) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
try {
|
if (context.setLineDash !== undefined) {
|
||||||
var context = document.createElement('CANVAS').getContext('2d');
|
ol.has.CANVAS_LINE_DASH = true;
|
||||||
if (!context) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (context.setLineDash !== undefined) {
|
|
||||||
ol.has.CANVAS_LINE_DASH = true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
})();
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +148,7 @@ ol.has.WEBGL;
|
|||||||
if (gl) {
|
if (gl) {
|
||||||
hasWebGL = true;
|
hasWebGL = true;
|
||||||
textureSize = /** @type {number} */
|
textureSize = /** @type {number} */
|
||||||
(gl.getParameter(gl.MAX_TEXTURE_SIZE));
|
(gl.getParameter(gl.MAX_TEXTURE_SIZE));
|
||||||
extensions = gl.getSupportedExtensions();
|
extensions = gl.getSupportedExtensions();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ ol.ImageCanvas = function(extent, resolution, pixelRatio, attributions,
|
|||||||
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
||||||
|
|
||||||
var state = opt_loader !== undefined ?
|
var state = opt_loader !== undefined ?
|
||||||
ol.ImageState.IDLE : ol.ImageState.LOADED;
|
ol.ImageState.IDLE : ol.ImageState.LOADED;
|
||||||
|
|
||||||
ol.ImageBase.call(this, extent, resolution, pixelRatio, state, attributions);
|
ol.ImageBase.call(this, extent, resolution, pixelRatio, state, attributions);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.provide('ol.ImageTile');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Tile');
|
goog.require('ol.Tile');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
|
goog.require('ol.dom');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Image}
|
* @type {Image|HTMLCanvasElement}
|
||||||
*/
|
*/
|
||||||
this.image_ = new Image();
|
this.image_ = new Image();
|
||||||
if (crossOrigin !== null) {
|
if (crossOrigin !== null) {
|
||||||
@@ -59,6 +60,7 @@ ol.inherits(ol.ImageTile, ol.Tile);
|
|||||||
ol.ImageTile.prototype.disposeInternal = function() {
|
ol.ImageTile.prototype.disposeInternal = function() {
|
||||||
if (this.state == ol.TileState.LOADING) {
|
if (this.state == ol.TileState.LOADING) {
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
|
this.image_.src = ol.ImageTile.blankImage.toDataURL('image/png');
|
||||||
}
|
}
|
||||||
if (this.interimTile) {
|
if (this.interimTile) {
|
||||||
this.interimTile.dispose();
|
this.interimTile.dispose();
|
||||||
@@ -94,8 +96,8 @@ ol.ImageTile.prototype.getKey = function() {
|
|||||||
*/
|
*/
|
||||||
ol.ImageTile.prototype.handleImageError_ = function() {
|
ol.ImageTile.prototype.handleImageError_ = function() {
|
||||||
this.state = ol.TileState.ERROR;
|
this.state = ol.TileState.ERROR;
|
||||||
this.image_ = ol.ImageTile.blankImage;
|
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
|
this.image_ = ol.ImageTile.blankImage;
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -148,7 +150,11 @@ ol.ImageTile.prototype.unlistenImage_ = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A blank image.
|
* A blank image.
|
||||||
* @type {Image}
|
* @type {HTMLCanvasElement}
|
||||||
*/
|
*/
|
||||||
ol.ImageTile.blankImage = new Image();
|
ol.ImageTile.blankImage = (function() {
|
||||||
ol.ImageTile.blankImage.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
var ctx = ol.dom.createCanvasContext2D(1, 1);
|
||||||
|
ctx.fillStyle = 'rgba(0,0,0,0)';
|
||||||
|
ctx.fillRect(0, 0, 1, 1);
|
||||||
|
return ctx.canvas;
|
||||||
|
})();
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ ol.interaction.defaults = function(opt_options) {
|
|||||||
var kinetic = new ol.Kinetic(-0.005, 0.05, 100);
|
var kinetic = new ol.Kinetic(-0.005, 0.05, 100);
|
||||||
|
|
||||||
var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
|
var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
|
||||||
options.altShiftDragRotate : true;
|
options.altShiftDragRotate : true;
|
||||||
if (altShiftDragRotate) {
|
if (altShiftDragRotate) {
|
||||||
interactions.push(new ol.interaction.DragRotate());
|
interactions.push(new ol.interaction.DragRotate());
|
||||||
}
|
}
|
||||||
|
|
||||||
var doubleClickZoom = options.doubleClickZoom !== undefined ?
|
var doubleClickZoom = options.doubleClickZoom !== undefined ?
|
||||||
options.doubleClickZoom : true;
|
options.doubleClickZoom : true;
|
||||||
if (doubleClickZoom) {
|
if (doubleClickZoom) {
|
||||||
interactions.push(new ol.interaction.DoubleClickZoom({
|
interactions.push(new ol.interaction.DoubleClickZoom({
|
||||||
delta: options.zoomDelta,
|
delta: options.zoomDelta,
|
||||||
@@ -67,7 +67,7 @@ ol.interaction.defaults = function(opt_options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
|
var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
|
||||||
true;
|
true;
|
||||||
if (pinchRotate) {
|
if (pinchRotate) {
|
||||||
interactions.push(new ol.interaction.PinchRotate());
|
interactions.push(new ol.interaction.PinchRotate());
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ ol.interaction.defaults = function(opt_options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
|
var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
|
||||||
options.mouseWheelZoom : true;
|
options.mouseWheelZoom : true;
|
||||||
if (mouseWheelZoom) {
|
if (mouseWheelZoom) {
|
||||||
interactions.push(new ol.interaction.MouseWheelZoom({
|
interactions.push(new ol.interaction.MouseWheelZoom({
|
||||||
constrainResolution: options.constrainResolution,
|
constrainResolution: options.constrainResolution,
|
||||||
@@ -99,7 +99,7 @@ ol.interaction.defaults = function(opt_options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var shiftDragZoom = options.shiftDragZoom !== undefined ?
|
var shiftDragZoom = options.shiftDragZoom !== undefined ?
|
||||||
options.shiftDragZoom : true;
|
options.shiftDragZoom : true;
|
||||||
if (shiftDragZoom) {
|
if (shiftDragZoom) {
|
||||||
interactions.push(new ol.interaction.DragZoom({
|
interactions.push(new ol.interaction.DragZoom({
|
||||||
duration: options.zoomDuration
|
duration: options.zoomDuration
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ ol.interaction.DragAndDrop = function(opt_options) {
|
|||||||
* @type {Array.<function(new: ol.format.Feature)>}
|
* @type {Array.<function(new: ol.format.Feature)>}
|
||||||
*/
|
*/
|
||||||
this.formatConstructors_ = options.formatConstructors ?
|
this.formatConstructors_ = options.formatConstructors ?
|
||||||
options.formatConstructors : [];
|
options.formatConstructors : [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.proj.Projection}
|
* @type {ol.proj.Projection}
|
||||||
*/
|
*/
|
||||||
this.projection_ = options.projection ?
|
this.projection_ = options.projection ?
|
||||||
ol.proj.get(options.projection) : null;
|
ol.proj.get(options.projection) : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -49,6 +49,12 @@ ol.interaction.DragAndDrop = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.dropListenKeys_ = null;
|
this.dropListenKeys_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.source.Vector}
|
||||||
|
*/
|
||||||
|
this.source_ = options.source || null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Element}
|
* @type {Element}
|
||||||
@@ -122,6 +128,10 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.source_) {
|
||||||
|
this.source_.clear();
|
||||||
|
this.source_.addFeatures(features);
|
||||||
|
}
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new ol.interaction.DragAndDrop.Event(
|
new ol.interaction.DragAndDrop.Event(
|
||||||
ol.interaction.DragAndDrop.EventType_.ADD_FEATURES, file,
|
ol.interaction.DragAndDrop.EventType_.ADD_FEATURES, file,
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ ol.interaction.DragBox = function(opt_options) {
|
|||||||
* @type {ol.EventsConditionType}
|
* @type {ol.EventsConditionType}
|
||||||
*/
|
*/
|
||||||
this.condition_ = options.condition ?
|
this.condition_ = options.condition ?
|
||||||
options.condition : ol.events.condition.always;
|
options.condition : ol.events.condition.always;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.DragBoxEndConditionType}
|
* @type {ol.DragBoxEndConditionType}
|
||||||
*/
|
*/
|
||||||
this.boxEndCondition_ = options.boxEndCondition ?
|
this.boxEndCondition_ = options.boxEndCondition ?
|
||||||
options.boxEndCondition : ol.interaction.DragBox.defaultBoxEndCondition;
|
options.boxEndCondition : ol.interaction.DragBox.defaultBoxEndCondition;
|
||||||
};
|
};
|
||||||
ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
|
ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ ol.interaction.DragBox.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
this.box_.setPixels(this.startPixel_, mapBrowserEvent.pixel);
|
this.box_.setPixels(this.startPixel_, mapBrowserEvent.pixel);
|
||||||
|
|
||||||
this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXDRAG,
|
this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXDRAG,
|
||||||
mapBrowserEvent.coordinate, mapBrowserEvent));
|
mapBrowserEvent.coordinate, mapBrowserEvent));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ ol.interaction.DragPan = function(opt_options) {
|
|||||||
* @type {ol.EventsConditionType}
|
* @type {ol.EventsConditionType}
|
||||||
*/
|
*/
|
||||||
this.condition_ = options.condition ?
|
this.condition_ = options.condition ?
|
||||||
options.condition : ol.events.condition.noModifierKeys;
|
options.condition : ol.events.condition.noModifierKeys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user