Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb9e13a3e5 | ||
|
|
d1b1444744 | ||
|
|
8992ed68f9 | ||
|
|
cb63b398d3 | ||
|
|
ce89a82e6a | ||
|
|
1c269d6e0b | ||
|
|
83b8fe4b33 |
@@ -2,7 +2,7 @@ version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:latest-browsers
|
||||
- image: circleci/node:10-browsers
|
||||
|
||||
working_directory: ~/repo
|
||||
|
||||
@@ -27,14 +27,6 @@ jobs:
|
||||
name: Run Tests
|
||||
command: npm test
|
||||
|
||||
- store_artifacts:
|
||||
path: coverage/
|
||||
destination: coverage
|
||||
|
||||
- store_artifacts:
|
||||
path: rendering/cases/
|
||||
destination: rendering
|
||||
|
||||
- run:
|
||||
name: Build Examples
|
||||
command: npm run build-examples
|
||||
@@ -42,19 +34,3 @@ jobs:
|
||||
- store_artifacts:
|
||||
path: build/examples
|
||||
destination: examples
|
||||
|
||||
- run:
|
||||
name: Build API Docs
|
||||
command: npm run apidoc
|
||||
|
||||
- store_artifacts:
|
||||
path: build/apidoc
|
||||
destination: apidoc
|
||||
|
||||
- run:
|
||||
name: Build Website
|
||||
command: npm run build-site
|
||||
|
||||
- store_artifacts:
|
||||
path: public
|
||||
destination: website
|
||||
|
||||
@@ -11,3 +11,7 @@ insert_final_newline = true
|
||||
[*.md]
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
9
.github/ISSUE_TEMPLATE.md
vendored
Normal file
9
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<!--
|
||||
Thank you for your interest in making OpenLayers better!
|
||||
|
||||
If you are reporting a bug, please link to an example that reproduces the problem. This will make it easier for people who may want to help you debug.
|
||||
|
||||
If you have a usage question, you might want to try Stack Overflow first: https://stackoverflow.com/questions/tagged/openlayers
|
||||
|
||||
Thanks
|
||||
-->
|
||||
19
.github/ISSUE_TEMPLATE/bug_report.md
vendored
19
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,19 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
labels:
|
||||
- bug
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
13
.github/ISSUE_TEMPLATE/feature_request.md
vendored
13
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,13 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
labels:
|
||||
- feature request
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,5 +2,3 @@
|
||||
/coverage/
|
||||
/dist/
|
||||
node_modules/
|
||||
/.cache/
|
||||
/public/
|
||||
|
||||
@@ -42,7 +42,7 @@ Your pull request must:
|
||||
|
||||
* Follow OpenLayers's coding style.
|
||||
|
||||
* Pass the integration tests run automatically by the CircleCI Continuous
|
||||
* Pass the integration tests run automatically by the Travis Continuous
|
||||
Integration system.
|
||||
|
||||
* Address a single issue or add a single item of functionality.
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
You will obviously start by
|
||||
[forking](https://github.com/openlayers/openlayers/fork) the OpenLayers repository.
|
||||
|
||||
### CircleCI
|
||||
### Travis CI
|
||||
|
||||
The CircleCI hook is enabled on the Github repository. This means every pull request
|
||||
The Travis CI hook is enabled on the Github repository. This means every pull request
|
||||
is run through a full test suite to ensure it compiles and passes the tests. Failing
|
||||
pull requests will not be merged.
|
||||
|
||||
|
||||
37
LICENSE.md
37
LICENSE.md
@@ -1,25 +1,26 @@
|
||||
BSD 2-Clause License
|
||||
Copyright 2005-present OpenLayers Contributors. All rights reserved.
|
||||
|
||||
Copyright 2005-present, OpenLayers Contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
THIS SOFTWARE IS PROVIDED BY OPENLAYERS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of OpenLayers Contributors.
|
||||
|
||||
13
Makefile
Normal file
13
Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
SRC_GLSL := $(shell find src -type f -name '*.glsl')
|
||||
SRC_SHADER_JS := $(patsubst %shader.glsl,%shader.js,$(SRC_GLSL))
|
||||
SRC_SHADERLOCATIONS_JS := $(patsubst %shader.glsl,%shader/Locations.js,$(SRC_GLSL))
|
||||
|
||||
.PHONY: shaders
|
||||
shaders: $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS)
|
||||
|
||||
%shader.js: %shader.glsl src/ol/webgl/shader.mustache tasks/glslunit.js
|
||||
@node tasks/glslunit.js --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shader.mustache > $@
|
||||
|
||||
%shader/Locations.js: %shader.glsl src/ol/webgl/shaderlocations.mustache tasks/glslunit.js
|
||||
@mkdir -p $(@D)
|
||||
@node tasks/glslunit.js --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shaderlocations.mustache > $@
|
||||
28
README.md
28
README.md
@@ -1,6 +1,6 @@
|
||||
# OpenLayers
|
||||
|
||||
[OpenLayers](https://openlayers.org/) is a high-performance, feature-packed library for creating interactive maps on the web. It can display map tiles, vector data and markers loaded from any source on any web page. OpenLayers has been developed to further the use of geographic information of all kinds. It is completely free, Open Source JavaScript, released under the [BSD 2-Clause License](https://opensource.org/licenses/BSD-2-Clause).
|
||||
[OpenLayers](https://openlayers.org/) is a high-performance, feature-packed library for creating interactive maps on the web. It can display map tiles, vector data and markers loaded from any source on any web page. OpenLayers has been developed to further the use of geographic information of all kinds. It is completely free, Open Source JavaScript, released under the 2-clause BSD License (also known as the FreeBSD).
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -41,30 +41,6 @@ See the following examples for more detail on bundling OpenLayers with your appl
|
||||
* Using [Parcel](https://github.com/openlayers/ol-parcel)
|
||||
* Using [Browserify](https://github.com/openlayers/ol-browserify)
|
||||
|
||||
## IntelliSense support and type checking for VS Code
|
||||
|
||||
The `ol` package contains a `src/` folder with JSDoc annotated sources. TypeScript can get type definitions from these sources with a `jsconfig.json` config file in the project root:
|
||||
```js
|
||||
{
|
||||
"compilerOptions": {
|
||||
"checkJs": true,
|
||||
// Point to the JSDoc typed sources when using modules from the ol package
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"ol": ["node_modules/ol/src"],
|
||||
"ol/*": ["node_modules/ol/src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"**/*.js",
|
||||
"node_modules/ol/**/*.js"
|
||||
]
|
||||
}
|
||||
```
|
||||
Project template with this configuration: https://gist.github.com/9a7253cb4712e8bf38d75d8ac898e36c.
|
||||
|
||||
Note that the above only works when authoring in plain JavaScript. For similar configurations with a `tsconfig.json` in TypeScript projects, your mileage may vary.
|
||||
|
||||
## Supported Browsers
|
||||
|
||||
OpenLayers runs on all modern browsers that support [HTML5](https://html.spec.whatwg.org/multipage/) and [ECMAScript 5](http://www.ecma-international.org/ecma-262/5.1/). This includes Chrome, Firefox, Safari and Edge. For older browsers and platforms like Internet Explorer (down to version 9) and Android 4.x, [polyfills](http://polyfill.io) for `requestAnimationFrame` and `Element.prototype.classList` are required, and using the KML format requires a polyfill for `URL`.
|
||||
@@ -86,4 +62,4 @@ 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)
|
||||
- Follow [@openlayers](https://twitter.com/openlayers) on Twitter
|
||||
|
||||
[](https://circleci.com/gh/openlayers/openlayers/tree/master)
|
||||
[](https://travis-ci.org/openlayers/openlayers)
|
||||
|
||||
@@ -2,259 +2,6 @@
|
||||
|
||||
### Next version
|
||||
|
||||
#### Backwards incompatible changes
|
||||
|
||||
#### Removal of `GEOLOCATION` constant from `ol/has`
|
||||
|
||||
If you were previously using this constant, you can check if `'geolocation'` is define in `navigator` instead.
|
||||
|
||||
```js
|
||||
if ('geolocation' in navigator) {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
#### Removal of CSS print rules
|
||||
|
||||
The CSS media print rules were removed from the `ol.css` file. To get the previous behavior, use the following CSS:
|
||||
|
||||
```css
|
||||
@media print {
|
||||
.ol-control {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Removal of optional this arguments
|
||||
|
||||
The optional this (i.e. opt_this) arguments were removed from the following methods.
|
||||
Please use closures, the es6 arrow function or the bind method to achieve this effect (Bind is explained here:
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
|
||||
|
||||
* `forEachCorner` in `ol/extent`
|
||||
* `LRUCache#forEach`
|
||||
* `RBush#forEach` and `RBush#forEachInExtent`
|
||||
|
||||
##### The `setCenter`, `setZoom`, `setResolution` and `setRotation` methods on `ol/View` do not bypass constraints anymore
|
||||
|
||||
Previously, these methods allowed setting values that were inconsistent with the given view constraints.
|
||||
This is no longer the case and all changes to the view state now follow the same logic:
|
||||
target values are provided and constraints are applied on these to determine the actual values to be used.
|
||||
|
||||
##### Removal of the `constrainResolution` option on `View.fit`, `PinchZoom`, `MouseWheelZoom` and `ol/interaction.js`
|
||||
|
||||
The `constrainResolution` option is now only supported by the `View` class. A `View.setConstrainResolution` method was added as well.
|
||||
|
||||
Generally, the responsibility of applying center/rotation/resolutions constraints was moved from interactions and controls to the `View` class.
|
||||
|
||||
##### The view `extent` option now applies to the whole viewport
|
||||
|
||||
Previously, this options only constrained the view *center*. This behaviour can still be obtained by specifying `constrainCenterOnly` in the view options.
|
||||
|
||||
As a side effect, the view `rotate` method is gone and has been replaced with `adjustRotation` which takes a delta as input.
|
||||
|
||||
##### The view is constrained so only one world is visible
|
||||
|
||||
Previously, maps showed multiple worlds at low zoom levels. In addition, it used to be possible to pan off the north or south edge of the world. Now, the view is restricted to show only one world, and you cannot pan off the edge. To get the previous behavior, configure the `ol/View` with `multiWorld: true`.
|
||||
|
||||
##### Removal of deprecated methods
|
||||
|
||||
The `inherits` function that was used to inherit the prototype methods from one constructor into another has been removed.
|
||||
The standard ECMAScript classes should be used instead.
|
||||
|
||||
The deprecated `getSnapToPixel` and `setSnapToPixel` functions from the `ImageStyle` class have been removed.
|
||||
|
||||
##### New internal tile coordinates
|
||||
|
||||
Previously, the internal tile coordinates used in the library had an unusual row order – the origin of the tile coordinate system was at the top left as expected, but the rows increased upwards. This meant that all tile coordinates within a tile grid's extent had negative `y` values.
|
||||
|
||||
Now, the internal tile coordinates used in the library have the same row order as standard (e.g. XYZ) tile coordinates. The origin is at the top left (as before), and rows or `y` values increase downward. So the top left tile of a tile grid is now `0, 0`, whereas it was `0, -1` before.
|
||||
|
||||
```
|
||||
x, y values for tile coordinates
|
||||
|
||||
origin
|
||||
*__________________________
|
||||
| | | |
|
||||
| 0, 0 | 1, 0 | 2, 0 |
|
||||
|________|________|________|
|
||||
| | | |
|
||||
| 0, 1 | 1, 1 | 2, 1 |
|
||||
|________|________|________|
|
||||
| | | |
|
||||
| 0, 2 | 1, 2 | 2, 2 |
|
||||
|________|________|________|
|
||||
```
|
||||
|
||||
This change should only affect you if you were using a custom `tileLoadFunction` or `tileUrlFunction`. For example, if you used to have a `tileUrlFunction` that looked like this:
|
||||
|
||||
```js
|
||||
// before
|
||||
function tileUrlFunction(tileCoord) {
|
||||
const z = tileCoord[0];
|
||||
const x = tileCoord[1];
|
||||
const y = -tileCoord[2] - 1;
|
||||
// do something with z, x, y
|
||||
}
|
||||
```
|
||||
|
||||
You would now do something like this:
|
||||
```js
|
||||
// after
|
||||
function tileUrlFunction(tileCoord) {
|
||||
const z = tileCoord[0];
|
||||
const x = tileCoord[1];
|
||||
const y = tileCoord[2];
|
||||
// do something with z, x, y
|
||||
}
|
||||
```
|
||||
|
||||
In addition (this should be exceedingly rare), if you previously created a `ol/tilegrid/WMTS` by hand and you were providing an array of `sizes`, you no longer have to provide a negative height if your tile origin is the top-left corner (the common case). On the other hand, if you are providing a custom array of `sizes` and your origin is the bottom of the grid (this is uncommon), your height values must now be negative.
|
||||
|
||||
##### Removal of the "vector" render mode for vector tile layers
|
||||
|
||||
If you were previously using `VectorTile` layers with `renderMode: 'vector'`, you have to remove this configuration option. That mode was removed. `'hybrid'` (default) and `'image'` are still available.
|
||||
|
||||
##### Removal of the "renderMode" option for vector layers
|
||||
|
||||
If you were previously using `Vector` layers with `renderMode: 'image'`, you have to remove this configuration option. Instead, use the new `ol/layer/VectorImage` layer with your `ol/source/Vector`.
|
||||
|
||||
##### New declutter behavior
|
||||
|
||||
If a map has more than one layer with `declutter` set to true, decluttering now considers all `Vector` and `VectorTile` layers, instead of decluttering each layer separately. Only `VectorImage` layers continue to be decluttered separately. The higher the z-index of a layer, the higher the priority of its decluttered items.
|
||||
|
||||
Within a layer, the declutter order has changed. Previously, styles with a lower `zIndex` were prioritized over those with a higher `zIndex`. Now the opposite order is used.
|
||||
|
||||
On vector layers, even if decluttered images or texts have a lower z-Index than polygons or lines, they will now be rendered on top of the polygons or lines. For vector tile layers, this was the case already in previous releases.
|
||||
|
||||
##### New `prerender` and `postrender` layer events replace old `precompose`, `render` and `postcompose` events
|
||||
|
||||
If you were previously registering for `precompose` and `postcompose` events, you should now register for `prerender` and `postrender` events on layers. Instead of the previous `render` event, you should now listen for `postrender`. Layers are no longer composed to a single Canvas element. Instead, they are added to the map viewport as individual elements.
|
||||
|
||||
##### New `getVectorContext` function provides access to the immediate vector rendering API
|
||||
|
||||
Previously, render events included a `vectorContext` property that allowed you to render features or geometries directly to the map. This is still possible, but you now have to explicitly create a vector context with the `getVectorContext` function. This change makes the immediate rendering API an explicit dependency if your application uses it. If you don't use this API, your application bundle will not include the vector rendering modules (as it did before).
|
||||
|
||||
Here is an abbreviated example of how to use the `getVectorContext` function:
|
||||
|
||||
```js
|
||||
import {getVectorContext} from 'ol/render';
|
||||
|
||||
// construct your map and layers as usual
|
||||
|
||||
layer.on('postrender', function(event) {
|
||||
const vectorContext = getVectorContext(event);
|
||||
// use any of the drawing methods on the vector context
|
||||
});
|
||||
```
|
||||
|
||||
##### Layers can only be added to a single map
|
||||
|
||||
Previously, it was possible to render a single layer in two maps. Now, each layer can only belong to a single map (in the same way that a single DOM element can only have one parent).
|
||||
|
||||
##### The `OverviewMap` requires a list of layers.
|
||||
|
||||
Due to the constraint above (layers can only be added to a single map), the overview map needs to be constructed with a list of layers.
|
||||
|
||||
##### The `ol/Graticule` has been replaced by `ol/layer/Graticule`
|
||||
|
||||
Previously, a graticule was not a layer. Now it is. See the graticule example for details on how to add a graticule layer to your map.
|
||||
|
||||
##### `ol/format/Feature` API change
|
||||
|
||||
The `getLastExtent()` method, which was required for custom `tileLoadFunction`s in `ol/source/Vector`, has been removed because it is no longer needed (see below).
|
||||
|
||||
##### `ol/VectorTile` API changes
|
||||
|
||||
* Removal of the `getProjection()` and `setProjection()` methods. These were used in custom `tileLoadFunction`s on `ol/source/VectorTile`, which work differently now (see below).
|
||||
* Removal of the `getExtent()` and `setExtent()` methods. These were used in custom `tileLoadFunction`s on `ol/source/VectorTile`, which work differently now (see below).
|
||||
|
||||
##### Custom tileLoadFunction on a VectorTile source needs changes
|
||||
|
||||
Previously, applications needed to call `setProjection()` and `setExtent()` on the tile in a custom `tileLoadFunction` on `ol/source/VectorTile`. The format's `getLastExtent()` method was used to get the extent. All this is no longer needed. Instead, the `extent` (first argument to the loader function) and `projection` (third argument to the loader function) are simply passed as `extent` and `featureProjection` options to the format's `readFeatures()` method.
|
||||
|
||||
Example for an old `tileLoadFunction`:
|
||||
|
||||
```js
|
||||
function(tile, url) {
|
||||
tile.setLoader(function() {
|
||||
fetch(url).then(function(response) {
|
||||
response.arrayBuffer().then(function(data) {
|
||||
var format = tile.getFormat();
|
||||
tile.setProjection(format.readProjection(data));
|
||||
tile.setFeatures(format.readFeatures(data, {
|
||||
// featureProjection is not required for ol/format/MVT
|
||||
featureProjection: map.getView().getProjection()
|
||||
}));
|
||||
tile.setExtent(format.getLastExtent());
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
This function needs to be changed to:
|
||||
|
||||
```js
|
||||
function(tile, url) {
|
||||
tile.setLoader(function(extent, resolution, projection) {
|
||||
fetch(url).then(function(response) {
|
||||
response.arrayBuffer().then(function(data) {
|
||||
var format = tile.getFormat();
|
||||
tile.setFeatures(format.readFeatures(data, {
|
||||
// extent is only required for ol/format/MVT
|
||||
extent: extent,
|
||||
featureProjection: projection
|
||||
}));
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
##### Drop of support for the experimental WebGL renderer
|
||||
|
||||
The WebGL map and layers renderers are gone, replaced by a `WebGLHelper` function that provides a lightweight,
|
||||
low-level access to the WebGL API. This is implemented in a new `WebGLPointsLayer` which does simple rendering of large number
|
||||
of points with custom shaders.
|
||||
|
||||
This is now used in the `Heatmap` layer.
|
||||
|
||||
The removed classes and components are:
|
||||
* `WebGLMap` and `WebGLMapRenderer`
|
||||
* `WebGLLayerRenderer`
|
||||
* `WebGLImageLayer` and `WebGLImageLayerRenderer`
|
||||
* `WebGLTileLayer` and `WebGLTileLayerRenderer`
|
||||
* `WebGLVectorLayer` and `WebGLVectorLayerRenderer`
|
||||
* `WebGLReplay` and derived classes, along with associated shaders
|
||||
* `WebGLReplayGroup`
|
||||
* `WebGLImmediateRenderer`
|
||||
* `WebGLMap`
|
||||
* The shader build process using `mustache` and the `Makefile` at the root
|
||||
|
||||
##### Removal of the AtlasManager
|
||||
|
||||
Following the removal of the experimental WebGL renderer, the AtlasManager has been removed as well. The atlas was only used by this renderer.
|
||||
The non API `getChecksum` functions of the style is also removed.
|
||||
|
||||
##### Change of the behavior of the vector source's clear() and refresh() methods
|
||||
|
||||
The `ol/source/Vector#clear()` method no longer triggers a reload of the data from the server. If you were previously using `clear()` to refetch from the server, you now have to use `refresh()`.
|
||||
|
||||
The `ol/source/Vector#refresh()` method now removes all features from the source and triggers a reload of the data from the server. If you were previously using the `refresh()` method to re-render a vector layer, you should instead call `ol/layer/Vector#changed()`.
|
||||
|
||||
#### Other changes
|
||||
|
||||
##### Allow declutter in image render mode
|
||||
|
||||
It is now possible to configure vector tile layers with `declutter: true` and `renderMode: 'image'`. However, note that decluttering will be done per tile, resulting in labels and point symbols getting cut off at tile boundaries.
|
||||
Until now, using both options forced the render mode to be `hybrid`.
|
||||
|
||||
##### Always load tiles while animating or interacting
|
||||
|
||||
`ol/PluggableMap` and subclasses no longer support the `loadTilesWhileAnimating` and `loadTilesWhileInteracting` options. These options were used to enable tile loading during animations and interactions. With the new DOM composition render strategy, it is no longer necessary to postpone tile loading until after animations or interactions.
|
||||
|
||||
### v5.3.0
|
||||
|
||||
#### The `getUid` function returns string
|
||||
|
||||
6
changelog/v5.3.1.md
Normal file
6
changelog/v5.3.1.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# 5.3.1
|
||||
|
||||
The 5.3.1 release is a patch that addresses an issue when using `angular-cli` to build an OpenLayers-based application.
|
||||
|
||||
* [#9253](https://github.com/openlayers/openlayers/pull/9253) - Add proj.js to the sideEffects list ([@romanzoller](https://github.com/romanzoller))
|
||||
|
||||
6
changelog/v5.3.2.md
Normal file
6
changelog/v5.3.2.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# 5.3.2
|
||||
|
||||
The 5.3.2 release is a patch that addresses a tile source issue with old tile data when the source revision changed.
|
||||
|
||||
* [#9422](https://github.com/openlayers/openlayers/pull/9422) - Clear context when source revision changed (v5.3.x fix) ([@elemoine](https://github.com/elemoine))
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"opts": {
|
||||
"recurse": true,
|
||||
"template": "node_modules/jsdoc-json"
|
||||
},
|
||||
"tags": {
|
||||
"allowUnknownTags": true
|
||||
},
|
||||
"source": {
|
||||
"includePattern": "\\.js$",
|
||||
"include": [
|
||||
"src/ol"
|
||||
]
|
||||
},
|
||||
"plugins": [
|
||||
"jsdoc-plugin-typescript",
|
||||
"config/jsdoc/api-info/plugins/api",
|
||||
"config/jsdoc/api-info/plugins/module"
|
||||
],
|
||||
"typescript": {
|
||||
"moduleRoot": "src"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
/**
|
||||
* Handle the api annotation.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = dictionary => {
|
||||
|
||||
dictionary.defineTag('api', {
|
||||
onTagged: (doclet, tag) => {
|
||||
doclet.api = true;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
/**
|
||||
* This plugin adds an `exportMap` property to @module doclets. Each export map
|
||||
* is an object with properties named like the local identifier and values named
|
||||
* like the exported identifier.
|
||||
*
|
||||
* For example, the code below
|
||||
*
|
||||
* export {foo as bar};
|
||||
*
|
||||
* would be a map like `{foo: 'bar'}`.
|
||||
*
|
||||
* In the case of an export declaration with a source, the export identifier is
|
||||
* prefixed by the source. For example, this code
|
||||
*
|
||||
* export {foo as bar} from 'ol/bam';
|
||||
*
|
||||
* would be a map like `{'ol/bam foo': 'bar'}`.
|
||||
*
|
||||
* If a default export is a literal or object expression, the local name will be
|
||||
* an empty string. For example
|
||||
*
|
||||
* export default {foo: 'bar'};
|
||||
*
|
||||
* would be a map like `{'': 'default'}`.
|
||||
*/
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
|
||||
|
||||
/**
|
||||
* A lookup of export maps per source filepath.
|
||||
*/
|
||||
const exportMapLookup = {};
|
||||
|
||||
function loc(filepath, node) {
|
||||
return `${filepath}:${node.loc.start.line}`;
|
||||
}
|
||||
|
||||
function nameFromChildIdentifier(filepath, node) {
|
||||
assert.ok(node.id, `expected identifer in ${loc(filepath, node)}`);
|
||||
assert.strictEqual(node.id.type, 'Identifier', `expected identifer in ${loc(filepath, node)}`);
|
||||
return node.id.name;
|
||||
}
|
||||
|
||||
function handleExportNamedDeclaration(filepath, node) {
|
||||
if (!(filepath in exportMapLookup)) {
|
||||
exportMapLookup[filepath] = {};
|
||||
}
|
||||
const exportMap = exportMapLookup[filepath];
|
||||
|
||||
const declaration = node.declaration;
|
||||
if (declaration) {
|
||||
// `export class Foo{}` or `export function foo() {}`
|
||||
if (declaration.type === 'ClassDeclaration' || declaration.type === 'FunctionDeclaration') {
|
||||
const name = nameFromChildIdentifier(filepath, declaration);
|
||||
exportMap[name] = name;
|
||||
return;
|
||||
}
|
||||
|
||||
// `export const foo = 'bar', bam = 42`
|
||||
if (declaration.type === 'VariableDeclaration') {
|
||||
const declarations = declaration.declarations;
|
||||
assert.ok(declarations.length > 0, `expected variable declarations in ${loc(filepath, declaration)}`);
|
||||
for (const declarator of declarations) {
|
||||
assert.strictEqual(declarator.type, 'VariableDeclarator', `unexpected "${declarator.type}" in ${loc(filepath, declarator)}`);
|
||||
const name = nameFromChildIdentifier(filepath, declarator);
|
||||
exportMap[name] = name;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unexpected named export "${declaration.type}" in ${loc(filepath, declaration)}`);
|
||||
}
|
||||
|
||||
let prefix = '';
|
||||
const source = node.source;
|
||||
if (source) {
|
||||
// `export foo from 'bar'`
|
||||
assert.strictEqual(source.type, 'Literal', `unexpected export source "${source.type}" in ${loc(filepath, source)}`);
|
||||
prefix = `${source.value} `;
|
||||
}
|
||||
|
||||
const specifiers = node.specifiers;
|
||||
assert.ok(specifiers.length > 0, `expected export specifiers in ${loc(filepath, node)}`);
|
||||
// `export {foo, bar}` or `export {default as Foo} from 'bar'`
|
||||
for (const specifier of specifiers) {
|
||||
assert.strictEqual(specifier.type, 'ExportSpecifier', `unexpected export specifier in ${loc(filepath, specifier)}`);
|
||||
|
||||
const local = specifier.local;
|
||||
assert.strictEqual(local.type, 'Identifier', `unexpected local specifier "${local.type} in ${loc(filepath, local)}`);
|
||||
|
||||
const exported = specifier.exported;
|
||||
assert.strictEqual(local.type, 'Identifier', `unexpected exported specifier "${exported.type} in ${loc(filepath, exported)}`);
|
||||
|
||||
exportMap[prefix + local.name] = exported.name;
|
||||
}
|
||||
}
|
||||
|
||||
function handleDefaultDeclaration(filepath, node) {
|
||||
if (!(filepath in exportMapLookup)) {
|
||||
exportMapLookup[filepath] = {};
|
||||
}
|
||||
const exportMap = exportMapLookup[filepath];
|
||||
|
||||
const declaration = node.declaration;
|
||||
if (declaration) {
|
||||
// `export default class Foo{}` or `export default function foo () {}`
|
||||
if (declaration.type === 'ClassDeclaration' || declaration.type === 'FunctionDeclaration') {
|
||||
const name = nameFromChildIdentifier(filepath, declaration);
|
||||
exportMap[name] = 'default';
|
||||
return;
|
||||
}
|
||||
|
||||
// `export default foo`
|
||||
if (declaration.type === 'Identifier') {
|
||||
exportMap[declaration.name] = 'default';
|
||||
return;
|
||||
}
|
||||
|
||||
// `export default {foo: 'bar'}` or `export default 42`
|
||||
if (declaration.type === 'ObjectExpression' || declaration.type === 'Literal') {
|
||||
exportMap[''] = 'default';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Unexpected default export "${declaration.type}" in ${loc(filepath, declaration)}`);
|
||||
}
|
||||
|
||||
exports.astNodeVisitor = {
|
||||
visitNode: (node, event, parser, filepath) => {
|
||||
if (node.type === 'ExportNamedDeclaration') {
|
||||
return handleExportNamedDeclaration(filepath, node);
|
||||
}
|
||||
|
||||
if (node.type === 'ExportDefaultDeclaration') {
|
||||
return handleDefaultDeclaration(filepath, node);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const moduleLookup = {};
|
||||
|
||||
exports.handlers = {
|
||||
|
||||
// create a lookup of @module doclets
|
||||
newDoclet: event => {
|
||||
const doclet = event.doclet;
|
||||
if (doclet.kind === 'module') {
|
||||
const filepath = path.join(doclet.meta.path, doclet.meta.filename);
|
||||
|
||||
assert.ok(!(filepath in moduleLookup), `duplicate @module doc in ${filepath}`);
|
||||
moduleLookup[filepath] = doclet;
|
||||
}
|
||||
},
|
||||
|
||||
// assign the `exportMap` property to @module doclets
|
||||
parseComplete: event => {
|
||||
for (const filepath in moduleLookup) {
|
||||
assert.ok(filepath in exportMapLookup, `missing ${filepath} in export map lookup`);
|
||||
moduleLookup[filepath].exportMap = exportMapLookup[filepath];
|
||||
}
|
||||
|
||||
// make sure there was a @module doclet for each export map
|
||||
for (const filepath in exportMapLookup) {
|
||||
assert.ok(filepath in moduleLookup, `missing @module doclet in ${filepath}`);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,43 +1,43 @@
|
||||
<table><tr>
|
||||
<th width="33.3%">Map</th><th width="33.3%">View</th><th width="33.3%">Layers</th>
|
||||
</tr><tr>
|
||||
<td><p>A <a href="module-ol_Map-Map.html">map</a> is made of <a href="module-ol_layer_Base-BaseLayer.html">layers</a>, a <a href="module-ol_View-View.html">view</a> to visualize them, <a href="module-ol_interaction_Interaction-Interaction.html">interactions</a> to modify map content and <a href="module-ol_control_Control-Control.html">controls</a> with UI components.</p>
|
||||
<a href="module-ol_Map-Map.html">Overview</a><br>
|
||||
<a href="module-ol_Map-Map.html#Map">Creation</a><br>
|
||||
<a href="module-ol_MapBrowserEvent-MapBrowserEvent.html">Events</a></td>
|
||||
<td><p>A [map](module-ol_Map-Map.html) is made of [layers](module-ol_layer_Base-BaseLayer.html), a [view](module-ol_View-View.html) to visualize them, [interactions](module-ol_interaction_Interaction-Interaction.html) to modify map content and [controls](module-ol_control_Control-Control.html) with UI components.</p>
|
||||
[Overview](module-ol_Map-Map.html)<br>
|
||||
[Creation](module-ol_Map-Map.html#Map)<br>
|
||||
[Events](module-ol_MapBrowserEvent-MapBrowserEvent.html)</td>
|
||||
<td><p>The view manages the visual parameters of the map view, like resolution or rotation.</p>
|
||||
<a href="module-ol_View-View.html">View</a> with center, projection, resolution and rotation</td>
|
||||
<td><p>Layers are lightweight containers that get their data from <a href="module-ol_source_Source-Source.html">sources</a>.</p>
|
||||
<a href="module-ol_layer_Tile-TileLayer.html">ol/layer/Tile</a><br>
|
||||
<a href="module-ol_layer_Image-ImageLayer.html">ol/layer/Image</a><br>
|
||||
<a href="module-ol_layer_Vector-VectorLayer.html">ol/layer/Vector</a><br>
|
||||
<a href="module-ol_layer_VectorTile-VectorTileLayer.html">ol/layer/VectorTile</a></td>
|
||||
[View](module-ol_View-View.html) with center, projection, resolution and rotation</td>
|
||||
<td><p>Layers are lightweight containers that get their data from [sources](module-ol_source_Source-Source.html).</p>
|
||||
[ol/layer/Tile](module-ol_layer_Tile-TileLayer.html)<br>
|
||||
[ol/layer/Image](module-ol_layer_Image-ImageLayer.html)<br>
|
||||
[ol/layer/Vector](module-ol_layer_Vector-VectorLayer.html)<br>
|
||||
[ol/layer/VectorTile](module-ol_layer_VectorTile-VectorTileLayer.html)</td>
|
||||
</tr><tr>
|
||||
<th>Controls</th><th>Interactions</th><th>Sources and formats</th>
|
||||
</tr><tr>
|
||||
<td><a href="module-ol_control_util.html#.defaults">Map default controls</a><br>
|
||||
<a href="module-ol_control_Control-Control.html">All controls</a>
|
||||
<td>[Map default controls](module-ol_control_util.html#.defaults)<br>
|
||||
[All controls](module-ol_control_Control-Control.html)
|
||||
</td>
|
||||
<td>
|
||||
<a href="module-ol_interaction.html#~defaults">Map default interactions</a><br>
|
||||
Interactions for <a href="module-ol_Feature-Feature.html">vector features</a>
|
||||
<ul><li><a href="module-ol_interaction_Select-Select.html">ol/interaction/Select</a></li>
|
||||
<li><a href="module-ol_interaction_Draw-Draw.html">ol/interaction/Draw</a></li>
|
||||
<li><a href="module-ol_interaction_Modify-Modify.html">ol/interaction/Modify</a></li></ul>
|
||||
<a href="module-ol_interaction_Interaction-Interaction.html">All interactions</a></td>
|
||||
<td><a href="module-ol_source_Tile-TileSource.html">Tile sources</a> for <a href="module-ol_layer_Tile-TileLayer.html">ol/layer/Tile</a>
|
||||
<br><a href="module-ol_source_Image-ImageSource.html">Image sources</a> for <a href="module-ol_layer_Image-ImageLayer.html">ol/layer/Image</a>
|
||||
<br><a href="module-ol_source_Vector-VectorSource.html">Vector sources</a> for <a href="module-ol_layer_Vector-VectorLayer.html">ol/layer/Vector</a>
|
||||
<br><a href="module-ol_source_VectorTile-VectorTile.html">Vector tile sources</a> for <a href="module-ol_layer_VectorTile-VectorTileLayer.html">ol/layer/VectorTile</a>
|
||||
<br><a href="module-ol_format_Feature-FeatureFormat.html">Formats</a> for reading/writing vector data
|
||||
<br><a href="module-ol_format_WMSCapabilities-WMSCapabilities.html">ol/format/WMSCapabilities</a></td></tr>
|
||||
[Map default interactions](module-ol_interaction.html#~defaults)<br>
|
||||
Interactions for [vector features](module-ol_Feature-Feature.html)
|
||||
<ul><li>[ol/interaction/Select](module-ol_interaction_Select-Select.html)</li>
|
||||
<li>[ol/interaction/Draw](module-ol_interaction_Draw-Draw.html)</li>
|
||||
<li>[ol/interaction/Modify](module-ol_interaction_Modify-Modify.html)</li></ul>
|
||||
[All interactions](module-ol_interaction_Interaction-Interaction.html)</td>
|
||||
<td>[Tile sources](module-ol_source_Tile-TileSource.html) for [ol/layer/Tile](module-ol_layer_Tile-TileLayer.html)
|
||||
<br>[Image sources](module-ol_source_Image-ImageSource.html) for [ol/layer/Image](module-ol_layer_Image-ImageLayer.html)
|
||||
<br>[Vector sources](module-ol_source_Vector-VectorSource.html) for [ol/layer/Vector](module-ol_layer_Vector-VectorLayer.html)
|
||||
<br>[Vector tile sources](module-ol_source_VectorTile-VectorTile.html) for [ol/layer/VectorTile](module-ol_layer_VectorTile-VectorTileLayer.html)
|
||||
<br>[Formats](module-ol_format_Feature-FeatureFormat.html) for reading/writing vector data
|
||||
<br>[ol/format/WMSCapabilities](module-ol_format_WMSCapabilities-WMSCapabilities.html)</td></tr>
|
||||
<tr><th>Projections</th><th>Observable objects</th><th>Other components</th></tr>
|
||||
<tr><td><p>All coordinates and extents need to be provided in view projection (default: EPSG:3857). To transform, use <a href="module-ol_proj.html#.transform">ol/proj#transform()</a> and <a href="module-ol_proj.html#.transformExtent">ol/proj#transformExtent()</a>.</p>
|
||||
<a href="module-ol_proj.html">ol/proj</a></td>
|
||||
<td><p>Changes to all <a href="module-ol_Object-BaseObject.html">ol/Object</a>s can be observed by calling the <a href="module-ol_Object-BaseObject.html#on">object.on('propertychange')</a> method. Listeners receive an <a href="module-ol_Object-ObjectEvent.html">ol/Object.ObjectEvent</a> with information on the changed property and old value.</p>
|
||||
<tr><td><p>All coordinates and extents need to be provided in view projection (default: EPSG:3857). To transform, use [ol/proj#transform()](module-ol_proj.html#.transform) and [ol/proj#transformExtent()](module-ol_proj.html#.transformExtent).</p>
|
||||
[ol/proj](module-ol_proj.html)</td>
|
||||
<td><p>Changes to all [ol/Object](module-ol_Object-BaseObject.html)s can be observed by calling the [object.on('propertychange')](module-ol_Object-BaseObject.html#on) method. Listeners receive an [ol/Object.ObjectEvent](module-ol_Object-ObjectEvent.html) with information on the changed property and old value.</p>
|
||||
<td>
|
||||
<a href="module-ol_Geolocation.html">ol/Geolocation</a><br>
|
||||
<a href="module-ol_Overlay-Overlay.html">ol/Overlay</a><br></td>
|
||||
[ol/Geolocation](module-ol_Geolocation.html)<br>
|
||||
[ol/Overlay](module-ol_Overlay-Overlay.html)<br></td>
|
||||
</tr></table>
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
const events = {};
|
||||
const classes = {};
|
||||
|
||||
exports.handlers = {
|
||||
|
||||
newDoclet: function(e) {
|
||||
const doclet = e.doclet;
|
||||
if (doclet.kind !== 'event') {
|
||||
return;
|
||||
}
|
||||
|
||||
const cls = doclet.longname.split('#')[0];
|
||||
let cls;
|
||||
if (doclet.kind == 'event') {
|
||||
cls = doclet.longname.split('#')[0];
|
||||
if (!(cls in events)) {
|
||||
events[cls] = [];
|
||||
}
|
||||
events[cls].push(doclet.longname);
|
||||
} else if (doclet.kind == 'class' && !(doclet.longname in classes)) {
|
||||
classes[doclet.longname] = doclet;
|
||||
}
|
||||
},
|
||||
|
||||
parseComplete: function(e) {
|
||||
const doclets = e.doclets;
|
||||
for (let i = 0, ii = doclets.length - 1; i < ii; ++i) {
|
||||
const doclet = doclets[i];
|
||||
let doclet, i, ii, j, jj, event, fires;
|
||||
for (i = 0, ii = doclets.length - 1; i < ii; ++i) {
|
||||
doclet = doclets[i];
|
||||
if (doclet.fires) {
|
||||
if (doclet.kind == 'class') {
|
||||
const fires = [];
|
||||
for (let j = 0, jj = doclet.fires.length; j < jj; ++j) {
|
||||
const event = doclet.fires[j].replace('event:', '');
|
||||
fires = [];
|
||||
for (j = 0, jj = doclet.fires.length; j < jj; ++j) {
|
||||
event = doclet.fires[j].replace('event:', '');
|
||||
if (events[event]) {
|
||||
fires.push.apply(fires, events[event]);
|
||||
} else if (doclet.fires[j] !== 'event:ObjectEvent') {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
/*
|
||||
* This is a hack to prevent inheritDoc tags from entirely removing
|
||||
* documentation of the method that inherits the documentation.
|
||||
*
|
||||
* TODO: Remove this hack when https://github.com/jsdoc3/jsdoc/issues/53
|
||||
* is addressed.
|
||||
*/
|
||||
|
||||
|
||||
exports.defineTags = function(dictionary) {
|
||||
dictionary.defineTag('inheritDoc', {
|
||||
mustHaveValue: false,
|
||||
@@ -92,11 +96,6 @@ exports.handlers = {
|
||||
incompleteDoclet[key] = candidate[key];
|
||||
}
|
||||
}
|
||||
// We have found a matching parent doc and applied it so we
|
||||
// don't want to ignore this doclet anymore.
|
||||
incompleteDoclet.ignore = false;
|
||||
// We found a match so we can stop break
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,62 +4,12 @@ var version = obj.packageInfo.version;
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script>
|
||||
var gaProperty = 'UA-2577926-1';
|
||||
// Disable tracking if the opt-out cookie exists.
|
||||
var disableStr = 'ga-disable-' + gaProperty;
|
||||
if (document.cookie.indexOf(disableStr + '=true') > -1) {
|
||||
window[disableStr] = true;
|
||||
}
|
||||
function gaOptout() {
|
||||
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
|
||||
window[disableStr] = true;
|
||||
}
|
||||
function gaOptoutRevoke() {
|
||||
document.cookie = disableStr + '=false; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
|
||||
window[disableStr] = false;
|
||||
}
|
||||
</script>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-2577926-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-2577926-1', { 'anonymize_ip': true });
|
||||
</script>
|
||||
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
|
||||
<script>
|
||||
window.addEventListener("load", function() {
|
||||
window.cookieconsent.initialise({
|
||||
'palette': {
|
||||
'popup': {
|
||||
'background': '#eaf7f7',
|
||||
'text': '#5c7291'
|
||||
},
|
||||
'button': {
|
||||
'background': '#56cbdb',
|
||||
'text': '#ffffff'
|
||||
}
|
||||
},
|
||||
'theme': 'edgeless',
|
||||
'type': 'opt-out',
|
||||
'onInitialise': function (status) {
|
||||
if (!this.hasConsented()) {
|
||||
gaOptout()
|
||||
}
|
||||
},
|
||||
'onStatusChange': function(status, chosenBefore) {
|
||||
if (!this.hasConsented()) {
|
||||
gaOptout()
|
||||
}
|
||||
},
|
||||
'onRevokeChoice': function() {
|
||||
gaOptoutRevoke()
|
||||
}
|
||||
})
|
||||
});
|
||||
gtag('config', 'UA-2577926-1');
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenLayers v<?js= version ?> API - <?js= title ?></title>
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
"target": "ES5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
||||
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
"allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
"sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "../build/ol", /* Redirect output structure to the directory. */
|
||||
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
"importHelpers": false, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": false, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": false, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
"inlineSources": false /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
},
|
||||
"include": [
|
||||
"../build/ol/src/**/*.js"
|
||||
],
|
||||
"exclude": []
|
||||
}
|
||||
@@ -111,7 +111,7 @@ Features for `updates` must have an id set by the feature reader or `ol.Feature#
|
||||
|
||||
### 28
|
||||
|
||||
`renderMode` must be `'image'` or `'hybrid'`.
|
||||
`renderMode` must be `'image'`, `'hybrid'` or `'vector'`.
|
||||
|
||||
### 29
|
||||
|
||||
@@ -220,11 +220,3 @@ Duplicate item added to a unique collection. For example, it may be that you tr
|
||||
### 59
|
||||
|
||||
Invalid command found in the PBF. This indicates that the loaded vector tile may be corrupt.
|
||||
|
||||
### 60
|
||||
|
||||
Missing or invalid `size`.
|
||||
|
||||
### 61
|
||||
|
||||
Cannot determine IIIF Image API version from provided image information JSON.
|
||||
|
||||
29
doc/faq.md
29
doc/faq.md
@@ -21,7 +21,7 @@ Table of contents:
|
||||
* [Why aren't there any features in my source?](#why-aren-t-there-any-features-in-my-source-)
|
||||
* [How do I force a re-render of the map?](#how-do-i-force-a-re-render-of-the-map-)
|
||||
* [Why are my features not found?](#why-are-my-features-not-found-)
|
||||
* [Why is zooming or clicking off, inaccurate?](#user-content-why-is-zooming-or-clicking-off-inaccurate)
|
||||
|
||||
|
||||
## What projection is OpenLayers using?
|
||||
|
||||
@@ -371,30 +371,3 @@ const vectorLayer = new VectorLayer({
|
||||
```
|
||||
|
||||
The recommended value is the size of the largest symbol, line width or label.
|
||||
|
||||
## Why is zooming or clicking in the map off/inaccurate?
|
||||
|
||||
OpenLayers does not update the map when the container element is resized. This can be caused by progressive updates
|
||||
to CSS styles or manually resizing the map. When that happens, any interaction will become inaccurate: the map would zoom in and out, and end up not being centered on the pointer. This makes it hard to do certain interactions, e.g. selecting the desired feature.
|
||||
|
||||
There is currently no built-in way to react to element's size changes, as [Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) is only implemented in Chrome.
|
||||
|
||||
There is however an easy to use [polyfill](https://github.com/que-etc/resize-observer-polyfill):
|
||||
|
||||
```javascript
|
||||
import Map from 'ol/Map';
|
||||
import ResizeObserver from 'resize-observer-polyfill';
|
||||
|
||||
const mapElement = document.querySelector('#map')
|
||||
const map = new Map({
|
||||
target: mapElement
|
||||
})
|
||||
|
||||
const sizeObserver = new ResizeObserver(() => {
|
||||
map.updateSize()
|
||||
})
|
||||
sizeObserver.observe(mapElement)
|
||||
|
||||
// called when the map is destroyed
|
||||
// sizeObserver.disconnect()
|
||||
```
|
||||
|
||||
@@ -18,14 +18,14 @@ Below you'll find a complete working example. Create a new file, copy in the co
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/{{ latest }}/css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/{{ latest }}/css/ol.css" type="text/css">
|
||||
<style>
|
||||
.map {
|
||||
height: 400px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/{{ latest }}/build/ol.js"></script>
|
||||
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/{{ latest }}/build/ol.js"></script>
|
||||
<title>OpenLayers example</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -60,7 +60,7 @@ To include a map a web page you will need 3 things:
|
||||
### Include OpenLayers
|
||||
|
||||
```xml
|
||||
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/{{ latest }}/build/ol.js"></script>
|
||||
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/{{ latest }}/build/ol.js"></script>
|
||||
```
|
||||
|
||||
The first part is to include the JavaScript library. For the purpose of this tutorial, here we simply point to the openlayers.org website to get the whole library. In a production environment, we would build a custom version of the library including only the module needed for our application.
|
||||
|
||||
@@ -17,7 +17,7 @@ OpenLayers is available as [`ol` npm package](https://npmjs.com/package/ol), whi
|
||||
|
||||
## Renderers and Browser Support
|
||||
|
||||
By default, OpenLayers uses a performance optimized Canvas renderer.
|
||||
By default, OpenLayers uses a performance optimized Canvas renderer. An experimental WebGL renderer (without text rendering support) is also available.
|
||||
|
||||
OpenLayers runs on all modern browsers that support [HTML5](https://html.spec.whatwg.org/multipage/) and [ECMAScript 5](http://www.ecma-international.org/ecma-262/5.1/). This includes Chrome, Firefox, Safari and Edge. For older browsers and platforms like Internet Explorer (down to version 9) and Android 4.x, [polyfills](http://polyfill.io), the application bundle needs to be transpiled (e.g. using [Babel](https://babeljs.io)) and bundled with polyfills for `requestAnimationFrame`, `Element.prototype.classList` and `URL`.
|
||||
|
||||
@@ -44,6 +44,6 @@ import {Tile, Vector} from 'ol/layer';
|
||||
In addition to these re-exported classes, modules with lowercase names also provide constants or functions as named exports:
|
||||
|
||||
```js
|
||||
import {getUid} from 'ol';
|
||||
import {inherits} from 'ol';
|
||||
import {fromLonLat} from 'ol/proj';
|
||||
```
|
||||
|
||||
@@ -11,11 +11,9 @@ In this tutorial, we will be using [Parcel](https://parceljs.org) to bundle our
|
||||
|
||||
## Initial steps
|
||||
|
||||
Create a new empty directory for your project and navigate to it by running `mkdir new-project && cd new-project`. Initialize your project with
|
||||
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.
|
||||
|
||||
npm init
|
||||
|
||||
This will create a `package.json` file in your working directory. Add OpenLayers as dependency to your application with
|
||||
Add OpenLayers as dependency to your application with
|
||||
|
||||
npm install ol
|
||||
|
||||
@@ -71,21 +69,13 @@ You will also need an `index.html` file that will use your bundle. Here is a sim
|
||||
|
||||
## Creating a bundle
|
||||
|
||||
With two additional lines in `package.json` you can introduce the commands `npm run build` and `npm start` to manually build your bundle and watch for changes, respectively. The final `package.json` with the two additional commands `"start"` and `"build"` should look like this:
|
||||
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`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "parcel index.html",
|
||||
"build": "parcel build --public-url . index.html"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
```
|
||||
That's it. Now to run your application, enter
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"GyroNorm": false,
|
||||
"jsPDF": false,
|
||||
"jsts": false,
|
||||
"mapboxgl": false,
|
||||
"saveAs": false,
|
||||
"toastr": false,
|
||||
"topojson": false,
|
||||
|
||||
@@ -24,6 +24,9 @@ const map = new Map({
|
||||
source: new OSM()
|
||||
})
|
||||
],
|
||||
// Improve user experience by loading tiles while animating. Will make
|
||||
// animations stutter on mobile or slow devices.
|
||||
loadTilesWhileAnimating: true,
|
||||
view: view
|
||||
});
|
||||
|
||||
|
||||
@@ -12,8 +12,9 @@ cloak:
|
||||
<div id="map" class="map"></div>
|
||||
<select id="layer-select">
|
||||
<option value="Aerial">Aerial</option>
|
||||
<option value="AerialWithLabelsOnDemand" selected>Aerial with labels</option>
|
||||
<option value="RoadOnDemand">Road</option>
|
||||
<option value="CanvasDark">Road dark</option>
|
||||
<option value="OrdnanceSurvey">Ordnance Survey</option>
|
||||
<option value="AerialWithLabels" selected>Aerial with labels</option>
|
||||
<option value="Road">Road (static)</option>
|
||||
<option value="RoadOnDemand">Road (dynamic)</option>
|
||||
<option value="collinsBart">Collins Bart</option>
|
||||
<option value="ordnanceSurvey">Ordnance Survey</option>
|
||||
</select>
|
||||
|
||||
@@ -5,11 +5,12 @@ import BingMaps from '../src/ol/source/BingMaps.js';
|
||||
|
||||
|
||||
const styles = [
|
||||
'Road',
|
||||
'RoadOnDemand',
|
||||
'Aerial',
|
||||
'AerialWithLabelsOnDemand',
|
||||
'CanvasDark',
|
||||
'OrdnanceSurvey'
|
||||
'AerialWithLabels',
|
||||
'collinsBart',
|
||||
'ordnanceSurvey'
|
||||
];
|
||||
const layers = [];
|
||||
let i, ii;
|
||||
@@ -28,6 +29,9 @@ for (i = 0, ii = styles.length; i < ii; ++i) {
|
||||
}
|
||||
const map = new Map({
|
||||
layers: layers,
|
||||
// Improve user experience by loading tiles while dragging/zooming. Will make
|
||||
// zooming choppy on mobile or slow devices.
|
||||
loadTilesWhileInteracting: true,
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [-6655.5402445057125, 6709968.258934638],
|
||||
|
||||
4
examples/blend-modes.css
Normal file
4
examples/blend-modes.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.map{
|
||||
background-repeat: repeat;
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAApSURBVBiVY7x///5/BjSgqKjIiC7GhC6ACwygQgxHMzAwMGDz4FDwDAD5/wevjSk4mwAAAABJRU5ErkJggg==);
|
||||
}
|
||||
68
examples/blend-modes.html
Normal file
68
examples/blend-modes.html
Normal file
@@ -0,0 +1,68 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Blend Modes
|
||||
shortdesc: Shows how to change the canvas compositing / blending mode in post- and precompose eventhandlers.
|
||||
docs: >
|
||||
<p>This example shows how to change the canvas compositing / blending mode in
|
||||
post- and precompose event handlers. The Canvas 2D API provides the property
|
||||
<code>globalCompositeOperation</code> with which one can influence which
|
||||
composition operation will be used when drawing on the canvas. The various
|
||||
options are well described on the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation">MDN
|
||||
documentation page</a>.</p>
|
||||
|
||||
<p>In this example three circles on the corners of an equilateral triangle are
|
||||
drawn with red, green or blue styles respectively. By setting the
|
||||
<code>globalCompositeOperation</code> you can change how these colors turn out
|
||||
when they are combined on the map.</p>
|
||||
|
||||
<p>You can select an operation in the select-field and you can also control
|
||||
which layers will be affected by the chosen operation through the layer
|
||||
checkboxes.</p>
|
||||
tags: "blendmode, blend-mode, blend mode, blendingmode, blending-mode, blending mode, composition, compositing, canvas, vector"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<form class="form-horizontal">
|
||||
<label>
|
||||
<select id="blend-mode" class="form-control">
|
||||
<option value="source-over">source-over (default)</option>
|
||||
<option>source-in</option>
|
||||
<option>source-out</option>
|
||||
<option>source-atop</option>
|
||||
<option>destination-over</option>
|
||||
<option>destination-in</option>
|
||||
<option>destination-out</option>
|
||||
<option>destination-atop</option>
|
||||
<option>lighter</option>
|
||||
<option>copy</option>
|
||||
<option>xor</option>
|
||||
<option>multiply</option>
|
||||
<option>screen</option>
|
||||
<option>overlay</option>
|
||||
<option>darken</option>
|
||||
<option>lighten</option>
|
||||
<option>color-dodge</option>
|
||||
<option>color-burn</option>
|
||||
<option>hard-light</option>
|
||||
<option>soft-light</option>
|
||||
<option selected>difference</option>
|
||||
<option>exclusion</option>
|
||||
<option>hue</option>
|
||||
<option>saturation</option>
|
||||
<option>color</option>
|
||||
<option>luminosity</option>
|
||||
</select>
|
||||
Canvas compositing / blending mode
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" id="affect-red" checked>
|
||||
Red circle affected
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" id="affect-green" checked>
|
||||
Green circle affected
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" id="affect-blue" checked>
|
||||
Blue circle affected
|
||||
</label>
|
||||
</form>
|
||||
173
examples/blend-modes.js
Normal file
173
examples/blend-modes.js
Normal file
@@ -0,0 +1,173 @@
|
||||
import Feature from '../src/ol/Feature.js';
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import Point from '../src/ol/geom/Point.js';
|
||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Circle as CircleStyle, Fill, Stroke, Style} from '../src/ol/style.js';
|
||||
|
||||
|
||||
// Create separate layers for red, green an blue circles.
|
||||
//
|
||||
// Every layer has one feature that is styled with a circle, together the
|
||||
// features form the corners of an equilateral triangle and their styles overlap
|
||||
const redLayer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
features: [new Feature(new Point([0, 0]))]
|
||||
}),
|
||||
style: new Style({
|
||||
image: new CircleStyle({
|
||||
fill: new Fill({
|
||||
color: 'rgba(255,0,0,0.8)'
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: 'rgb(255,0,0)',
|
||||
width: 15
|
||||
}),
|
||||
radius: 120
|
||||
})
|
||||
})
|
||||
});
|
||||
const greenLayer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
// 433.013 is roughly 250 * Math.sqrt(3)
|
||||
features: [new Feature(new Point([250, 433.013]))]
|
||||
}),
|
||||
style: new Style({
|
||||
image: new CircleStyle({
|
||||
fill: new Fill({
|
||||
color: 'rgba(0,255,0,0.8)'
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: 'rgb(0,255,0)',
|
||||
width: 15
|
||||
}),
|
||||
radius: 120
|
||||
})
|
||||
})
|
||||
});
|
||||
const blueLayer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
features: [new Feature(new Point([500, 0]))]
|
||||
}),
|
||||
style: new Style({
|
||||
image: new CircleStyle({
|
||||
fill: new Fill({
|
||||
color: 'rgba(0,0,255,0.8)'
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: 'rgb(0,0,255)',
|
||||
width: 15
|
||||
}),
|
||||
radius: 120
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
// Create the map, the view is centered on the triangle. Zooming and panning is
|
||||
// restricted to a sane area
|
||||
const map = new Map({
|
||||
layers: [
|
||||
redLayer,
|
||||
greenLayer,
|
||||
blueLayer
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [250, 220],
|
||||
extent: [0, 0, 500, 500],
|
||||
resolution: 4,
|
||||
minResolution: 2,
|
||||
maxResolution: 32
|
||||
})
|
||||
});
|
||||
|
||||
// Get the form elements and bind the listeners
|
||||
const select = document.getElementById('blend-mode');
|
||||
const affectRed = document.getElementById('affect-red');
|
||||
const affectGreen = document.getElementById('affect-green');
|
||||
const affectBlue = document.getElementById('affect-blue');
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the globalCompositeOperation to the value of the select
|
||||
* field and it is bound to the precompose event of the layers.
|
||||
*
|
||||
* @param {module:ol/render/Event~RenderEvent} evt The render event.
|
||||
*/
|
||||
const setBlendModeFromSelect = function(evt) {
|
||||
evt.context.globalCompositeOperation = select.value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This method resets the globalCompositeOperation to the default value of
|
||||
* 'source-over' and it is bound to the postcompose event of the layers.
|
||||
*
|
||||
* @param {module:ol/render/Event~RenderEvent} evt The render event.
|
||||
*/
|
||||
const resetBlendModeFromSelect = function(evt) {
|
||||
evt.context.globalCompositeOperation = 'source-over';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Bind the pre- and postcompose handlers to the passed layer.
|
||||
*
|
||||
* @param {module:ol/layer/Vector} layer The layer to bind the handlers to.
|
||||
*/
|
||||
const bindLayerListeners = function(layer) {
|
||||
layer.on('precompose', setBlendModeFromSelect);
|
||||
layer.on('postcompose', resetBlendModeFromSelect);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Unind the pre- and postcompose handlers to the passed layers.
|
||||
*
|
||||
* @param {module:ol/layer/Vector} layer The layer to unbind the handlers from.
|
||||
*/
|
||||
const unbindLayerListeners = function(layer) {
|
||||
layer.un('precompose', setBlendModeFromSelect);
|
||||
layer.un('postcompose', resetBlendModeFromSelect);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler for the click event of the 'affect-XXX' checkboxes.
|
||||
*
|
||||
* @this {HTMLInputElement}
|
||||
*/
|
||||
const affectLayerClicked = function() {
|
||||
let layer;
|
||||
if (this.id == 'affect-red') {
|
||||
layer = redLayer;
|
||||
} else if (this.id == 'affect-green') {
|
||||
layer = greenLayer;
|
||||
} else {
|
||||
layer = blueLayer;
|
||||
}
|
||||
if (this.checked) {
|
||||
bindLayerListeners(layer);
|
||||
} else {
|
||||
unbindLayerListeners(layer);
|
||||
}
|
||||
map.render();
|
||||
};
|
||||
|
||||
|
||||
// Rerender map when blend mode changes
|
||||
select.addEventListener('change', function() {
|
||||
map.render();
|
||||
});
|
||||
|
||||
// Unbind / bind listeners depending on the checked state when the checkboxes
|
||||
// are clicked
|
||||
affectRed.addEventListener('click', affectLayerClicked);
|
||||
affectGreen.addEventListener('click', affectLayerClicked);
|
||||
affectBlue.addEventListener('click', affectLayerClicked);
|
||||
|
||||
// Initially bind listeners
|
||||
bindLayerListeners(redLayer);
|
||||
bindLayerListeners(greenLayer);
|
||||
bindLayerListeners(blueLayer);
|
||||
@@ -61,8 +61,8 @@ const style = new Style({
|
||||
* The styling function for the vector layer, will return an array of styles
|
||||
* which either contains the aboove gradient or pattern.
|
||||
*
|
||||
* @param {import("../src/ol/Feature.js").default} feature The feature to style.
|
||||
* @return {Style} The style to use for the feature.
|
||||
* @param {module:ol/Feature~Feature} feature The feature to style.
|
||||
* @return {module:ol/style/Style} The style to use for the feature.
|
||||
*/
|
||||
const getStackedStyle = function(feature) {
|
||||
const id = feature.getId();
|
||||
|
||||
@@ -4,7 +4,10 @@ title: Canvas Tiles
|
||||
shortdesc: Renders tiles with coordinates for debugging.
|
||||
docs: >
|
||||
The black grid tiles are generated on the client with an HTML5 canvas. The
|
||||
displayed tile coordinates are the XYZ tile coordinates.
|
||||
displayed tile coordinates are OpenLayers tile coordinates. These increase
|
||||
from bottom to top, but standard XYZ tiling scheme coordinates increase from
|
||||
top to bottom. To calculate the `y` for a standard XYZ tile coordinate, use
|
||||
`-y - 1`.
|
||||
tags: "layers, openstreetmap, canvas"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import {OSM, TileDebug} from '../src/ol/source.js';
|
||||
|
||||
|
||||
const osmSource = new OSM();
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new OSM()
|
||||
source: osmSource
|
||||
}),
|
||||
new TileLayer({
|
||||
source: new TileDebug()
|
||||
source: new TileDebug({
|
||||
projection: 'EPSG:3857',
|
||||
tileGrid: osmSource.getTileGrid()
|
||||
})
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
zoom: 1
|
||||
center: fromLonLat([-0.1275, 51.507222]),
|
||||
zoom: 10
|
||||
})
|
||||
});
|
||||
|
||||
@@ -21,6 +21,8 @@ tags: "center, rotation, openstreetmap"
|
||||
<div class="padding-bottom"></div>
|
||||
<div class="center"></div>
|
||||
</div>
|
||||
<button id="zoomtoswitzerland">Zoom to Switzerland</button> (best fit).<br/>
|
||||
<button id="zoomtoswitzerlandbest">Zoom to Switzerland</button> (best fit),<br/>
|
||||
<button id="zoomtoswitzerlandconstrained">Zoom to Switzerland</button> (respect resolution constraint).<br/>
|
||||
<button id="zoomtoswitzerlandnearest">Zoom to Switzerland</button> (nearest),<br/>
|
||||
<button id="zoomtolausanne">Zoom to Lausanne</button> (with min resolution),<br/>
|
||||
<button id="centerlausanne">Center on Lausanne</button>
|
||||
|
||||
@@ -47,25 +47,40 @@ const map = new Map({
|
||||
view: view
|
||||
});
|
||||
|
||||
const zoomtoswitzerland =
|
||||
document.getElementById('zoomtoswitzerland');
|
||||
zoomtoswitzerland.addEventListener('click', function() {
|
||||
const zoomtoswitzerlandbest = document.getElementById('zoomtoswitzerlandbest');
|
||||
zoomtoswitzerlandbest.addEventListener('click', function() {
|
||||
const feature = source.getFeatures()[0];
|
||||
const polygon = /** @type {import("../src/ol/geom/SimpleGeometry.js").default} */ (feature.getGeometry());
|
||||
const polygon = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
||||
view.fit(polygon, {padding: [170, 50, 30, 150], constrainResolution: false});
|
||||
}, false);
|
||||
|
||||
const zoomtoswitzerlandconstrained =
|
||||
document.getElementById('zoomtoswitzerlandconstrained');
|
||||
zoomtoswitzerlandconstrained.addEventListener('click', function() {
|
||||
const feature = source.getFeatures()[0];
|
||||
const polygon = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
||||
view.fit(polygon, {padding: [170, 50, 30, 150]});
|
||||
}, false);
|
||||
|
||||
const zoomtoswitzerlandnearest =
|
||||
document.getElementById('zoomtoswitzerlandnearest');
|
||||
zoomtoswitzerlandnearest.addEventListener('click', function() {
|
||||
const feature = source.getFeatures()[0];
|
||||
const polygon = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
||||
view.fit(polygon, {padding: [170, 50, 30, 150], nearest: true});
|
||||
}, false);
|
||||
|
||||
const zoomtolausanne = document.getElementById('zoomtolausanne');
|
||||
zoomtolausanne.addEventListener('click', function() {
|
||||
const feature = source.getFeatures()[1];
|
||||
const point = /** @type {import("../src/ol/geom/SimpleGeometry.js").default} */ (feature.getGeometry());
|
||||
const point = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
||||
view.fit(point, {padding: [170, 50, 30, 150], minResolution: 50});
|
||||
}, false);
|
||||
|
||||
const centerlausanne = document.getElementById('centerlausanne');
|
||||
centerlausanne.addEventListener('click', function() {
|
||||
const feature = source.getFeatures()[1];
|
||||
const point = /** @type {import("../src/ol/geom/Point.js").default} */ (feature.getGeometry());
|
||||
const size = map.getSize();
|
||||
const point = /** @type {module:ol/geom/Point~Point} */ (feature.getGeometry());
|
||||
const size = /** @type {module:ol/size~Size} */ (map.getSize());
|
||||
view.centerOn(point.getCoordinates(), size, [570, 500]);
|
||||
}, false);
|
||||
|
||||
@@ -100,7 +100,8 @@ function xyz2rgb(x) {
|
||||
|
||||
const raster = new RasterSource({
|
||||
sources: [new Stamen({
|
||||
layer: 'watercolor'
|
||||
layer: 'watercolor',
|
||||
transition: 0
|
||||
})],
|
||||
operation: function(pixels, data) {
|
||||
const hcl = rgb2hcl(pixels[0]);
|
||||
|
||||
@@ -9,11 +9,14 @@ import OSM from '../src/ol/source/OSM.js';
|
||||
// Define rotate to north control.
|
||||
//
|
||||
|
||||
class RotateNorthControl extends Control {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {module:ol/control/Control~Control}
|
||||
* @param {Object=} opt_options Control options.
|
||||
*/
|
||||
class RotateNorthControl extends Control {
|
||||
|
||||
constructor(opt_options) {
|
||||
const options = opt_options || {};
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ import {TileJSON, Vector as VectorSource} from '../src/ol/source.js';
|
||||
import {Fill, Icon, Stroke, Style} from '../src/ol/style.js';
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {module:ol/interaction/Pointer}
|
||||
*/
|
||||
class Drag extends PointerInteraction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -18,7 +22,7 @@ class Drag extends PointerInteraction {
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {import("../src/ol/coordinate.js").Coordinate}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
* @private
|
||||
*/
|
||||
this.coordinate_ = null;
|
||||
@@ -30,7 +34,7 @@ class Drag extends PointerInteraction {
|
||||
this.cursor_ = 'pointer';
|
||||
|
||||
/**
|
||||
* @type {Feature}
|
||||
* @type {module:ol/Feature~Feature}
|
||||
* @private
|
||||
*/
|
||||
this.feature_ = null;
|
||||
@@ -45,7 +49,7 @@ class Drag extends PointerInteraction {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../src/ol/MapBrowserEvent.js").default} evt Map browser event.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt Map browser event.
|
||||
* @return {boolean} `true` to start the drag sequence.
|
||||
*/
|
||||
function handleDownEvent(evt) {
|
||||
@@ -66,7 +70,7 @@ function handleDownEvent(evt) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../src/ol/MapBrowserEvent.js").default} evt Map browser event.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt Map browser event.
|
||||
*/
|
||||
function handleDragEvent(evt) {
|
||||
const deltaX = evt.coordinate[0] - this.coordinate_[0];
|
||||
@@ -81,7 +85,7 @@ function handleDragEvent(evt) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../src/ol/MapBrowserEvent.js").default} evt Event.
|
||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt Event.
|
||||
*/
|
||||
function handleMoveEvent(evt) {
|
||||
if (this.cursor_) {
|
||||
@@ -137,13 +141,13 @@ const map = new Map({
|
||||
features: [pointFeature, lineFeature, polygonFeature]
|
||||
}),
|
||||
style: new Style({
|
||||
image: new Icon({
|
||||
image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({
|
||||
anchor: [0.5, 46],
|
||||
anchorXUnits: 'fraction',
|
||||
anchorYUnits: 'pixels',
|
||||
opacity: 0.95,
|
||||
src: 'data/icon.png'
|
||||
}),
|
||||
})),
|
||||
stroke: new Stroke({
|
||||
width: 3,
|
||||
color: [255, 0, 0, 1]
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
path.boundary {
|
||||
fill: none;
|
||||
stroke: #777;
|
||||
}
|
||||
@@ -3,10 +3,10 @@ layout: example.html
|
||||
title: d3 Integration
|
||||
shortdesc: Example of using OpenLayers and d3 together.
|
||||
docs: >
|
||||
The example loads TopoJSON geometries and uses d3 (<code>d3.geo.path</code>) to render these geometries to a SVG element.
|
||||
<p>The example loads TopoJSON geometries and uses d3 (<code>d3.geo.path</code>) to render these geometries to a canvas element that is then used as the image of an OpenLayers image layer.</p>
|
||||
tags: "d3"
|
||||
resources:
|
||||
- https://unpkg.com/d3@5.9.2/dist/d3.js
|
||||
- https://unpkg.com/d3@4.12.0/build/d3.js
|
||||
- https://unpkg.com/topojson@3.0.2/dist/topojson.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
124
examples/d3.js
vendored
124
examples/d3.js
vendored
@@ -1,70 +1,10 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {getWidth, getCenter} from '../src/ol/extent.js';
|
||||
import {Layer, Tile as TileLayer} from '../src/ol/layer.js';
|
||||
import SourceState from '../src/ol/source/State';
|
||||
import {Image as ImageLayer, Tile as TileLayer} from '../src/ol/layer.js';
|
||||
import {fromLonLat, toLonLat} from '../src/ol/proj.js';
|
||||
import Stamen from '../src/ol/source/Stamen.js';
|
||||
import {ImageCanvas as ImageCanvasSource, Stamen} from '../src/ol/source.js';
|
||||
|
||||
class CanvasLayer extends Layer {
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.features = options.features;
|
||||
|
||||
this.svg = d3.select(document.createElement('div')).append('svg')
|
||||
.style('position', 'absolute');
|
||||
|
||||
this.svg.append('path')
|
||||
.datum(this.features)
|
||||
.attr('class', 'boundary');
|
||||
}
|
||||
|
||||
getSourceState() {
|
||||
return SourceState.READY;
|
||||
}
|
||||
|
||||
render(frameState) {
|
||||
const width = frameState.size[0];
|
||||
const height = frameState.size[1];
|
||||
const projection = frameState.viewState.projection;
|
||||
const d3Projection = d3.geoMercator().scale(1).translate([0, 0]);
|
||||
let d3Path = d3.geoPath().projection(d3Projection);
|
||||
|
||||
const pixelBounds = d3Path.bounds(this.features);
|
||||
const pixelBoundsWidth = pixelBounds[1][0] - pixelBounds[0][0];
|
||||
const pixelBoundsHeight = pixelBounds[1][1] - pixelBounds[0][1];
|
||||
|
||||
const geoBounds = d3.geoBounds(this.features);
|
||||
const geoBoundsLeftBottom = fromLonLat(geoBounds[0], projection);
|
||||
const geoBoundsRightTop = fromLonLat(geoBounds[1], projection);
|
||||
let geoBoundsWidth = geoBoundsRightTop[0] - geoBoundsLeftBottom[0];
|
||||
if (geoBoundsWidth < 0) {
|
||||
geoBoundsWidth += getWidth(projection.getExtent());
|
||||
}
|
||||
const geoBoundsHeight = geoBoundsRightTop[1] - geoBoundsLeftBottom[1];
|
||||
|
||||
const widthResolution = geoBoundsWidth / pixelBoundsWidth;
|
||||
const heightResolution = geoBoundsHeight / pixelBoundsHeight;
|
||||
const r = Math.max(widthResolution, heightResolution);
|
||||
const scale = r / frameState.viewState.resolution;
|
||||
|
||||
const center = toLonLat(getCenter(frameState.extent), projection);
|
||||
d3Projection.scale(scale).center(center).translate([width / 2, height / 2]);
|
||||
|
||||
d3Path = d3Path.projection(d3Projection);
|
||||
d3Path(this.features);
|
||||
|
||||
this.svg.attr('width', width);
|
||||
this.svg.attr('height', height);
|
||||
|
||||
this.svg.select('path')
|
||||
.attr('d', d3Path);
|
||||
|
||||
return this.svg.node();
|
||||
}
|
||||
}
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
@@ -85,11 +25,63 @@ const map = new Map({
|
||||
/**
|
||||
* Load the topojson data and create an ol/layer/Image for that data.
|
||||
*/
|
||||
d3.json('data/topojson/us.json').then(function(us) {
|
||||
d3.json('data/topojson/us.json', function(error, us) {
|
||||
const features = topojson.feature(us, us.objects.counties);
|
||||
|
||||
const layer = new CanvasLayer({
|
||||
features: topojson.feature(us, us.objects.counties)
|
||||
/**
|
||||
* This function uses d3 to render the topojson features to a canvas.
|
||||
* @param {module:ol/extent~Extent} extent Extent.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {module:ol/size~Size} size Size.
|
||||
* @param {module:ol/proj/Projection~Projection} projection Projection.
|
||||
* @return {HTMLCanvasElement} A canvas element.
|
||||
*/
|
||||
const canvasFunction = function(extent, resolution, pixelRatio, size, projection) {
|
||||
const canvasWidth = size[0];
|
||||
const canvasHeight = size[1];
|
||||
|
||||
const canvas = d3.select(document.createElement('canvas'));
|
||||
canvas.attr('width', canvasWidth).attr('height', canvasHeight);
|
||||
|
||||
const context = canvas.node().getContext('2d');
|
||||
|
||||
const d3Projection = d3.geoMercator().scale(1).translate([0, 0]);
|
||||
let d3Path = d3.geoPath().projection(d3Projection);
|
||||
|
||||
const pixelBounds = d3Path.bounds(features);
|
||||
const pixelBoundsWidth = pixelBounds[1][0] - pixelBounds[0][0];
|
||||
const pixelBoundsHeight = pixelBounds[1][1] - pixelBounds[0][1];
|
||||
|
||||
const geoBounds = d3.geoBounds(features);
|
||||
const geoBoundsLeftBottom = fromLonLat(geoBounds[0], projection);
|
||||
const geoBoundsRightTop = fromLonLat(geoBounds[1], projection);
|
||||
let geoBoundsWidth = geoBoundsRightTop[0] - geoBoundsLeftBottom[0];
|
||||
if (geoBoundsWidth < 0) {
|
||||
geoBoundsWidth += getWidth(projection.getExtent());
|
||||
}
|
||||
const geoBoundsHeight = geoBoundsRightTop[1] - geoBoundsLeftBottom[1];
|
||||
|
||||
const widthResolution = geoBoundsWidth / pixelBoundsWidth;
|
||||
const heightResolution = geoBoundsHeight / pixelBoundsHeight;
|
||||
const r = Math.max(widthResolution, heightResolution);
|
||||
const scale = r / (resolution / pixelRatio);
|
||||
|
||||
const center = toLonLat(getCenter(extent), projection);
|
||||
d3Projection.scale(scale).center(center)
|
||||
.translate([canvasWidth / 2, canvasHeight / 2]);
|
||||
d3Path = d3Path.projection(d3Projection).context(context);
|
||||
d3Path(features);
|
||||
context.stroke();
|
||||
|
||||
return canvas.node();
|
||||
};
|
||||
|
||||
const layer = new ImageLayer({
|
||||
source: new ImageCanvasSource({
|
||||
canvasFunction: canvasFunction,
|
||||
projection: 'EPSG:3857'
|
||||
})
|
||||
});
|
||||
|
||||
map.addLayer(layer);
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect width="20" height="20" style="fill:#fff" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 194 B |
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB |
@@ -29,7 +29,7 @@ gn.init().then(function() {
|
||||
gn.start(function(event) {
|
||||
const center = view.getCenter();
|
||||
const resolution = view.getResolution();
|
||||
const alpha = toRadians(event.do.alpha);
|
||||
const alpha = toRadians(event.do.beta);
|
||||
const beta = toRadians(event.do.beta);
|
||||
const gamma = toRadians(event.do.gamma);
|
||||
|
||||
@@ -40,6 +40,6 @@ gn.init().then(function() {
|
||||
center[0] -= resolution * gamma * 25;
|
||||
center[1] += resolution * beta * 25;
|
||||
|
||||
view.setCenter(center);
|
||||
view.setCenter(view.constrainCenter(center));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ layout: example.html
|
||||
title: Drag-and-Drop Image Vector
|
||||
shortdesc: Example of using the drag-and-drop interaction with image vector rendering.
|
||||
docs: >
|
||||
Example of using the drag-and-drop interaction with an `ol/layer/VectorImage` layer. Drag and drop GPX, GeoJSON, IGC, KML, or TopoJSON files on to the map. Each file is rendered to an image on the client.
|
||||
Example of using the drag-and-drop interaction with an `ol/layer/Vector` with `renderMode: 'image'`. Drag and drop GPX, GeoJSON, IGC, KML, or TopoJSON files on to the map. Each file is rendered to an image on the client.
|
||||
tags: "drag-and-drop-image-vector, gpx, geojson, igc, kml, topojson, vector, image"
|
||||
cloak:
|
||||
- key: As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5
|
||||
|
||||
@@ -2,7 +2,7 @@ import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {GPX, GeoJSON, IGC, KML, TopoJSON} from '../src/ol/format.js';
|
||||
import {defaults as defaultInteractions, DragAndDrop} from '../src/ol/interaction.js';
|
||||
import {VectorImage as VectorImageLayer, Tile as TileLayer} from '../src/ol/layer.js';
|
||||
import {Vector as VectorLayer, Tile as TileLayer} from '../src/ol/layer.js';
|
||||
import {BingMaps, Vector as VectorSource} from '../src/ol/source.js';
|
||||
|
||||
const dragAndDropInteraction = new DragAndDrop({
|
||||
@@ -36,7 +36,8 @@ dragAndDropInteraction.on('addfeatures', function(event) {
|
||||
const vectorSource = new VectorSource({
|
||||
features: event.features
|
||||
});
|
||||
map.addLayer(new VectorImageLayer({
|
||||
map.addLayer(new VectorLayer({
|
||||
renderMode: 'image',
|
||||
source: vectorSource
|
||||
}));
|
||||
map.getView().fit(vectorSource.getExtent());
|
||||
|
||||
@@ -4,14 +4,14 @@ import {MultiPoint, Point} from '../src/ol/geom.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import OSM from '../src/ol/source/OSM.js';
|
||||
import {Circle as CircleStyle, Fill, Stroke, Style} from '../src/ol/style.js';
|
||||
import {getVectorContext} from '../src/ol/render.js';
|
||||
|
||||
const tileLayer = new TileLayer({
|
||||
source: new OSM()
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
layers: [tileLayer],
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new OSM()
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
@@ -46,8 +46,8 @@ const omegaTheta = 30000; // Rotation period in ms
|
||||
const R = 7e6;
|
||||
const r = 2e6;
|
||||
const p = 2e6;
|
||||
tileLayer.on('postrender', function(event) {
|
||||
const vectorContext = getVectorContext(event);
|
||||
map.on('postcompose', function(event) {
|
||||
const vectorContext = event.vectorContext;
|
||||
const frameState = event.frameState;
|
||||
const theta = 2 * Math.PI * frameState.time / omegaTheta;
|
||||
const coordinates = [];
|
||||
|
||||
18
examples/earthquake-clusters.css
Normal file
18
examples/earthquake-clusters.css
Normal file
@@ -0,0 +1,18 @@
|
||||
#map {
|
||||
position: relative;
|
||||
}
|
||||
#info {
|
||||
position: absolute;
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
z-index: 100;
|
||||
}
|
||||
.tooltip.in {
|
||||
opacity: 1;
|
||||
}
|
||||
.tooltip.top .tooltip-arrow {
|
||||
border-top-color: white;
|
||||
}
|
||||
.tooltip-inner {
|
||||
border: 2px solid white;
|
||||
}
|
||||
@@ -26,8 +26,9 @@ const styleFunction = function(feature) {
|
||||
scale = size / 10;
|
||||
let style = styleCache[size];
|
||||
if (!style) {
|
||||
const canvas = document.createElement('canvas');
|
||||
const vectorContext = toContext(canvas.getContext('2d'),
|
||||
const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('canvas'));
|
||||
const vectorContext = toContext(
|
||||
/** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')),
|
||||
{size: [size, size], pixelRatio: 1});
|
||||
vectorContext.setStyle(new Style({
|
||||
fill: new Fill({color: 'rgba(255, 153, 0, 0.4)'}),
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
.overlay {
|
||||
background-color: yellow;
|
||||
border-radius: 6px;
|
||||
padding: 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -3,13 +3,12 @@ layout: example.html
|
||||
title: Map Export
|
||||
shortdesc: Example of exporting a map as a PNG image.
|
||||
docs: >
|
||||
Example of exporting a map as a PNG image. This example use the <a href="https://www.npmjs.com/package/html-to-image">html-to-image</a>
|
||||
library.
|
||||
Example of exporting a map as a PNG image. This example requires a browser
|
||||
that supports <a href="https://developer.mozilla.org/de/docs/Web/API/HTMLCanvasElement/toBlob#Browser_compatibility">
|
||||
<code>canvas.toBlob()</code></a>.
|
||||
tags: "export, png, openstreetmap"
|
||||
resources:
|
||||
- https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<div style="display: none;">
|
||||
<div class="overlay" id="null">Null Island</div>
|
||||
</div>
|
||||
<a id="export-png" class="btn btn-default"><i class="fa fa-download"></i> Download PNG</a>
|
||||
<a id="image-download" download="map.png"></a>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import Overlay from '../src/ol/Overlay.js';
|
||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
|
||||
|
||||
import {toPng} from 'html-to-image';
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
@@ -26,28 +23,16 @@ const map = new Map({
|
||||
})
|
||||
});
|
||||
|
||||
map.addOverlay(new Overlay({
|
||||
position: [0, 0],
|
||||
element: document.getElementById('null')
|
||||
}));
|
||||
|
||||
|
||||
// export options for html-to-image.
|
||||
// See: https://github.com/bubkoo/html-to-image#options
|
||||
const exportOptions = {
|
||||
filter: function(element) {
|
||||
return element.className ? element.className.indexOf('ol-control') === -1 : true;
|
||||
}
|
||||
};
|
||||
|
||||
document.getElementById('export-png').addEventListener('click', function() {
|
||||
map.once('rendercomplete', function() {
|
||||
toPng(map.getTargetElement(), exportOptions)
|
||||
.then(function(dataURL) {
|
||||
const link = document.getElementById('image-download');
|
||||
link.href = dataURL;
|
||||
link.click();
|
||||
map.once('rendercomplete', function(event) {
|
||||
const canvas = event.context.canvas;
|
||||
if (navigator.msSaveBlob) {
|
||||
navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
|
||||
} else {
|
||||
canvas.toBlob(function(blob) {
|
||||
saveAs(blob, 'map.png');
|
||||
});
|
||||
}
|
||||
});
|
||||
map.renderSync();
|
||||
});
|
||||
|
||||
@@ -4,8 +4,6 @@ import WKT from '../src/ol/format/WKT.js';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
|
||||
|
||||
import {toJpeg} from 'html-to-image';
|
||||
|
||||
const raster = new TileLayer({
|
||||
source: new OSM()
|
||||
});
|
||||
@@ -43,15 +41,6 @@ const dims = {
|
||||
a5: [210, 148]
|
||||
};
|
||||
|
||||
|
||||
// export options for html-to-image.
|
||||
// See: https://github.com/bubkoo/html-to-image#options
|
||||
const exportOptions = {
|
||||
filter: function(element) {
|
||||
return element.className.indexOf('ol-control') === -1;
|
||||
}
|
||||
};
|
||||
|
||||
const exportButton = document.getElementById('export-pdf');
|
||||
|
||||
exportButton.addEventListener('click', function() {
|
||||
@@ -64,23 +53,21 @@ exportButton.addEventListener('click', function() {
|
||||
const dim = dims[format];
|
||||
const width = Math.round(dim[0] * resolution / 25.4);
|
||||
const height = Math.round(dim[1] * resolution / 25.4);
|
||||
const size = map.getSize();
|
||||
const size = /** @type {module:ol/size~Size} */ (map.getSize());
|
||||
const extent = map.getView().calculateExtent(size);
|
||||
|
||||
map.once('rendercomplete', function() {
|
||||
toJpeg(map.getTargetElement(), exportOptions).then(function(dataUrl) {
|
||||
map.once('rendercomplete', function(event) {
|
||||
const canvas = event.context.canvas;
|
||||
const data = canvas.toDataURL('image/jpeg');
|
||||
const pdf = new jsPDF('landscape', undefined, format);
|
||||
pdf.addImage(dataUrl, 'JPEG', 0, 0, dim[0], dim[1]);
|
||||
pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
|
||||
pdf.save('map.pdf');
|
||||
// Reset original map size
|
||||
map.setSize(size);
|
||||
map.getView().fit(extent, {
|
||||
size: size
|
||||
});
|
||||
map.getView().fit(extent, {size});
|
||||
exportButton.disabled = false;
|
||||
document.body.style.cursor = 'auto';
|
||||
});
|
||||
});
|
||||
|
||||
// Set print size
|
||||
const printSize = [width, height];
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Constrained Extent
|
||||
shortdesc: Example of a view with a constrained extent.
|
||||
docs: >
|
||||
This map has a view that is constrained in an extent. This is done using the `extent` view option. Please note that specifying `constrainOnlyCenter: true` would only apply the extent restriction to the view center.
|
||||
tags: "view, extent, constrain, restrict"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
@@ -1,25 +0,0 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import OSM from '../src/ol/source/OSM.js';
|
||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
||||
import ZoomSlider from '../src/ol/control/ZoomSlider';
|
||||
|
||||
const view = new View({
|
||||
center: [328627.563458, 5921296.662223],
|
||||
zoom: 8,
|
||||
extent: [-572513.341856, 5211017.966314,
|
||||
916327.095083, 6636950.728974]
|
||||
});
|
||||
|
||||
new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new OSM()
|
||||
})
|
||||
],
|
||||
keyboardEventTarget: document,
|
||||
target: 'map',
|
||||
view: view,
|
||||
controls: defaultControls().extend([new ZoomSlider()])
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {platformModifierKeyOnly} from '../src/ol/events/condition.js';
|
||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
||||
import ExtentInteraction from '../src/ol/interaction/Extent.js';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
@@ -26,7 +27,9 @@ const map = new Map({
|
||||
})
|
||||
});
|
||||
|
||||
const extent = new ExtentInteraction();
|
||||
const extent = new ExtentInteraction({
|
||||
condition: platformModifierKeyOnly
|
||||
});
|
||||
map.addInteraction(extent);
|
||||
extent.setActive(false);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ layout: example.html
|
||||
title: Custom Animation
|
||||
shortdesc: Demonstrates how to animate features.
|
||||
docs: >
|
||||
This example shows how to use <b>postrender</b> and <b>vectorContext</b> to
|
||||
This example shows how to use <b>postcompose</b> and <b>vectorContext</b> to
|
||||
animate features. Here we choose to do a flash animation each time a feature
|
||||
is added to the layer.
|
||||
tags: "animation, vector, feature, flash"
|
||||
|
||||
@@ -8,16 +8,16 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
|
||||
import {Circle as CircleStyle, Stroke, Style} from '../src/ol/style.js';
|
||||
import {getVectorContext} from '../src/ol/render.js';
|
||||
|
||||
const tileLayer = new TileLayer({
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new OSM({
|
||||
wrapX: false
|
||||
})
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
layers: [tileLayer],
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
@@ -44,10 +44,10 @@ function addRandomFeature() {
|
||||
const duration = 3000;
|
||||
function flash(feature) {
|
||||
const start = new Date().getTime();
|
||||
const listenerKey = tileLayer.on('postrender', animate);
|
||||
const listenerKey = map.on('postcompose', animate);
|
||||
|
||||
function animate(event) {
|
||||
const vectorContext = getVectorContext(event);
|
||||
const vectorContext = event.vectorContext;
|
||||
const frameState = event.frameState;
|
||||
const flashGeom = feature.getGeometry().clone();
|
||||
const elapsed = frameState.time - start;
|
||||
@@ -72,7 +72,7 @@ function flash(feature) {
|
||||
unByKey(listenerKey);
|
||||
return;
|
||||
}
|
||||
// tell OpenLayers to continue postrender animation
|
||||
// tell OpenLayers to continue postcompose animation
|
||||
map.render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ layout: example.html
|
||||
title: Marker Animation
|
||||
shortdesc: Demonstrates how to move a feature along a line.
|
||||
docs: >
|
||||
This example shows how to use <b>postrender</b> events and a <b>vector context</b> to
|
||||
animate a marker feature along a line. In this example an encoded polyline
|
||||
This example shows how to use <b>postcompose</b> and <b>vectorContext</b> to
|
||||
animate a (marker) feature along a line. In this example an encoded polyline
|
||||
is being used.
|
||||
tags: "animation, feature, postrender, polyline"
|
||||
tags: "animation, feature, postcompose, polyline"
|
||||
cloak:
|
||||
- key: As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5
|
||||
value: Your Bing Maps Key from http://www.bingmapsportal.com/ here
|
||||
|
||||
@@ -7,7 +7,6 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Circle as CircleStyle, Fill, Icon, Stroke, Style} from '../src/ol/style.js';
|
||||
import {getVectorContext} from '../src/ol/render.js';
|
||||
|
||||
// This long string is placed here due to jsFiddle limitations.
|
||||
// It is usually loaded with AJAX.
|
||||
@@ -53,7 +52,7 @@ const polyline = [
|
||||
'~@ym@yjA??a@cFd@kBrCgDbAUnAcBhAyAdk@et@??kF}D??OL'
|
||||
].join('');
|
||||
|
||||
const route = /** @type {import("../src/ol/geom/LineString.js").default} */ (new Polyline({
|
||||
const route = /** @type {module:ol/geom/LineString~LineString} */ (new Polyline({
|
||||
factor: 1e6
|
||||
}).readGeometry(polyline, {
|
||||
dataProjection: 'EPSG:4326',
|
||||
@@ -124,6 +123,7 @@ const vectorLayer = new VectorLayer({
|
||||
const center = [-5639523.95, -3501274.52];
|
||||
const map = new Map({
|
||||
target: document.getElementById('map'),
|
||||
loadTilesWhileAnimating: true,
|
||||
view: new View({
|
||||
center: center,
|
||||
zoom: 10,
|
||||
@@ -133,7 +133,7 @@ const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new BingMaps({
|
||||
imagerySet: 'AerialWithLabelsOnDemand',
|
||||
imagerySet: 'AerialWithLabels',
|
||||
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
||||
})
|
||||
}),
|
||||
@@ -142,7 +142,7 @@ const map = new Map({
|
||||
});
|
||||
|
||||
const moveFeature = function(event) {
|
||||
const vectorContext = getVectorContext(event);
|
||||
const vectorContext = event.vectorContext;
|
||||
const frameState = event.frameState;
|
||||
|
||||
if (animating) {
|
||||
@@ -160,7 +160,7 @@ const moveFeature = function(event) {
|
||||
const feature = new Feature(currentPoint);
|
||||
vectorContext.drawFeature(feature, styles.geoMarker);
|
||||
}
|
||||
// tell OpenLayers to continue the postrender animation
|
||||
// tell OpenLayers to continue the postcompose animation
|
||||
map.render();
|
||||
};
|
||||
|
||||
@@ -176,7 +176,7 @@ function startAnimation() {
|
||||
geoMarker.setStyle(null);
|
||||
// just in case you pan somewhere else
|
||||
map.getView().setCenter(center);
|
||||
vectorLayer.on('postrender', moveFeature);
|
||||
map.on('postcompose', moveFeature);
|
||||
map.render();
|
||||
}
|
||||
}
|
||||
@@ -191,10 +191,10 @@ function stopAnimation(ended) {
|
||||
|
||||
// if animation cancelled set the marker at the beginning
|
||||
const coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
|
||||
const geometry = /** @type {import("../src/ol/geom/Point").default} */ (geoMarker.getGeometry());
|
||||
geometry.setCoordinates(coord);
|
||||
/** @type {module:ol/geom/Point~Point} */ (geoMarker.getGeometry())
|
||||
.setCoordinates(coord);
|
||||
//remove listener
|
||||
vectorLayer.un('postrender', moveFeature);
|
||||
map.un('postcompose', moveFeature);
|
||||
}
|
||||
|
||||
startButton.addEventListener('click', startAnimation, false);
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Filtering features with WebGL
|
||||
shortdesc: Using WebGL to filter large quantities of features
|
||||
docs: >
|
||||
This example shows how to use `ol/renderer/webgl/PointsLayer` to dynamically filter a large amount
|
||||
of point geometries. The above map is based on a dataset from the NASA containing 45k recorded meteorite
|
||||
landing sites. Each meteorite is marked by a circle on the map (the bigger the circle, the heavier
|
||||
the object). A pulse effect has been added, which is slightly offset by the year of the impact.
|
||||
|
||||
Adjusting the sliders causes the objects outside of the date range to be filtered out of the map. This is done using
|
||||
a custom fragment shader on the layer renderer, and by using the `v_opacity` attribute of the rendered objects
|
||||
to store the year of impact.
|
||||
|
||||
tags: "webgl, icon, sprite, filter, feature"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<form>
|
||||
<div id="status">Show impacts between <span class="min-year"></span> and <span class="max-year"></span></div>
|
||||
|
||||
<label>Minimum year:</label>
|
||||
<input id="min-year" type="range" min="1850" max="2015" step="1" value="1850"/>
|
||||
<label>Maximum year:</label>
|
||||
<input id="max-year" type="range" min="1850" max="2015" step="1" value="2015"/>
|
||||
</form>
|
||||
@@ -1,163 +0,0 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import Feature from '../src/ol/Feature';
|
||||
import Point from '../src/ol/geom/Point';
|
||||
import VectorLayer from '../src/ol/layer/Vector';
|
||||
import {Vector} from '../src/ol/source';
|
||||
import {fromLonLat} from '../src/ol/proj';
|
||||
import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer';
|
||||
import {clamp, lerp} from '../src/ol/math';
|
||||
import Stamen from '../src/ol/source/Stamen';
|
||||
|
||||
const vectorSource = new Vector({
|
||||
attributions: 'NASA'
|
||||
});
|
||||
|
||||
const oldColor = [180, 140, 140];
|
||||
const newColor = [255, 80, 80];
|
||||
|
||||
const startTime = Date.now() * 0.001;
|
||||
|
||||
// hanle input values & events
|
||||
const minYearInput = document.getElementById('min-year');
|
||||
const maxYearInput = document.getElementById('max-year');
|
||||
function updateStatusText() {
|
||||
const div = document.getElementById('status');
|
||||
div.querySelector('span.min-year').textContent = minYearInput.value;
|
||||
div.querySelector('span.max-year').textContent = maxYearInput.value;
|
||||
}
|
||||
minYearInput.addEventListener('input', updateStatusText);
|
||||
minYearInput.addEventListener('change', updateStatusText);
|
||||
maxYearInput.addEventListener('input', updateStatusText);
|
||||
maxYearInput.addEventListener('change', updateStatusText);
|
||||
updateStatusText();
|
||||
|
||||
class WebglPointsLayer extends VectorLayer {
|
||||
createRenderer() {
|
||||
return new WebGLPointsLayerRenderer(this, {
|
||||
colorCallback: function(feature, color) {
|
||||
// color is interpolated based on year
|
||||
const ratio = clamp((feature.get('year') - 1800) / (2013 - 1800), 0, 1);
|
||||
|
||||
color[0] = lerp(oldColor[0], newColor[0], ratio) / 255;
|
||||
color[1] = lerp(oldColor[1], newColor[1], ratio) / 255;
|
||||
color[2] = lerp(oldColor[2], newColor[2], ratio) / 255;
|
||||
color[3] = 1;
|
||||
|
||||
return color;
|
||||
},
|
||||
sizeCallback: function(feature) {
|
||||
return 18 * clamp(feature.get('mass') / 200000, 0, 1) + 8;
|
||||
},
|
||||
fragmentShader: [
|
||||
'precision mediump float;',
|
||||
|
||||
'uniform float u_time;',
|
||||
'uniform float u_minYear;',
|
||||
'uniform float u_maxYear;',
|
||||
|
||||
'varying vec2 v_texCoord;',
|
||||
'varying float v_opacity;',
|
||||
'varying vec4 v_color;',
|
||||
|
||||
'void main(void) {',
|
||||
' float impactYear = v_opacity;',
|
||||
|
||||
// filter out pixels if the year is outside of the given range
|
||||
' if (impactYear < u_minYear || v_opacity > u_maxYear) {',
|
||||
' discard;',
|
||||
' }',
|
||||
|
||||
' vec2 texCoord = v_texCoord * 2.0 - vec2(1.0, 1.0);',
|
||||
' float sqRadius = texCoord.x * texCoord.x + texCoord.y * texCoord.y;',
|
||||
' float value = 2.0 * (1.0 - sqRadius);',
|
||||
' float alpha = smoothstep(0.0, 1.0, value);',
|
||||
|
||||
' vec3 color = v_color.rgb;',
|
||||
' float period = 8.0;',
|
||||
' color.g *= 2.0 * (1.0 - sqrt(mod(u_time + impactYear * 0.025, period) / period));',
|
||||
|
||||
' gl_FragColor = vec4(color, v_color.a);',
|
||||
' gl_FragColor.a *= alpha;',
|
||||
' gl_FragColor.rgb *= gl_FragColor.a;',
|
||||
'}'
|
||||
].join(' '),
|
||||
opacityCallback: function(feature) {
|
||||
// here the opacity channel of the vertices is used to store the year of impact
|
||||
return feature.get('year');
|
||||
},
|
||||
uniforms: {
|
||||
u_time: function() {
|
||||
return Date.now() * 0.001 - startTime;
|
||||
},
|
||||
u_minYear: function() {
|
||||
return parseInt(minYearInput.value);
|
||||
},
|
||||
u_maxYear: function() {
|
||||
return parseInt(maxYearInput.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function loadData() {
|
||||
const client = new XMLHttpRequest();
|
||||
client.open('GET', 'data/csv/meteorite_landings.csv');
|
||||
client.onload = function() {
|
||||
const csv = client.responseText;
|
||||
const features = [];
|
||||
|
||||
let prevIndex = csv.indexOf('\n') + 1; // scan past the header line
|
||||
|
||||
let curIndex;
|
||||
while ((curIndex = csv.indexOf('\n', prevIndex)) != -1) {
|
||||
const line = csv.substr(prevIndex, curIndex - prevIndex).split(',');
|
||||
prevIndex = curIndex + 1;
|
||||
|
||||
const coords = fromLonLat([parseFloat(line[4]), parseFloat(line[3])]);
|
||||
if (isNaN(coords[0]) || isNaN(coords[1])) {
|
||||
// guard against bad data
|
||||
continue;
|
||||
}
|
||||
|
||||
features.push(new Feature({
|
||||
mass: parseFloat(line[1]) || 0,
|
||||
year: parseInt(line[2]) || 0,
|
||||
geometry: new Point(coords)
|
||||
}));
|
||||
}
|
||||
|
||||
vectorSource.addFeatures(features);
|
||||
};
|
||||
client.send();
|
||||
}
|
||||
|
||||
loadData();
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new Stamen({
|
||||
layer: 'toner'
|
||||
})
|
||||
}),
|
||||
new WebglPointsLayer({
|
||||
source: vectorSource
|
||||
})
|
||||
],
|
||||
target: document.getElementById('map'),
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
})
|
||||
});
|
||||
|
||||
// animate the map
|
||||
function animate() {
|
||||
map.render();
|
||||
window.requestAnimationFrame(animate);
|
||||
}
|
||||
animate();
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Flight Animation
|
||||
shortdesc: Demonstrates how to animate flights with ´postrender´.
|
||||
shortdesc: Demonstrates how to animate flights with ´postcompose´.
|
||||
docs: >
|
||||
This example shows how to use <b>postrender</b> and <b>vectorContext</b> to
|
||||
This example shows how to use <b>postcompose</b> and <b>vectorContext</b> to
|
||||
animate flights. A great circle arc between two airports is calculated using
|
||||
<a href="https://github.com/springmeyer/arc.js">arc.js</a> and then the flight
|
||||
paths are animated with <b>postrender</b>. The flight data is provided by
|
||||
paths are animated with <b>postcompose</b>. The flight data is provided by
|
||||
<a href="http://openflights.org/data.html">OpenFlights</a> (a simplified data
|
||||
set from the <a href="https://www.mapbox.com/mapbox.js/example/v1.0.0/animating-flight-paths/">
|
||||
Mapbox.js documentation</a> is used).
|
||||
|
||||
@@ -6,17 +6,14 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import Stamen from '../src/ol/source/Stamen.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Stroke, Style} from '../src/ol/style.js';
|
||||
import {getVectorContext} from '../src/ol/render.js';
|
||||
|
||||
const tileLayer = new TileLayer({
|
||||
source: new Stamen({
|
||||
layer: 'toner'
|
||||
})
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
tileLayer
|
||||
new TileLayer({
|
||||
source: new Stamen({
|
||||
layer: 'toner'
|
||||
})
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
@@ -66,7 +63,7 @@ const flightsSource = new VectorSource({
|
||||
addLater(feature, i * 50);
|
||||
}
|
||||
}
|
||||
tileLayer.on('postrender', animateFlights);
|
||||
map.on('postcompose', animateFlights);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -88,7 +85,7 @@ map.addLayer(flightsLayer);
|
||||
|
||||
const pointsPerMs = 0.1;
|
||||
function animateFlights(event) {
|
||||
const vectorContext = getVectorContext(event);
|
||||
const vectorContext = event.vectorContext;
|
||||
const frameState = event.frameState;
|
||||
vectorContext.setStyle(style);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
.map:-moz-full-screen {
|
||||
height: 100%;
|
||||
}
|
||||
.map:-webkit-full-screen {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.map:-ms-fullscreen {
|
||||
height: 100%;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
.fullscreen:-moz-full-screen {
|
||||
height: 100%;
|
||||
}
|
||||
.fullscreen:-webkit-full-screen {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.fullscreen:-ms-fullscreen {
|
||||
height: 100%;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
.map:-moz-full-screen {
|
||||
height: 100%;
|
||||
}
|
||||
.map:-webkit-full-screen {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.map:-ms-fullscreen {
|
||||
height: 100%;
|
||||
|
||||
@@ -77,7 +77,7 @@ fetch(url).then(function(response) {
|
||||
tileLoadFunction: function(tile) {
|
||||
const format = tile.getFormat();
|
||||
const tileCoord = tile.getTileCoord();
|
||||
const data = tileIndex.getTile(tileCoord[0], tileCoord[1], tileCoord[2]);
|
||||
const data = tileIndex.getTile(tileCoord[0], tileCoord[1], -tileCoord[2] - 1);
|
||||
|
||||
const features = format.readFeatures(
|
||||
JSON.stringify({
|
||||
|
||||
@@ -13,13 +13,13 @@ const view = new View({
|
||||
zoom: 19
|
||||
});
|
||||
|
||||
const tileLayer = new TileLayer({
|
||||
source: new OSM()
|
||||
});
|
||||
|
||||
// creating the map
|
||||
const map = new Map({
|
||||
layers: [tileLayer],
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new OSM()
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
view: view
|
||||
});
|
||||
@@ -36,7 +36,7 @@ map.addOverlay(marker);
|
||||
// LineString to store the different geolocation positions. This LineString
|
||||
// is time aware.
|
||||
// The Z dimension is actually used to store the rotation (heading).
|
||||
const positions = new LineString([], 'XYZM');
|
||||
const positions = new LineString([], /** @type {module:ol/geom/GeometryLayout} */ ('XYZM'));
|
||||
|
||||
// Geolocation Control
|
||||
const geolocation = new Geolocation({
|
||||
@@ -155,7 +155,7 @@ const geolocateBtn = document.getElementById('geolocate');
|
||||
geolocateBtn.addEventListener('click', function() {
|
||||
geolocation.setTracking(true); // Start position tracking
|
||||
|
||||
tileLayer.on('postrender', updateView);
|
||||
map.on('postcompose', updateView);
|
||||
map.render();
|
||||
|
||||
disableButtons();
|
||||
@@ -197,7 +197,7 @@ simulateBtn.addEventListener('click', function() {
|
||||
}
|
||||
geolocate();
|
||||
|
||||
tileLayer.on('postrender', updateView);
|
||||
map.on('postcompose', updateView);
|
||||
map.render();
|
||||
|
||||
disableButtons();
|
||||
|
||||
@@ -33,11 +33,8 @@ map.on('singleclick', function(evt) {
|
||||
evt.coordinate, viewResolution, 'EPSG:3857',
|
||||
{'INFO_FORMAT': 'text/html'});
|
||||
if (url) {
|
||||
fetch(url)
|
||||
.then((response) => response.text())
|
||||
.then((html) => {
|
||||
document.getElementById('info').innerHTML = html;
|
||||
});
|
||||
document.getElementById('info').innerHTML =
|
||||
'<iframe seamless src="' + url + '"></iframe>';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -33,11 +33,8 @@ map.on('singleclick', function(evt) {
|
||||
evt.coordinate, viewResolution, 'EPSG:3857',
|
||||
{'INFO_FORMAT': 'text/html'});
|
||||
if (url) {
|
||||
fetch(url)
|
||||
.then((response) => response.text())
|
||||
.then((html) => {
|
||||
document.getElementById('info').innerHTML = html;
|
||||
});
|
||||
document.getElementById('info').innerHTML =
|
||||
'<iframe seamless src="' + url + '"></iframe>';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Map Graticule
|
||||
shortdesc: This example shows how to add a graticule layer to a map.
|
||||
shortdesc: This example shows how to add a graticule overlay to a map.
|
||||
docs: >
|
||||
This example shows how to add a graticule layer to a map.
|
||||
This example shows how to add a graticule overlay to a map.
|
||||
tags: "graticule"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Graticule from '../src/ol/layer/Graticule.js';
|
||||
import Graticule from '../src/ol/Graticule.js';
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
@@ -13,16 +13,6 @@ const map = new Map({
|
||||
source: new OSM({
|
||||
wrapX: false
|
||||
})
|
||||
}),
|
||||
new Graticule({
|
||||
// the style to use for the lines, optional.
|
||||
strokeStyle: new Stroke({
|
||||
color: 'rgba(255,120,0,0.9)',
|
||||
width: 2,
|
||||
lineDash: [0.5, 4]
|
||||
}),
|
||||
showLabels: true,
|
||||
wrapX: false
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
@@ -31,3 +21,16 @@ const map = new Map({
|
||||
zoom: 5
|
||||
})
|
||||
});
|
||||
|
||||
// Create the graticule component
|
||||
const graticule = new Graticule({
|
||||
// the style to use for the lines, optional.
|
||||
strokeStyle: new Stroke({
|
||||
color: 'rgba(255,120,0,0.9)',
|
||||
width: 2,
|
||||
lineDash: [0.5, 4]
|
||||
}),
|
||||
showLabels: true
|
||||
});
|
||||
|
||||
graticule.setMap(map);
|
||||
|
||||
@@ -4,7 +4,7 @@ title: Earthquakes Heatmap
|
||||
shortdesc: Demonstrates the use of a heatmap layer.
|
||||
docs: >
|
||||
This example parses a KML file and renders the features as a <code>ol/layer/Heatmap</code> layer.
|
||||
tags: "heatmap, kml, vector, style, webgl"
|
||||
tags: "heatmap, kml, vector, style"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<form>
|
||||
|
||||
@@ -43,14 +43,11 @@ const map = new Map({
|
||||
})
|
||||
});
|
||||
|
||||
const blurHandler = function() {
|
||||
vector.setBlur(parseInt(blur.value, 10));
|
||||
};
|
||||
blur.addEventListener('input', blurHandler);
|
||||
blur.addEventListener('change', blurHandler);
|
||||
|
||||
const radiusHandler = function() {
|
||||
blur.addEventListener('input', function() {
|
||||
vector.setBlur(parseInt(blur.value, 10));
|
||||
});
|
||||
|
||||
radius.addEventListener('input', function() {
|
||||
vector.setRadius(parseInt(radius.value, 10));
|
||||
};
|
||||
radius.addEventListener('input', radiusHandler);
|
||||
radius.addEventListener('change', radiusHandler);
|
||||
});
|
||||
|
||||
@@ -69,6 +69,9 @@ for (i = 0, ii = hereLayers.length; i < ii; ++i) {
|
||||
|
||||
const map = new Map({
|
||||
layers: layers,
|
||||
// Improve user experience by loading tiles while dragging/zooming. Will make
|
||||
// zooming choppy on mobile or slow devices.
|
||||
loadTilesWhileInteracting: true,
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [921371.9389, 6358337.7609],
|
||||
|
||||
3
examples/icon-color.css
Normal file
3
examples/icon-color.css
Normal file
@@ -0,0 +1,3 @@
|
||||
#map {
|
||||
position: relative;
|
||||
}
|
||||
@@ -22,27 +22,27 @@ const madrid = new Feature({
|
||||
});
|
||||
|
||||
rome.setStyle(new Style({
|
||||
image: new Icon({
|
||||
image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({
|
||||
color: '#8959A8',
|
||||
crossOrigin: 'anonymous',
|
||||
src: 'data/square.svg'
|
||||
})
|
||||
src: 'data/dot.png'
|
||||
}))
|
||||
}));
|
||||
|
||||
london.setStyle(new Style({
|
||||
image: new Icon({
|
||||
image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({
|
||||
color: '#4271AE',
|
||||
crossOrigin: 'anonymous',
|
||||
src: 'data/dot.png'
|
||||
})
|
||||
}))
|
||||
}));
|
||||
|
||||
madrid.setStyle(new Style({
|
||||
image: new Icon({
|
||||
image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({
|
||||
color: [113, 140, 0],
|
||||
crossOrigin: 'anonymous',
|
||||
src: 'data/dot.png'
|
||||
})
|
||||
}))
|
||||
}));
|
||||
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ import {Icon, Style} from '../src/ol/style.js';
|
||||
|
||||
function createStyle(src, img) {
|
||||
return new Style({
|
||||
image: new Icon({
|
||||
image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({
|
||||
anchor: [0.5, 0.96],
|
||||
crossOrigin: 'anonymous',
|
||||
src: src,
|
||||
img: img,
|
||||
imgSize: img ? [img.width, img.height] : undefined
|
||||
})
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Icon Sprites with WebGL
|
||||
shortdesc: Rendering many icons with WebGL
|
||||
shortdesc: Icon sprite with WebGL
|
||||
docs: >
|
||||
This example shows how to use `ol/renderer/webgl/PointsLayer` to render
|
||||
a very large amount of sprites. The above map is based on a dataset from the National UFO Reporting Center: each
|
||||
icon marks a UFO sighting according to its reported shape (disk, light, fireball...). The older the sighting, the redder
|
||||
the icon.
|
||||
|
||||
A very simple sprite atlas is used in the form of a PNG file containing all icons on a grid. Then, the `texCoordCallback`
|
||||
option of the `ol/renderer/webgl/PointsLayer` constructor is used to specify which sprite to use according to the sighting shape.
|
||||
|
||||
The dataset contains around 80k points and can be found here: https://www.kaggle.com/NUFORC/ufo-sightings
|
||||
tags: "webgl, icon, sprite, point, ufo"
|
||||
<p>In this example a sprite image is used for the icon styles. Using a sprite is required to get good performance with WebGL.</p>
|
||||
tags: "webgl, icon, sprite, vector, point"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<div id="info"> </div>
|
||||
|
||||
@@ -1,121 +1,136 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import Feature from '../src/ol/Feature.js';
|
||||
import Map from '../src/ol/WebGLMap.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import TileJSON from '../src/ol/source/TileJSON';
|
||||
import Feature from '../src/ol/Feature';
|
||||
import Point from '../src/ol/geom/Point';
|
||||
import VectorLayer from '../src/ol/layer/Vector';
|
||||
import {Vector} from '../src/ol/source';
|
||||
import {fromLonLat} from '../src/ol/proj';
|
||||
import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer';
|
||||
import {lerp} from '../src/ol/math';
|
||||
import Point from '../src/ol/geom/Point.js';
|
||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Icon, Style} from '../src/ol/style.js';
|
||||
|
||||
const vectorSource = new Vector({
|
||||
features: [],
|
||||
attributions: 'National UFO Reporting Center'
|
||||
});
|
||||
|
||||
const texture = document.createElement('img');
|
||||
texture.src = 'data/ufo_shapes.png';
|
||||
const iconInfo = [{
|
||||
offset: [0, 0],
|
||||
opacity: 1.0,
|
||||
rotateWithView: true,
|
||||
rotation: 0.0,
|
||||
scale: 1.0,
|
||||
size: [55, 55]
|
||||
}, {
|
||||
offset: [110, 86],
|
||||
opacity: 0.75,
|
||||
rotateWithView: false,
|
||||
rotation: Math.PI / 2.0,
|
||||
scale: 1.25,
|
||||
size: [55, 55]
|
||||
}, {
|
||||
offset: [55, 0],
|
||||
opacity: 0.5,
|
||||
rotateWithView: true,
|
||||
rotation: Math.PI / 3.0,
|
||||
scale: 1.5,
|
||||
size: [55, 86]
|
||||
}, {
|
||||
offset: [212, 0],
|
||||
opacity: 1.0,
|
||||
rotateWithView: true,
|
||||
rotation: 0.0,
|
||||
scale: 1.0,
|
||||
size: [44, 44]
|
||||
}];
|
||||
|
||||
// This describes the content of the associated sprite sheet
|
||||
// coords are u0, v0, u1, v1 for a given shape
|
||||
const shapeTextureCoords = {
|
||||
'light': [0, 0.5, 0.25, 0],
|
||||
'sphere': [0.25, 0.5, 0.5, 0],
|
||||
'circle': [0.25, 0.5, 0.5, 0],
|
||||
'disc': [0.5, 0.5, 0.75, 0],
|
||||
'oval': [0.5, 0.5, 0.75, 0],
|
||||
'triangle': [0.75, 0.5, 1, 0],
|
||||
'fireball': [0, 1, 0.25, 0.5],
|
||||
'default': [0.75, 1, 1, 0.5]
|
||||
};
|
||||
let i;
|
||||
|
||||
const oldColor = [255, 160, 110];
|
||||
const newColor = [180, 255, 200];
|
||||
|
||||
class WebglPointsLayer extends VectorLayer {
|
||||
createRenderer() {
|
||||
return new WebGLPointsLayerRenderer(this, {
|
||||
texture: texture,
|
||||
colorCallback: function(feature, color) {
|
||||
// color is interpolated based on year (min is 1910, max is 2013)
|
||||
// please note: most values are between 2000-2013
|
||||
const ratio = (feature.get('year') - 1950) / (2013 - 1950);
|
||||
|
||||
color[0] = lerp(oldColor[0], newColor[0], ratio * ratio) / 255;
|
||||
color[1] = lerp(oldColor[1], newColor[1], ratio * ratio) / 255;
|
||||
color[2] = lerp(oldColor[2], newColor[2], ratio * ratio) / 255;
|
||||
color[3] = 1;
|
||||
|
||||
return color;
|
||||
},
|
||||
texCoordCallback: function(feature, component) {
|
||||
let coords = shapeTextureCoords[feature.get('shape')];
|
||||
if (!coords) {
|
||||
coords = shapeTextureCoords['default'];
|
||||
}
|
||||
return coords[component];
|
||||
},
|
||||
sizeCallback: function() {
|
||||
return 16;
|
||||
}
|
||||
const iconCount = iconInfo.length;
|
||||
const icons = new Array(iconCount);
|
||||
for (i = 0; i < iconCount; ++i) {
|
||||
const info = iconInfo[i];
|
||||
icons[i] = new Icon({
|
||||
offset: info.offset,
|
||||
opacity: info.opacity,
|
||||
rotateWithView: info.rotateWithView,
|
||||
rotation: info.rotation,
|
||||
scale: info.scale,
|
||||
size: info.size,
|
||||
crossOrigin: 'anonymous',
|
||||
src: 'data/Butterfly.png'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function loadData() {
|
||||
const client = new XMLHttpRequest();
|
||||
client.open('GET', 'data/csv/ufo_sighting_data.csv');
|
||||
client.onload = function() {
|
||||
const csv = client.responseText;
|
||||
const features = [];
|
||||
|
||||
let prevIndex = csv.indexOf('\n') + 1; // scan past the header line
|
||||
|
||||
let curIndex;
|
||||
while ((curIndex = csv.indexOf('\n', prevIndex)) != -1) {
|
||||
const line = csv.substr(prevIndex, curIndex - prevIndex).split(',');
|
||||
prevIndex = curIndex + 1;
|
||||
|
||||
const coords = fromLonLat([parseFloat(line[5]), parseFloat(line[4])]);
|
||||
|
||||
// only keep valid points
|
||||
if (isNaN(coords[0]) || isNaN(coords[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
features.push(new Feature({
|
||||
datetime: line[0],
|
||||
year: parseInt(/[0-9]{4}/.exec(line[0])[0]), // extract the year as int
|
||||
shape: line[2],
|
||||
duration: line[3],
|
||||
geometry: new Point(coords)
|
||||
}));
|
||||
}
|
||||
vectorSource.addFeatures(features);
|
||||
};
|
||||
client.send();
|
||||
}
|
||||
|
||||
loadData();
|
||||
|
||||
new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new TileJSON({
|
||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-dark.json?secure',
|
||||
crossOrigin: 'anonymous'
|
||||
const featureCount = 50000;
|
||||
const features = new Array(featureCount);
|
||||
let feature, geometry;
|
||||
const e = 25000000;
|
||||
for (i = 0; i < featureCount; ++i) {
|
||||
geometry = new Point(
|
||||
[2 * e * Math.random() - e, 2 * e * Math.random() - e]);
|
||||
feature = new Feature(geometry);
|
||||
feature.setStyle(
|
||||
new Style({
|
||||
image: icons[i % (iconCount - 1)]
|
||||
})
|
||||
}),
|
||||
new WebglPointsLayer({
|
||||
);
|
||||
features[i] = feature;
|
||||
}
|
||||
|
||||
const vectorSource = new VectorSource({
|
||||
features: features
|
||||
});
|
||||
const vector = new VectorLayer({
|
||||
source: vectorSource
|
||||
})
|
||||
],
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
layers: [vector],
|
||||
target: document.getElementById('map'),
|
||||
view: new View({
|
||||
center: [0, 4000000],
|
||||
zoom: 2
|
||||
center: [0, 0],
|
||||
zoom: 5
|
||||
})
|
||||
});
|
||||
|
||||
const overlayFeatures = [];
|
||||
for (i = 0; i < featureCount; i += 30) {
|
||||
const clone = features[i].clone();
|
||||
clone.setStyle(null);
|
||||
overlayFeatures.push(clone);
|
||||
}
|
||||
|
||||
new VectorLayer({
|
||||
map: map,
|
||||
source: new VectorSource({
|
||||
features: overlayFeatures
|
||||
}),
|
||||
style: new Style({
|
||||
image: icons[iconCount - 1]
|
||||
})
|
||||
});
|
||||
|
||||
map.on('click', function(evt) {
|
||||
const info = document.getElementById('info');
|
||||
info.innerHTML =
|
||||
'Hold on a second, while I catch those butterflies for you ...';
|
||||
|
||||
window.setTimeout(function() {
|
||||
const features = [];
|
||||
map.forEachFeatureAtPixel(evt.pixel, function(feature) {
|
||||
features.push(feature);
|
||||
return false;
|
||||
});
|
||||
|
||||
if (features.length === 1) {
|
||||
info.innerHTML = 'Got one butterfly';
|
||||
} else if (features.length > 1) {
|
||||
info.innerHTML = 'Got ' + features.length + ' butterflies';
|
||||
} else {
|
||||
info.innerHTML = 'Couldn\'t catch a single butterfly';
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
|
||||
map.on('pointermove', function(evt) {
|
||||
if (evt.dragging) {
|
||||
return;
|
||||
}
|
||||
const pixel = map.getEventPixel(evt.originalEvent);
|
||||
const hit = map.hasFeatureAtPixel(pixel);
|
||||
map.getTarget().style.cursor = hit ? 'pointer' : '';
|
||||
});
|
||||
|
||||
3
examples/icon.css
Normal file
3
examples/icon.css
Normal file
@@ -0,0 +1,3 @@
|
||||
#map {
|
||||
position: relative;
|
||||
}
|
||||
@@ -17,12 +17,12 @@ const iconFeature = new Feature({
|
||||
});
|
||||
|
||||
const iconStyle = new Style({
|
||||
image: new Icon({
|
||||
image: new Icon(/** @type {module:ol/style/Icon~Options} */ ({
|
||||
anchor: [0.5, 46],
|
||||
anchorXUnits: 'fraction',
|
||||
anchorYUnits: 'pixels',
|
||||
src: 'data/icon.png'
|
||||
})
|
||||
}))
|
||||
});
|
||||
|
||||
iconFeature.setStyle(iconStyle);
|
||||
|
||||
@@ -7,7 +7,6 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import OSM, {ATTRIBUTION} from '../src/ol/source/OSM.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Circle as CircleStyle, Fill, Stroke, Style} from '../src/ol/style.js';
|
||||
import {getVectorContext} from '../src/ol/render.js';
|
||||
|
||||
|
||||
const colors = {
|
||||
@@ -74,10 +73,6 @@ vectorSource.on('addfeature', function(event) {
|
||||
time.duration = time.stop - time.start;
|
||||
});
|
||||
|
||||
const vectorLayer = new VectorLayer({
|
||||
source: vectorSource,
|
||||
style: styleFunction
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
@@ -91,7 +86,10 @@ const map = new Map({
|
||||
'?apikey=0e6fc415256d4fbb9b5166a718591d71'
|
||||
})
|
||||
}),
|
||||
vectorLayer
|
||||
new VectorLayer({
|
||||
source: vectorSource,
|
||||
style: styleFunction
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
@@ -155,8 +153,8 @@ const style = new Style({
|
||||
stroke: stroke
|
||||
})
|
||||
});
|
||||
vectorLayer.on('postrender', function(evt) {
|
||||
const vectorContext = getVectorContext(evt);
|
||||
map.on('postcompose', function(evt) {
|
||||
const vectorContext = evt.vectorContext;
|
||||
vectorContext.setStyle(style);
|
||||
if (point !== null) {
|
||||
vectorContext.drawGeometry(point);
|
||||
@@ -183,7 +181,7 @@ document.getElementById('time').addEventListener('input', function() {
|
||||
const value = parseInt(this.value, 10) / 100;
|
||||
const m = time.start + (time.duration * value);
|
||||
vectorSource.forEachFeature(function(feature) {
|
||||
const geometry = /** @type {import("../src/ol/geom/LineString.js").default} */ (feature.getGeometry());
|
||||
const geometry = /** @type {module:ol/geom/LineString~LineString} */ (feature.getGeometry());
|
||||
const coordinate = geometry.getCoordinateAtM(m, true);
|
||||
let highlight = feature.get('highlight');
|
||||
if (highlight === undefined) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: IIIF Image API
|
||||
shortdesc: Example of a IIIF Image API source.
|
||||
docs: >
|
||||
Example of a tile source for an International Image Interoperability Framework (IIIF) Image Service.
|
||||
Try any Image API version 1 or 2 service.
|
||||
tags: "IIIF, IIIF Image API, tile source"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<div class="controls">
|
||||
<div id="iiif-notification"> </div>
|
||||
Enter <code>info.json</code> URL:
|
||||
<input type="text" id="imageInfoUrl" value="https://iiif.ub.uni-leipzig.de/iiif/j2k/0000/0107/0000010732/00000072.jpx/info.json">
|
||||
<button id="display">Display image</button>
|
||||
</div>
|
||||
@@ -1,46 +0,0 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import IIIF from '../src/ol/source/IIIF.js';
|
||||
import IIIFInfo from '../src/ol/format/IIIFInfo.js';
|
||||
|
||||
const layer = new TileLayer(),
|
||||
map = new Map({
|
||||
layers: [layer],
|
||||
target: 'map'
|
||||
}),
|
||||
notifyDiv = document.getElementById('iiif-notification'),
|
||||
urlInput = document.getElementById('imageInfoUrl'),
|
||||
displayButton = document.getElementById('display');
|
||||
|
||||
function refreshMap(imageInfoUrl) {
|
||||
fetch(imageInfoUrl).then(function(response) {
|
||||
response.json().then(function(imageInfo) {
|
||||
const options = new IIIFInfo(imageInfo).getTileSourceOptions();
|
||||
if (options === undefined || options.version === undefined) {
|
||||
notifyDiv.textContent = 'Data seems to be no valid IIIF image information.';
|
||||
return;
|
||||
}
|
||||
options.zDirection = -1;
|
||||
const iiifTileSource = new IIIF(options);
|
||||
layer.setSource(iiifTileSource);
|
||||
map.setView(new View({
|
||||
resolutions: iiifTileSource.getTileGrid().getResolutions(),
|
||||
extent: iiifTileSource.getTileGrid().getExtent(),
|
||||
constrainOnlyCenter: true
|
||||
}));
|
||||
map.getView().fit(iiifTileSource.getTileGrid().getExtent());
|
||||
notifyDiv.textContent = '';
|
||||
}).catch(function(body) {
|
||||
notifyDiv.textContent = 'Could not read image info json. ' + body;
|
||||
});
|
||||
}).catch(function() {
|
||||
notifyDiv.textContent = 'Could not read data from URL.';
|
||||
});
|
||||
}
|
||||
|
||||
displayButton.addEventListener('click', function() {
|
||||
refreshMap(urlInput.value);
|
||||
});
|
||||
|
||||
refreshMap(urlInput.value);
|
||||
@@ -3,9 +3,9 @@ layout: example.html
|
||||
title: Image Filters
|
||||
shortdesc: Apply a filter to imagery
|
||||
docs: >
|
||||
<p>Layer rendering can be manipulated in <code>prerender</code> and <code>postrender</code> event listeners.
|
||||
<p>Layer rendering can be manipulated in <code>precompose</code> and <code>postcompose</code> event listeners.
|
||||
These listeners get an event with a reference to the Canvas rendering context.
|
||||
In this example, the <code>postrender</code> listener applies a filter to the image data.</p>
|
||||
In this example, the <code>postcompose</code> listener applies a filter to the image data.</p>
|
||||
tags: "filter, image manipulation"
|
||||
cloak:
|
||||
- key: As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5
|
||||
|
||||
@@ -90,9 +90,9 @@ select.onchange = function() {
|
||||
|
||||
|
||||
/**
|
||||
* Apply a filter on "postrender" events.
|
||||
* Apply a filter on "postcompose" events.
|
||||
*/
|
||||
imagery.on('postrender', function(event) {
|
||||
imagery.on('postcompose', function(event) {
|
||||
convolve(event.context, selectedKernel);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import ImageWMS from '../src/ol/source/ImageWMS.js';
|
||||
|
||||
/**
|
||||
* Renders a progress bar.
|
||||
* @param {HTMLElement} el The target element.
|
||||
* @param {Element} el The target element.
|
||||
* @constructor
|
||||
*/
|
||||
function Progress(el) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Vector Image Layer
|
||||
shortdesc: Example of rendering vector data as an image layer.
|
||||
title: Image Vector Layer
|
||||
shortdesc: Example of an image vector layer.
|
||||
docs: >
|
||||
<p>This example uses <code>ol/layer/VectorImage</code> for faster rendering during interaction and animations, at the cost of less accurate rendering.</p>
|
||||
<p>This example uses <code>ol/layer/Vector</code> with `renderMode: 'image'`. This mode results in faster rendering during interaction and animations, at the cost of less accurate rendering.</p>
|
||||
tags: "vector, image"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
||||
import VectorImageLayer from '../src/ol/layer/VectorImage.js';
|
||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Fill, Stroke, Style, Text} from '../src/ol/style.js';
|
||||
@@ -20,8 +19,8 @@ const style = new Style({
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new VectorImageLayer({
|
||||
imageRatio: 2,
|
||||
new VectorLayer({
|
||||
renderMode: 'image',
|
||||
source: new VectorSource({
|
||||
url: 'data/geojson/countries.geojson',
|
||||
format: new GeoJSON()
|
||||
|
||||
@@ -11,25 +11,9 @@
|
||||
body {
|
||||
padding-top: 70px;
|
||||
}
|
||||
img.header-logo {
|
||||
padding-left: 18px;
|
||||
}
|
||||
input.search-query {
|
||||
color: #333;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
input.search-query {
|
||||
width: 110px;
|
||||
}
|
||||
#count {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 374px) {
|
||||
input.search-query {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.example {
|
||||
display: block;
|
||||
padding: 10px;
|
||||
@@ -198,9 +182,9 @@
|
||||
<body>
|
||||
|
||||
<header class="navbar navbar-fixed-top" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<div class="container">
|
||||
<div class="display-table pull-left">
|
||||
<a class="navbar-brand" href="./"><img class="header-logo" src="./resources/logo-70x70.png"> OpenLayers</a>
|
||||
<a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers Examples</a>
|
||||
<form class="navbar-form" role="search">
|
||||
<input name="q" type="text" id="keywords" class="search-query" placeholder="Search" autofocus>
|
||||
<span id="count"></span>
|
||||
|
||||
@@ -4,11 +4,16 @@ title: Interaction Options
|
||||
shortdesc: Shows interaction options for custom scroll and zoom behavior.
|
||||
docs: >
|
||||
This example uses a custom `ol/interaction/defaults` configuration:
|
||||
by default, wheel/trackpad zoom and drag panning is always active, which
|
||||
|
||||
* By default, wheel/trackpad zoom and drag panning is always active, which
|
||||
can be unexpected on pages with a lot of scrollable content and an embedded
|
||||
map. To perform wheel/trackpad zoom and drag-pan actions only when the map
|
||||
has the focus, set `onFocusOnly: true` as option. This requires a map div
|
||||
with a `tabindex` attribute set.
|
||||
* By default, pinch-zoom and wheel/trackpad zoom interactions can leave the
|
||||
map at fractional zoom levels. If instead you want to constrain
|
||||
wheel/trackpad zooming to integer zoom levels, set
|
||||
`constrainResolution: true`.
|
||||
tags: "trackpad, mousewheel, zoom, scroll, interaction, fractional"
|
||||
---
|
||||
<div tabindex="1" id="map" class="map"></div>
|
||||
|
||||
@@ -7,7 +7,7 @@ import OSM from '../src/ol/source/OSM.js';
|
||||
|
||||
const map = new Map({
|
||||
interactions: defaultInteractions({
|
||||
onFocusOnly: true
|
||||
constrainResolution: true, onFocusOnly: true
|
||||
}),
|
||||
layers: [
|
||||
new TileLayer({
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user