Compare commits
1 Commits
v5.0.0-bet
...
v4.1.2-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
646c9fb177 |
9
.babelrc
9
.babelrc
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"plugins": ["jsdoc-closure"],
|
|
||||||
"parserOpts": {
|
|
||||||
"parser": "recast"
|
|
||||||
},
|
|
||||||
"generatorOpts": {
|
|
||||||
"generator": "recast"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
8
.github/ISSUE_TEMPLATE.md
vendored
8
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,8 +0,0 @@
|
|||||||
Thank you for your interest in making OpenLayers better!
|
|
||||||
|
|
||||||
To keep this project manageable for maintainers, we ask you to please check all boxes below before submitting an issue.
|
|
||||||
|
|
||||||
- [ ] I am submitting a bug or feature request, not a usage question. Go to https://stackoverflow.com/questions/tagged/openlayers for questions.
|
|
||||||
- [ ] I have searched GitHub to see if a similar bug or feature request has already been reported.
|
|
||||||
- [ ] I have verified that the issue is present in the latest version of OpenLayers (see 'LATEST' on https://openlayers.org/).
|
|
||||||
- [ ] If reporting a bug, I have created a [CodePen](https://codepen.io) or prepared a stack trace (using the latest version and unminified code, so e.g. `ol-debug.js`, not `ol.js`) that shows the issue.
|
|
||||||
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,8 +0,0 @@
|
|||||||
Thank you for your interest in making OpenLayers better!
|
|
||||||
|
|
||||||
In order to get your proposed changes merged into the master branch, we ask you to please make sure the following boxes are checked *before* submitting your pull request.
|
|
||||||
|
|
||||||
- [ ] This pull request addresses an issue that has been marked with the 'Pull request accepted' label & I have added the link to that issue.
|
|
||||||
- [ ] It contains one or more small, incremental, logically separate commits, with no merge commits.
|
|
||||||
- [ ] I have used clear commit messages.
|
|
||||||
- [ ] Existing tests pass for me locally & I have added or updated tests for new or changed functionality.
|
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
/build/
|
/build/
|
||||||
/coverage/
|
|
||||||
/dist/
|
|
||||||
/node_modules/
|
/node_modules/
|
||||||
src/index.js
|
/dist/
|
||||||
|
/coverage/
|
||||||
|
|||||||
1
.npmignore
Normal file
1
.npmignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build/
|
||||||
32
.travis.yml
32
.travis.yml
@@ -1,17 +1,33 @@
|
|||||||
|
sudo: false
|
||||||
|
|
||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
node_js:
|
node_js:
|
||||||
- '8'
|
- "6.1"
|
||||||
|
|
||||||
|
addons:
|
||||||
|
firefox: "52.0"
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
|
env:
|
||||||
|
- DISPLAY=:99.0
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- "npm prune"
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- "rm src/ol/renderer/webgl/*shader.js"
|
||||||
|
- "sh -e /etc/init.d/xvfb start"
|
||||||
|
- "npm ls || true"
|
||||||
|
|
||||||
|
script: "make ci"
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- cat coverage/lcov.info | coveralls
|
- "make test-coverage"
|
||||||
|
- "cat coverage/lcov.info | ./node_modules/.bin/coveralls"
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
addons:
|
|
||||||
hosts:
|
|
||||||
- travis.dev
|
|
||||||
jwt:
|
|
||||||
# This is the encrypted SAUCE_ACCESS_KEY
|
|
||||||
secure: bb2Ibzu9RLe6ZlIG7JVcuH7IoLMxa/i3LTM7t8mbsPjVOGs5ycyJ7M9MbvqB/F2EzbeV4XB2c9ufI4TkaLYceY5kdWjfZVN8iasr+GFqKMv1uR4i6bpu8KmHJ+blxwfY1QOQ/cGwEx+fbeycMtpTc3Y3GyXaPlCQLhbZvesMg88=
|
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ This page describes what you need to know to contribute code to OpenLayers as a
|
|||||||
|
|
||||||
## Contributor License Agreement
|
## Contributor License Agreement
|
||||||
|
|
||||||
Your contribution will be under our [license](https://raw.githubusercontent.com/openlayers/openlayers/master/LICENSE.md) as per [GitHub's terms of service](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license).
|
Before accepting a contribution, we ask that you provide us a Contributor
|
||||||
|
License Agreement. If you are making your contribution as part of work for
|
||||||
|
your employer, please follow the guidelines on submitting a [Corporate
|
||||||
|
Contributor License Agreement](https://raw.github.com/openlayers/cla/master/ccla.txt). If you are
|
||||||
|
making your contribution as an individual, you can submit a digital [Individual
|
||||||
|
Contributor License Agreement](https://docs.google.com/spreadsheet/viewform?formkey=dGNNVUJEMXF2dERTU0FXM3JjNVBQblE6MQ).
|
||||||
|
|
||||||
|
|
||||||
## Pull request guidelines
|
## Pull request guidelines
|
||||||
@@ -55,6 +60,66 @@ Your pull request must:
|
|||||||
* Be possible to merge automatically.
|
* Be possible to merge automatically.
|
||||||
|
|
||||||
|
|
||||||
|
### The `check` build target
|
||||||
|
|
||||||
|
It is strongly recommended that you run
|
||||||
|
|
||||||
|
$ make check
|
||||||
|
|
||||||
|
before every commit. This will catch many problems quickly, and it is much
|
||||||
|
faster than waiting for the Travis CI integration tests to run.
|
||||||
|
|
||||||
|
The `check` build target runs a number of quick tests on your code. These
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Lint
|
||||||
|
* Compile
|
||||||
|
* Tests
|
||||||
|
|
||||||
|
|
||||||
|
### Follow OpenLayers's coding style
|
||||||
|
|
||||||
|
OpenLayers follows [Google's JavaScript Style
|
||||||
|
Guide](https://google.github.io/styleguide/javascriptguide.xml).
|
||||||
|
This is checked using [ESLint](http://eslint.org/), you
|
||||||
|
can run the linter locally on your machine before committing using the `lint`
|
||||||
|
target:
|
||||||
|
|
||||||
|
$ make lint
|
||||||
|
|
||||||
|
In addition to fixing problems identified by the linter, please also follow the
|
||||||
|
style of the existing OpenLayers code, which includes:
|
||||||
|
|
||||||
|
* Always wrap the body of `for`, `if`, and `while` statements in braces.
|
||||||
|
|
||||||
|
* Class methods should be in alphabetical order.
|
||||||
|
|
||||||
|
* `var` declarations should not span multiple lines. If you cannot fit all
|
||||||
|
the declarations in a single line, then start a new `var` declaration on a
|
||||||
|
new line. Within a single line, variables should be declared in
|
||||||
|
alphabetical order.
|
||||||
|
|
||||||
|
* Do not use assignments inside expressions.
|
||||||
|
|
||||||
|
* Use uppercase for `@const` variables.
|
||||||
|
|
||||||
|
### Configure your editor
|
||||||
|
|
||||||
|
If possible, configure your editor to follow the coding conventions of the
|
||||||
|
library. A `.editorconfig` file is included at the root of the repository that
|
||||||
|
can be used to configure whitespace and charset handling in your editor. See
|
||||||
|
that file for a description of the conventions. The [EditorConfig](
|
||||||
|
http://editorconfig.org/#download) site links to plugins for various editors.
|
||||||
|
|
||||||
|
### Pass the integration tests run automatically by the Travis CI system
|
||||||
|
|
||||||
|
The integration tests contain a number of automated checks to ensure that the
|
||||||
|
code follows the OpenLayers style and does not break tests or examples. You
|
||||||
|
can run the integration tests locally using the `ci` target:
|
||||||
|
|
||||||
|
$ make ci
|
||||||
|
|
||||||
|
|
||||||
### Address a single issue or add a single item of functionality
|
### Address a single issue or add a single item of functionality
|
||||||
|
|
||||||
Please submit separate pull requests for separate issues. This allows each to
|
Please submit separate pull requests for separate issues. This allows each to
|
||||||
@@ -108,3 +173,33 @@ Occasionally other changes to `master` might mean that your pull request cannot
|
|||||||
be merged automatically. In this case you may need to rebase your branch on a
|
be merged automatically. In this case you may need to rebase your branch on a
|
||||||
more recent `master`, resolve any conflicts, and `git push --force` to update
|
more recent `master`, resolve any conflicts, and `git push --force` to update
|
||||||
your branch so that it can be merged automatically.
|
your branch so that it can be merged automatically.
|
||||||
|
|
||||||
|
## Building on Windows
|
||||||
|
|
||||||
|
Most developers build on Linux. Building on Windows is possible under Cygwin.
|
||||||
|
When installing Cygwin from https://www.cygwin.com/, include the developer
|
||||||
|
tools to get GNU make.
|
||||||
|
|
||||||
|
First (before npm install), to avoid file permission problems between Windows
|
||||||
|
and Cygwin, edit Cygwin's /etc/fstab file to disable ACLs like this
|
||||||
|
`none /cygdrive cygdrive binary,noacl,posix=0,user 0 0`
|
||||||
|
|
||||||
|
Python is normally installed with Cygwin so need not be installed separately.
|
||||||
|
By default Cygwin will use its own version of Python rather than Window's,
|
||||||
|
so the Python modules should be installed for Cygwin's Python.
|
||||||
|
|
||||||
|
The build targets `check-deps`, `serve`, `lint`, `build`, `test`, `check` and
|
||||||
|
`host-examples` described above should all work. `host-examples` takes quite a
|
||||||
|
while to run. If a target does not run properly first time, try it again.
|
||||||
|
|
||||||
|
Currently, Firefox fails to run http://localhost:3000/build/examples
|
||||||
|
from make serve, but Chrome and Internet Explorer will.
|
||||||
|
|
||||||
|
Microsoft Visual Studio's javascript debugger may be used to debug the
|
||||||
|
build/hosted/your-branch/examples. It will be convenient to set
|
||||||
|
build/hosted/your-branch/examples/index.html as the startup page.
|
||||||
|
|
||||||
|
Your OpenLayers source tree need not be under the Cygwin root.
|
||||||
|
if you checkout to c:/openlayers then you can build under Cygwin at /cygdrive/c/openlayers .
|
||||||
|
However, keep the path to the OpenLayers files short otherwise you may see
|
||||||
|
`ENAMETOOLONG` errors.
|
||||||
|
|||||||
@@ -15,32 +15,103 @@ pull requests will not be merged.
|
|||||||
|
|
||||||
The minimum requirements are:
|
The minimum requirements are:
|
||||||
|
|
||||||
|
* GNU Make
|
||||||
* Git
|
* Git
|
||||||
* [Node.js](http://nodejs.org/) (version 8 and above)
|
* [Node.js](http://nodejs.org/) (higher than 0.12.x)
|
||||||
|
* Python 2.6 or 2.7
|
||||||
|
* Java 7 (JRE and JDK)
|
||||||
|
|
||||||
The executables `git` and `node` should be in your `PATH`.
|
The executables `git`, `node`, and `java` should be in your `PATH`.
|
||||||
|
|
||||||
|
You can check your configuration by running:
|
||||||
|
|
||||||
|
$ make check-deps
|
||||||
|
|
||||||
To install the Node.js dependencies run
|
To install the Node.js dependencies run
|
||||||
|
|
||||||
$ npm install
|
$ npm install
|
||||||
|
|
||||||
|
## Working with the build tool
|
||||||
|
|
||||||
|
As an OpenLayers developer you will use `make` to run build targets defined in the
|
||||||
|
`Makefile` located at the root of the repository. The `Makefile` includes
|
||||||
|
targets for running the linter, the compiler, the tests, etc.
|
||||||
|
|
||||||
|
The usage of `make` is as follows:
|
||||||
|
|
||||||
|
$ make <target>
|
||||||
|
|
||||||
|
where `<target>` is the name of the build target you want to execute. For
|
||||||
|
example:
|
||||||
|
|
||||||
|
$ make test
|
||||||
|
|
||||||
|
The main build targets are `serve`, `lint`, `build`, `test`, and `check`. The
|
||||||
|
latter is a meta-target that basically runs `lint`, `build`, and `test`.
|
||||||
|
|
||||||
|
The `serve` target starts a node-based web server, which we will refer to as the *dev server*. You'll need to start that server for running the examples and the tests in a browser. More information on that further down.
|
||||||
|
|
||||||
|
Other targets include `apidoc` and `ci`. The latter is the target used on Travis CI. See OpenLayers's [Travis configuration file](https://github.com/openlayers/openlayers/blob/master/.travis.yml).
|
||||||
|
|
||||||
|
## Running the `check` target
|
||||||
|
|
||||||
|
The `check` target is to be run before pushing code to GitHub and opening pull
|
||||||
|
requests. Branches that don't pass `check` won't pass the integration tests,
|
||||||
|
and have therefore no chance of being merged into `master`.
|
||||||
|
|
||||||
|
To run the `check` target:
|
||||||
|
|
||||||
|
$ make check
|
||||||
|
|
||||||
|
If you want to run the full suite of integration tests, see "Running the integration
|
||||||
|
tests" below.
|
||||||
|
|
||||||
## Running examples
|
## Running examples
|
||||||
|
|
||||||
To run the examples you first need to start the dev server:
|
To run the examples you first need to start the dev server:
|
||||||
|
|
||||||
$ npm run serve-examples
|
$ make serve
|
||||||
|
|
||||||
Then, load <http://localhost:5000/> in your browser.
|
Then, just point your browser <http://localhost:3000/build/examples> in your browser. For example <http://localhost:3000/build/examples/side-by-side.html>.
|
||||||
|
|
||||||
|
Run examples against the `ol.js` standalone build:
|
||||||
|
|
||||||
|
The examples can also be run against the `ol.js` standalone build, just like
|
||||||
|
the examples [hosted](https://openlayers.org/en/master/examples/) on GitHub.
|
||||||
|
Start by executing the `host-examples` build target:
|
||||||
|
|
||||||
|
$ make host-examples
|
||||||
|
|
||||||
|
After running `host-examples` you can now open the examples index page in the browser: <http://localhost:3000/build/hosted/master/examples/>. (This assumes that you still have the dev server running.)
|
||||||
|
|
||||||
|
Append `?mode=raw` to make the example work in full debug mode. In raw mode the OpenLayers and Closure Library scripts are loaded individually by the Closure Library's `base.js` script (which the example page loads and executes before any other script).
|
||||||
|
|
||||||
## Running tests
|
## Running tests
|
||||||
|
|
||||||
To run the tests once:
|
To run the tests in a browser start the dev server (`make serve`) and open <http://localhost:3000/test/index.html> in the browser.
|
||||||
|
|
||||||
$ npm test
|
To run the tests on the console (headless testing with PhantomJS) use the `test` target:
|
||||||
|
|
||||||
To run the tests continuously during development:
|
$ make test
|
||||||
|
|
||||||
$ npm run karma
|
See also the test-specific [README](../master/test/README.md).
|
||||||
|
|
||||||
|
## Running the integration tests
|
||||||
|
|
||||||
|
When you submit a pull request the [Travis continuous integration
|
||||||
|
server](https://travis-ci.org/) will run a full suite of tests, including
|
||||||
|
building all versions of the library and checking that all of the examples
|
||||||
|
work. You will receive an email with the results, and the status will be
|
||||||
|
displayed in the pull request.
|
||||||
|
|
||||||
|
To run the full suite of integration tests use the `ci` target:
|
||||||
|
|
||||||
|
$ make ci
|
||||||
|
|
||||||
|
Running the full suite of integration tests currently takes 5-10 minutes.
|
||||||
|
|
||||||
|
This makes sure that your commit won't break the build. It also runs JSDoc3 to
|
||||||
|
make sure that there are no invalid API doc directives.
|
||||||
|
|
||||||
## Adding examples
|
## Adding examples
|
||||||
|
|
||||||
@@ -52,3 +123,14 @@ implies creating two or three files in this directory, an `.html` file, a `.js`
|
|||||||
file, and, optionally, a `.css` file.
|
file, and, optionally, a `.css` file.
|
||||||
|
|
||||||
You can use `simple.js` and `simple.html` as templates for new examples.
|
You can use `simple.js` and `simple.html` as templates for new examples.
|
||||||
|
|
||||||
|
### Use of the `goog` namespace in examples
|
||||||
|
|
||||||
|
Short story: the OpenLayers examples should not use the `goog` namespace, except
|
||||||
|
for `goog.require`.
|
||||||
|
|
||||||
|
Longer story: we want that the OpenLayers examples work in multiple modes, with the
|
||||||
|
standalone lib (which has implications of the symbols and properties we
|
||||||
|
export), and compiled together with the OpenLayers library.
|
||||||
|
|
||||||
|
Compiling the examples together with the library makes it mandatory to declare dependencies with `goog.require` statements.
|
||||||
|
|||||||
312
Makefile
312
Makefile
@@ -1,13 +1,313 @@
|
|||||||
|
OS := $(shell uname)
|
||||||
|
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
SRC_GLSL := $(shell find src -type f -name '*.glsl')
|
SRC_GLSL := $(shell find src -type f -name '*.glsl')
|
||||||
SRC_SHADER_JS := $(patsubst %shader.glsl,%shader.js,$(SRC_GLSL))
|
SRC_SHADER_JS := $(patsubst %shader.glsl,%shader.js,$(SRC_GLSL))
|
||||||
SRC_SHADERLOCATIONS_JS := $(patsubst %shader.glsl,%shader/Locations.js,$(SRC_GLSL))
|
SRC_JS := $(filter-out $(SRC_SHADER_JS),$(shell find src -name '*.js'))
|
||||||
|
SRC_JSDOC = $(shell find src -type f -name '*.jsdoc')
|
||||||
|
|
||||||
|
SPEC_JS := $(shell find test/spec -type f -name '*.js')
|
||||||
|
SPEC_RENDERING_JS := $(shell find test_rendering/spec -name '*.js')
|
||||||
|
|
||||||
|
EXAMPLES := $(shell find examples -type f)
|
||||||
|
EXAMPLES_HTML := $(filter-out examples/index.html,$(shell find examples -maxdepth 1 -type f -name '*.html'))
|
||||||
|
EXAMPLES_JS := $(patsubst %.html,%.js,$(EXAMPLES_HTML))
|
||||||
|
|
||||||
|
BUILD_EXAMPLES := $(subst examples,build/examples,$(EXAMPLES)) build/examples/index.js
|
||||||
|
|
||||||
|
BUILD_HOSTED := build/hosted/$(BRANCH)
|
||||||
|
BUILD_HOSTED_EXAMPLES := $(addprefix $(BUILD_HOSTED)/,$(EXAMPLES))
|
||||||
|
BUILD_HOSTED_EXAMPLES_JS := $(addprefix $(BUILD_HOSTED)/,$(EXAMPLES_JS))
|
||||||
|
|
||||||
|
UNPHANTOMABLE_EXAMPLES = examples/shaded-relief.html examples/raster.html examples/region-growing.html examples/color-manipulation.html
|
||||||
|
CHECK_EXAMPLE_TIMESTAMPS = $(patsubst examples/%.html,build/timestamps/check-%-timestamp,$(filter-out $(UNPHANTOMABLE_EXAMPLES),$(EXAMPLES_HTML)))
|
||||||
|
|
||||||
|
TASKS_JS := $(shell find tasks -name '*.js')
|
||||||
|
|
||||||
|
ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
|
||||||
|
CLOSURE_LIB = $(shell cygpath -u $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())'))
|
||||||
|
else
|
||||||
|
CLOSURE_LIB = $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())')
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS),Darwin)
|
||||||
|
STAT_COMPRESSED = stat -f ' compressed: %z bytes'
|
||||||
|
STAT_UNCOMPRESSED = stat -f 'uncompressed: %z bytes'
|
||||||
|
else
|
||||||
|
STAT_COMPRESSED = stat -c ' compressed: %s bytes'
|
||||||
|
STAT_UNCOMPRESSED = stat -c 'uncompressed: %s bytes'
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: default
|
||||||
|
default: help
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@echo
|
||||||
|
@echo "The most common targets are:"
|
||||||
|
@echo
|
||||||
|
@echo "- install Install node dependencies"
|
||||||
|
@echo "- serve Start dev server for running examples and tests"
|
||||||
|
@echo "- test Run unit tests in the console"
|
||||||
|
@echo "- check Perform a number of checks on the code"
|
||||||
|
@echo "- clean Remove generated files"
|
||||||
|
@echo "- help Display this help message"
|
||||||
|
@echo
|
||||||
|
@echo "Other less frequently used targets are:"
|
||||||
|
@echo
|
||||||
|
@echo "- build Build ol.js, ol-debug.js, ol.js.map and ol.css"
|
||||||
|
@echo "- lint Check the code with the linter"
|
||||||
|
@echo "- ci Run the full continuous integration process"
|
||||||
|
@echo "- apidoc Build the API documentation using JSDoc"
|
||||||
|
@echo "- cleanall Remove all the build artefacts"
|
||||||
|
@echo "- check-deps Check if the required dependencies are installed"
|
||||||
|
@echo
|
||||||
|
|
||||||
|
.PHONY: apidoc
|
||||||
|
apidoc: build/timestamps/jsdoc-$(BRANCH)-timestamp
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: build/ol.css build/ol.js build/ol-debug.js build/ol.js.map
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check: lint build/ol.js test
|
||||||
|
|
||||||
|
.PHONY: check-examples
|
||||||
|
check-examples: $(CHECK_EXAMPLE_TIMESTAMPS)
|
||||||
|
|
||||||
|
.PHONY: check-deps
|
||||||
|
check-deps: EXECUTABLES = git node python java
|
||||||
|
check-deps:
|
||||||
|
@for exe in $(EXECUTABLES) ;\
|
||||||
|
do \
|
||||||
|
which $${exe} > /dev/null && \
|
||||||
|
echo "Program $${exe} OK" || \
|
||||||
|
echo "Program $${exe} MISSING!" ;\
|
||||||
|
done ;\
|
||||||
|
|
||||||
|
.PHONY: ci
|
||||||
|
ci: lint build test test-rendering package compile-examples check-examples apidoc
|
||||||
|
|
||||||
|
.PHONY: compile-examples
|
||||||
|
compile-examples: build/compiled-examples/all.combined.js
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -f build/timestamps/eslint-timestamp
|
||||||
|
rm -f build/timestamps/check-*-timestamp
|
||||||
|
rm -f build/ol.css
|
||||||
|
rm -f build/ol.js
|
||||||
|
rm -f build/ol.js.map
|
||||||
|
rm -f build/ol-debug.js
|
||||||
|
rm -f build/test_requires.js
|
||||||
|
rm -f build/test_rendering_requires.js
|
||||||
|
rm -rf build/examples
|
||||||
|
rm -rf build/compiled-examples
|
||||||
|
rm -rf build/package
|
||||||
|
rm -rf $(BUILD_HOSTED)
|
||||||
|
|
||||||
|
.PHONY: cleanall
|
||||||
|
cleanall:
|
||||||
|
rm -rf build
|
||||||
|
|
||||||
|
.PHONY: css
|
||||||
|
css: build/ol.css
|
||||||
|
|
||||||
|
.PHONY: examples
|
||||||
|
examples: $(BUILD_EXAMPLES)
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: build/timestamps/node-modules-timestamp
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint: build/timestamps/eslint-timestamp
|
||||||
|
|
||||||
|
.PHONY: npm-install
|
||||||
|
npm-install: build/timestamps/node-modules-timestamp
|
||||||
|
|
||||||
.PHONY: shaders
|
.PHONY: shaders
|
||||||
shaders: $(SRC_SHADER_JS) $(SRC_SHADERLOCATIONS_JS)
|
shaders: $(SRC_SHADER_JS)
|
||||||
|
|
||||||
%shader.js: %shader.glsl src/ol/webgl/shader.mustache tasks/glslunit.js
|
.PHONY: serve
|
||||||
@node tasks/glslunit.js --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shader.mustache > $@
|
serve: build/test_requires.js build/test_rendering_requires.js
|
||||||
|
node tasks/serve.js
|
||||||
|
|
||||||
%shader/Locations.js: %shader.glsl src/ol/webgl/shaderlocations.mustache tasks/glslunit.js
|
.PHONY: test
|
||||||
|
test: build/timestamps/node-modules-timestamp build/test_requires.js
|
||||||
|
node tasks/test.js
|
||||||
|
|
||||||
|
.PHONY: test-coverage
|
||||||
|
test-coverage: build/timestamps/node-modules-timestamp
|
||||||
|
node tasks/test-coverage.js
|
||||||
|
|
||||||
|
.PHONY: test-rendering
|
||||||
|
test-rendering: build/timestamps/node-modules-timestamp \
|
||||||
|
build/test_rendering_requires.js
|
||||||
|
@rm -rf build/slimerjs-profile
|
||||||
|
@mkdir -p build/slimerjs-profile
|
||||||
|
@cp -r test_rendering/slimerjs-profile/* build/slimerjs-profile/
|
||||||
|
node tasks/test-rendering.js
|
||||||
|
|
||||||
|
.PHONY: host-examples
|
||||||
|
host-examples: $(BUILD_HOSTED_EXAMPLES) \
|
||||||
|
$(BUILD_HOSTED)/build/ol.js \
|
||||||
|
$(BUILD_HOSTED)/build/ol-debug.js \
|
||||||
|
$(BUILD_HOSTED)/css/ol.css \
|
||||||
|
$(BUILD_HOSTED)/examples/loader.js \
|
||||||
|
$(BUILD_HOSTED)/examples/index.js \
|
||||||
|
$(BUILD_HOSTED)/build/ol-deps.js
|
||||||
|
|
||||||
|
.PHONY: host-libraries
|
||||||
|
host-libraries: build/timestamps/node-modules-timestamp
|
||||||
|
@rm -rf $(BUILD_HOSTED)/closure-library
|
||||||
|
@mkdir -p $(BUILD_HOSTED)/closure-library
|
||||||
|
@cp -r $(CLOSURE_LIB)/* $(BUILD_HOSTED)/closure-library/
|
||||||
|
@rm -rf $(BUILD_HOSTED)/ol/ol
|
||||||
|
@mkdir -p $(BUILD_HOSTED)/ol/ol
|
||||||
|
@cp -r src/ol/* $(BUILD_HOSTED)/ol/ol/
|
||||||
|
@rm -rf $(BUILD_HOSTED)/ol.ext
|
||||||
|
@mkdir -p $(BUILD_HOSTED)/ol.ext
|
||||||
|
@cp -r build/ol.ext/* $(BUILD_HOSTED)/ol.ext/
|
||||||
|
|
||||||
|
$(BUILD_EXAMPLES): $(EXAMPLES) package.json
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@node tasks/glslunit.js --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shaderlocations.mustache > $@
|
@node tasks/build-examples.js
|
||||||
|
|
||||||
|
build/timestamps/check-%-timestamp: $(BUILD_HOSTED)/examples/%.html \
|
||||||
|
$(BUILD_HOSTED)/examples/%.js \
|
||||||
|
$(filter $(BUILD_HOSTED)/examples/resources/%,$(BUILD_HOSTED_EXAMPLES)) \
|
||||||
|
$(filter $(BUILD_HOSTED)/examples/data/%,$(BUILD_HOSTED_EXAMPLES)) \
|
||||||
|
$(BUILD_HOSTED)/examples/loader.js \
|
||||||
|
$(BUILD_HOSTED)/build/ol.js \
|
||||||
|
$(BUILD_HOSTED)/css/ol.css
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
node tasks/check-example.js $<
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
build/compiled-examples/all.js: $(EXAMPLES_JS)
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@python bin/combine-examples.py $^ > $@
|
||||||
|
|
||||||
|
build/compiled-examples/all.combined.js: config/examples-all.json build/compiled-examples/all.js \
|
||||||
|
$(SRC_JS) $(SRC_SHADER_JS) \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
node tasks/build.js $< $@
|
||||||
|
|
||||||
|
build/compiled-examples/%.json: config/example.json build/examples/%.js \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@sed -e 's|{{id}}|$*|' $< > $@
|
||||||
|
|
||||||
|
build/compiled-examples/%.combined.js: build/compiled-examples/%.json \
|
||||||
|
$(SRC_JS) $(SRC_SHADER_JS) \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
node tasks/build.js $< $@
|
||||||
|
|
||||||
|
build/timestamps/jsdoc-$(BRANCH)-timestamp: config/jsdoc/api/index.md \
|
||||||
|
config/jsdoc/api/conf.json $(SRC_JS) \
|
||||||
|
$(SRC_SHADER_JS) \
|
||||||
|
$(shell find config/jsdoc/api/template -type f) \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@rm -rf $(BUILD_HOSTED)/apidoc
|
||||||
|
./node_modules/.bin/jsdoc config/jsdoc/api/index.md -c config/jsdoc/api/conf.json --package package.json -d $(BUILD_HOSTED)/apidoc
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
$(BUILD_HOSTED_EXAMPLES_JS): $(BUILD_HOSTED)/examples/%.js: build/examples/%.js
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@python bin/split-example.py $< $(@D)
|
||||||
|
|
||||||
|
$(BUILD_HOSTED)/examples/loader.js: bin/loader_hosted_examples.js
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@cp $< $@
|
||||||
|
|
||||||
|
$(BUILD_HOSTED)/examples/%: build/examples/%
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@cp $< $@
|
||||||
|
|
||||||
|
$(BUILD_HOSTED)/build/ol.js: build/ol.js
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@cp $< $@
|
||||||
|
|
||||||
|
$(BUILD_HOSTED)/build/ol-debug.js: build/ol-debug.js
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@cp $< $@
|
||||||
|
|
||||||
|
$(BUILD_HOSTED)/css/ol.css: build/ol.css
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@cp $< $@
|
||||||
|
|
||||||
|
$(BUILD_HOSTED)/build/ol-deps.js: host-libraries
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@python $(CLOSURE_LIB)/closure/bin/build/depswriter.py \
|
||||||
|
--root_with_prefix "src ../../../ol" \
|
||||||
|
--root_with_prefix "build/ol.ext ../../../ol.ext" \
|
||||||
|
--root $(BUILD_HOSTED)/closure-library/closure/goog \
|
||||||
|
--root_with_prefix "$(BUILD_HOSTED)/closure-library/third_party ../../third_party" \
|
||||||
|
--output_file $@
|
||||||
|
|
||||||
|
build/timestamps/eslint-timestamp: $(SRC_JS) $(SPEC_JS) $(SPEC_RENDERING_JS) \
|
||||||
|
$(TASKS_JS) $(EXAMPLES_JS) \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@echo "Running eslint..."
|
||||||
|
@./node_modules/.bin/eslint tasks test test_rendering src examples
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
build/timestamps/node-modules-timestamp: package.json
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
npm install
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
build/ol.css: css/ol.css build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@echo "Running cleancss..."
|
||||||
|
@./node_modules/.bin/cleancss $< > $@
|
||||||
|
|
||||||
|
build/ol.js: config/ol.json $(SRC_JS) $(SRC_SHADER_JS) \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
node tasks/build.js $< $@
|
||||||
|
@$(STAT_UNCOMPRESSED) $@
|
||||||
|
@cp $@ /tmp/
|
||||||
|
@gzip /tmp/ol.js
|
||||||
|
@$(STAT_COMPRESSED) /tmp/ol.js.gz
|
||||||
|
@rm /tmp/ol.js.gz
|
||||||
|
|
||||||
|
build/ol.js.map: config/ol.json $(SRC_JS) $(SRC_SHADER_JS) \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
node tasks/build.js $< $@
|
||||||
|
|
||||||
|
build/ol-debug.js: config/ol-debug.json $(SRC_JS) $(SRC_SHADER_JS) \
|
||||||
|
build/timestamps/node-modules-timestamp
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
node tasks/build.js $< $@
|
||||||
|
@$(STAT_UNCOMPRESSED) $@
|
||||||
|
@cp $@ /tmp/
|
||||||
|
@gzip /tmp/ol-debug.js
|
||||||
|
@$(STAT_COMPRESSED) /tmp/ol-debug.js.gz
|
||||||
|
@rm /tmp/ol-debug.js.gz
|
||||||
|
|
||||||
|
build/test_requires.js: $(SPEC_JS) $(SRC_JS)
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@node tasks/generate-requires.js $^ > $@
|
||||||
|
|
||||||
|
build/test_rendering_requires.js: $(SPEC_RENDERING_JS)
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@node tasks/generate-requires.js $^ > $@
|
||||||
|
|
||||||
|
%shader.js: %shader.glsl src/ol/webgl/shader.mustache bin/pyglslunit.py build/timestamps/node-modules-timestamp
|
||||||
|
@python bin/pyglslunit.py --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shader.mustache > $@
|
||||||
|
|
||||||
|
.PHONY: package
|
||||||
|
package:
|
||||||
|
@rm -rf build/package
|
||||||
|
@cp -r package build
|
||||||
|
@cd ./src && cp -r ol/* ../build/package
|
||||||
|
@rm build/package/typedefs.js
|
||||||
|
@cp css/ol.css build/package
|
||||||
|
./node_modules/.bin/jscodeshift --transform transforms/module.js build/package
|
||||||
|
npm run lint-package
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -4,22 +4,14 @@
|
|||||||
[](https://greenkeeper.io/)
|
[](https://greenkeeper.io/)
|
||||||
[](https://coveralls.io/github/openlayers/openlayers?branch=master)
|
[](https://coveralls.io/github/openlayers/openlayers?branch=master)
|
||||||
[](http://osgeo.org/)
|
[](http://osgeo.org/)
|
||||||
[](https://www.jsdelivr.com/package/npm/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 2-clause BSD License (also known as the FreeBSD).
|
[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
|
## Getting Started
|
||||||
|
|
||||||
Use one of the following methods to use OpenLayers in your project:
|
- Download the [latest release](https://openlayers.org/download/)
|
||||||
|
- Install with npm: `npm install openlayers`
|
||||||
* For use with webpack, Rollup, Browserify, or other module bundlers, install the [`ol` package](https://www.npmjs.com/package/ol):
|
- Clone the repo: `git clone git@github.com:openlayers/openlayers.git`
|
||||||
```
|
|
||||||
npm install ol
|
|
||||||
```
|
|
||||||
|
|
||||||
* If you just want to add a `<script>` tag to test things out, you can link directly to one of the full builds from [cdnjs](https://cdnjs.com/libraries/openlayers) (not recommended for production)
|
|
||||||
|
|
||||||
* For use with Closure Library (rare), install the [`openlayers` package](https://npmjs.com/package/openlayers) and read the [tutorial](http://openlayers.org/en/latest/doc/tutorials/closure.html).
|
|
||||||
|
|
||||||
## Supported Browsers
|
## Supported Browsers
|
||||||
|
|
||||||
@@ -41,3 +33,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)
|
- Need help? Find it on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers)
|
||||||
- Follow [@openlayers](https://twitter.com/openlayers) on Twitter
|
- Follow [@openlayers](https://twitter.com/openlayers) on Twitter
|
||||||
|
- Discuss with openlayers users on IRC in `#openlayers` at `chat.freenode`
|
||||||
|
|||||||
33
bin/check-example.js
Normal file
33
bin/check-example.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// A PhantomJS script used to check that the hosted examples load
|
||||||
|
// without errors. This script is executed by the build tool's
|
||||||
|
// check-examples target.
|
||||||
|
//
|
||||||
|
var args = require('system').args;
|
||||||
|
if (args.length != 2) {
|
||||||
|
phantom.exit(2);
|
||||||
|
}
|
||||||
|
var examplePath = args[1];
|
||||||
|
var page = require('webpage').create();
|
||||||
|
page.onError = function(msg, trace) {
|
||||||
|
var msgStack = ['JavaScript ERROR: ' + msg];
|
||||||
|
if (trace) {
|
||||||
|
msgStack.push('TRACE:');
|
||||||
|
trace.forEach(function(t) {
|
||||||
|
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function + '")' : ''));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.error(msgStack.join('\n'));
|
||||||
|
phantom.exit(1);
|
||||||
|
};
|
||||||
|
page.open(examplePath, function(s) {
|
||||||
|
var exitCode = 0;
|
||||||
|
if (s != 'success') {
|
||||||
|
exitCode = 1;
|
||||||
|
console.error('PAGE LOAD ERROR');
|
||||||
|
}
|
||||||
|
phantom.exit(exitCode);
|
||||||
|
});
|
||||||
|
page.onConsoleMessage = function(msg) {
|
||||||
|
console.log('console:', msg);
|
||||||
|
};
|
||||||
27
bin/combine-examples.py
Executable file
27
bin/combine-examples.py
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
examples = {}
|
||||||
|
requires = set()
|
||||||
|
for filename in argv[1:]:
|
||||||
|
lines = open(filename, 'rU').readlines()
|
||||||
|
if len(lines) > 0 and lines[0].startswith('// NOCOMPILE'):
|
||||||
|
continue
|
||||||
|
requires.update(line for line in lines if line.startswith('goog.require'))
|
||||||
|
examples[filename] = [line for line in lines if not line.startswith('goog.require')]
|
||||||
|
for require in sorted(requires):
|
||||||
|
sys.stdout.write(require)
|
||||||
|
for filename in sorted(examples.keys()):
|
||||||
|
sys.stdout.write('// ' + filename + '\n')
|
||||||
|
sys.stdout.write('(function(){\n')
|
||||||
|
for line in examples[filename]:
|
||||||
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.write('})();\n')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main(sys.argv))
|
||||||
180
bin/example-screenshot.js
Normal file
180
bin/example-screenshot.js
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script is supposed to be executed via phantomjs. It will generate
|
||||||
|
* screenshots of the html files in the directory specified by a commandline
|
||||||
|
* option when these files are served through a webserver which can also be
|
||||||
|
* specified. The screenshots will be in the current working directory.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* user@host:~/openlayers/bin $ phantomjs example-screenshot.js \
|
||||||
|
* http://localhost:8000/openlayers/examples/ \
|
||||||
|
* ../examples
|
||||||
|
*
|
||||||
|
* The above command will generate `*.png` files in `examples/` for all html
|
||||||
|
* files that are served through `http://localhost:8000/openlayers/examples/`.
|
||||||
|
*
|
||||||
|
* So if there is a file `my-humpty-example.html` inside of the relative folder
|
||||||
|
* `../examples/` which is being served through the webserver so that
|
||||||
|
* `http://localhost:8000/openlayers/examples/my-humpty-example.html` is a valid and
|
||||||
|
* reachable URL, this script will generate a screenshot and store it as
|
||||||
|
* `my-humpty-example.html.png`.
|
||||||
|
*
|
||||||
|
* The query string `?mode=raw` will be appended to the generated URL.
|
||||||
|
*
|
||||||
|
* Known limitations:
|
||||||
|
*
|
||||||
|
* As phantomjs doesn't support WebGL (see e.g.
|
||||||
|
* https://github.com/ariya/phantomjs/wiki/Supported-Web-Standards and
|
||||||
|
* http://code.google.com/p/phantomjs/issues/detail?id=273) This won't render
|
||||||
|
* OpenLayers maps rendered through the webglrenderer.
|
||||||
|
*
|
||||||
|
* In parts based upon this gist: https://gist.github.com/crazy4groovy/3160121
|
||||||
|
*/
|
||||||
|
(function() { // global closure
|
||||||
|
|
||||||
|
var page = require('webpage').create(), // imports
|
||||||
|
fs = require('fs'),
|
||||||
|
system = require('system'),
|
||||||
|
// arguments
|
||||||
|
baseExamplesUrl = system.args[1],
|
||||||
|
exampleDir = system.args[2],
|
||||||
|
// various settings
|
||||||
|
ignoreFiles = [
|
||||||
|
'index.html'
|
||||||
|
],
|
||||||
|
intervalMillisecs = 25,
|
||||||
|
renderMillisecs = 2000,
|
||||||
|
// basic variables
|
||||||
|
curDir = fs.workingDirectory,
|
||||||
|
exampleDirList = fs.list(exampleDir),
|
||||||
|
pageindex = 0,
|
||||||
|
fileName = '',
|
||||||
|
htmlFiles = [],
|
||||||
|
lenHtmlFiles = 0,
|
||||||
|
loadInProgress = false;
|
||||||
|
|
||||||
|
// simple object with helper functions
|
||||||
|
var util = {
|
||||||
|
/**
|
||||||
|
* Returns the basename of a file given a path.
|
||||||
|
*/
|
||||||
|
baseName: function(path) {
|
||||||
|
var parts = path.split(fs.separator);
|
||||||
|
return parts[parts.length - 1];
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Super basic test whether a file can be considered a HTML-file.
|
||||||
|
*/
|
||||||
|
isHtmlFile: function(filename) {
|
||||||
|
return (/\.html?$/).test(filename);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Appends a slash to given string if it isn't there already.
|
||||||
|
*/
|
||||||
|
appendSlash: function(str) {
|
||||||
|
return ((/\/$/).test(str)) ? str : str + '/';
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Generates an URL out of given baseurl and path.
|
||||||
|
*/
|
||||||
|
buildUrl: function(baseurl, path) {
|
||||||
|
var name = util.baseName(path),
|
||||||
|
mode = 'raw';
|
||||||
|
return util.appendSlash(baseurl) + name + '?mode=' + mode;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Simple progressbar logger that uses our globals pageindex & lenHtmlFiles.
|
||||||
|
*/
|
||||||
|
logProgress: function() {
|
||||||
|
var doneSymbol = '-',
|
||||||
|
todoSymbol = ' ',
|
||||||
|
currentSymbol = '>',
|
||||||
|
barStrLeft = '[',
|
||||||
|
barStrRight = ']',
|
||||||
|
progresStep = 5, // one doneSymbol equals this percentage
|
||||||
|
totalSteps = Math.round(100 / progresStep),
|
||||||
|
ratio = (lenHtmlFiles === 0) ? 0 : (pageindex / lenHtmlFiles),
|
||||||
|
percent = (ratio === 0) ? 0 : ratio * 100,
|
||||||
|
normalizedNumDone = Math.floor(ratio * totalSteps),
|
||||||
|
normalizedNumTodo = totalSteps - normalizedNumDone,
|
||||||
|
progressLine = '',
|
||||||
|
i = 0;
|
||||||
|
// the progress bar
|
||||||
|
progressLine += barStrLeft;
|
||||||
|
for (; i < normalizedNumDone; i++) {
|
||||||
|
progressLine += doneSymbol;
|
||||||
|
}
|
||||||
|
for (i = 0; i < normalizedNumTodo; i++) {
|
||||||
|
progressLine += (i === 0) ? currentSymbol : todoSymbol;
|
||||||
|
}
|
||||||
|
progressLine += barStrRight;
|
||||||
|
// the percentage information
|
||||||
|
// pad if necessary
|
||||||
|
if (percent < 10) {
|
||||||
|
progressLine += ' ';
|
||||||
|
} else if (percent < 100) {
|
||||||
|
progressLine += ' ';
|
||||||
|
}
|
||||||
|
progressLine += ' ' + percent.toFixed(1) + ' % done';
|
||||||
|
// additional information
|
||||||
|
if (fileName !== '') {
|
||||||
|
progressLine += ', ' + util.baseName(fileName) + '';
|
||||||
|
}
|
||||||
|
console.log(progressLine);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// iterate over all files in examples directory
|
||||||
|
// and find the HTML files.
|
||||||
|
for (var i = 0; i < exampleDirList.length; i++) {
|
||||||
|
var fullpath = exampleDir + fs.separator + exampleDirList[i];
|
||||||
|
if (fs.isFile(fullpath) && util.isHtmlFile(fullpath) &&
|
||||||
|
ignoreFiles.indexOf(util.baseName(fullpath)) === -1) {
|
||||||
|
//TODO: make this more async (i.e. pop on/off stack WHILE rending pages)
|
||||||
|
htmlFiles.push(fullpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lenHtmlFiles = htmlFiles.length;
|
||||||
|
|
||||||
|
console.log('Capturing ' + lenHtmlFiles + ' example screenshots.');
|
||||||
|
|
||||||
|
// The main interval function that is executed regularly and renders a
|
||||||
|
// page to a file
|
||||||
|
var interval = setInterval(function() {
|
||||||
|
if (!loadInProgress && pageindex < lenHtmlFiles) {
|
||||||
|
util.logProgress();
|
||||||
|
fileName = htmlFiles[pageindex];
|
||||||
|
page.viewportSize = { width: 800, height: 600 };
|
||||||
|
page.clipRect = {
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: page.viewportSize.width,
|
||||||
|
height: page.viewportSize.height
|
||||||
|
};
|
||||||
|
page.open(util.buildUrl(baseExamplesUrl, htmlFiles[pageindex]));
|
||||||
|
}
|
||||||
|
if (pageindex == lenHtmlFiles) {
|
||||||
|
util.logProgress();
|
||||||
|
console.log(lenHtmlFiles + ' screenshots captured.');
|
||||||
|
phantom.exit();
|
||||||
|
}
|
||||||
|
}, intervalMillisecs);
|
||||||
|
|
||||||
|
// set loadInProgress flag so we only process one image at time.
|
||||||
|
page.onLoadStarted = function() {
|
||||||
|
loadInProgress = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// When the page is loaded, render it to an image
|
||||||
|
page.onLoadFinished = function() {
|
||||||
|
var dest = exampleDir + fs.separator + util.baseName(fileName) + '.png';
|
||||||
|
window.setTimeout(function() {
|
||||||
|
loadInProgress = false;
|
||||||
|
page.render(dest); // actually render the page.
|
||||||
|
pageindex++;
|
||||||
|
}, renderMillisecs);
|
||||||
|
};
|
||||||
|
|
||||||
|
})(); // eof global closure
|
||||||
69
bin/loader_hosted_examples.js
Normal file
69
bin/loader_hosted_examples.js
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* This loader is used for the hosted examples. It is used in place of the
|
||||||
|
* development loader (examples/loader.js).
|
||||||
|
*
|
||||||
|
* The loader loads ol.js and the example's script in "production" mode; it
|
||||||
|
* loads Closure Library's base.js, ol-deps.js, the example's "goog.require"
|
||||||
|
* script, and the example's script in "development" mode.
|
||||||
|
*
|
||||||
|
* The ol.js and ol-deps.js scripts are built using OpenLayers's Makefile. They are
|
||||||
|
* located in the ../build/ directory, relative to this script.
|
||||||
|
*
|
||||||
|
* The script must be named loader.js.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
*
|
||||||
|
* <script src="../loader.js?id=my-demo"></script>
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
var i, pair;
|
||||||
|
|
||||||
|
var href = window.location.href, start, end, paramsString, pairs,
|
||||||
|
pageParams = {};
|
||||||
|
if (href.indexOf('?') > 0) {
|
||||||
|
start = href.indexOf('?') + 1;
|
||||||
|
end = href.indexOf('#') > 0 ? href.indexOf('#') : href.length;
|
||||||
|
paramsString = href.substring(start, end);
|
||||||
|
pairs = paramsString.split(/[&;]/);
|
||||||
|
for (i = 0; i < pairs.length; ++i) {
|
||||||
|
pair = pairs[i].split('=');
|
||||||
|
if (pair[0]) {
|
||||||
|
pageParams[decodeURIComponent(pair[0])] =
|
||||||
|
decodeURIComponent(pair[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var scripts = document.getElementsByTagName('script');
|
||||||
|
var src, index, search, chunks, scriptParams = {};
|
||||||
|
for (i = scripts.length - 1; i >= 0; --i) {
|
||||||
|
src = scripts[i].getAttribute('src');
|
||||||
|
if (~(index = src.indexOf('loader.js?'))) {
|
||||||
|
search = src.substr(index + 10);
|
||||||
|
chunks = search ? search.split('&') : [];
|
||||||
|
for (i = chunks.length - 1; i >= 0; --i) {
|
||||||
|
pair = chunks[i].split('=');
|
||||||
|
if (pair[0]) {
|
||||||
|
scriptParams[decodeURIComponent(pair[0])] =
|
||||||
|
decodeURIComponent(pair[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var raw = pageParams.mode && pageParams.mode.toLowerCase() === 'raw';
|
||||||
|
|
||||||
|
var scriptId = encodeURIComponent(scriptParams.id);
|
||||||
|
if (!raw) {
|
||||||
|
document.write('<scr' + 'ipt type="text/javascript" src="../build/ol.js"></scr' + 'ipt>');
|
||||||
|
} else {
|
||||||
|
window.CLOSURE_NO_DEPS = true; // we've got our own deps file
|
||||||
|
document.write('<scr' + 'ipt type="text/javascript" src="../closure-library/closure/goog/base.js"></scr' + 'ipt>');
|
||||||
|
document.write('<scr' + 'ipt type="text/javascript" src="../build/ol-deps.js"></scr' + 'ipt>');
|
||||||
|
document.write('<scr' + 'ipt type="text/javascript" src="' + scriptId + '-require.js"></scr' + 'ipt>');
|
||||||
|
}
|
||||||
|
document.write('<scr' + 'ipt type="text/javascript" src="' + scriptId + '.js"></scr' + 'ipt>');
|
||||||
|
}());
|
||||||
120
bin/pyglslunit.py
Normal file
120
bin/pyglslunit.py
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from optparse import OptionParser
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ESCAPE_SEQUENCE = {
|
||||||
|
'\\': '\\\\',
|
||||||
|
'\n': '\\n',
|
||||||
|
'\t': '\\t'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def js_escape(s):
|
||||||
|
return ''.join(ESCAPE_SEQUENCE.get(c, c) for c in s)
|
||||||
|
|
||||||
|
|
||||||
|
def glsl_compress(s, shortNames):
|
||||||
|
# strip leading whitespace
|
||||||
|
s = re.sub(r'\A\s+', '', s)
|
||||||
|
# strip trailing whitespace
|
||||||
|
s = re.sub(r'\s+\Z', '', s)
|
||||||
|
# strip multi-line comments
|
||||||
|
s = re.sub(r'/\*.*?\*/', '', s)
|
||||||
|
# strip single line comments
|
||||||
|
s = re.sub(r'//.*?\n', '', s)
|
||||||
|
# replace multiple whitespace with a single space
|
||||||
|
s = re.sub(r'\s+', ' ', s)
|
||||||
|
# remove whitespace between non-word tokens
|
||||||
|
s = re.sub(r'(\S)\s+([^\w])', r'\1\2', s)
|
||||||
|
s = re.sub(r'([^\w])\s+(\S)', r'\1\2', s)
|
||||||
|
# replace original names with short names
|
||||||
|
for originalName, shortName in shortNames.items():
|
||||||
|
s = s.replace(originalName, shortName)
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
option_parser = OptionParser()
|
||||||
|
option_parser.add_option('--input')
|
||||||
|
option_parser.add_option('--output')
|
||||||
|
options, args = option_parser.parse_args(argv[1:])
|
||||||
|
|
||||||
|
context = {}
|
||||||
|
nextShortName = ord('a')
|
||||||
|
shortNames = {}
|
||||||
|
|
||||||
|
common, vertex, fragment = [], [], []
|
||||||
|
attributes, uniforms, varyings = {}, {}, {}
|
||||||
|
block = None
|
||||||
|
for line in open(options.input, 'rU'):
|
||||||
|
if line.startswith('//!'):
|
||||||
|
m = re.match(r'//!\s+NAMESPACE=(\S+)\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
context['namespace'] = m.group(1)
|
||||||
|
continue
|
||||||
|
m = re.match(r'//!\s+CLASS=(\S+)\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
context['className'] = m.group(1)
|
||||||
|
continue
|
||||||
|
m = re.match(r'//!\s+COMMON\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
block = common
|
||||||
|
continue
|
||||||
|
m = re.match(r'//!\s+VERTEX\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
block = vertex
|
||||||
|
continue
|
||||||
|
m = re.match(r'//!\s+FRAGMENT\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
block = fragment
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if block is None:
|
||||||
|
assert line.rstrip() == ''
|
||||||
|
else:
|
||||||
|
block.append(line)
|
||||||
|
m = re.match(r'attribute\s+\S+\s+(\S+);\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
attribute = m.group(1)
|
||||||
|
if attribute not in attributes:
|
||||||
|
shortName = chr(nextShortName)
|
||||||
|
nextShortName += 1
|
||||||
|
attributes[attribute] = {'originalName': attribute, 'shortName': shortName}
|
||||||
|
shortNames[attribute] = shortName
|
||||||
|
m = re.match(r'uniform\s+\S+\s+(\S+);\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
uniform = m.group(1)
|
||||||
|
if uniform not in uniforms:
|
||||||
|
shortName = chr(nextShortName)
|
||||||
|
nextShortName += 1
|
||||||
|
uniforms[uniform] = {'originalName': uniform, 'shortName': shortName}
|
||||||
|
shortNames[uniform] = shortName
|
||||||
|
m = re.match(r'varying\s+\S+\s+(\S+);\s*\Z', line)
|
||||||
|
if m:
|
||||||
|
varying = m.group(1)
|
||||||
|
if varying not in varyings:
|
||||||
|
shortName = chr(nextShortName)
|
||||||
|
nextShortName += 1
|
||||||
|
shortNames[varying] = shortName
|
||||||
|
|
||||||
|
context['getOriginalFragmentSource'] = js_escape(''.join(common + fragment))
|
||||||
|
context['getOriginalVertexSource'] = js_escape(''.join(common + vertex))
|
||||||
|
context['getFragmentSource'] = glsl_compress(''.join(common + fragment), shortNames)
|
||||||
|
context['getVertexSource'] = glsl_compress(''.join(common + vertex), shortNames)
|
||||||
|
context['getAttributes'] = [attributes[a] for a in sorted(attributes.keys())]
|
||||||
|
context['getUniforms'] = [uniforms[u] for u in sorted(uniforms.keys())]
|
||||||
|
|
||||||
|
if options.output and options.output != '-':
|
||||||
|
output = open(options.output, 'wb')
|
||||||
|
else:
|
||||||
|
output = sys.stdout
|
||||||
|
json.dump(context, output)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main(sys.argv))
|
||||||
39
bin/split-example.py
Normal file
39
bin/split-example.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def split_example_file(example, dst_dir):
|
||||||
|
lines = open(example, 'rU').readlines()
|
||||||
|
|
||||||
|
target_lines = []
|
||||||
|
target_require_lines = []
|
||||||
|
|
||||||
|
found_requires = False
|
||||||
|
found_code = False
|
||||||
|
for line in lines:
|
||||||
|
m = re.match(r'goog.require\(\'(.*)\'\);', line)
|
||||||
|
if m:
|
||||||
|
found_requires = True
|
||||||
|
target_require_lines.append(line)
|
||||||
|
elif found_requires:
|
||||||
|
if found_code or line not in ('\n', '\r\n'):
|
||||||
|
found_code = True
|
||||||
|
target_lines.append(line)
|
||||||
|
|
||||||
|
target = open(
|
||||||
|
os.path.join(dst_dir, os.path.basename(example)), 'wb')
|
||||||
|
target_require = open(
|
||||||
|
os.path.join(dst_dir, os.path.basename(example)
|
||||||
|
.replace('.js', '-require.js')),
|
||||||
|
'wb')
|
||||||
|
|
||||||
|
target.writelines(target_lines)
|
||||||
|
target.close()
|
||||||
|
|
||||||
|
target_require.writelines(target_require_lines)
|
||||||
|
target_require.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
split_example_file(*sys.argv[1:])
|
||||||
@@ -2,311 +2,6 @@
|
|||||||
|
|
||||||
### Next release
|
### Next release
|
||||||
|
|
||||||
#### Removal of ol.FeatureStyleFunction
|
|
||||||
|
|
||||||
The signature of the vector style function passed to the feature has changed. The function now always takes the `feature` and the `resolution` as arguments, the `feature` is no longer bound to `this`.
|
|
||||||
|
|
||||||
Old code:
|
|
||||||
```js
|
|
||||||
feature.setStyle(function(resolution) {
|
|
||||||
var text = this.get('name');
|
|
||||||
...
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
New code:
|
|
||||||
```js
|
|
||||||
feature.setStyle(function(feature, resolution) {
|
|
||||||
var text = feature.get('name');
|
|
||||||
...
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Changed behavior of the `Draw` interaction
|
|
||||||
|
|
||||||
For better drawing experience, two changes were made to the behavior of the Draw interaction:
|
|
||||||
|
|
||||||
1. On long press, the current vertex can be dragged to its desired position.
|
|
||||||
2. On touch move (e.g. when panning the map on a mobile device), no draw cursor is shown, and the geometry being drawn is not updated. But because of 1., the draw cursor will appear on long press. Mouse moves are not affected by this change.
|
|
||||||
|
|
||||||
#### Changes in proj4 integration
|
|
||||||
|
|
||||||
Because relying on a globally available proj4 is not practical with ES modules, we have made a change to the way we integrate proj4:
|
|
||||||
|
|
||||||
* The `setProj4()` function from the `ol/proj` module was removed.
|
|
||||||
* A new `ol/proj/proj4` module with a `register()` function was added. Regardless of whether the application imports `proj4` or uses a global `proj4`, this function needs to be called with the proj4 instance as argument whenever projection definitions were added to proj4's registry with (`proj4.defs`).
|
|
||||||
|
|
||||||
It is also recommended to no longer use a global `proj4`. Instead,
|
|
||||||
|
|
||||||
npm install proj4
|
|
||||||
|
|
||||||
and import it:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import proj4 from 'proj4';
|
|
||||||
```
|
|
||||||
|
|
||||||
Applications can be updated by importing the `register` function from the `ol/proj/proj4` module
|
|
||||||
|
|
||||||
```js
|
|
||||||
import {register} from 'ol/proj/proj4'
|
|
||||||
```
|
|
||||||
|
|
||||||
and calling it before using projections, and any time the proj4 registry was changed by `proj4.defs()` calls:
|
|
||||||
|
|
||||||
```js
|
|
||||||
register(proj4);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Removal of logos
|
|
||||||
|
|
||||||
The map and sources no longer accept a `logo` option. Instead, if you wish to append a logo to your map, add the desired markup directly in your HTML. In addition, you can use the `attributions` property of a source to display arbitrary markup per-source with the attribution control.
|
|
||||||
|
|
||||||
#### Replacement of `ol/Sphere` constructor with `ol/sphere` functions
|
|
||||||
|
|
||||||
The `ol/Sphere` constructor has been removed. If you were using the `getGeodesicArea` method, use the `getArea` function instead. If you were using the `haversineDistance` method, use the `getDistance` function instead.
|
|
||||||
|
|
||||||
Examples before:
|
|
||||||
```js
|
|
||||||
// using ol@4
|
|
||||||
import Sphere from 'ol/sphere';
|
|
||||||
|
|
||||||
var sphere = new Sphere(Sphere.DEFAULT_RADIUS);
|
|
||||||
var area = sphere.getGeodesicArea(polygon);
|
|
||||||
var distance = sphere.haversineDistance(g1, g2);
|
|
||||||
```
|
|
||||||
|
|
||||||
Examples after:
|
|
||||||
```js
|
|
||||||
// using ol@5
|
|
||||||
import {circular as circularPolygon} from 'ol/geom/Polygon';
|
|
||||||
import {getArea, getDistance} from 'ol/sphere';
|
|
||||||
|
|
||||||
var area = getArea(polygon);
|
|
||||||
var distance = getDistance(g1, g2);
|
|
||||||
var circle = circularPolygon(center, radius);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### New signature for the `circular` function for creating polygons
|
|
||||||
|
|
||||||
The `circular` function exported from `ol/geom/Polygon` no longer requires a `Sphere` as the first argument.
|
|
||||||
|
|
||||||
Example before:
|
|
||||||
```js
|
|
||||||
// using ol@4
|
|
||||||
import Polygon from 'ol/geom/polygon';
|
|
||||||
import Sphere from 'ol/sphere';
|
|
||||||
|
|
||||||
var poly = Polygon.circular(new Sphere(Sphere.DEFAULT_RADIUS), center, radius);
|
|
||||||
```
|
|
||||||
|
|
||||||
Example after:
|
|
||||||
```js
|
|
||||||
// using ol@5
|
|
||||||
import {circular as circularPolygon} from 'ol/geom/Polygon';
|
|
||||||
|
|
||||||
var poly = circularPolygon(center, radius);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Removal of optional this arguments.
|
|
||||||
|
|
||||||
The following methods did get the optional this (i.e. opt_this) arguments removed. Please use closures, the es6 arrow function or the bind method to achieve this effect (Bind is explained here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
|
|
||||||
|
|
||||||
* Collection#forEach
|
|
||||||
* geom/LineString#forEachSegment
|
|
||||||
* Observable#on, #once, #un
|
|
||||||
* source/TileUTFGrid#forDataAtCoordinateAndResolution
|
|
||||||
* source/Vector#forEachFeature, #forEachFeatureInExtent, #forEachFeatureIntersectingExtent
|
|
||||||
|
|
||||||
### v4.6.0
|
|
||||||
|
|
||||||
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow`
|
|
||||||
|
|
||||||
To update your applications, simply replace `exceedLength` with `overflow`.
|
|
||||||
|
|
||||||
#### Deprecation of `ol.source.ImageVector`
|
|
||||||
|
|
||||||
Rendering vector sources as image is now directly supported by `ol.layer.Vector` with the new `renderMode: 'image'` configuration option. Change code like this:
|
|
||||||
|
|
||||||
```js
|
|
||||||
new ol.layer.Image({
|
|
||||||
source: new ol.source.ImageVector({
|
|
||||||
style: myStyle,
|
|
||||||
source: new ol.source.Vector({
|
|
||||||
url: 'my/data.json',
|
|
||||||
format: new ol.format.GeoJSON()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
||||||
```
|
|
||||||
to:
|
|
||||||
|
|
||||||
```js
|
|
||||||
new ol.layer.Vector({
|
|
||||||
renderMode: 'image',
|
|
||||||
style: myStyle,
|
|
||||||
source: new ol.source.Vector({
|
|
||||||
url: 'my/data.json',
|
|
||||||
format: new ol.format.GeoJSON()
|
|
||||||
})
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### v4.5.0
|
|
||||||
|
|
||||||
#### Removed GeoJSON crs workaround for GeoServer
|
|
||||||
|
|
||||||
Previous version of GeoServer returned invalid crs in GeoJSON output. The workaround in `ol.format.GeoJSON` used to read this crs code is now removed.
|
|
||||||
|
|
||||||
#### Deprecation of `ol.Attribution`
|
|
||||||
|
|
||||||
`ol.Attribution` is deprecated and will be removed in the next major version. Instead, you can construct a source with a string attribution or an array of strings. For dynamic attributions, you can provide a function that gets called with the current frame state.
|
|
||||||
|
|
||||||
Before:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.XYZ({
|
|
||||||
attributions: [
|
|
||||||
new ol.Attribution({html: 'some attribution'})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
After:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.XYZ({
|
|
||||||
attributions: 'some attribution'
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
In addition to passing a string or an array of strings for the `attributions` option, you can also pass a function that will get called with the current frame state.
|
|
||||||
```js
|
|
||||||
var source = new ol.source.XYZ({
|
|
||||||
attributions: function(frameState) {
|
|
||||||
// inspect the frame state and return attributions
|
|
||||||
return 'some attribution'; // or ['multiple', 'attributions'] or null
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### v4.4.0
|
|
||||||
|
|
||||||
#### Behavior change for polygon labels
|
|
||||||
|
|
||||||
Polygon labels are now only rendered when the label does not exceed the polygon at the label position. To get the old behavior, configure your `ol.style.Text` with `exceedLength: true`.
|
|
||||||
|
|
||||||
#### Minor change for custom `tileLoadFunction` with `ol.source.VectorTile`
|
|
||||||
|
|
||||||
It is no longer necessary to set the projection on the tile. Instead, the `readFeatures` method must be called with the tile's extent as `extent` option and the view's projection as `featureProjection`.
|
|
||||||
|
|
||||||
Before:
|
|
||||||
```js
|
|
||||||
tile.setLoader(function() {
|
|
||||||
var data = // ... fetch data
|
|
||||||
var format = tile.getFormat();
|
|
||||||
tile.setFeatures(format.readFeatures(data));
|
|
||||||
tile.setProjection(format.readProjection(data));
|
|
||||||
// uncomment the line below for ol.format.MVT only
|
|
||||||
//tile.setExtent(format.getLastExtent());
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
After:
|
|
||||||
```js
|
|
||||||
tile.setLoader(function() {
|
|
||||||
var data = // ... fetch data
|
|
||||||
var format = tile.getFormat();
|
|
||||||
tile.setFeatures(format.readFeatures(data, {
|
|
||||||
featureProjection: map.getView().getProjection(),
|
|
||||||
// uncomment the line below for ol.format.MVT only
|
|
||||||
//extent: tile.getExtent()
|
|
||||||
}));
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Deprecation of `ol.DeviceOrientation`
|
|
||||||
|
|
||||||
`ol.DeviceOrientation` is deprecated and will be removed in the next major version.
|
|
||||||
The device-orientation example has been updated to use the (gyronorm.js)[https://github.com/dorukeker/gyronorm.js] library.
|
|
||||||
|
|
||||||
|
|
||||||
### v4.3.0
|
|
||||||
|
|
||||||
#### `ol.source.VectorTile` no longer requires a `tileGrid` option
|
|
||||||
|
|
||||||
By default, the `ol.source.VectorTile` constructor creates an XYZ tile grid (in Web Mercator) for 512 pixel tiles and assumes a max zoom level of 22. If you were creating a vector tile source with an explicit `tileGrid` option, you can now remove this.
|
|
||||||
|
|
||||||
Before:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.VectorTile({
|
|
||||||
tileGrid: ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22}),
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
After:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.VectorTile({
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
If you need to change the max zoom level, you can pass the source a `maxZoom` option. If you need to change the tile size, you can pass the source a `tileSize` option. If you need a completely custom tile grid, you can still pass the source a `tileGrid` option.
|
|
||||||
|
|
||||||
#### `ol.interaction.Modify` deletes with `alt` key only
|
|
||||||
|
|
||||||
To delete features with the modify interaction, press the `alt` key while clicking on an existing vertex. If you want to configure the modify interaction with a different delete condition, use the `deleteCondition` option. For example, to allow deletion on a single click with no modifier keys, configure the interaction like this:
|
|
||||||
```js
|
|
||||||
var interaction = new ol.interaction.Modify({
|
|
||||||
source: source,
|
|
||||||
deleteCondition: function(event) {
|
|
||||||
return ol.events.condition.noModifierKeys(event) && ol.events.condition.singleClick(event);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The motivation for this change is to make the modify, draw, and snap interactions all work well together. Previously, the use of these interactions with the default configuration would make it so you couldn't reliably add new vertices (click with no modifier) and delete existing vertices (click with no modifier).
|
|
||||||
|
|
||||||
#### `ol.source.VectorTile` no longer has a `tilePixelRatio` option
|
|
||||||
|
|
||||||
The `tilePixelRatio` option was only used for tiles in projections with `tile-pixels` as units. For tiles read with `ol.format.MVT` and the default tile loader, or tiles with the default pixel size of 4096 pixels, no changes are necessary. For the very rare cases that do not fall under these categories, a custom `tileLoadFunction` now needs to be configured on the `ol.source.VectorTile`. In addition to calling `tile.setFeatures()` and `tile.setProjection()`, it also needs to contain code like the following:
|
|
||||||
```js
|
|
||||||
var extent = tile.getFormat() instanceof ol.format.MVT ?
|
|
||||||
tile.getLastExtent() :
|
|
||||||
[0, 0, tilePixelRatio * tileSize, tilePixelRatio * tileSize];
|
|
||||||
tile.setExtent(extent);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `ol.animate` now takes the shortest arc for rotation animation
|
|
||||||
|
|
||||||
Usually rotation animations should animate along the shortest arc. There are rare occasions where a spinning animation effect is desired. So if you previously had something like
|
|
||||||
```js
|
|
||||||
map.getView().animate({
|
|
||||||
rotation: 2 * Math.PI,
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
```
|
|
||||||
we recommend to split the animation into two parts and use different easing functions. The code below results in the same effect as the snippet above did with previous versions:
|
|
||||||
```js
|
|
||||||
map.getView().animate({
|
|
||||||
rotation: Math.PI,
|
|
||||||
easing: ol.easing.easeIn
|
|
||||||
}, {
|
|
||||||
rotation: 2 * Math.PI,
|
|
||||||
easing: ol.easing.easeOut
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### v4.2.0
|
|
||||||
|
|
||||||
#### Return values of two `ol.style.RegularShape` getters have changed
|
|
||||||
|
|
||||||
To provide a more consistent behaviour the following getters now return the same value that was given to constructor:
|
|
||||||
|
|
||||||
`ol.style.RegularShape#getPoints` does not return the double amount of points anymore if a radius2 is set.
|
|
||||||
|
|
||||||
`ol.style.RegularShape#getRadius2` will return `undefined` if no radius2 is set.
|
|
||||||
|
|
||||||
### v4.1.0
|
### v4.1.0
|
||||||
|
|
||||||
#### Adding duplicate layers to a map throws
|
#### Adding duplicate layers to a map throws
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
# 4.2.0
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
The v4.2.0 release includes features and fixes from 87 pull requests.
|
|
||||||
|
|
||||||
#### New `movestart` event on `ol.Map`
|
|
||||||
|
|
||||||
The map now has a `movestart` event, as countarpart to the already existing `moveend` event.
|
|
||||||
|
|
||||||
#### New `moveTolerance` option in `ol.Map`
|
|
||||||
|
|
||||||
Some touch devices do not play well with OpenLayers's way of detecting clicks. To overcome this, a new `moveTolerance` option was introduced, so users can override the 1 pixel threshold above which a touch-release sequence won't be considered a click any more.
|
|
||||||
|
|
||||||
#### Support for multiple layers in `ol.format.TopoJSON`
|
|
||||||
|
|
||||||
With the new `layerName` and `layers` options, applications can extract the layer as additional attribute for vector features from `ol.format.TopoJSON`. This can especially be useful for styling vector tile layers.
|
|
||||||
|
|
||||||
#### New `tileJSON` option for `ol.source.TileJSON`
|
|
||||||
|
|
||||||
Like `ol.source.TileUTFGrid`, `ol.source.TileJSON` now also has a `tileJSON` option to configue it with inline TileJSON instead of a TileJSON URL.
|
|
||||||
|
|
||||||
#### New `ol.format.filter.during` filter
|
|
||||||
|
|
||||||
Although OpenLayers has no support for WFS v2.0, we added `ol.format.filter.during` for the `During` temporal operator.
|
|
||||||
|
|
||||||
#### Improved vector tile rendering at non-native resolutions
|
|
||||||
|
|
||||||
The vector tile renderer now uses an internal tile grid for all resolutions to cache pre-rendered tiles, even if the tile source does not have tiles for the viewed resolution. This improves rendering quality and performance.
|
|
||||||
|
|
||||||
#### New `insertVertexCondition` for `ol.interaction.Modify`
|
|
||||||
|
|
||||||
Applications can now control whether a vertex will be inserted into the modified geometry. This makes it easier to modify custom geometries.
|
|
||||||
|
|
||||||
#### New `callback` option for `ol.View#fit()`
|
|
||||||
|
|
||||||
To allow applications to perform custom actions when an animation associated with `ol.View#fit()` is completed, that method now has a new `callback` option.
|
|
||||||
|
|
||||||
#### New `ol.View#getInteracting()` getter
|
|
||||||
|
|
||||||
Like `ol.View#getAnimating()` returns `true` during a view animation, `ol.View#getInteracting()` returns `true` while users are interacting with the view.
|
|
||||||
|
|
||||||
#### New `hasZ` option for `ol.format.WFS#writeTransaction()`
|
|
||||||
|
|
||||||
When the new `hasZ` option is set to `true`, 3D coordinates will be preserved and encoded when writing a WFS transaction.
|
|
||||||
|
|
||||||
#### New `wrapX` option for `ol.source.Stamen`
|
|
||||||
|
|
||||||
Like other tile sources, `ol.source.Stamen` now also has a `wrapX` option, which allows applications to turn off wrapping the world in x direction.
|
|
||||||
|
|
||||||
#### Label support for `ol.Graticule`
|
|
||||||
|
|
||||||
The `ol.Graticule` component has several new options to add and control the output of labels. To turn on labelling, configure `ol.Graticule` with `showLabels: true`. The new options to control label formatting are `lonLabelFormatter`, `latLabelFormatter`, `lonLabelPosition` and `latLabelPosition`.
|
|
||||||
|
|
||||||
#### Return values of two `ol.style.RegularShape` getters have changed
|
|
||||||
|
|
||||||
To provide a more consistent behaviour the following getters now return the same value that was given to constructor:
|
|
||||||
|
|
||||||
`ol.style.RegularShape#getPoints` does not return the double amount of points anymore if a radius2 is set.
|
|
||||||
|
|
||||||
`ol.style.RegularShape#getRadius2` will return `undefined` if no radius2 is set.
|
|
||||||
|
|
||||||
## Detailed changes
|
|
||||||
|
|
||||||
* [#6912](https://github.com/openlayers/openlayers/pull/6912) - Use class instead of style for Translate cursor ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6858](https://github.com/openlayers/openlayers/pull/6858) - Webgl vector improvements ([@GaborFarkas](https://github.com/GaborFarkas))
|
|
||||||
* [#6890](https://github.com/openlayers/openlayers/pull/6890) - Add a movestart event ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6910](https://github.com/openlayers/openlayers/pull/6910) - Avoid duplicates in Observables list ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6902](https://github.com/openlayers/openlayers/pull/6902) - Require minimum duration for kinetic animation ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6904](https://github.com/openlayers/openlayers/pull/6904) - chore(package): update sinon to version 2.3.4 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6901](https://github.com/openlayers/openlayers/pull/6901) - Added release note for changed methods of ol.style.regularShape ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
|
||||||
* [#6886](https://github.com/openlayers/openlayers/pull/6886) - Make ol.source.Cluster extensible ([@gberaudo](https://github.com/gberaudo))
|
|
||||||
* [#6887](https://github.com/openlayers/openlayers/pull/6887) - Disable rotation for views with enableRotation: false ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6900](https://github.com/openlayers/openlayers/pull/6900) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6897](https://github.com/openlayers/openlayers/pull/6897) - ProjectionLike in proj.getPointResolution ([@probins](https://github.com/probins))
|
|
||||||
* [#6888](https://github.com/openlayers/openlayers/pull/6888) - Add note about custom functions to getPointResolution ([@probins](https://github.com/probins))
|
|
||||||
* [#6893](https://github.com/openlayers/openlayers/pull/6893) - Fix decimals options when writing features ([@tchandelle](https://github.com/tchandelle))
|
|
||||||
* [#6759](https://github.com/openlayers/openlayers/pull/6759) - Regular shape points ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
|
||||||
* [#6892](https://github.com/openlayers/openlayers/pull/6892) - Accept a ol.ProjectionLike instead of ol.proj.Projection ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6883](https://github.com/openlayers/openlayers/pull/6883) - Remove unused ol.pointer.EventSource#getMapping function ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6870](https://github.com/openlayers/openlayers/pull/6870) - Center map on proper earth, not one to the left ([@kannes](https://github.com/kannes))
|
|
||||||
* [#6872](https://github.com/openlayers/openlayers/pull/6872) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6876](https://github.com/openlayers/openlayers/pull/6876) - Only test ol.interaction.DragAndDrop if FileReader is supported ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6874](https://github.com/openlayers/openlayers/pull/6874) - Remove unused var from ol.proj ([@probins](https://github.com/probins))
|
|
||||||
* [#6875](https://github.com/openlayers/openlayers/pull/6875) - chore(package): update sinon to version 2.3.2 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6867](https://github.com/openlayers/openlayers/pull/6867) - add getArea to api ([@cs09g](https://github.com/cs09g))
|
|
||||||
* [#6863](https://github.com/openlayers/openlayers/pull/6863) - change size to optional ([@cs09g](https://github.com/cs09g))
|
|
||||||
* [#6864](https://github.com/openlayers/openlayers/pull/6864) - fix(package): update closure-util to version 1.21.0 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6834](https://github.com/openlayers/openlayers/pull/6834) - Move tolerance option ([@notnotse](https://github.com/notnotse))
|
|
||||||
* [#6856](https://github.com/openlayers/openlayers/pull/6856) - Fix creation of new URL in readSharedStyle_ and readSharedStyleMap_ ([@oterral](https://github.com/oterral))
|
|
||||||
* [#6852](https://github.com/openlayers/openlayers/pull/6852) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6851](https://github.com/openlayers/openlayers/pull/6851) - Register/unregister listeners in setActive ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6832](https://github.com/openlayers/openlayers/pull/6832) - Force state of error tiles when usInterimTilesOnError is false ([@oterral](https://github.com/oterral))
|
|
||||||
* [#6849](https://github.com/openlayers/openlayers/pull/6849) - Create URL object only when we can ([@oterral](https://github.com/oterral))
|
|
||||||
* [#6845](https://github.com/openlayers/openlayers/pull/6845) - Snap on circles ([@tchandelle](https://github.com/tchandelle))
|
|
||||||
* [#6842](https://github.com/openlayers/openlayers/pull/6842) - add condition to check if active ([@cs09g](https://github.com/cs09g))
|
|
||||||
* [#6844](https://github.com/openlayers/openlayers/pull/6844) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6841](https://github.com/openlayers/openlayers/pull/6841) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6839](https://github.com/openlayers/openlayers/pull/6839) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6838](https://github.com/openlayers/openlayers/pull/6838) - fix(package): update handlebars to version 4.0.10 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6817](https://github.com/openlayers/openlayers/pull/6817) - Multiple layers in TopoJSON vector tiles ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6833](https://github.com/openlayers/openlayers/pull/6833) - Fix geojson-vt example for line and point geometries ([@oterral](https://github.com/oterral))
|
|
||||||
* [#6829](https://github.com/openlayers/openlayers/pull/6829) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6819](https://github.com/openlayers/openlayers/pull/6819) - Adjust/fix API for working with vector tile features ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6818](https://github.com/openlayers/openlayers/pull/6818) - Add tileJSON option to ol.source.TileJSON ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6805](https://github.com/openlayers/openlayers/pull/6805) - Display country name on click select ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6813](https://github.com/openlayers/openlayers/pull/6813) - Prepend the version with a v ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#6814](https://github.com/openlayers/openlayers/pull/6814) - Re-add ol.render.Feature#getGeometry() ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6812](https://github.com/openlayers/openlayers/pull/6812) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6786](https://github.com/openlayers/openlayers/pull/6786) - Add ol.format.filter.during ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6806](https://github.com/openlayers/openlayers/pull/6806) - Add note about features with the same id ([@drnextgis](https://github.com/drnextgis))
|
|
||||||
* [#6802](https://github.com/openlayers/openlayers/pull/6802) - Remove unused setFeatures and getFormat methods ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6801](https://github.com/openlayers/openlayers/pull/6801) - Add getId method for ol.render.Feature ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6778](https://github.com/openlayers/openlayers/pull/6778) - Add a small tolerance when testing pointer event positions ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6796](https://github.com/openlayers/openlayers/pull/6796) - Re-add accidently dropped condition ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6798](https://github.com/openlayers/openlayers/pull/6798) - chore(package): update clean-css-cli to version 4.1.2 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6795](https://github.com/openlayers/openlayers/pull/6795) - Fix ol.DrawGeometryFunctionType coordinates argument type ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6797](https://github.com/openlayers/openlayers/pull/6797) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6779](https://github.com/openlayers/openlayers/pull/6779) - Decouple source and rendered tile grid of vector tile sources ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6785](https://github.com/openlayers/openlayers/pull/6785) - Add insertVertexCondition to ol.interaction.Modify options ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6792](https://github.com/openlayers/openlayers/pull/6792) - Create intermediate canvas when resolutions have changed ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6790](https://github.com/openlayers/openlayers/pull/6790) - Update resemblejs to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6784](https://github.com/openlayers/openlayers/pull/6784) - chore(package): update clean-css-cli to version 4.1.0 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6556](https://github.com/openlayers/openlayers/pull/6556) - Reading kml xunits/yunits insetPixels ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
|
||||||
* [#6775](https://github.com/openlayers/openlayers/pull/6775) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6774](https://github.com/openlayers/openlayers/pull/6774) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6770](https://github.com/openlayers/openlayers/pull/6770) - Enforce the "no missing requires" rule ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#6772](https://github.com/openlayers/openlayers/pull/6772) - Remove html tag from shortdesc ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6769](https://github.com/openlayers/openlayers/pull/6769) - Update handlebars to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6757](https://github.com/openlayers/openlayers/pull/6757) - Fix crashing on creation of snap-interaction, if Circle is among the features to snap to. ([@hajjimurad](https://github.com/hajjimurad))
|
|
||||||
* [#6766](https://github.com/openlayers/openlayers/pull/6766) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6765](https://github.com/openlayers/openlayers/pull/6765) - Add new callback function to view.FitOptions ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6764](https://github.com/openlayers/openlayers/pull/6764) - Added View#getInteracting() to the api ([@mblinsitu](https://github.com/mblinsitu))
|
|
||||||
* [#6760](https://github.com/openlayers/openlayers/pull/6760) - Update handlebars to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6761](https://github.com/openlayers/openlayers/pull/6761) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6755](https://github.com/openlayers/openlayers/pull/6755) - Add missing goog.require ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6751](https://github.com/openlayers/openlayers/pull/6751) - Update coveralls to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6750](https://github.com/openlayers/openlayers/pull/6750) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6741](https://github.com/openlayers/openlayers/pull/6741) - Allow user selection in overlay container ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6744](https://github.com/openlayers/openlayers/pull/6744) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6737](https://github.com/openlayers/openlayers/pull/6737) - Graticule labels ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6740](https://github.com/openlayers/openlayers/pull/6740) - Fix spelling ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6730](https://github.com/openlayers/openlayers/pull/6730) - Update metalsmith-layouts to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6732](https://github.com/openlayers/openlayers/pull/6732) - Use firefox < 53 in travis ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6677](https://github.com/openlayers/openlayers/pull/6677) - Add an option to writeTransaction to support 3D geometries ([@Jenselme](https://github.com/Jenselme))
|
|
||||||
* [#6524](https://github.com/openlayers/openlayers/pull/6524) - Don't append feature prefix twice in WFS requests ([@Jenselme](https://github.com/Jenselme))
|
|
||||||
* [#6727](https://github.com/openlayers/openlayers/pull/6727) - Add default value in doc for the hitTolerance option ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6724](https://github.com/openlayers/openlayers/pull/6724) - Add wrapX option to Stamen source ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6728](https://github.com/openlayers/openlayers/pull/6728) - Fix tissot examples docs ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6725](https://github.com/openlayers/openlayers/pull/6725) - Update dependencies to enable Greenkeeper 🌴 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6711](https://github.com/openlayers/openlayers/pull/6711) - Correct path to cleancss ([@tschaub](https://github.com/tschaub))
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
# 4.3.0
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
The v4.3.0 release includes features and fixes from 92 pull requests.
|
|
||||||
|
|
||||||
#### New `map.getFeaturesAtPixel()` method
|
|
||||||
|
|
||||||
When you want to get all features at a given pixel, use the new `map.getFeaturesAtPixel()` method.
|
|
||||||
|
|
||||||
Before:
|
|
||||||
```js
|
|
||||||
var features = [];
|
|
||||||
map.forEachFeatureAtPixel(pixel, function(feature) {
|
|
||||||
features.push(feature);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
After:
|
|
||||||
```js
|
|
||||||
var features = map.getFeaturesAtPixel(pixel);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `ol.Sphere` functions for spherical measures
|
|
||||||
|
|
||||||
The new `ol.Sphere.getArea()` and `ol.Sphere.getLength()` methods can be used to calculate spherical measures on geometries. This is the recommended over using the `geometry.getArea()` or `geometry.getLength()` methods.
|
|
||||||
|
|
||||||
Bad:
|
|
||||||
```js
|
|
||||||
geometry.getArea();
|
|
||||||
```
|
|
||||||
|
|
||||||
Good:
|
|
||||||
```js
|
|
||||||
ol.Sphere.getArea(geometry);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `ol.interaction.DragAndDrop` can be configured with a vector source
|
|
||||||
|
|
||||||
It is now possible to configure the drag and drop interaction with a vector source:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var dragAndDrop = new ol.interaction.DragAndDrop({source: source});
|
|
||||||
```
|
|
||||||
|
|
||||||
Any dropped features will replace all existing features on the source.
|
|
||||||
|
|
||||||
#### `ol.interaction.Modify` can be configured with a vector source
|
|
||||||
|
|
||||||
It is now possible to configure the modify interaction with a vector source (in addition to a feature collection):
|
|
||||||
|
|
||||||
```js
|
|
||||||
var modify = new ol.interaction.Modify({source: source});
|
|
||||||
```
|
|
||||||
|
|
||||||
With this configuration, all features on the source are eligible for modification while the interaction is active.
|
|
||||||
|
|
||||||
#### `ol.interaction.Modify` deletes with `alt` key only
|
|
||||||
|
|
||||||
To delete features with the modify interaction, press the `alt` key while clicking on an existing vertex. If you want to configure the modify interaction with a different delete condition, use the `deleteCondition` option. For example, to allow deletion on a single click with no modifier keys, configure the interaction like this:
|
|
||||||
```js
|
|
||||||
var interaction = new ol.interaction.Modify({
|
|
||||||
source: source,
|
|
||||||
deleteCondition: function(event) {
|
|
||||||
return ol.events.condition.noModifierKeys(event) && ol.events.condition.singleClick(event);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The motivation for this change is to make the modify, draw, and snap interactions all work well together. Previously, the use of these interactions with the default configuration would make it so you couldn't reliably add new vertices (click with no modifier) and delete existing vertices (click with no modifier).
|
|
||||||
|
|
||||||
#### `ol.source.VectorTile` no longer requires a `tileGrid` option
|
|
||||||
|
|
||||||
By default, the `ol.source.VectorTile` constructor creates an XYZ tile grid (in Web Mercator) for 512 pixel tiles and assumes a max zoom level of 22. If you were creating a vector tile source with an explicit `tileGrid` option, you can now remove this.
|
|
||||||
|
|
||||||
Before:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.VectorTile({
|
|
||||||
tileGrid: ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22}),
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
After:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.VectorTile({
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
If you need to change the max zoom level, you can pass the source a `maxZoom` option. If you need to change the tile size, you can pass the source a `tileSize` option. If you need a completely custom tile grid, you can still pass the source a `tileGrid` option.
|
|
||||||
|
|
||||||
#### `ol.source.VectorTile` no longer has a `tilePixelRatio` option
|
|
||||||
|
|
||||||
The `tilePixelRatio` option was only used for tiles in projections with `tile-pixels` as units. For tiles read with `ol.format.MVT` and the default tile loader, or tiles with the default pixel size of 4096 pixels, no changes are necessary. For the very rare cases that do not fall under these categories, a custom `tileLoadFunction` now needs to be configured on the `ol.source.VectorTile`. In addition to calling `tile.setFeatures()` and `tile.setProjection()`, it also needs to contain code like the following:
|
|
||||||
```js
|
|
||||||
var extent = tile.getFormat() instanceof ol.format.MVT ?
|
|
||||||
tile.getLastExtent() :
|
|
||||||
[0, 0, tilePixelRatio * tileSize, tilePixelRatio * tileSize];
|
|
||||||
tile.setExtent(extent);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `ol.animate` now takes the shortest arc for rotation animation
|
|
||||||
|
|
||||||
Usually rotation animations should animate along the shortest arc. There are rare occasions where a spinning animation effect is desired. So if you previously had something like
|
|
||||||
```js
|
|
||||||
map.getView().animate({
|
|
||||||
rotation: 2 * Math.PI,
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
```
|
|
||||||
we recommend to split the animation into two parts and use different easing functions. The code below results in the same effect as the snippet above did with previous versions:
|
|
||||||
```js
|
|
||||||
map.getView().animate({
|
|
||||||
rotation: Math.PI,
|
|
||||||
easing: ol.easing.easeIn
|
|
||||||
}, {
|
|
||||||
rotation: 2 * Math.PI,
|
|
||||||
easing: ol.easing.easeOut
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Full List of Changes
|
|
||||||
|
|
||||||
* [#7117](https://github.com/openlayers/openlayers/pull/7117) - Sensible default tilegrid for vector tiles ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7116](https://github.com/openlayers/openlayers/pull/7116) - fix(package): update rollup to version 0.47.2 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7111](https://github.com/openlayers/openlayers/pull/7111) - Remove broken wrapX handling from ol.Graticule ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7107](https://github.com/openlayers/openlayers/pull/7107) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7106](https://github.com/openlayers/openlayers/pull/7106) - Update proj4 to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7105](https://github.com/openlayers/openlayers/pull/7105) - Functions for spherical calculations ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7104](https://github.com/openlayers/openlayers/pull/7104) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6807](https://github.com/openlayers/openlayers/pull/6807) - Initialize hasZ in the constructor of GML3 ([@Jenselme](https://github.com/Jenselme))
|
|
||||||
* [#7102](https://github.com/openlayers/openlayers/pull/7102) - Allow drag and drop interaction to be configured with a source ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#6825](https://github.com/openlayers/openlayers/pull/6825) - Read/write Tessellate tag in KML format ([@oterral](https://github.com/oterral))
|
|
||||||
* [#7098](https://github.com/openlayers/openlayers/pull/7098) - Use fractional coordinates for CSS positioning ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7064](https://github.com/openlayers/openlayers/pull/7064) - Do not use Array.prototype.forEach when dealing with potentially large arrays ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7093](https://github.com/openlayers/openlayers/pull/7093) - Allow modify interaction to be configured with a source ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7096](https://github.com/openlayers/openlayers/pull/7096) - Add new Map#getFeaturesAtPixel method ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7094](https://github.com/openlayers/openlayers/pull/7094) - Add missing zIndex options ([@icholy](https://github.com/icholy))
|
|
||||||
* [#7087](https://github.com/openlayers/openlayers/pull/7087) - Fix scale line for EPSG:4326 maps ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7088](https://github.com/openlayers/openlayers/pull/7088) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7085](https://github.com/openlayers/openlayers/pull/7085) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7084](https://github.com/openlayers/openlayers/pull/7084) - Fix a typo in the street-labels example ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7082](https://github.com/openlayers/openlayers/pull/7082) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7079](https://github.com/openlayers/openlayers/pull/7079) - Optimize custom renderer code, examples and API ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7080](https://github.com/openlayers/openlayers/pull/7080) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7078](https://github.com/openlayers/openlayers/pull/7078) - Fix return type annotation of ol.layer.VectorTile.getSource ([@geosense](https://github.com/geosense))
|
|
||||||
* [#7073](https://github.com/openlayers/openlayers/pull/7073) - Make ol.layer.Group change handling consistent ([@gberaudo](https://github.com/gberaudo))
|
|
||||||
* [#7075](https://github.com/openlayers/openlayers/pull/7075) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7072](https://github.com/openlayers/openlayers/pull/7072) - Improve API docs for ol.VectorTile ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7070](https://github.com/openlayers/openlayers/pull/7070) - Get tilePixelRatio from MVT tiles ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7069](https://github.com/openlayers/openlayers/pull/7069) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7068](https://github.com/openlayers/openlayers/pull/7068) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7066](https://github.com/openlayers/openlayers/pull/7066) - Fix ol.interaction.Extent event type and documentation ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7032](https://github.com/openlayers/openlayers/pull/7032) - Fix KML Export Icon Anchor ([@raiyni](https://github.com/raiyni))
|
|
||||||
* [#7065](https://github.com/openlayers/openlayers/pull/7065) - Only use API functions in example ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7022](https://github.com/openlayers/openlayers/pull/7022) - Allow styles to configure a custom renderer ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7061](https://github.com/openlayers/openlayers/pull/7061) - Update docs and issue and pull request instructions ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7059](https://github.com/openlayers/openlayers/pull/7059) - Allow to configure Extent interaction with an extent ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7060](https://github.com/openlayers/openlayers/pull/7060) - Removing invalid urn ([@wnordmann](https://github.com/wnordmann))
|
|
||||||
* [#7051](https://github.com/openlayers/openlayers/pull/7051) - Changing the EPSG3857.PROJECTION array assignment and adding urn:ogc:… ([@wnordmann](https://github.com/wnordmann))
|
|
||||||
* [#7045](https://github.com/openlayers/openlayers/pull/7045) - Respect pixelRatio when scaling images ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7023](https://github.com/openlayers/openlayers/pull/7023) - Update tile size and resolutions of vector tile examples ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7005](https://github.com/openlayers/openlayers/pull/7005) - Add spatial reference inside geometry in EsriFormat ([@Sol1du2](https://github.com/Sol1du2))
|
|
||||||
* [#7034](https://github.com/openlayers/openlayers/pull/7034) - Move non-build dependencies to devDependencies ([@probins](https://github.com/probins))
|
|
||||||
* [#7050](https://github.com/openlayers/openlayers/pull/7050) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6976](https://github.com/openlayers/openlayers/pull/6976) - Example - Earthquake Clusters - Change evt.type of interaction ([@ehanoj](https://github.com/ehanoj))
|
|
||||||
* [#7048](https://github.com/openlayers/openlayers/pull/7048) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7041](https://github.com/openlayers/openlayers/pull/7041) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7042](https://github.com/openlayers/openlayers/pull/7042) - Line dash offset ([@gkresic](https://github.com/gkresic))
|
|
||||||
* [#6980](https://github.com/openlayers/openlayers/pull/6980) - Added tileClass to TileWMS ([@ZachTRice](https://github.com/ZachTRice))
|
|
||||||
* [#7028](https://github.com/openlayers/openlayers/pull/7028) - Fix Graticule use of incorrect min/maxLon values ([@greggian](https://github.com/greggian))
|
|
||||||
* [#7021](https://github.com/openlayers/openlayers/pull/7021) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7018](https://github.com/openlayers/openlayers/pull/7018) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7015](https://github.com/openlayers/openlayers/pull/7015) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7014](https://github.com/openlayers/openlayers/pull/7014) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7013](https://github.com/openlayers/openlayers/pull/7013) - Remove ol.sphere.WGS84 and ol.sphere.NORMAL ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#6981](https://github.com/openlayers/openlayers/pull/6981) - Render transparent vector layers to an intermediate canvas ([@gberaudo](https://github.com/gberaudo))
|
|
||||||
* [#6899](https://github.com/openlayers/openlayers/pull/6899) - Use number literal for sphere radius ([@probins](https://github.com/probins))
|
|
||||||
* [#7011](https://github.com/openlayers/openlayers/pull/7011) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7008](https://github.com/openlayers/openlayers/pull/7008) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7007](https://github.com/openlayers/openlayers/pull/7007) - fix(package): update rollup to version 0.45.0 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6996](https://github.com/openlayers/openlayers/pull/6996) - 6987: Memory leak with WMS time source with reprojection ([@ch08532](https://github.com/ch08532))
|
|
||||||
* [#7003](https://github.com/openlayers/openlayers/pull/7003) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7004](https://github.com/openlayers/openlayers/pull/7004) - Use https for bing and stamen attributions ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6998](https://github.com/openlayers/openlayers/pull/6998) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6999](https://github.com/openlayers/openlayers/pull/6999) - Make VectorTile source work with multiple layers ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6988](https://github.com/openlayers/openlayers/pull/6988) - Add missing type annotations ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6984](https://github.com/openlayers/openlayers/pull/6984) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6970](https://github.com/openlayers/openlayers/pull/6970) - Fix Bug when adding/removing layer with no cache ([@cmortazavi](https://github.com/cmortazavi))
|
|
||||||
* [#6972](https://github.com/openlayers/openlayers/pull/6972) - Handle error tiles properly ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6973](https://github.com/openlayers/openlayers/pull/6973) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6971](https://github.com/openlayers/openlayers/pull/6971) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6968](https://github.com/openlayers/openlayers/pull/6968) - Shortest arc rotation animation improvements and upgrade notes ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6966](https://github.com/openlayers/openlayers/pull/6966) - Add getResolutionForZoom method for ol.View ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6965](https://github.com/openlayers/openlayers/pull/6965) - Use shortest rotation delta for animation ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6967](https://github.com/openlayers/openlayers/pull/6967) - Add RoadOnDemand imagery set to Bing example ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6964](https://github.com/openlayers/openlayers/pull/6964) - Fix KML ExtendedData reading ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6958](https://github.com/openlayers/openlayers/pull/6958) - Remove error tiles after loading is finished ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6793](https://github.com/openlayers/openlayers/pull/6793) - Webgl text ([@GaborFarkas](https://github.com/GaborFarkas))
|
|
||||||
* [#6960](https://github.com/openlayers/openlayers/pull/6960) - Queue tiles before loading ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#6957](https://github.com/openlayers/openlayers/pull/6957) - Greenkeeper/eslint 4.1.1 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6955](https://github.com/openlayers/openlayers/pull/6955) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6916](https://github.com/openlayers/openlayers/pull/6916) - Upgrade eslint to v4.0.0 ([@marcjansen](https://github.com/marcjansen))
|
|
||||||
* [#6943](https://github.com/openlayers/openlayers/pull/6943) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6939](https://github.com/openlayers/openlayers/pull/6939) - Abort loading when tile is disposed ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6930](https://github.com/openlayers/openlayers/pull/6930) - Handle setActive(false) on an interaction without map ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#6936](https://github.com/openlayers/openlayers/pull/6936) - Do not stop the render loop when all wanted tiles are aborted ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6920](https://github.com/openlayers/openlayers/pull/6920) - Fix minor type strength inconsistency ([@klokantech](https://github.com/klokantech))
|
|
||||||
* [#6935](https://github.com/openlayers/openlayers/pull/6935) - Use transparent image from canvas context ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6933](https://github.com/openlayers/openlayers/pull/6933) - Improve proj.get() logic ([@probins](https://github.com/probins))
|
|
||||||
* [#6931](https://github.com/openlayers/openlayers/pull/6931) - Make sure we use the default featurePrefix ([@bartvde](https://github.com/bartvde))
|
|
||||||
* [#6928](https://github.com/openlayers/openlayers/pull/6928) - Only adjust resolution when center within projection extent ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6923](https://github.com/openlayers/openlayers/pull/6923) - Load tasks/build-ext.js in strict mode ([@fredj](https://github.com/fredj))
|
|
||||||
* [#6918](https://github.com/openlayers/openlayers/pull/6918) - Remove unnecessary pixelRatio check ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6917](https://github.com/openlayers/openlayers/pull/6917) - Correct typo in graticule docs ([@probins](https://github.com/probins))
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# 4.3.1
|
|
||||||
|
|
||||||
The v4.3.1 release includes a few fixes that didn't make it into v4.3.0. No special upgrade considerations.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7122](https://github.com/openlayers/openlayers/pull/7122) - Immediately complete no-op animations ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7120](https://github.com/openlayers/openlayers/pull/7120) - Fix hit detection for overzoomed vector tiles ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7114](https://github.com/openlayers/openlayers/pull/7114) - Immediate WebGL text renderer and other improvements ([@GaborFarkas](https://github.com/GaborFarkas))
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 4.3.2
|
|
||||||
|
|
||||||
The v4.3.2 release includes a single fix.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7140](https://github.com/openlayers/openlayers/pull/7140) - Export ol.Sphere.getLength and ol.Sphere.getArea ([@fredj](https://github.com/fredj))
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 4.3.3
|
|
||||||
|
|
||||||
The v4.3.3 release reverts the fractional pixel positioning of overlays.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7258](https://github.com/openlayers/openlayers/pull/7258) - Revert changes made in #7098 ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 4.3.4
|
|
||||||
|
|
||||||
The v4.3.4 release includes a fix for Safari on iOS 11.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7285](https://github.com/openlayers/openlayers/pull/7285) - Convert pointerId to string for object lookups ([@tschaub](https://github.com/tschaub))
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
# 4.4.0
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
The 4.4.0 release includes features and fixes from 80 pull requests, including first time contributions from @EduardoNogueira, @ath0mas, @f7o, @trevorblades, @viethang, and @wb14123. There are some really nice rendering enhancements included in this release. It is now possible to render labels along lines (see [#7239](https://github.com/openlayers/openlayers/pull/7239) for more detail) and polygon labels are only rendered if they fit within the polygon ([#7292](https://github.com/openlayers/openlayers/pull/7292)). In addition, we now render tiles with an opacity transition, so tiled layers more gracefully fade in ([#7267](https://github.com/openlayers/openlayers/pull/7267)).
|
|
||||||
|
|
||||||
### Upgrade notes
|
|
||||||
|
|
||||||
#### Behavior change for polygon labels
|
|
||||||
|
|
||||||
Polygon labels are now only rendered when the label does not exceed the polygon at the label position. To get the old behavior, configure your `ol.style.Text` with `exceedLength: true`.
|
|
||||||
|
|
||||||
#### Minor change for custom `tileLoadFunction` with `ol.source.VectorTile`
|
|
||||||
|
|
||||||
It is no longer necessary to set the projection on the tile. Instead, the `readFeatures` method must be called with the tile's extent as `extent` option and the view's projection as `featureProjection`.
|
|
||||||
|
|
||||||
Before:
|
|
||||||
```js
|
|
||||||
tile.setLoader(function() {
|
|
||||||
var data = // ... fetch data
|
|
||||||
var format = tile.getFormat();
|
|
||||||
tile.setFeatures(format.readFeatures(data));
|
|
||||||
tile.setProjection(format.readProjection(data));
|
|
||||||
// uncomment the line below for ol.format.MVT only
|
|
||||||
//tile.setExtent(format.getLastExtent());
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
After:
|
|
||||||
```js
|
|
||||||
tile.setLoader(function() {
|
|
||||||
var data = // ... fetch data
|
|
||||||
var format = tile.getFormat();
|
|
||||||
tile.setFeatures(format.readFeatures(data, {
|
|
||||||
featureProjection: map.getView().getProjection(),
|
|
||||||
// uncomment the line below for ol.format.MVT only
|
|
||||||
//extent: tile.getExtent()
|
|
||||||
}));
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Deprecation of `ol.DeviceOrientation`
|
|
||||||
|
|
||||||
`ol.DeviceOrientation` is deprecated and will be removed in the next major version.
|
|
||||||
The device-orientation example has been updated to use the (gyronorm.js)[https://github.com/dorukeker/gyronorm.js] library.
|
|
||||||
|
|
||||||
|
|
||||||
## Detailed changes
|
|
||||||
|
|
||||||
See below for the full list of changes.
|
|
||||||
|
|
||||||
* [#7306](https://github.com/openlayers/openlayers/pull/7306) - Enable mouse wheel in freehand draw mode ([@trevorblades](https://github.com/trevorblades))
|
|
||||||
* [#7297](https://github.com/openlayers/openlayers/pull/7297) - Fix multipoint instruction set ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7267](https://github.com/openlayers/openlayers/pull/7267) - Render tiles with an opacity transition ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7292](https://github.com/openlayers/openlayers/pull/7292) - Only render polygon labels when they fit ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7289](https://github.com/openlayers/openlayers/pull/7289) - Release v4.3.4 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7287](https://github.com/openlayers/openlayers/pull/7287) - Fix vertical stroke/fill alignment for text along lines ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7285](https://github.com/openlayers/openlayers/pull/7285) - Convert pointerId to string for object lookups ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7280](https://github.com/openlayers/openlayers/pull/7280) - Updated docs for deleteCondition ([@EduardoNogueira](https://github.com/EduardoNogueira))
|
|
||||||
* [#7274](https://github.com/openlayers/openlayers/pull/7274) - Add ability to change the loader of a vector source ([@bartvde](https://github.com/bartvde))
|
|
||||||
* [#7259](https://github.com/openlayers/openlayers/pull/7259) - Add missing param doc tag for ol.format.WKT.prototype.writeFeatures ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7260](https://github.com/openlayers/openlayers/pull/7260) - Release v4.3.3 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7258](https://github.com/openlayers/openlayers/pull/7258) - Revert changes made in #7098. ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7220](https://github.com/openlayers/openlayers/pull/7220) - Mark ol.format.filter.Spatial as abstract class ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7249](https://github.com/openlayers/openlayers/pull/7249) - Script to rename files so the case matches the module name ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7252](https://github.com/openlayers/openlayers/pull/7252) - fix osmxml to read ways before the definition of nodes ([@wb14123](https://github.com/wb14123))
|
|
||||||
* [#7253](https://github.com/openlayers/openlayers/pull/7253) - Nicer wording in the issue template ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7236](https://github.com/openlayers/openlayers/pull/7236) - reusing images in ol.style.Icon#clone ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
|
||||||
* [#7246](https://github.com/openlayers/openlayers/pull/7246) - Compare measured lengths with a tolerance ([@marcjansen](https://github.com/marcjansen))
|
|
||||||
* [#7247](https://github.com/openlayers/openlayers/pull/7247) - Raise tolerance of rendering tests to pass on Firefox 55 (GNU/Linux) ([@marcjansen](https://github.com/marcjansen))
|
|
||||||
* [#7239](https://github.com/openlayers/openlayers/pull/7239) - Render text along lines ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7242](https://github.com/openlayers/openlayers/pull/7242) - Use EMPTY and LOADED state properly on ol.VectorImageTile ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7234](https://github.com/openlayers/openlayers/pull/7234) - Fix abort handling of tileload events ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7221](https://github.com/openlayers/openlayers/pull/7221) - update zoomify source to accept tileIndex placeholders and handle iip… ([@thhomas](https://github.com/thhomas))
|
|
||||||
* [#6871](https://github.com/openlayers/openlayers/pull/6871) - Correct controls position in Center example ([@ath0mas](https://github.com/ath0mas))
|
|
||||||
* [#7229](https://github.com/openlayers/openlayers/pull/7229) - Fix JSDoc paths for custom builds ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7230](https://github.com/openlayers/openlayers/pull/7230) - Remove unused context handling for ol.Image ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7225](https://github.com/openlayers/openlayers/pull/7225) - Fix hit detection for image layers ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7223](https://github.com/openlayers/openlayers/pull/7223) - Transform updates ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7219](https://github.com/openlayers/openlayers/pull/7219) - Change cartodb domain from cartodb.com to carto.com ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7210](https://github.com/openlayers/openlayers/pull/7210) - Avoid unnecessary calculations for a zoom factor of 2 ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7209](https://github.com/openlayers/openlayers/pull/7209) - Remove grid.getTileRangeForExtentAndResolution() ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7201](https://github.com/openlayers/openlayers/pull/7201) - Prerender text to images ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7208](https://github.com/openlayers/openlayers/pull/7208) - Do not calculate coverage when running tests locally ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7206](https://github.com/openlayers/openlayers/pull/7206) - Only load source tiles that intersect the source tile grid's extent ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7203](https://github.com/openlayers/openlayers/pull/7203) - Enable Edge tests on SauceLabs ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7194](https://github.com/openlayers/openlayers/pull/7194) - Deprecate ol.DeviceOrientation ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7198](https://github.com/openlayers/openlayers/pull/7198) - Use geometry name in WFS updates ([@bartvde](https://github.com/bartvde))
|
|
||||||
* [#7205](https://github.com/openlayers/openlayers/pull/7205) - Release v4.3.2 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7172](https://github.com/openlayers/openlayers/pull/7172) - added clear method to vectortile source ([@f7o](https://github.com/f7o))
|
|
||||||
* [#7196](https://github.com/openlayers/openlayers/pull/7196) - renderSync() to make sure overlay is initially visible ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7193](https://github.com/openlayers/openlayers/pull/7193) - Fix KML links for documents created locally in Safari ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6977](https://github.com/openlayers/openlayers/pull/6977) - Fixed modify feature test ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
|
||||||
* [#7190](https://github.com/openlayers/openlayers/pull/7190) - Use jsts version 1.4.0 in example ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7191](https://github.com/openlayers/openlayers/pull/7191) - Fix provide/require for autogenerated shader files ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7192](https://github.com/openlayers/openlayers/pull/7192) - Fix typo ([@viethang](https://github.com/viethang))
|
|
||||||
* [#7133](https://github.com/openlayers/openlayers/pull/7133) - Issue/6991/WFS Write Dimension ([@Sol1du2](https://github.com/Sol1du2))
|
|
||||||
* [#7141](https://github.com/openlayers/openlayers/pull/7141) - Issue/6990/Wfs Read srsDimension ([@Sol1du2](https://github.com/Sol1du2))
|
|
||||||
* [#7187](https://github.com/openlayers/openlayers/pull/7187) - Simpler tile pixel handling and faster parsing for ol.format.MVT vector tiles ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7182](https://github.com/openlayers/openlayers/pull/7182) - Avoid instanceof checks in global test extensions ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7168](https://github.com/openlayers/openlayers/pull/7168) - Exclude greenkeeper merges from changelog ([@gberaudo](https://github.com/gberaudo))
|
|
||||||
* [#7162](https://github.com/openlayers/openlayers/pull/7162) - Bring back coverage ([@marcjansen](https://github.com/marcjansen))
|
|
||||||
* [#7165](https://github.com/openlayers/openlayers/pull/7165) - More assorted test fixes ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7142](https://github.com/openlayers/openlayers/pull/7142) - Adds unit test to test the projection inside the geometry of esriJson ([@Sol1du2](https://github.com/Sol1du2))
|
|
||||||
* [#7163](https://github.com/openlayers/openlayers/pull/7163) - Remove bundling magic for Mapbox styles script ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7160](https://github.com/openlayers/openlayers/pull/7160) - Assorted test updates ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7158](https://github.com/openlayers/openlayers/pull/7158) - Retain comments when replacing nodes ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7153](https://github.com/openlayers/openlayers/pull/7153) - Scripts for in-place transforms ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7154](https://github.com/openlayers/openlayers/pull/7154) - Unused require in examples/d3.js ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7151](https://github.com/openlayers/openlayers/pull/7151) - Get rid of useless test exports ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7152](https://github.com/openlayers/openlayers/pull/7152) - Adjust the pull request template (tests, CLA, wording) ([@marcjansen](https://github.com/marcjansen))
|
|
||||||
* [#7150](https://github.com/openlayers/openlayers/pull/7150) - Remove problematic spies from scaleline tests ([@marcjansen](https://github.com/marcjansen))
|
|
||||||
* [#7149](https://github.com/openlayers/openlayers/pull/7149) - Remove unused requires ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7148](https://github.com/openlayers/openlayers/pull/7148) - Remove ol.ENABLE_WEBGL wrap from WebGL files ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7147](https://github.com/openlayers/openlayers/pull/7147) - Remove unnecessary import in events.test.js ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7146](https://github.com/openlayers/openlayers/pull/7146) - Avoid modifying imports ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7145](https://github.com/openlayers/openlayers/pull/7145) - Spaceless provides ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7136](https://github.com/openlayers/openlayers/pull/7136) - Use data URI instead of whole empty image ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7137](https://github.com/openlayers/openlayers/pull/7137) - Developer documentation updates ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7138](https://github.com/openlayers/openlayers/pull/7138) - Improvements to the new test setup ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7140](https://github.com/openlayers/openlayers/pull/7140) - Export ol.Sphere.getLength and ol.Sphere.getArea ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7131](https://github.com/openlayers/openlayers/pull/7131) - Print ES6 import hint on each doc page ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6953](https://github.com/openlayers/openlayers/pull/6953) - Run tests in real browsers with Karma ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7127](https://github.com/openlayers/openlayers/pull/7127) - Use static GeoJSON instead of Overpass query for faster loading ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7125](https://github.com/openlayers/openlayers/pull/7125) - Do not try to render error tiles from VectorTile source ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#6855](https://github.com/openlayers/openlayers/pull/6855) - Pluggable renderers ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7128](https://github.com/openlayers/openlayers/pull/7128) - Make view.animate() tolerate undefined views ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7124](https://github.com/openlayers/openlayers/pull/7124) - Release v4.3.1 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7122](https://github.com/openlayers/openlayers/pull/7122) - Immediately complete no-op animations ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7120](https://github.com/openlayers/openlayers/pull/7120) - Fix hit detection for overzoomed vector tiles ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7114](https://github.com/openlayers/openlayers/pull/7114) - Immediate WebGL text renderer and other improvements ([@GaborFarkas](https://github.com/GaborFarkas))
|
|
||||||
|
|
||||||
|
|
||||||
Additionally a number of updates where made to our dependencies:
|
|
||||||
* [#7307](https://github.com/openlayers/openlayers/pull/7307) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7302](https://github.com/openlayers/openlayers/pull/7302) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7298](https://github.com/openlayers/openlayers/pull/7298) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7295](https://github.com/openlayers/openlayers/pull/7295) - chore(package): update coveralls to version 3.0.0 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7291](https://github.com/openlayers/openlayers/pull/7291) - Update pbf to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7290](https://github.com/openlayers/openlayers/pull/7290) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7281](https://github.com/openlayers/openlayers/pull/7281) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7273](https://github.com/openlayers/openlayers/pull/7273) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7272](https://github.com/openlayers/openlayers/pull/7272) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7269](https://github.com/openlayers/openlayers/pull/7269) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7265](https://github.com/openlayers/openlayers/pull/7265) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7263](https://github.com/openlayers/openlayers/pull/7263) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7254](https://github.com/openlayers/openlayers/pull/7254) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7257](https://github.com/openlayers/openlayers/pull/7257) - Update jsdoc to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7251](https://github.com/openlayers/openlayers/pull/7251) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7243](https://github.com/openlayers/openlayers/pull/7243) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7240](https://github.com/openlayers/openlayers/pull/7240) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7238](https://github.com/openlayers/openlayers/pull/7238) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7212](https://github.com/openlayers/openlayers/pull/7212) - chore(package): update clean-css-cli to version 4.1.9 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7213](https://github.com/openlayers/openlayers/pull/7213) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7207](https://github.com/openlayers/openlayers/pull/7207) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7188](https://github.com/openlayers/openlayers/pull/7188) - fix(package): update rollup to version 0.49.1 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7166](https://github.com/openlayers/openlayers/pull/7166) - fix(package): update rollup to version 0.48.1 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7161](https://github.com/openlayers/openlayers/pull/7161) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7144](https://github.com/openlayers/openlayers/pull/7144) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7135](https://github.com/openlayers/openlayers/pull/7135) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7126](https://github.com/openlayers/openlayers/pull/7126) - Update phantomjs-prebuilt to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# 4.4.1
|
|
||||||
|
|
||||||
The v4.4.1 release includes a fix for the [`ol` package](https://www.npmjs.com/package/ol) and a fix for a tile rendering regression.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7323](https://github.com/openlayers/openlayers/pull/7323) - Only clear the canvas when needed ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7313](https://github.com/openlayers/openlayers/pull/7313) - Use lowercase module identifiers until ol@5 ([@tschaub](https://github.com/tschaub))
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# 4.4.2
|
|
||||||
|
|
||||||
The v4.4.2 release fixes a number of rendering issues in the 4.4 releases.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7327](https://github.com/openlayers/openlayers/pull/7327) - Prune the tile cache after updating a source's URL ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7341](https://github.com/openlayers/openlayers/pull/7341) - Proper rendering of raster sources when there is a tile transition ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7339](https://github.com/openlayers/openlayers/pull/7339) - Use correct text stroke on HiDPI devices ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7345](https://github.com/openlayers/openlayers/pull/7345) - Handle different lineWidth scaling in Safari ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7346](https://github.com/openlayers/openlayers/pull/7346) - Pre-render text images for configured scale ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7350](https://github.com/openlayers/openlayers/pull/7350) - Calculate correct text box size ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
# 4.5.0
|
|
||||||
|
|
||||||
### Summary
|
|
||||||
|
|
||||||
The 4.5 release includes enhancements and fixes from 50 or so pull requests. Headlining this release, vector layers got a new `declutter` option that can be used to avoid overlapping labels. See the [street labels example](http://openlayers.org/en/latest/examples/street-labels.html) for a demonstration of this feature.
|
|
||||||
|
|
||||||
Please note that if you are using `closure-util` to build your OpenLayers based application, it is time to migrate to using the [`ol` package](https://www.npmjs.com/package/ol) and a module bundler like webpack. OpenLayers has not had a dependency on the Closure Library since the [3.19 release](https://github.com/openlayers/openlayers/releases/tag/v3.19.0); and with the 5.0 release we will be moving completely away from `goog.require` and `goog.provide`, dropping support for `closure-util`, and going with ES modules for our sources.
|
|
||||||
|
|
||||||
We will be adding details to the wiki about upcoming changes in 5.0 and tips on how to upgrade. We'll likely have a few more 4.x releases before the 5.0 release. But if you're interested in continuing to get feature enhancements in future releases, migrating to the `ol` package now will make the transition easier.
|
|
||||||
|
|
||||||
### Upgrade notes
|
|
||||||
|
|
||||||
#### Removed GeoJSON crs workaround for GeoServer
|
|
||||||
|
|
||||||
Previous version of GeoServer returned invalid crs in GeoJSON output. The workaround in `ol.format.GeoJSON` used to read this crs code is now removed.
|
|
||||||
|
|
||||||
#### Deprecation of `ol.Attribution`
|
|
||||||
|
|
||||||
`ol.Attribution` is deprecated and will be removed in the next major version. Instead, you can construct a source with a string attribution or an array of strings. For dynamic attributions, you can provide a function that gets called with the current frame state.
|
|
||||||
|
|
||||||
Before:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.XYZ({
|
|
||||||
attributions: [
|
|
||||||
new ol.Attribution({html: 'some attribution'})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
After:
|
|
||||||
```js
|
|
||||||
var source = new ol.source.XYZ({
|
|
||||||
attributions: 'some attribution'
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
In addition to passing a string or an array of strings for the `attributions` option, you can also pass a function that will get called with the current frame state.
|
|
||||||
```js
|
|
||||||
var source = new ol.source.XYZ({
|
|
||||||
attributions: function(frameState) {
|
|
||||||
// inspect the frame state and return attributions
|
|
||||||
return 'some attribution'; // or ['multiple', 'attributions'] or null
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Detailed changes
|
|
||||||
|
|
||||||
See below for the full list of changes.
|
|
||||||
|
|
||||||
* [#7456](https://github.com/openlayers/openlayers/pull/7456) - Retry if sauce connect fails ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7440](https://github.com/openlayers/openlayers/pull/7440) - Attempt to make font loading tests more stable ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7444](https://github.com/openlayers/openlayers/pull/7444) - Simpler style management ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7438](https://github.com/openlayers/openlayers/pull/7438) - Call getProjection() only once ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7430](https://github.com/openlayers/openlayers/pull/7430) - Add support for hex colors with alpha ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7431](https://github.com/openlayers/openlayers/pull/7431) - Avoid returning undefined zoom ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7436](https://github.com/openlayers/openlayers/pull/7436) - Always use source projection loading image tiles ([@pjeweb](https://github.com/pjeweb))
|
|
||||||
* [#7433](https://github.com/openlayers/openlayers/pull/7433) - Don't use getHints if it's not needed ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7362](https://github.com/openlayers/openlayers/pull/7362) - Added option to the ol.format.GeoJSON to allow the reading of the geometry_name from the geojson ([@Alexandre27](https://github.com/Alexandre27))
|
|
||||||
* [#7426](https://github.com/openlayers/openlayers/pull/7426) - Update InteractionOptions.prototype.handleEvent docs ([@glen-nu](https://github.com/glen-nu))
|
|
||||||
* [#7423](https://github.com/openlayers/openlayers/pull/7423) - Get rendered features by coordinate when wrapping ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7421](https://github.com/openlayers/openlayers/pull/7421) - Keep longitude between -180 and 180 ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7420](https://github.com/openlayers/openlayers/pull/7420) - Fix MapGuide example resolves #7325 ([@TDesjardins](https://github.com/TDesjardins))
|
|
||||||
* [#7340](https://github.com/openlayers/openlayers/pull/7340) - Clear label cache when fonts become available ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7414](https://github.com/openlayers/openlayers/pull/7414) - Only split text at line angle changes ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7411](https://github.com/openlayers/openlayers/pull/7411) - Add getLayers and setLayers functions to ol.format.WMSGetFeatureInfo ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7328](https://github.com/openlayers/openlayers/pull/7328) - Declutter text and images ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7406](https://github.com/openlayers/openlayers/pull/7406) - Add option to Zoomify source for setting custom extent ([@lasselaakkonen](https://github.com/lasselaakkonen))
|
|
||||||
* [#7410](https://github.com/openlayers/openlayers/pull/7410) - Add getFeatureType and setFeatureType functions to ol.format.WFS ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7379](https://github.com/openlayers/openlayers/pull/7379) - Add support for custom tile size to Zoomify source ([@lasselaakkonen](https://github.com/lasselaakkonen))
|
|
||||||
* [#7376](https://github.com/openlayers/openlayers/pull/7376) - changed visibility of overlay properties to protected ([@virtualcitySYSTEMS](https://github.com/virtualcitySYSTEMS))
|
|
||||||
* [#7377](https://github.com/openlayers/openlayers/pull/7377) - Add support to specify CSS class name when creating ol.Overlay ([@notnotse](https://github.com/notnotse))
|
|
||||||
* [#7383](https://github.com/openlayers/openlayers/pull/7383) - Handle null tile coordinates correctly ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7375](https://github.com/openlayers/openlayers/pull/7375) - Read 'Abstract', 'AccessConstraints' and 'Fees' in ol.format.OWS ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7378](https://github.com/openlayers/openlayers/pull/7378) - Fix incorrect docs about ol.source.Raster ([@notnotse](https://github.com/notnotse))
|
|
||||||
* [#7371](https://github.com/openlayers/openlayers/pull/7371) - Add @api annotation to ol.VectorTile.getExtent ([@notnotse](https://github.com/notnotse))
|
|
||||||
* [#7369](https://github.com/openlayers/openlayers/pull/7369) - Always request the Bing API with the 'culture' value ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7364](https://github.com/openlayers/openlayers/pull/7364) - Remove GeoJSON workaround for GeoServer ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7355](https://github.com/openlayers/openlayers/pull/7355) - Pass pixel tolerance as a parameter to constructor of ol.interaction.Extent ([@marcosox](https://github.com/marcosox))
|
|
||||||
* [#7356](https://github.com/openlayers/openlayers/pull/7356) - Fix documentation for target option in the controls ([@EduardoNogueira](https://github.com/EduardoNogueira))
|
|
||||||
* [#7359](https://github.com/openlayers/openlayers/pull/7359) - Rename entry to input - regarding options to rollup lib - Issue #7358 ([@akkumar](https://github.com/akkumar))
|
|
||||||
* [#7357](https://github.com/openlayers/openlayers/pull/7357) - Release v4.4.2 ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7350](https://github.com/openlayers/openlayers/pull/7350) - Calculate correct text box size ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7349](https://github.com/openlayers/openlayers/pull/7349) - Do not use tileUrlFunction for renderer tile coordinates ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7305](https://github.com/openlayers/openlayers/pull/7305) - Fix #7304: Re-calculate the resolution when the WMS source is reprojected ([@oterral](https://github.com/oterral))
|
|
||||||
* [#7346](https://github.com/openlayers/openlayers/pull/7346) - Pre-render text images for configured scale ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7345](https://github.com/openlayers/openlayers/pull/7345) - Handle different lineWidth scaling in Safari ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7344](https://github.com/openlayers/openlayers/pull/7344) - Make text height detection independent of css settings ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7341](https://github.com/openlayers/openlayers/pull/7341) - Proper rendering of raster sources when there is a tile transition ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7339](https://github.com/openlayers/openlayers/pull/7339) - Use correct text stroke on HiDPI devices ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7327](https://github.com/openlayers/openlayers/pull/7327) - Prune the tile cache after updating a source's URL ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7333](https://github.com/openlayers/openlayers/pull/7333) - Pluggable Map/Layers - function calls to handles and create ([@waxenegger](https://github.com/waxenegger))
|
|
||||||
* [#7329](https://github.com/openlayers/openlayers/pull/7329) - Reworked attribution handling ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7337](https://github.com/openlayers/openlayers/pull/7337) - Always create a new blank image to avoid CSP violations ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7330](https://github.com/openlayers/openlayers/pull/7330) - Add upgrade notes to 4.4.0 changelog ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7321](https://github.com/openlayers/openlayers/pull/7321) - Release v4.4.1 ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7323](https://github.com/openlayers/openlayers/pull/7323) - Only clear the canvas when needed ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7313](https://github.com/openlayers/openlayers/pull/7313) - Use lowercase module identifiers until ol@5 ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7316](https://github.com/openlayers/openlayers/pull/7316) - fix copy-paste error in 4.4.0 changelog ([@mprins](https://github.com/mprins))
|
|
||||||
* [#7315](https://github.com/openlayers/openlayers/pull/7315) - Add new ol.format.filter.Contains spatial operator ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7311](https://github.com/openlayers/openlayers/pull/7311) - Release v4.4.0 ([@tschaub](https://github.com/tschaub))
|
|
||||||
|
|
||||||
Additionally a number of updates where made to our dependencies:
|
|
||||||
<details>
|
|
||||||
<summary>Click to expand</summary>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7455">#7455</a> - Update eslint to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7447">#7447</a> - chore(package): update rollup-plugin-commonjs to version 8.2.6 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7448">#7448</a> - chore(package): update debounce to version 1.1.0 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7451">#7451</a> - chore(package): update karma to version 1.7.1 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7446">#7446</a> - fix(package): update rollup to version 0.51.3 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7428">#7428</a> - Update sinon to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7425">#7425</a> - Update async to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7418">#7418</a> - Update sinon to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7416">#7416</a> - Update sinon to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7417">#7417</a> - Update phantomjs-prebuilt to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7399">#7399</a> - Update eslint to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7395">#7395</a> - Update closure-util to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7392">#7392</a> - Update sinon to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7380">#7380</a> - Update rollup-plugin-cleanup to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7366">#7366</a> - Update handlebars to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7360">#7360</a> - Update eslint to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7354">#7354</a> - Update closure-util to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7319">#7319</a> - Update closure-util to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
<li><a href="https://github.com/openlayers/openlayers/pull/7314">#7314</a> - Update mocha to the latest version 🚀 (<a href="https://github.com/openlayers">@openlayers</a>)</li>
|
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
# v4.6.0
|
|
||||||
|
|
||||||
### Summary
|
|
||||||
|
|
||||||
The 4.6 release includes enhancements and fixes from 30 or so pull requests. Headlining this release, vector layers got new `textBackgroundFill`, `textBackgroundStroke` and `padding` options that can be used to render background boxes for text. `ol.source.ImageVector` is now deprecated and replaced by a more convenient way to render vectors as images: by simply setting `renderMode: 'image'` on the vector layer.
|
|
||||||
|
|
||||||
Please note that if you are using `closure-util` to build your OpenLayers based application, it is time to migrate to using the [`ol` package](https://www.npmjs.com/package/ol) and a module bundler like webpack. OpenLayers has not had a dependency on the Closure Library since the [3.19 release](https://github.com/openlayers/openlayers/releases/tag/v3.19.0); and with the 5.0 release we will be moving completely away from `goog.require` and `goog.provide`, dropping support for `closure-util`, and going with ES modules for our sources.
|
|
||||||
|
|
||||||
See the [wiki](https://github.com/openlayers/openlayers/wiki/OpenLayers-v5.x) about upcoming changes in 5.0 and tips on how to upgrade. We likely won't have another 4.x release before the 5.0 release. If you're interested in continuing to get feature enhancements in future releases, migrating to the `ol` package now will make the transition easier.
|
|
||||||
|
|
||||||
|
|
||||||
### Upgrade notes
|
|
||||||
|
|
||||||
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow`
|
|
||||||
|
|
||||||
To update your applications, simply replace `exceedLength` with `overflow`.
|
|
||||||
|
|
||||||
#### Deprecation of `ol.source.ImageVector`
|
|
||||||
|
|
||||||
Rendering vector sources as image is now directly supported by `ol.layer.Vector` with the new `renderMode: 'image'` configuration option. Change code like this:
|
|
||||||
|
|
||||||
```js
|
|
||||||
new ol.layer.Image({
|
|
||||||
source: new ol.source.ImageVector({
|
|
||||||
style: myStyle,
|
|
||||||
source: new ol.source.Vector({
|
|
||||||
url: 'my/data.json',
|
|
||||||
format: new ol.format.GeoJSON()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
||||||
```
|
|
||||||
to:
|
|
||||||
|
|
||||||
```js
|
|
||||||
new ol.layer.Vector({
|
|
||||||
renderMode: 'image',
|
|
||||||
style: myStyle,
|
|
||||||
source: new ol.source.Vector({
|
|
||||||
url: 'my/data.json',
|
|
||||||
format: new ol.format.GeoJSON()
|
|
||||||
})
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Detailed changes
|
|
||||||
|
|
||||||
See below for the full list of changes.
|
|
||||||
|
|
||||||
* [#7538](https://github.com/openlayers/openlayers/pull/7538) - removeFromLoadedExtents to remove extents that failed to load ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7537](https://github.com/openlayers/openlayers/pull/7537) - Fix Draw.removeLastPoint exception when no points to remove ([@walkermatt](https://github.com/walkermatt))
|
|
||||||
* [#7461](https://github.com/openlayers/openlayers/pull/7461) - Use the matrixSet projection by default ([@oterral](https://github.com/oterral))
|
|
||||||
* [#5883](https://github.com/openlayers/openlayers/pull/5883) - Fixes setUrl() for WMTS sources (ol.source.WMTS) ([@bylexus](https://github.com/bylexus))
|
|
||||||
* [#7531](https://github.com/openlayers/openlayers/pull/7531) - Update the ol package readme ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7372](https://github.com/openlayers/openlayers/pull/7372) - Add method to set max cache size in ol.style.IconImageCache ([@notnotse](https://github.com/notnotse))
|
|
||||||
* [#7530](https://github.com/openlayers/openlayers/pull/7530) - Check forward/back 1 world if wrapping ([@raiyni](https://github.com/raiyni))
|
|
||||||
* [#7526](https://github.com/openlayers/openlayers/pull/7526) - Allow clicks to be stopped while drawing ([@tschaub](https://github.com/tschaub))
|
|
||||||
* [#7524](https://github.com/openlayers/openlayers/pull/7524) - Snap view center to pixel ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7521](https://github.com/openlayers/openlayers/pull/7521) - fix setMinZoom/setMaxZoom ([@cs09g](https://github.com/cs09g))
|
|
||||||
* [#7519](https://github.com/openlayers/openlayers/pull/7519) - Reuse declutter tree for hit detection ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7499](https://github.com/openlayers/openlayers/pull/7499) - Remove attributions from olx.FrameState instances ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7501](https://github.com/openlayers/openlayers/pull/7501) - Option to render vector layers as images ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7516](https://github.com/openlayers/openlayers/pull/7516) - Deprecate exceedLength and replace with overflow ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7510](https://github.com/openlayers/openlayers/pull/7510) - Do not fade the states layer ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7513](https://github.com/openlayers/openlayers/pull/7513) - Make strokeKey safer ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7514](https://github.com/openlayers/openlayers/pull/7514) - Prune the label cache less aggressively ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7505](https://github.com/openlayers/openlayers/pull/7505) - Remove ol.DeviceOrientation link from API index ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7497](https://github.com/openlayers/openlayers/pull/7497) - Use getGeometry ([@nicholas-l](https://github.com/nicholas-l))
|
|
||||||
* [#7495](https://github.com/openlayers/openlayers/pull/7495) - Remove layer renderers when viewport is removed ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7492](https://github.com/openlayers/openlayers/pull/7492) - Remove unneeded type cast from examples ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7489](https://github.com/openlayers/openlayers/pull/7489) - Allow string to be passed as ol.interaction.Draw type ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7445](https://github.com/openlayers/openlayers/pull/7445) - Load css rules from full-screen.css in examples ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7481](https://github.com/openlayers/openlayers/pull/7481) - Make zoom to extent control extensible ([@gberaudo](https://github.com/gberaudo))
|
|
||||||
* [#7477](https://github.com/openlayers/openlayers/pull/7477) - Make text states available for replay time ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7482](https://github.com/openlayers/openlayers/pull/7482) - Reset rotation after rendering ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7480](https://github.com/openlayers/openlayers/pull/7480) - Create a new image when loading tile after an error ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7476](https://github.com/openlayers/openlayers/pull/7476) - Reset text measurements when available fonts change ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7454](https://github.com/openlayers/openlayers/pull/7454) - Add text background rendering and text padding ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7468](https://github.com/openlayers/openlayers/pull/7468) - Add new API-key for HERE example ([@chrismayer](https://github.com/chrismayer))
|
|
||||||
* [#7465](https://github.com/openlayers/openlayers/pull/7465) - Export ol.proj.Projection#getAxisOrientation function ([@fredj](https://github.com/fredj))
|
|
||||||
* [#7462](https://github.com/openlayers/openlayers/pull/7462) - Respect metersPerUnit in ScaleLine control ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
|
|
||||||
|
|
||||||
Additionally a number of updates where made to our dependencies:
|
|
||||||
* [#7536](https://github.com/openlayers/openlayers/pull/7536) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7533](https://github.com/openlayers/openlayers/pull/7533) - Update marked to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7527](https://github.com/openlayers/openlayers/pull/7527) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7511](https://github.com/openlayers/openlayers/pull/7511) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7512](https://github.com/openlayers/openlayers/pull/7512) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
* [#7484](https://github.com/openlayers/openlayers/pull/7484) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# 4.6.1
|
|
||||||
|
|
||||||
The v4.6.1 release fixes a number of issues in the 4.6 releases.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7543](https://github.com/openlayers/openlayers/pull/7543) - Donut polygon labels do not get a chance to get rendered ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7542](https://github.com/openlayers/openlayers/pull/7542) - Still respect deprecated exceedLength option ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
* [#7541](https://github.com/openlayers/openlayers/pull/7541) - Fix case of vectorrendertype.js ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 4.6.2
|
|
||||||
|
|
||||||
The v4.6.2 release fixes a regression that could cause tremendous amounts of unneeded vector data to be fetched from the source.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7546](https://github.com/openlayers/openlayers/pull/7546) - Do not request features for wrapped extent ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 4.6.3
|
|
||||||
|
|
||||||
The v4.6.3 release fixes a performance issue when `renderMode: 'image'` is set on an `ol.layer.Vector`.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7554](https://github.com/openlayers/openlayers/pull/7554) - Only compose image vector frame when the replay group has changed ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 4.6.4
|
|
||||||
|
|
||||||
The v4.6.4 release fixes a feature selection issue when `renderMode: 'image'` is set on an `ol.layer.Vector`.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7559](https://github.com/openlayers/openlayers/pull/7559) - Handle skipping and unskipping features with renderMode: 'image' ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 4.6.5
|
|
||||||
|
|
||||||
The v4.6.5 release fixes a hit detection issue when `declutter: true` is set on an `ol.layer.VectorTile`.
|
|
||||||
|
|
||||||
## Fixes
|
|
||||||
|
|
||||||
* [#7669](https://github.com/openlayers/openlayers/pull/7559) - Use declutter tree only for text and image replays ([@ahocevar](https://github.com/ahocevar))
|
|
||||||
45
config/example.json
Normal file
45
config/example.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"exports": [],
|
||||||
|
"src": [
|
||||||
|
"src/**/*.js",
|
||||||
|
"build/ol.ext/*.js",
|
||||||
|
"build/examples/{{id}}.js"
|
||||||
|
],
|
||||||
|
"compile": {
|
||||||
|
"js": [
|
||||||
|
"externs/olx.js",
|
||||||
|
"externs/oli.js"
|
||||||
|
],
|
||||||
|
"externs": [
|
||||||
|
"externs/bingmaps.js",
|
||||||
|
"externs/cartodb.js",
|
||||||
|
"externs/bootstrap.js",
|
||||||
|
"externs/closure-compiler.js",
|
||||||
|
"externs/esrijson.js",
|
||||||
|
"externs/example.js",
|
||||||
|
"externs/geojson.js",
|
||||||
|
"externs/jquery-1.9.js",
|
||||||
|
"externs/proj4js.js",
|
||||||
|
"externs/tilejson.js",
|
||||||
|
"externs/topojson.js"
|
||||||
|
],
|
||||||
|
"jscomp_error": [
|
||||||
|
"*"
|
||||||
|
],
|
||||||
|
"jscomp_off": [
|
||||||
|
"lintChecks",
|
||||||
|
"analyzerChecks",
|
||||||
|
"missingProvide",
|
||||||
|
"unknownDefines"
|
||||||
|
],
|
||||||
|
"extra_annotation_name": [
|
||||||
|
"api", "observable"
|
||||||
|
],
|
||||||
|
"rewrite_polyfills": "false",
|
||||||
|
"compilation_level": "ADVANCED",
|
||||||
|
"warning_level": "VERBOSE",
|
||||||
|
"output_wrapper": "(function(){%output%})();",
|
||||||
|
"use_types_for_optimization": true,
|
||||||
|
"manage_closure_dependencies": true
|
||||||
|
}
|
||||||
|
}
|
||||||
45
config/examples-all.json
Normal file
45
config/examples-all.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"exports": [],
|
||||||
|
"src": [
|
||||||
|
"src/**/*.js",
|
||||||
|
"build/ol.ext/*.js",
|
||||||
|
"build/compiled-examples/all.js"
|
||||||
|
],
|
||||||
|
"compile": {
|
||||||
|
"js": [
|
||||||
|
"externs/olx.js",
|
||||||
|
"externs/oli.js"
|
||||||
|
],
|
||||||
|
"externs": [
|
||||||
|
"externs/bingmaps.js",
|
||||||
|
"externs/bootstrap.js",
|
||||||
|
"externs/cartodb.js",
|
||||||
|
"externs/closure-compiler.js",
|
||||||
|
"externs/esrijson.js",
|
||||||
|
"externs/example.js",
|
||||||
|
"externs/geojson.js",
|
||||||
|
"externs/jquery-1.9.js",
|
||||||
|
"externs/proj4js.js",
|
||||||
|
"externs/tilejson.js",
|
||||||
|
"externs/topojson.js"
|
||||||
|
],
|
||||||
|
"jscomp_error": [
|
||||||
|
"*"
|
||||||
|
],
|
||||||
|
"jscomp_off": [
|
||||||
|
"lintChecks",
|
||||||
|
"analyzerChecks",
|
||||||
|
"unusedLocalVariables"
|
||||||
|
],
|
||||||
|
"extra_annotation_name": [
|
||||||
|
"api", "observable"
|
||||||
|
],
|
||||||
|
"rewrite_polyfills": "false",
|
||||||
|
"compilation_level": "ADVANCED",
|
||||||
|
"warning_level": "VERBOSE",
|
||||||
|
"output_wrapper": "(function(){%output%})();",
|
||||||
|
"use_types_for_optimization": true,
|
||||||
|
"manage_closure_dependencies": true
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
{{{ extraHead.local }}}
|
{{{ extraHead.local }}}
|
||||||
{{{ css.tag }}}
|
{{{ css.tag }}}
|
||||||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
|
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js"></script>
|
<script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>
|
||||||
<title>{{ title }}</title>
|
<title>{{ title }}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -52,12 +52,13 @@
|
|||||||
<div class="span12">
|
<div class="span12">
|
||||||
<p id="shortdesc">{{ shortdesc }}</p>
|
<p id="shortdesc">{{ shortdesc }}</p>
|
||||||
<div id="docs">{{ md docs }}</div>
|
<div id="docs">{{ md docs }}</div>
|
||||||
|
<div id="api-links">Related API documentation: {{{ js.apiHtml }}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div id="source-controls">
|
<div id="source-controls">
|
||||||
<a id="copy-button" data-clipboard-target="#example-source"><i class="fa fa-clipboard"></i> Copy</a>
|
<a id="copy-button"><i class="fa fa-clipboard"></i> Copy</a>
|
||||||
<a id="codepen-button"><i class="fa fa-codepen"></i> Edit</a>
|
<a id="codepen-button"><i class="fa fa-codepen"></i> Edit</a>
|
||||||
</div>
|
</div>
|
||||||
<form method="POST" id="codepen-form" target="_blank" action="https://codepen.io/pen/define/">
|
<form method="POST" id="codepen-form" target="_blank" action="https://codepen.io/pen/define/">
|
||||||
@@ -104,7 +105,7 @@
|
|||||||
var branchSearch = url.match(/\/([^\/]*)\/examples\//);
|
var branchSearch = url.match(/\/([^\/]*)\/examples\//);
|
||||||
var cookieText = 'dismissed=-' + latestVersion + '-';
|
var cookieText = 'dismissed=-' + latestVersion + '-';
|
||||||
var dismissed = document.cookie.indexOf(cookieText) != -1;
|
var dismissed = document.cookie.indexOf(cookieText) != -1;
|
||||||
if (branchSearch && !dismissed && /^v[0-9\.]*$/.test(branchSearch[1]) && '{{ olVersion }}' != latestVersion) {
|
if (!dismissed && /^v[0-9\.]*$/.test(branchSearch[1]) && '{{ olVersion }}' != latestVersion) {
|
||||||
var link = url.replace(branchSearch[0], '/latest/examples/');
|
var link = url.replace(branchSearch[0], '/latest/examples/');
|
||||||
fetch(link, {method: 'head'}).then(function(response) {
|
fetch(link, {method: 'head'}).then(function(response) {
|
||||||
var a = document.getElementById('latest-link');
|
var a = document.getElementById('latest-link');
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"plugins/markdown",
|
"node_modules/jsdoc/plugins/markdown",
|
||||||
"config/jsdoc/api/plugins/inheritdoc",
|
"config/jsdoc/api/plugins/inheritdoc",
|
||||||
"config/jsdoc/api/plugins/typedefs",
|
"config/jsdoc/api/plugins/typedefs",
|
||||||
"config/jsdoc/api/plugins/events",
|
"config/jsdoc/api/plugins/events",
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ Interactions for [vector features](ol.Feature.html)
|
|||||||
<tr><th>Projections</th><th>Observable objects</th><th>Other components</th></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 [ol.proj.transform()](ol.proj.html#.transform) and [ol.proj.transformExtent()](ol.proj.html#.transformExtent).</p>
|
<tr><td><p>All coordinates and extents need to be provided in view projection (default: EPSG:3857). To transform, use [ol.proj.transform()](ol.proj.html#.transform) and [ol.proj.transformExtent()](ol.proj.html#.transformExtent).</p>
|
||||||
[ol.proj](ol.proj.html)</td>
|
[ol.proj](ol.proj.html)</td>
|
||||||
<td><p>Changes to all [ol.Objects](ol.Object.html) can be observed by calling the [object.on('propertychange')](ol.Object.html#on) method. Listeners receive an [ol.Object.Event](ol.Object.Event.html) with information on the changed property and old value.</p>
|
<td><p>Changes to all [ol.Objects](ol.Object.html) can observed by calling the [object.on('propertychange')](ol.Object.html#on) method. Listeners receive an [ol.Object.Event](ol.Object.Event.html) with information on the changed property and old value.</p>
|
||||||
<td>
|
<td>[ol.DeviceOrientation](ol.DeviceOrientation.html)<br>
|
||||||
[ol.Geolocation](ol.Geolocation.html)<br>
|
[ol.Geolocation](ol.Geolocation.html)<br>
|
||||||
[ol.Overlay](ol.Overlay.html)<br></td>
|
[ol.Overlay](ol.Overlay.html)<br></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ exports.handlers = {
|
|||||||
cls.observables = [];
|
cls.observables = [];
|
||||||
}
|
}
|
||||||
observable = observables[doclet.observable];
|
observable = observables[doclet.observable];
|
||||||
if (observable.type && cls.observables.indexOf(observable) == -1) {
|
if (cls.observables.indexOf(observable) == -1) {
|
||||||
cls.observables.push(observable);
|
cls.observables.push(observable);
|
||||||
}
|
}
|
||||||
if (!cls.fires) {
|
if (!cls.fires) {
|
||||||
|
|||||||
@@ -17,19 +17,6 @@
|
|||||||
<?js if (doc.variation) { ?>
|
<?js if (doc.variation) { ?>
|
||||||
<sup class="variation"><?js= doc.variation ?></sup>
|
<sup class="variation"><?js= doc.variation ?></sup>
|
||||||
<?js } ?></h2>
|
<?js } ?></h2>
|
||||||
<br>
|
|
||||||
<?js if (doc.stability || doc.kind == 'namespace') {
|
|
||||||
var ancestors = doc.ancestors.map(a => a.replace(/>\./g, '>').replace(/\.</g, '<')).join('/');
|
|
||||||
var name = doc.name.toLowerCase();
|
|
||||||
var parts = [];
|
|
||||||
if (ancestors) {
|
|
||||||
parts.push(ancestors);
|
|
||||||
}
|
|
||||||
parts.push(name);
|
|
||||||
var importPath = parts.join('/');
|
|
||||||
?>
|
|
||||||
<pre class="prettyprint source"><code>import <?js= doc.name ?> from '<?js= importPath ?>';</code></pre>
|
|
||||||
<?js } ?>
|
|
||||||
<?js if (doc.classdesc) { ?>
|
<?js if (doc.classdesc) { ?>
|
||||||
<div class="class-description"><?js= doc.classdesc ?></div>
|
<div class="class-description"><?js= doc.classdesc ?></div>
|
||||||
<?js } ?>
|
<?js } ?>
|
||||||
|
|||||||
@@ -16,10 +16,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?js
|
<?js
|
||||||
var self = this;
|
var self = this;
|
||||||
var propsByName = {};
|
|
||||||
props.forEach(function(prop) {
|
props.forEach(function(prop) {
|
||||||
if (!prop || propsByName[prop.name]) { return; }
|
if (!prop) { return; }
|
||||||
propsByName[prop.name] = prop;
|
|
||||||
var setter = prop.readonly ? 'no' : 'yes';
|
var setter = prop.readonly ? 'no' : 'yes';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ exports.defineTags = function(dictionary) {
|
|||||||
|
|
||||||
dictionary.defineTag('api', {
|
dictionary.defineTag('api', {
|
||||||
onTagged: function(doclet, tag) {
|
onTagged: function(doclet, tag) {
|
||||||
doclet.api = true;
|
doclet.api = tag.text || 'experimental';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
* @fileoverview Generates JSON output based on exportable symbols (those with
|
* @fileoverview Generates JSON output based on exportable symbols (those with
|
||||||
* an api tag) and boolean defines (with a define tag and a default value).
|
* an api tag) and boolean defines (with a define tag and a default value).
|
||||||
*/
|
*/
|
||||||
const assert = require('assert');
|
var assert = require('assert');
|
||||||
const path = require('path');
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +16,7 @@ const path = require('path');
|
|||||||
exports.publish = function(data, opts) {
|
exports.publish = function(data, opts) {
|
||||||
|
|
||||||
function getTypes(data) {
|
function getTypes(data) {
|
||||||
const types = [];
|
var types = [];
|
||||||
data.forEach(function(name) {
|
data.forEach(function(name) {
|
||||||
types.push(name.replace(/^function$/, 'Function'));
|
types.push(name.replace(/^function$/, 'Function'));
|
||||||
});
|
});
|
||||||
@@ -24,18 +25,18 @@ exports.publish = function(data, opts) {
|
|||||||
|
|
||||||
// get all doclets with the "api" property or define (excluding events) or
|
// get all doclets with the "api" property or define (excluding events) or
|
||||||
// with olx namespace
|
// with olx namespace
|
||||||
const classes = {};
|
var classes = {};
|
||||||
const docs = data(
|
var docs = data(
|
||||||
[
|
[
|
||||||
{define: {isObject: true}},
|
{define: {isObject: true}},
|
||||||
function() {
|
function() {
|
||||||
if (this.kind == 'class') {
|
if (this.kind == 'class') {
|
||||||
if (!('extends' in this) || typeof this.api == 'boolean') {
|
if (!('extends' in this) || typeof this.api == 'string') {
|
||||||
classes[this.longname] = this;
|
classes[this.longname] = this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (typeof this.api == 'boolean' ||
|
return (typeof this.api == 'string' ||
|
||||||
this.meta && (/[\\\/]externs$/).test(this.meta.path));
|
this.meta && (/[\\\/]externs$/).test(this.meta.path));
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -43,24 +44,24 @@ exports.publish = function(data, opts) {
|
|||||||
{kind: {'!is': 'event'}}).get();
|
{kind: {'!is': 'event'}}).get();
|
||||||
|
|
||||||
// get symbols data, filter out those that are members of private classes
|
// get symbols data, filter out those that are members of private classes
|
||||||
const symbols = [];
|
var symbols = [];
|
||||||
const defines = [];
|
var defines = [];
|
||||||
const typedefs = [];
|
var typedefs = [];
|
||||||
const externs = [];
|
var externs = [];
|
||||||
let base = [];
|
var base = [];
|
||||||
const augments = {};
|
var augments = {};
|
||||||
const symbolsByName = {};
|
var symbolsByName = {};
|
||||||
docs.filter(function(doc) {
|
docs.filter(function(doc) {
|
||||||
let include = true;
|
var include = true;
|
||||||
const constructor = doc.memberof;
|
var constructor = doc.memberof;
|
||||||
if (constructor && constructor.substr(-1) === '_' && constructor.indexOf('module:') === -1) {
|
if (constructor && constructor.substr(-1) === '_') {
|
||||||
assert.strictEqual(doc.inherited, true,
|
assert.strictEqual(doc.inherited, true,
|
||||||
'Unexpected export on private class: ' + doc.longname);
|
'Unexpected export on private class: ' + doc.longname);
|
||||||
include = false;
|
include = false;
|
||||||
}
|
}
|
||||||
return include;
|
return include;
|
||||||
}).forEach(function(doc) {
|
}).forEach(function(doc) {
|
||||||
const isExterns = (/[\\\/]externs$/).test(doc.meta.path);
|
var isExterns = (/[\\\/]externs$/).test(doc.meta.path);
|
||||||
if (isExterns && doc.longname.indexOf('olx.') === 0) {
|
if (isExterns && doc.longname.indexOf('olx.') === 0) {
|
||||||
if (doc.kind == 'typedef') {
|
if (doc.kind == 'typedef') {
|
||||||
typedefs.push({
|
typedefs.push({
|
||||||
@@ -68,11 +69,8 @@ exports.publish = function(data, opts) {
|
|||||||
types: ['{}']
|
types: ['{}']
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const typedef = typedefs[typedefs.length - 1];
|
var typedef = typedefs[typedefs.length - 1];
|
||||||
if (!typedef) {
|
var type = typedef.types[0];
|
||||||
throw new Error(`Expected to see a typedef before ${doc.longname} at ${doc.meta.filename}:${doc.meta.lineno}`);
|
|
||||||
}
|
|
||||||
const type = typedef.types[0];
|
|
||||||
typedef.types[0] = type
|
typedef.types[0] = type
|
||||||
.replace(/\}$/, ', ' + doc.longname.split('#')[1] +
|
.replace(/\}$/, ', ' + doc.longname.split('#')[1] +
|
||||||
': (' + getTypes(doc.type.names).join('|') + ')}')
|
': (' + getTypes(doc.type.names).join('|') + ')}')
|
||||||
@@ -91,10 +89,12 @@ exports.publish = function(data, opts) {
|
|||||||
types: getTypes(doc.type.names)
|
types: getTypes(doc.type.names)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const symbol = {
|
var types;
|
||||||
|
var symbol = {
|
||||||
name: doc.longname,
|
name: doc.longname,
|
||||||
kind: doc.kind,
|
kind: doc.kind,
|
||||||
description: doc.classdesc || doc.description,
|
description: doc.classdesc || doc.description,
|
||||||
|
stability: doc.api,
|
||||||
path: path.join(doc.meta.path, doc.meta.filename)
|
path: path.join(doc.meta.path, doc.meta.filename)
|
||||||
};
|
};
|
||||||
if (doc.augments) {
|
if (doc.augments) {
|
||||||
@@ -107,9 +107,9 @@ exports.publish = function(data, opts) {
|
|||||||
symbol.types = getTypes(doc.type.names);
|
symbol.types = getTypes(doc.type.names);
|
||||||
}
|
}
|
||||||
if (doc.params) {
|
if (doc.params) {
|
||||||
const params = [];
|
var params = [];
|
||||||
doc.params.forEach(function(param) {
|
doc.params.forEach(function(param) {
|
||||||
const paramInfo = {
|
var paramInfo = {
|
||||||
name: param.name
|
name: param.name
|
||||||
};
|
};
|
||||||
params.push(paramInfo);
|
params.push(paramInfo);
|
||||||
@@ -144,10 +144,10 @@ exports.publish = function(data, opts) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = isExterns ? externs : (doc.api ? symbols : base);
|
var target = isExterns ? externs : (doc.api ? symbols : base);
|
||||||
const existingSymbol = symbolsByName[symbol.name];
|
var existingSymbol = symbolsByName[symbol.name];
|
||||||
if (existingSymbol) {
|
if (existingSymbol) {
|
||||||
const idx = target.indexOf(existingSymbol);
|
var idx = target.indexOf(existingSymbol);
|
||||||
target.splice(idx, 1);
|
target.splice(idx, 1);
|
||||||
}
|
}
|
||||||
target.push(symbol);
|
target.push(symbol);
|
||||||
@@ -169,7 +169,6 @@ exports.publish = function(data, opts) {
|
|||||||
return (symbol.name in augments || symbol.virtual);
|
return (symbol.name in augments || symbol.virtual);
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
process.stdout.write(
|
process.stdout.write(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
symbols: symbols,
|
symbols: symbols,
|
||||||
@@ -178,6 +177,5 @@ exports.publish = function(data, opts) {
|
|||||||
externs: externs,
|
externs: externs,
|
||||||
base: base
|
base: base
|
||||||
}, null, 2));
|
}, null, 2));
|
||||||
});
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
4
config/ol-debug.json
Normal file
4
config/ol-debug.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"exports": ["*"],
|
||||||
|
"umd": true
|
||||||
|
}
|
||||||
38
config/ol.json
Normal file
38
config/ol.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"exports": ["*"],
|
||||||
|
"umd": true,
|
||||||
|
"compile": {
|
||||||
|
"externs": [
|
||||||
|
"externs/bingmaps.js",
|
||||||
|
"externs/cartodb.js",
|
||||||
|
"externs/closure-compiler.js",
|
||||||
|
"externs/esrijson.js",
|
||||||
|
"externs/geojson.js",
|
||||||
|
"externs/oli.js",
|
||||||
|
"externs/olx.js",
|
||||||
|
"externs/proj4js.js",
|
||||||
|
"externs/tilejson.js",
|
||||||
|
"externs/topojson.js"
|
||||||
|
],
|
||||||
|
"define": [
|
||||||
|
"ol.DEBUG_WEBGL=false"
|
||||||
|
],
|
||||||
|
"jscomp_error": [
|
||||||
|
"*"
|
||||||
|
],
|
||||||
|
"jscomp_off": [
|
||||||
|
"lintChecks",
|
||||||
|
"analyzerChecks"
|
||||||
|
],
|
||||||
|
"extra_annotation_name": [
|
||||||
|
"api", "observable"
|
||||||
|
],
|
||||||
|
"rewrite_polyfills": "false",
|
||||||
|
"compilation_level": "ADVANCED",
|
||||||
|
"warning_level": "VERBOSE",
|
||||||
|
"use_types_for_optimization": true,
|
||||||
|
"manage_closure_dependencies": true,
|
||||||
|
"create_source_map": "build/ol.js.map",
|
||||||
|
"source_map_format": "V3"
|
||||||
|
}
|
||||||
|
}
|
||||||
3
config/readme.md
Normal file
3
config/readme.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Configuration Files
|
||||||
|
|
||||||
|
This directory includes configuration files for the build scripts in and documentation templates.
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
const webpack = require('webpack');
|
|
||||||
const MinifyPlugin = require('babel-minify-webpack-plugin');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
entry: './src/index.js',
|
|
||||||
output: {
|
|
||||||
filename: 'build/ol.js'
|
|
||||||
},
|
|
||||||
devtool: 'source-map',
|
|
||||||
plugins: [
|
|
||||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
|
||||||
new MinifyPlugin()
|
|
||||||
]
|
|
||||||
};
|
|
||||||
29
css/ol.css
29
css/ol.css
@@ -44,21 +44,10 @@
|
|||||||
}
|
}
|
||||||
.ol-selectable {
|
.ol-selectable {
|
||||||
-webkit-touch-callout: default;
|
-webkit-touch-callout: default;
|
||||||
-webkit-user-select: text;
|
-webkit-user-select: auto;
|
||||||
-moz-user-select: text;
|
-moz-user-select: auto;
|
||||||
-ms-user-select: text;
|
-ms-user-select: auto;
|
||||||
user-select: text;
|
user-select: auto;
|
||||||
}
|
|
||||||
.ol-grabbing {
|
|
||||||
cursor: -webkit-grabbing;
|
|
||||||
cursor: -moz-grabbing;
|
|
||||||
cursor: grabbing;
|
|
||||||
}
|
|
||||||
.ol-grab {
|
|
||||||
cursor: move;
|
|
||||||
cursor: -webkit-grab;
|
|
||||||
cursor: -moz-grab;
|
|
||||||
cursor: grab;
|
|
||||||
}
|
}
|
||||||
.ol-control {
|
.ol-control {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -179,6 +168,9 @@
|
|||||||
.ol-attribution.ol-collapsed ul {
|
.ol-attribution.ol-collapsed ul {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
.ol-attribution.ol-logo-only ul {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
.ol-attribution:not(.ol-collapsed) {
|
.ol-attribution:not(.ol-collapsed) {
|
||||||
background: rgba(255,255,255,0.8);
|
background: rgba(255,255,255,0.8);
|
||||||
}
|
}
|
||||||
@@ -189,10 +181,17 @@
|
|||||||
height: 1.1em;
|
height: 1.1em;
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
}
|
}
|
||||||
|
.ol-attribution.ol-logo-only {
|
||||||
|
background: transparent;
|
||||||
|
bottom: .4em;
|
||||||
|
height: 1.1em;
|
||||||
|
line-height: 1em;
|
||||||
|
}
|
||||||
.ol-attribution.ol-uncollapsible img {
|
.ol-attribution.ol-uncollapsible img {
|
||||||
margin-top: -.2em;
|
margin-top: -.2em;
|
||||||
max-height: 1.6em;
|
max-height: 1.6em;
|
||||||
}
|
}
|
||||||
|
.ol-attribution.ol-logo-only button,
|
||||||
.ol-attribution.ol-uncollapsible button {
|
.ol-attribution.ol-uncollapsible button {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ Unknown `serverType` configured.
|
|||||||
|
|
||||||
### 10
|
### 10
|
||||||
|
|
||||||
The default `geometryFunction` can only handle `ol/geom/Point` geometries.
|
The default `geometryFunction` can only handle `ol.geom.Point` geometries.
|
||||||
|
|
||||||
### 11
|
### 11
|
||||||
|
|
||||||
@@ -165,6 +165,14 @@ Expected an `ol.style.Style` or an array of `ol.style.Style`.
|
|||||||
|
|
||||||
Expected `layers` to be an array or an `ol.Collection`.
|
Expected `layers` to be an array or an `ol.Collection`.
|
||||||
|
|
||||||
|
### 44
|
||||||
|
|
||||||
|
`logo.href` should be a string.
|
||||||
|
|
||||||
|
### 45
|
||||||
|
|
||||||
|
`logo.src` should be a string.
|
||||||
|
|
||||||
### 46
|
### 46
|
||||||
|
|
||||||
Incorrect format for `renderer` option.
|
Incorrect format for `renderer` option.
|
||||||
@@ -216,7 +224,3 @@ At least 2 conditions are required.
|
|||||||
### 58
|
### 58
|
||||||
|
|
||||||
Duplicate item added to a unique collection. For example, it may be that you tried to add the same layer to a map twice. Check for calls to `map.addLayer()` or other places where the map's layer collection is modified.
|
Duplicate item added to a unique collection. For example, it may be that you tried to add the same layer to a map twice. Check for calls to `map.addLayer()` or other places where the map's layer collection is modified.
|
||||||
|
|
||||||
### 59
|
|
||||||
|
|
||||||
Invalid command found in the PBF. This indicates that the loaded vector tile may be corrupt.
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ For a more in-depth overview of OpenLayers core concepts, check out the [tutoria
|
|||||||
|
|
||||||
Make sure to also check out the [OpenLayers workshop](/workshop/).
|
Make sure to also check out the [OpenLayers workshop](/workshop/).
|
||||||
|
|
||||||
Find additional reference material in the [API docs](../apidoc) and [examples](../examples).
|
Find additional reference material in the [API docs](../apidoc).
|
||||||
|
|
||||||
# Frequently Asked Questions (FAQ)
|
# Frequently Asked Questions (FAQ)
|
||||||
|
|
||||||
@@ -19,4 +19,4 @@ We have put together a document that lists [Frequently Asked Questions (FAQ)](fa
|
|||||||
|
|
||||||
# More questions?
|
# More questions?
|
||||||
|
|
||||||
If you cannot find an answer in the documentation or the FAQ, you can search [Stack Overflow](http://stackoverflow.com/questions/tagged/openlayers). If you cannot find an answer there, ask a new question there, using the tag 'openlayers'.
|
If you cannot find an answer in the documentation or the FAQ, you can ask your question on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers).
|
||||||
|
|||||||
@@ -5,56 +5,57 @@ layout: doc.hbs
|
|||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
When going beyond modifying existing examples you might be looking for a way to setup your own code with dependency management together with external dependencies like OpenLayers.
|
When going beyond modifying existing examples you might be looking for a
|
||||||
|
way to setup your own code with dependency management together with external
|
||||||
|
dependencies like OpenLayers.
|
||||||
|
|
||||||
This tutorial serves as a suggested project setup using NPM and Browserify for the most basic needs. There are several other options, and in particular you might be interested in a more modern one (ES2015) [using Webpack with OpenLayers](https://gist.github.com/tschaub/79025aef325cd2837364400a105405b8).
|
This tutorial serves as a suggested project setup using NPM and Browserify
|
||||||
|
for the most basic needs. There are several other options and in particular
|
||||||
|
you might be interested in
|
||||||
|
[compiling your own code together with OpenLayers](closure.html).
|
||||||
|
|
||||||
## Initial steps
|
## Initial steps
|
||||||
|
|
||||||
Create a new empty directory for your project and navigate to it by running `mkdir new-project && cd new-project`. Initialize your project using `npm init` and answer the questions asked.
|
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.
|
||||||
|
|
||||||
Add OpenLayers as dependency to your application with `npm install --save ol`.
|
At this point you can ask NPM to add required dependencies by running
|
||||||
|
`npm install --save-dev openlayers browserify watchify uglify-js`. Watchify and
|
||||||
At this point you can ask NPM to add required development dependencies by running
|
Uglify will be used to monitor for changes and to build into a minified
|
||||||
```
|
bundle.
|
||||||
npm install --save-dev cssify browserify cssify http-server uglify-js watchify
|
|
||||||
npm install --save-dev babelify babel-plugin-transform-es2015-modules-commonjs
|
|
||||||
```
|
|
||||||
We will be using `cssify` to include the css definitions required by OpenLayers in our bundle. `watchify`, `http-server` and `uglify-js` are used to monitor for changes and to build into a minified bundle. `babelify` and `babel-plugin-transform-es2015-modules-commonjs` are used to make the `ol` package, which was created using ES2015 modules, work with CommonJS.
|
|
||||||
|
|
||||||
## Application code and index.html
|
## Application code and index.html
|
||||||
|
|
||||||
Place your application code in `index.js`. Here is a simple starting point:
|
Place your application code in `index.js`. Here is a simple starting point:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
require('ol/ol.css');
|
var ol = require('openlayers');
|
||||||
var ol_Map = require('ol/map').default;
|
|
||||||
var ol_layer_Tile = require('ol/layer/tile').default;
|
|
||||||
var ol_source_OSM = require('ol/source/osm').default;
|
|
||||||
var ol_View = require('ol/view').default;
|
|
||||||
|
|
||||||
var map = new ol_Map({
|
var map = new ol.Map({
|
||||||
target: 'map',
|
target: 'map',
|
||||||
layers: [
|
layers: [
|
||||||
new ol_layer_Tile({
|
new ol.layer.Tile({
|
||||||
source: new ol_source_OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
view: new ol_View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 0
|
zoom: 0
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also need an `ìndex.html` file that will use your bundle. Here is a simple example:
|
You will also need an `ìndex.html` file that will use your bundle. Here is a simple
|
||||||
|
example:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Using Browserify with OpenLayers</title>
|
<title>Using Browserify with OpenLayers</title>
|
||||||
|
<link rel="stylesheet" href="node_modules/openlayers/dist/ol.css" type="text/css">
|
||||||
<style>
|
<style>
|
||||||
#map {
|
#map {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
@@ -71,17 +72,18 @@ You will also need an `ìndex.html` file that will use your bundle. Here is a si
|
|||||||
|
|
||||||
## Creating a bundle
|
## Creating a bundle
|
||||||
|
|
||||||
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`:
|
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
|
```json
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "watchify index.js -g cssify --outfile bundle.js & http-server",
|
"start": "watchify index.js --outfile bundle.js",
|
||||||
"build": "browserify -g cssify index.js | uglifyjs --compress --output bundle.js"
|
"build": "browserify index.js | uglifyjs --compress --output bundle.js"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Now to test your application open http://localhost:8080/ in your browser. `watchify` will update `bundle.js` whenever you change something. You simply need to reload the page in your browser to see the changes.
|
|
||||||
```
|
|
||||||
$ npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that `bundle.js` will contain your application code and all dependencies used in your application. From OpenLayers, it only contains the required components.
|
Note that `bundle.js` will contain your application code and all dependencies
|
||||||
|
used in your application, in this case the official full build of OpenLayers.
|
||||||
|
If you only need parts of OpenLayers you can create
|
||||||
|
[custom builds](../../builder).
|
||||||
|
|||||||
@@ -5,15 +5,11 @@ layout: doc.hbs
|
|||||||
|
|
||||||
# Compiling Application with Closure Compiler
|
# Compiling Application with Closure Compiler
|
||||||
|
|
||||||
**Note**: When building an application with dependencies that are available as [npm](https://npmjs.com/) packages, it will probably be easier to use the [ol](https://npmjs.com/package/ol) package and follow the instructions there.
|
|
||||||
|
|
||||||
The OpenLayers code uses the Closure Library, and it is compiled with the
|
The OpenLayers code uses the Closure Library, and it is compiled with the
|
||||||
Closure Compiler. Using OpenLayers in an application does not require using
|
Closure Compiler. Using OpenLayers in an application does not require using
|
||||||
Closure. But using Closure in an OpenLayers application is possible. And this
|
Closure. But using Closure in an OpenLayers application is possible. And this
|
||||||
is what this tutorial is about.
|
is what this tutorial is about.
|
||||||
|
|
||||||
When you want to include OpenLayers as separate script without bundling with your application, follow the [Creating custom builds](./custom-builds.html) tutorial instead.
|
|
||||||
|
|
||||||
This tutorial will teach you how to set up an OpenLayers application based on
|
This tutorial will teach you how to set up an OpenLayers application based on
|
||||||
the [`closure-util`](https://github.com/openlayers/closure-util) node package,
|
the [`closure-util`](https://github.com/openlayers/closure-util) node package,
|
||||||
which provides utilities for working with Closure. Using `closure-util` is one
|
which provides utilities for working with Closure. Using `closure-util` is one
|
||||||
@@ -124,7 +120,7 @@ goog.require('ol.source.OSM');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.PluggableMap}
|
* @type {ol.Map}
|
||||||
*/
|
*/
|
||||||
app.map = new ol.Map({
|
app.map = new ol.Map({
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ The easiest way to use a custom projection is to add the [Proj4js](http://proj4j
|
|||||||
Following example shows definition of a [British National Grid](https://epsg.io/27700):
|
Following example shows definition of a [British National Grid](https://epsg.io/27700):
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
@@ -107,7 +107,7 @@ In case you are creating a custom build of OpenLayers and do not need the reproj
|
|||||||
See [Custom builds](custom-builds.html#defines) tutorial on how to do this.
|
See [Custom builds](custom-builds.html#defines) tutorial on how to do this.
|
||||||
|
|
||||||
### Triangulation precision threshold
|
### Triangulation precision threshold
|
||||||
The default [triangulation error threshold](#dynamic-triangulation) in pixels is given by `ERROR_THRESHOLD` (0.5 pixel).
|
The default [triangulation error threshold](#dynamic-triangulation) in pixels is given by `ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD` (0.5 pixel).
|
||||||
In case a different threshold needs to be defined for different sources, the `reprojectionErrorThreshold` option can be passed when constructing the tile image source.
|
In case a different threshold needs to be defined for different sources, the `reprojectionErrorThreshold` option can be passed when constructing the tile image source.
|
||||||
|
|
||||||
###Limiting visibility of reprojected map by extent
|
###Limiting visibility of reprojected map by extent
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
"createMapboxStreetsV6Style": false,
|
"createMapboxStreetsV6Style": false,
|
||||||
"d3": false,
|
"d3": false,
|
||||||
"geojsonvt": false,
|
"geojsonvt": false,
|
||||||
"GyroNorm": false,
|
|
||||||
"jsPDF": false,
|
"jsPDF": false,
|
||||||
"jsts": false,
|
"jsts": false,
|
||||||
"saveAs": false,
|
"saveAs": false,
|
||||||
|
|||||||
@@ -1,10 +1,3 @@
|
|||||||
/*
|
|
||||||
* Jugl.js -- JavaScript Template Library
|
|
||||||
*
|
|
||||||
* Copyright 2007-2010 Tim Schaub
|
|
||||||
* Released under the MIT license. Please see
|
|
||||||
* http://github.com/tschaub/jugl/blob/master/license.txt for the full license.
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* Jugl.js -- JavaScript Template Library
|
* Jugl.js -- JavaScript Template Library
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,36 +1,36 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}),
|
}),
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('zoom-out').onclick = function() {
|
document.getElementById('zoom-out').onclick = function() {
|
||||||
const view = map.getView();
|
var view = map.getView();
|
||||||
const zoom = view.getZoom();
|
var zoom = view.getZoom();
|
||||||
view.setZoom(zoom - 1);
|
view.setZoom(zoom - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById('zoom-in').onclick = function() {
|
document.getElementById('zoom-in').onclick = function() {
|
||||||
const view = map.getView();
|
var view = map.getView();
|
||||||
const zoom = view.getZoom();
|
var zoom = view.getZoom();
|
||||||
view.setZoom(zoom + 1);
|
view.setZoom(zoom + 1);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {easeIn, easeOut} from '../src/ol/easing.js';
|
goog.require('ol.layer.Tile');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.proj');
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
goog.require('ol.source.OSM');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
|
||||||
|
|
||||||
const london = fromLonLat([-0.12755, 51.507222]);
|
var london = ol.proj.fromLonLat([-0.12755, 51.507222]);
|
||||||
const moscow = fromLonLat([37.6178, 55.7517]);
|
var moscow = ol.proj.fromLonLat([37.6178, 55.7517]);
|
||||||
const istanbul = fromLonLat([28.9744, 41.0128]);
|
var istanbul = ol.proj.fromLonLat([28.9744, 41.0128]);
|
||||||
const rome = fromLonLat([12.5, 41.9]);
|
var rome = ol.proj.fromLonLat([12.5, 41.9]);
|
||||||
const bern = fromLonLat([7.4458, 46.95]);
|
var bern = ol.proj.fromLonLat([7.4458, 46.95]);
|
||||||
|
|
||||||
const view = new View({
|
var view = new ol.View({
|
||||||
center: istanbul,
|
center: istanbul,
|
||||||
zoom: 6
|
zoom: 6
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
target: 'map',
|
target: 'map',
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
preload: 4,
|
preload: 4,
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
// Improve user experience by loading tiles while animating. Will make
|
// Improve user experience by loading tiles while animating. Will make
|
||||||
@@ -32,9 +31,7 @@ const map = new Map({
|
|||||||
|
|
||||||
// A bounce easing method (from https://github.com/DmitryBaranovskiy/raphael).
|
// A bounce easing method (from https://github.com/DmitryBaranovskiy/raphael).
|
||||||
function bounce(t) {
|
function bounce(t) {
|
||||||
const s = 7.5625;
|
var s = 7.5625, p = 2.75, l;
|
||||||
const p = 2.75;
|
|
||||||
let l;
|
|
||||||
if (t < (1 / p)) {
|
if (t < (1 / p)) {
|
||||||
l = s * t * t;
|
l = s * t * t;
|
||||||
} else {
|
} else {
|
||||||
@@ -76,16 +73,9 @@ onClick('rotate-right', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onClick('rotate-around-rome', function() {
|
onClick('rotate-around-rome', function() {
|
||||||
// Rotation animation takes the shortest arc, so animate in two parts
|
|
||||||
const rotation = view.getRotation();
|
|
||||||
view.animate({
|
view.animate({
|
||||||
rotation: rotation + Math.PI,
|
rotation: view.getRotation() + 2 * Math.PI,
|
||||||
anchor: rome,
|
anchor: rome
|
||||||
easing: easeIn
|
|
||||||
}, {
|
|
||||||
rotation: rotation + 2 * Math.PI,
|
|
||||||
anchor: rome,
|
|
||||||
easing: easeOut
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -113,27 +103,18 @@ onClick('bounce-to-istanbul', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onClick('spin-to-rome', function() {
|
onClick('spin-to-rome', function() {
|
||||||
// Rotation animation takes the shortest arc, so animate in two parts
|
|
||||||
const center = view.getCenter();
|
|
||||||
view.animate({
|
view.animate({
|
||||||
center: [
|
|
||||||
center[0] + (rome[0] - center[0]) / 2,
|
|
||||||
center[1] + (rome[1] - center[1]) / 2
|
|
||||||
],
|
|
||||||
rotation: Math.PI,
|
|
||||||
easing: easeIn
|
|
||||||
}, {
|
|
||||||
center: rome,
|
center: rome,
|
||||||
rotation: 2 * Math.PI,
|
rotation: 2 * Math.PI,
|
||||||
easing: easeOut
|
duration: 2000
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function flyTo(location, done) {
|
function flyTo(location, done) {
|
||||||
const duration = 2000;
|
var duration = 2000;
|
||||||
const zoom = view.getZoom();
|
var zoom = view.getZoom();
|
||||||
let parts = 2;
|
var parts = 2;
|
||||||
let called = false;
|
var called = false;
|
||||||
function callback(complete) {
|
function callback(complete) {
|
||||||
--parts;
|
--parts;
|
||||||
if (called) {
|
if (called) {
|
||||||
@@ -162,13 +143,13 @@ onClick('fly-to-bern', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function tour() {
|
function tour() {
|
||||||
const locations = [london, bern, rome, moscow, istanbul];
|
var locations = [london, bern, rome, moscow, istanbul];
|
||||||
let index = -1;
|
var index = -1;
|
||||||
function next(more) {
|
function next(more) {
|
||||||
if (more) {
|
if (more) {
|
||||||
++index;
|
++index;
|
||||||
if (index < locations.length) {
|
if (index < locations.length) {
|
||||||
const delay = index === 0 ? 0 : 750;
|
var delay = index === 0 ? 0 : 750;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
flyTo(locations[index], next);
|
flyTo(locations[index], next);
|
||||||
}, delay);
|
}, delay);
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import ImageLayer from '../src/ol/layer/Image.js';
|
goog.require('ol.layer.Image');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import ImageArcGISRest from '../src/ol/source/ImageArcGISRest.js';
|
goog.require('ol.source.ImageArcGISRest');
|
||||||
|
|
||||||
const url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/' +
|
var url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/' +
|
||||||
'Specialty/ESRI_StateCityHighway_USA/MapServer';
|
'Specialty/ESRI_StateCityHighway_USA/MapServer';
|
||||||
|
|
||||||
const layers = [
|
var layers = [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
}),
|
}),
|
||||||
new ImageLayer({
|
new ol.layer.Image({
|
||||||
source: new ImageArcGISRest({
|
source: new ol.source.ImageArcGISRest({
|
||||||
ratio: 1,
|
ratio: 1,
|
||||||
params: {},
|
params: {},
|
||||||
url: url
|
url: url
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: layers,
|
layers: layers,
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-10997148, 4569099],
|
center: [-10997148, 4569099],
|
||||||
zoom: 4
|
zoom: 4
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import TileArcGISRest from '../src/ol/source/TileArcGISRest.js';
|
goog.require('ol.source.TileArcGISRest');
|
||||||
|
|
||||||
const url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/' +
|
var url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/' +
|
||||||
'Specialty/ESRI_StateCityHighway_USA/MapServer';
|
'Specialty/ESRI_StateCityHighway_USA/MapServer';
|
||||||
|
|
||||||
const layers = [
|
var layers = [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
}),
|
}),
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
extent: [-13884991, 2870341, -7455066, 6338219],
|
extent: [-13884991, 2870341, -7455066, 6338219],
|
||||||
source: new TileArcGISRest({
|
source: new ol.source.TileArcGISRest({
|
||||||
url: url
|
url: url
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: layers,
|
layers: layers,
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-10997148, 4569099],
|
center: [-10997148, 4569099],
|
||||||
zoom: 4
|
zoom: 4
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import Attribution from '../src/ol/control/Attribution.js';
|
goog.require('ol.control.Attribution');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
const attribution = new Attribution({
|
var attribution = new ol.control.Attribution({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
});
|
});
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
controls: defaultControls({attribution: false}).extend([attribution]),
|
controls: ol.control.defaults({attribution: false}).extend([attribution]),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkSize() {
|
function checkSize() {
|
||||||
const small = map.getSize()[0] < 600;
|
var small = map.getSize()[0] < 600;
|
||||||
attribution.setCollapsible(small);
|
attribution.setCollapsible(small);
|
||||||
attribution.setCollapsed(small);
|
attribution.setCollapsed(small);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ cloak:
|
|||||||
<select id="layer-select">
|
<select id="layer-select">
|
||||||
<option value="Aerial">Aerial</option>
|
<option value="Aerial">Aerial</option>
|
||||||
<option value="AerialWithLabels" selected>Aerial with labels</option>
|
<option value="AerialWithLabels" selected>Aerial with labels</option>
|
||||||
<option value="Road">Road (static)</option>
|
<option value="Road">Road</option>
|
||||||
<option value="RoadOnDemand">Road (dynamic)</option>
|
|
||||||
<option value="collinsBart">Collins Bart</option>
|
<option value="collinsBart">Collins Bart</option>
|
||||||
<option value="ordnanceSurvey">Ordnance Survey</option>
|
<option value="ordnanceSurvey">Ordnance Survey</option>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
goog.require('ol.source.BingMaps');
|
||||||
|
|
||||||
|
|
||||||
const styles = [
|
var styles = [
|
||||||
'Road',
|
'Road',
|
||||||
'RoadOnDemand',
|
|
||||||
'Aerial',
|
'Aerial',
|
||||||
'AerialWithLabels',
|
'AerialWithLabels',
|
||||||
'collinsBart',
|
'collinsBart',
|
||||||
'ordnanceSurvey'
|
'ordnanceSurvey'
|
||||||
];
|
];
|
||||||
const layers = [];
|
var layers = [];
|
||||||
let i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = styles.length; i < ii; ++i) {
|
for (i = 0, ii = styles.length; i < ii; ++i) {
|
||||||
layers.push(new TileLayer({
|
layers.push(new ol.layer.Tile({
|
||||||
visible: false,
|
visible: false,
|
||||||
preload: Infinity,
|
preload: Infinity,
|
||||||
source: new BingMaps({
|
source: new ol.source.BingMaps({
|
||||||
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
|
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
|
||||||
imagerySet: styles[i]
|
imagerySet: styles[i]
|
||||||
// use maxZoom 19 to see stretched tiles instead of the BingMaps
|
// use maxZoom 19 to see stretched tiles instead of the BingMaps
|
||||||
@@ -27,22 +26,22 @@ for (i = 0, ii = styles.length; i < ii; ++i) {
|
|||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: layers,
|
layers: layers,
|
||||||
// Improve user experience by loading tiles while dragging/zooming. Will make
|
// Improve user experience by loading tiles while dragging/zooming. Will make
|
||||||
// zooming choppy on mobile or slow devices.
|
// zooming choppy on mobile or slow devices.
|
||||||
loadTilesWhileInteracting: true,
|
loadTilesWhileInteracting: true,
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-6655.5402445057125, 6709968.258934638],
|
center: [-6655.5402445057125, 6709968.258934638],
|
||||||
zoom: 13
|
zoom: 13
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const select = document.getElementById('layer-select');
|
var select = document.getElementById('layer-select');
|
||||||
function onChange() {
|
function onChange() {
|
||||||
const style = select.value;
|
var style = select.value;
|
||||||
for (let i = 0, ii = layers.length; i < ii; ++i) {
|
for (var i = 0, ii = layers.length; i < ii; ++i) {
|
||||||
layers[i].setVisible(styles[i] === style);
|
layers[i].setVisible(styles[i] === style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
import Feature from '../src/ol/Feature.js';
|
goog.require('ol.Feature');
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import Point from '../src/ol/geom/Point.js';
|
goog.require('ol.geom.Point');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
// Create separate layers for red, green an blue circles.
|
// Create separate layers for red, green an blue circles.
|
||||||
//
|
//
|
||||||
// Every layer has one feature that is styled with a circle, together the
|
// 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
|
// features form the corners of an equilateral triangle and their styles overlap
|
||||||
const redLayer = new VectorLayer({
|
var redLayer = new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
features: [new Feature(new Point([0, 0]))]
|
features: [new ol.Feature(new ol.geom.Point([0, 0]))]
|
||||||
}),
|
}),
|
||||||
style: new Style({
|
style: new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255,0,0,0.8)'
|
color: 'rgba(255,0,0,0.8)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgb(255,0,0)',
|
color: 'rgb(255,0,0)',
|
||||||
width: 15
|
width: 15
|
||||||
}),
|
}),
|
||||||
@@ -31,17 +31,17 @@ const redLayer = new VectorLayer({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const greenLayer = new VectorLayer({
|
var greenLayer = new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
// 433.013 is roughly 250 * Math.sqrt(3)
|
// 433.013 is roughly 250 * Math.sqrt(3)
|
||||||
features: [new Feature(new Point([250, 433.013]))]
|
features: [new ol.Feature(new ol.geom.Point([250, 433.013]))]
|
||||||
}),
|
}),
|
||||||
style: new Style({
|
style: new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,255,0,0.8)'
|
color: 'rgba(0,255,0,0.8)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgb(0,255,0)',
|
color: 'rgb(0,255,0)',
|
||||||
width: 15
|
width: 15
|
||||||
}),
|
}),
|
||||||
@@ -49,16 +49,16 @@ const greenLayer = new VectorLayer({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const blueLayer = new VectorLayer({
|
var blueLayer = new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
features: [new Feature(new Point([500, 0]))]
|
features: [new ol.Feature(new ol.geom.Point([500, 0]))]
|
||||||
}),
|
}),
|
||||||
style: new Style({
|
style: new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,0,255,0.8)'
|
color: 'rgba(0,0,255,0.8)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgb(0,0,255)',
|
color: 'rgb(0,0,255)',
|
||||||
width: 15
|
width: 15
|
||||||
}),
|
}),
|
||||||
@@ -69,14 +69,14 @@ const blueLayer = new VectorLayer({
|
|||||||
|
|
||||||
// Create the map, the view is centered on the triangle. Zooming and panning is
|
// Create the map, the view is centered on the triangle. Zooming and panning is
|
||||||
// restricted to a sane area
|
// restricted to a sane area
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
redLayer,
|
redLayer,
|
||||||
greenLayer,
|
greenLayer,
|
||||||
blueLayer
|
blueLayer
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [250, 220],
|
center: [250, 220],
|
||||||
extent: [0, 0, 500, 500],
|
extent: [0, 0, 500, 500],
|
||||||
resolution: 4,
|
resolution: 4,
|
||||||
@@ -86,10 +86,10 @@ const map = new Map({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Get the form elements and bind the listeners
|
// Get the form elements and bind the listeners
|
||||||
const select = document.getElementById('blend-mode');
|
var select = document.getElementById('blend-mode');
|
||||||
const affectRed = document.getElementById('affect-red');
|
var affectRed = document.getElementById('affect-red');
|
||||||
const affectGreen = document.getElementById('affect-green');
|
var affectGreen = document.getElementById('affect-green');
|
||||||
const affectBlue = document.getElementById('affect-blue');
|
var affectBlue = document.getElementById('affect-blue');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,7 @@ const affectBlue = document.getElementById('affect-blue');
|
|||||||
*
|
*
|
||||||
* @param {ol.render.Event} evt The render event.
|
* @param {ol.render.Event} evt The render event.
|
||||||
*/
|
*/
|
||||||
const setBlendModeFromSelect = function(evt) {
|
var setBlendModeFromSelect = function(evt) {
|
||||||
evt.context.globalCompositeOperation = select.value;
|
evt.context.globalCompositeOperation = select.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ const setBlendModeFromSelect = function(evt) {
|
|||||||
*
|
*
|
||||||
* @param {ol.render.Event} evt The render event.
|
* @param {ol.render.Event} evt The render event.
|
||||||
*/
|
*/
|
||||||
const resetBlendModeFromSelect = function(evt) {
|
var resetBlendModeFromSelect = function(evt) {
|
||||||
evt.context.globalCompositeOperation = 'source-over';
|
evt.context.globalCompositeOperation = 'source-over';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ const resetBlendModeFromSelect = function(evt) {
|
|||||||
*
|
*
|
||||||
* @param {ol.layer.Vector} layer The layer to bind the handlers to.
|
* @param {ol.layer.Vector} layer The layer to bind the handlers to.
|
||||||
*/
|
*/
|
||||||
const bindLayerListeners = function(layer) {
|
var bindLayerListeners = function(layer) {
|
||||||
layer.on('precompose', setBlendModeFromSelect);
|
layer.on('precompose', setBlendModeFromSelect);
|
||||||
layer.on('postcompose', resetBlendModeFromSelect);
|
layer.on('postcompose', resetBlendModeFromSelect);
|
||||||
};
|
};
|
||||||
@@ -130,7 +130,7 @@ const bindLayerListeners = function(layer) {
|
|||||||
*
|
*
|
||||||
* @param {ol.layer.Vector} layer The layer to unbind the handlers from.
|
* @param {ol.layer.Vector} layer The layer to unbind the handlers from.
|
||||||
*/
|
*/
|
||||||
const unbindLayerListeners = function(layer) {
|
var unbindLayerListeners = function(layer) {
|
||||||
layer.un('precompose', setBlendModeFromSelect);
|
layer.un('precompose', setBlendModeFromSelect);
|
||||||
layer.un('postcompose', resetBlendModeFromSelect);
|
layer.un('postcompose', resetBlendModeFromSelect);
|
||||||
};
|
};
|
||||||
@@ -141,8 +141,8 @@ const unbindLayerListeners = function(layer) {
|
|||||||
*
|
*
|
||||||
* @this {HTMLInputElement}
|
* @this {HTMLInputElement}
|
||||||
*/
|
*/
|
||||||
const affectLayerClicked = function() {
|
var affectLayerClicked = function() {
|
||||||
let layer;
|
var layer;
|
||||||
if (this.id == 'affect-red') {
|
if (this.id == 'affect-red') {
|
||||||
layer = redLayer;
|
layer = redLayer;
|
||||||
} else if (this.id == 'affect-green') {
|
} else if (this.id == 'affect-green') {
|
||||||
|
|||||||
@@ -1,73 +1,73 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {platformModifierKeyOnly} from '../src/ol/events/condition.js';
|
goog.require('ol.events.condition');
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
goog.require('ol.format.GeoJSON');
|
||||||
import DragBox from '../src/ol/interaction/DragBox.js';
|
goog.require('ol.interaction.DragBox');
|
||||||
import Select from '../src/ol/interaction/Select.js';
|
goog.require('ol.interaction.Select');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
|
|
||||||
|
|
||||||
const vectorSource = new VectorSource({
|
var vectorSource = new ol.source.Vector({
|
||||||
url: 'data/geojson/countries.geojson',
|
url: 'data/geojson/countries.geojson',
|
||||||
format: new GeoJSON()
|
format: new ol.format.GeoJSON()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
}),
|
}),
|
||||||
new VectorLayer({
|
new ol.layer.Vector({
|
||||||
source: vectorSource
|
source: vectorSource
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
// a normal select interaction to handle click
|
// a normal select interaction to handle click
|
||||||
const select = new Select();
|
var select = new ol.interaction.Select();
|
||||||
map.addInteraction(select);
|
map.addInteraction(select);
|
||||||
|
|
||||||
const selectedFeatures = select.getFeatures();
|
var selectedFeatures = select.getFeatures();
|
||||||
|
|
||||||
// a DragBox interaction used to select features by drawing boxes
|
// a DragBox interaction used to select features by drawing boxes
|
||||||
const dragBox = new DragBox({
|
var dragBox = new ol.interaction.DragBox({
|
||||||
condition: platformModifierKeyOnly
|
condition: ol.events.condition.platformModifierKeyOnly
|
||||||
});
|
});
|
||||||
|
|
||||||
map.addInteraction(dragBox);
|
map.addInteraction(dragBox);
|
||||||
|
|
||||||
|
var infoBox = document.getElementById('info');
|
||||||
|
|
||||||
dragBox.on('boxend', function() {
|
dragBox.on('boxend', function() {
|
||||||
// features that intersect the box are added to the collection of
|
// features that intersect the box are added to the collection of
|
||||||
// selected features
|
// selected features, and their names are displayed in the "info"
|
||||||
const extent = dragBox.getGeometry().getExtent();
|
// div
|
||||||
|
var info = [];
|
||||||
|
var extent = dragBox.getGeometry().getExtent();
|
||||||
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
|
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
|
||||||
selectedFeatures.push(feature);
|
selectedFeatures.push(feature);
|
||||||
|
info.push(feature.get('name'));
|
||||||
});
|
});
|
||||||
|
if (info.length > 0) {
|
||||||
|
infoBox.innerHTML = info.join(', ');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// clear selection when drawing a new box and when clicking on the map
|
// clear selection when drawing a new box and when clicking on the map
|
||||||
dragBox.on('boxstart', function() {
|
dragBox.on('boxstart', function() {
|
||||||
selectedFeatures.clear();
|
selectedFeatures.clear();
|
||||||
|
infoBox.innerHTML = ' ';
|
||||||
});
|
});
|
||||||
|
map.on('click', function() {
|
||||||
const infoBox = document.getElementById('info');
|
selectedFeatures.clear();
|
||||||
|
infoBox.innerHTML = ' ';
|
||||||
selectedFeatures.on(['add', 'remove'], function() {
|
|
||||||
const names = selectedFeatures.getArray().map(function(feature) {
|
|
||||||
return feature.get('name');
|
|
||||||
});
|
|
||||||
if (names.length > 0) {
|
|
||||||
infoBox.innerHTML = names.join(', ');
|
|
||||||
} else {
|
|
||||||
infoBox.innerHTML = 'No countries selected';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-8730000, 5930000],
|
center: [-8730000, 5930000],
|
||||||
rotation: Math.PI / 5,
|
rotation: Math.PI / 5,
|
||||||
zoom: 8
|
zoom: 8
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {getWidth} from '../src/ol/extent.js';
|
goog.require('ol.extent');
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
goog.require('ol.format.GeoJSON');
|
||||||
import {DEVICE_PIXEL_RATIO} from '../src/ol/has.js';
|
goog.require('ol.has');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
goog.require('ol.proj');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
const canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
const context = canvas.getContext('2d');
|
var context = canvas.getContext('2d');
|
||||||
|
|
||||||
// Gradient and pattern are in canvas pixel space, so we adjust for the
|
// Gradient and pattern are in canvas pixel space, so we adjust for the
|
||||||
// renderer's pixel ratio
|
// renderer's pixel ratio
|
||||||
const pixelRatio = DEVICE_PIXEL_RATIO;
|
var pixelRatio = ol.has.DEVICE_PIXEL_RATIO;
|
||||||
|
|
||||||
// Generate a rainbow gradient
|
// Generate a rainbow gradient
|
||||||
function gradient(feature, resolution) {
|
function gradient(feature, resolution) {
|
||||||
const extent = feature.getGeometry().getExtent();
|
var extent = feature.getGeometry().getExtent();
|
||||||
// Gradient starts on the left edge of each feature, and ends on the right.
|
// Gradient starts on the left edge of each feature, and ends on the right.
|
||||||
// Coordinate origin is the top-left corner of the extent of the geometry, so
|
// Coordinate origin is the top-left corner of the extent of the geometry, so
|
||||||
// we just divide the geometry's extent width by resolution and multiply with
|
// we just divide the geometry's extent width by resolution and multiply with
|
||||||
// pixelRatio to match the renderer's pixel coordinate system.
|
// pixelRatio to match the renderer's pixel coordinate system.
|
||||||
const grad = context.createLinearGradient(0, 0,
|
var grad = context.createLinearGradient(0, 0,
|
||||||
getWidth(extent) / resolution * pixelRatio, 0);
|
ol.extent.getWidth(extent) / resolution * pixelRatio, 0);
|
||||||
grad.addColorStop(0, 'red');
|
grad.addColorStop(0, 'red');
|
||||||
grad.addColorStop(1 / 6, 'orange');
|
grad.addColorStop(1 / 6, 'orange');
|
||||||
grad.addColorStop(2 / 6, 'yellow');
|
grad.addColorStop(2 / 6, 'yellow');
|
||||||
@@ -37,7 +37,7 @@ function gradient(feature, resolution) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate a canvasPattern with two circles on white background
|
// Generate a canvasPattern with two circles on white background
|
||||||
const pattern = (function() {
|
var pattern = (function() {
|
||||||
canvas.width = 11 * pixelRatio;
|
canvas.width = 11 * pixelRatio;
|
||||||
canvas.height = 11 * pixelRatio;
|
canvas.height = 11 * pixelRatio;
|
||||||
// white background
|
// white background
|
||||||
@@ -57,10 +57,10 @@ const pattern = (function() {
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
// Generate style for gradient or pattern fill
|
// Generate style for gradient or pattern fill
|
||||||
const fill = new Fill();
|
var fill = new ol.style.Fill();
|
||||||
const style = new Style({
|
var style = new ol.style.Style({
|
||||||
fill: fill,
|
fill: fill,
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#333',
|
color: '#333',
|
||||||
width: 2
|
width: 2
|
||||||
})
|
})
|
||||||
@@ -70,33 +70,33 @@ const style = new Style({
|
|||||||
* The styling function for the vector layer, will return an array of styles
|
* The styling function for the vector layer, will return an array of styles
|
||||||
* which either contains the aboove gradient or pattern.
|
* which either contains the aboove gradient or pattern.
|
||||||
*
|
*
|
||||||
* @param {module:ol/Feature~Feature} feature The feature to style.
|
* @param {ol.Feature} feature The feature to style.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @return {ol.style.Style} The style to use for the feature.
|
* @return {ol.style.Style} The style to use for the feature.
|
||||||
*/
|
*/
|
||||||
const getStackedStyle = function(feature, resolution) {
|
var getStackedStyle = function(feature, resolution) {
|
||||||
const id = feature.getId();
|
var id = feature.getId();
|
||||||
fill.setColor(id > 'J' ? gradient(feature, resolution) : pattern);
|
fill.setColor(id > 'J' ? gradient(feature, resolution) : pattern);
|
||||||
return style;
|
return style;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a vector layer that makes use of the style function above…
|
// Create a vector layer that makes use of the style function above…
|
||||||
const vectorLayer = new VectorLayer({
|
var vectorLayer = new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
url: 'data/geojson/countries.geojson',
|
url: 'data/geojson/countries.geojson',
|
||||||
format: new GeoJSON()
|
format: new ol.format.GeoJSON()
|
||||||
}),
|
}),
|
||||||
style: getStackedStyle
|
style: getStackedStyle
|
||||||
});
|
});
|
||||||
|
|
||||||
// … finally create a map with that layer.
|
// … finally create a map with that layer.
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
vectorLayer
|
vectorLayer
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: fromLonLat([7, 52]),
|
center: ol.proj.fromLonLat([7, 52]),
|
||||||
zoom: 3
|
zoom: 3
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,33 +1,34 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
goog.require('ol.proj');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import TileDebug from '../src/ol/source/TileDebug.js';
|
goog.require('ol.source.TileDebug');
|
||||||
|
|
||||||
|
|
||||||
const osmSource = new OSM();
|
var osmSource = new ol.source.OSM();
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: osmSource
|
source: osmSource
|
||||||
}),
|
}),
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new TileDebug({
|
source: new ol.source.TileDebug({
|
||||||
projection: 'EPSG:3857',
|
projection: 'EPSG:3857',
|
||||||
tileGrid: osmSource.getTileGrid()
|
tileGrid: osmSource.getTileGrid()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}),
|
}),
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: fromLonLat([-0.1275, 51.507222]),
|
center: ol.proj.transform(
|
||||||
|
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),
|
||||||
zoom: 10
|
zoom: 10
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import CartoDB from '../src/ol/source/CartoDB.js';
|
goog.require('ol.source.CartoDB');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
const mapConfig = {
|
var mapConfig = {
|
||||||
'layers': [{
|
'layers': [{
|
||||||
'type': 'cartodb',
|
'type': 'cartodb',
|
||||||
'options': {
|
'options': {
|
||||||
@@ -15,22 +15,22 @@ const mapConfig = {
|
|||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
const cartoDBSource = new CartoDB({
|
var cartoDBSource = new ol.source.CartoDB({
|
||||||
account: 'documentation',
|
account: 'documentation',
|
||||||
config: mapConfig
|
config: mapConfig
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
}),
|
}),
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: cartoDBSource
|
source: cartoDBSource
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -10,11 +10,7 @@ div.ol-zoom {
|
|||||||
top: 178px;
|
top: 178px;
|
||||||
left: 158px;
|
left: 158px;
|
||||||
}
|
}
|
||||||
div.ol-rotate {
|
div.ol-attribution {
|
||||||
top: 178px;
|
|
||||||
right: 58px;
|
|
||||||
}
|
|
||||||
.map div.ol-attribution {
|
|
||||||
bottom: 30px;
|
bottom: 30px;
|
||||||
right: 50px;
|
right: 50px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,97 +1,97 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
goog.require('ol.format.GeoJSON');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
const source = new VectorSource({
|
var source = new ol.source.Vector({
|
||||||
url: 'data/geojson/switzerland.geojson',
|
url: 'data/geojson/switzerland.geojson',
|
||||||
format: new GeoJSON()
|
format: new ol.format.GeoJSON()
|
||||||
});
|
});
|
||||||
const style = new Style({
|
var style = new ol.style.Style({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255, 255, 255, 0.6)'
|
color: 'rgba(255, 255, 255, 0.6)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#319FD3',
|
color: '#319FD3',
|
||||||
width: 1
|
width: 1
|
||||||
}),
|
}),
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: 5,
|
radius: 5,
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255, 255, 255, 0.6)'
|
color: 'rgba(255, 255, 255, 0.6)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#319FD3',
|
color: '#319FD3',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const vectorLayer = new VectorLayer({
|
var vectorLayer = new ol.layer.Vector({
|
||||||
source: source,
|
source: source,
|
||||||
style: style
|
style: style
|
||||||
});
|
});
|
||||||
const view = new View({
|
var view = new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 1
|
zoom: 1
|
||||||
});
|
});
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
}),
|
}),
|
||||||
vectorLayer
|
vectorLayer
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}),
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
const zoomtoswitzerlandbest = document.getElementById('zoomtoswitzerlandbest');
|
var zoomtoswitzerlandbest = document.getElementById('zoomtoswitzerlandbest');
|
||||||
zoomtoswitzerlandbest.addEventListener('click', function() {
|
zoomtoswitzerlandbest.addEventListener('click', function() {
|
||||||
const feature = source.getFeatures()[0];
|
var feature = source.getFeatures()[0];
|
||||||
const polygon = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
|
||||||
view.fit(polygon, {padding: [170, 50, 30, 150], constrainResolution: false});
|
view.fit(polygon, {padding: [170, 50, 30, 150], constrainResolution: false});
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
const zoomtoswitzerlandconstrained =
|
var zoomtoswitzerlandconstrained =
|
||||||
document.getElementById('zoomtoswitzerlandconstrained');
|
document.getElementById('zoomtoswitzerlandconstrained');
|
||||||
zoomtoswitzerlandconstrained.addEventListener('click', function() {
|
zoomtoswitzerlandconstrained.addEventListener('click', function() {
|
||||||
const feature = source.getFeatures()[0];
|
var feature = source.getFeatures()[0];
|
||||||
const polygon = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
|
||||||
view.fit(polygon, {padding: [170, 50, 30, 150]});
|
view.fit(polygon, {padding: [170, 50, 30, 150]});
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
const zoomtoswitzerlandnearest =
|
var zoomtoswitzerlandnearest =
|
||||||
document.getElementById('zoomtoswitzerlandnearest');
|
document.getElementById('zoomtoswitzerlandnearest');
|
||||||
zoomtoswitzerlandnearest.addEventListener('click', function() {
|
zoomtoswitzerlandnearest.addEventListener('click', function() {
|
||||||
const feature = source.getFeatures()[0];
|
var feature = source.getFeatures()[0];
|
||||||
const polygon = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
|
||||||
view.fit(polygon, {padding: [170, 50, 30, 150], nearest: true});
|
view.fit(polygon, {padding: [170, 50, 30, 150], nearest: true});
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
const zoomtolausanne = document.getElementById('zoomtolausanne');
|
var zoomtolausanne = document.getElementById('zoomtolausanne');
|
||||||
zoomtolausanne.addEventListener('click', function() {
|
zoomtolausanne.addEventListener('click', function() {
|
||||||
const feature = source.getFeatures()[1];
|
var feature = source.getFeatures()[1];
|
||||||
const point = /** @type {module:ol/geom/SimpleGeometry~SimpleGeometry} */ (feature.getGeometry());
|
var point = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
|
||||||
view.fit(point, {padding: [170, 50, 30, 150], minResolution: 50});
|
view.fit(point, {padding: [170, 50, 30, 150], minResolution: 50});
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
const centerlausanne = document.getElementById('centerlausanne');
|
var centerlausanne = document.getElementById('centerlausanne');
|
||||||
centerlausanne.addEventListener('click', function() {
|
centerlausanne.addEventListener('click', function() {
|
||||||
const feature = source.getFeatures()[1];
|
var feature = source.getFeatures()[1];
|
||||||
const point = /** @type {module:ol/geom/Point~Point} */ (feature.getGeometry());
|
var point = /** @type {ol.geom.Point} */ (feature.getGeometry());
|
||||||
const size = /** @type {ol.Size} */ (map.getSize());
|
var size = /** @type {ol.Size} */ (map.getSize());
|
||||||
view.centerOn(point.getCoordinates(), size, [570, 500]);
|
view.centerOn(point.getCoordinates(), size, [570, 500]);
|
||||||
}, false);
|
}, false);
|
||||||
|
|||||||
@@ -1,58 +1,58 @@
|
|||||||
import Feature from '../src/ol/Feature.js';
|
goog.require('ol.Feature');
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import Point from '../src/ol/geom/Point.js';
|
goog.require('ol.geom.Point');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import Cluster from '../src/ol/source/Cluster.js';
|
goog.require('ol.source.Cluster');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
import Text from '../src/ol/style/Text.js';
|
goog.require('ol.style.Text');
|
||||||
|
|
||||||
|
|
||||||
const distance = document.getElementById('distance');
|
var distance = document.getElementById('distance');
|
||||||
|
|
||||||
const count = 20000;
|
var count = 20000;
|
||||||
const features = new Array(count);
|
var features = new Array(count);
|
||||||
const e = 4500000;
|
var e = 4500000;
|
||||||
for (let i = 0; i < count; ++i) {
|
for (var i = 0; i < count; ++i) {
|
||||||
const coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e];
|
var coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e];
|
||||||
features[i] = new Feature(new Point(coordinates));
|
features[i] = new ol.Feature(new ol.geom.Point(coordinates));
|
||||||
}
|
}
|
||||||
|
|
||||||
const source = new VectorSource({
|
var source = new ol.source.Vector({
|
||||||
features: features
|
features: features
|
||||||
});
|
});
|
||||||
|
|
||||||
const clusterSource = new Cluster({
|
var clusterSource = new ol.source.Cluster({
|
||||||
distance: parseInt(distance.value, 10),
|
distance: parseInt(distance.value, 10),
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
|
|
||||||
const styleCache = {};
|
var styleCache = {};
|
||||||
const clusters = new VectorLayer({
|
var clusters = new ol.layer.Vector({
|
||||||
source: clusterSource,
|
source: clusterSource,
|
||||||
style: function(feature) {
|
style: function(feature) {
|
||||||
const size = feature.get('features').length;
|
var size = feature.get('features').length;
|
||||||
let style = styleCache[size];
|
var style = styleCache[size];
|
||||||
if (!style) {
|
if (!style) {
|
||||||
style = new Style({
|
style = new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: 10,
|
radius: 10,
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#fff'
|
color: '#fff'
|
||||||
}),
|
}),
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: '#3399CC'
|
color: '#3399CC'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
text: new Text({
|
text: new ol.style.Text({
|
||||||
text: size.toString(),
|
text: size.toString(),
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: '#fff'
|
color: '#fff'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -63,14 +63,14 @@ const clusters = new VectorLayer({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, clusters],
|
layers: [raster, clusters],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
// NOCOMPILE
|
// NOCOMPILE
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import ImageLayer from '../src/ol/layer/Image.js';
|
goog.require('ol.layer.Image');
|
||||||
import RasterSource from '../src/ol/source/Raster.js';
|
goog.require('ol.source.Raster');
|
||||||
import Stamen from '../src/ol/source/Stamen.js';
|
goog.require('ol.source.Stamen');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color manipulation functions below are adapted from
|
* Color manipulation functions below are adapted from
|
||||||
* https://github.com/d3/d3-color.
|
* https://github.com/d3/d3-color.
|
||||||
*/
|
*/
|
||||||
const Xn = 0.950470;
|
var Xn = 0.950470;
|
||||||
const Yn = 1;
|
var Yn = 1;
|
||||||
const Zn = 1.088830;
|
var Zn = 1.088830;
|
||||||
const t0 = 4 / 29;
|
var t0 = 4 / 29;
|
||||||
const t1 = 6 / 29;
|
var t1 = 6 / 29;
|
||||||
const t2 = 3 * t1 * t1;
|
var t2 = 3 * t1 * t1;
|
||||||
const t3 = t1 * t1 * t1;
|
var t3 = t1 * t1 * t1;
|
||||||
const twoPi = 2 * Math.PI;
|
var twoPi = 2 * Math.PI;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,23 +26,23 @@ const twoPi = 2 * Math.PI;
|
|||||||
* @return {Array.<number>} A pixel in HCL space.
|
* @return {Array.<number>} A pixel in HCL space.
|
||||||
*/
|
*/
|
||||||
function rgb2hcl(pixel) {
|
function rgb2hcl(pixel) {
|
||||||
const red = rgb2xyz(pixel[0]);
|
var red = rgb2xyz(pixel[0]);
|
||||||
const green = rgb2xyz(pixel[1]);
|
var green = rgb2xyz(pixel[1]);
|
||||||
const blue = rgb2xyz(pixel[2]);
|
var blue = rgb2xyz(pixel[2]);
|
||||||
|
|
||||||
const x = xyz2lab(
|
var x = xyz2lab(
|
||||||
(0.4124564 * red + 0.3575761 * green + 0.1804375 * blue) / Xn);
|
(0.4124564 * red + 0.3575761 * green + 0.1804375 * blue) / Xn);
|
||||||
const y = xyz2lab(
|
var y = xyz2lab(
|
||||||
(0.2126729 * red + 0.7151522 * green + 0.0721750 * blue) / Yn);
|
(0.2126729 * red + 0.7151522 * green + 0.0721750 * blue) / Yn);
|
||||||
const z = xyz2lab(
|
var z = xyz2lab(
|
||||||
(0.0193339 * red + 0.1191920 * green + 0.9503041 * blue) / Zn);
|
(0.0193339 * red + 0.1191920 * green + 0.9503041 * blue) / Zn);
|
||||||
|
|
||||||
const l = 116 * y - 16;
|
var l = 116 * y - 16;
|
||||||
const a = 500 * (x - y);
|
var a = 500 * (x - y);
|
||||||
const b = 200 * (y - z);
|
var b = 200 * (y - z);
|
||||||
|
|
||||||
const c = Math.sqrt(a * a + b * b);
|
var c = Math.sqrt(a * a + b * b);
|
||||||
let h = Math.atan2(b, a);
|
var h = Math.atan2(b, a);
|
||||||
if (h < 0) {
|
if (h < 0) {
|
||||||
h += twoPi;
|
h += twoPi;
|
||||||
}
|
}
|
||||||
@@ -61,16 +61,16 @@ function rgb2hcl(pixel) {
|
|||||||
* @return {Array.<number>} A pixel in RGB space.
|
* @return {Array.<number>} A pixel in RGB space.
|
||||||
*/
|
*/
|
||||||
function hcl2rgb(pixel) {
|
function hcl2rgb(pixel) {
|
||||||
const h = pixel[0];
|
var h = pixel[0];
|
||||||
const c = pixel[1];
|
var c = pixel[1];
|
||||||
const l = pixel[2];
|
var l = pixel[2];
|
||||||
|
|
||||||
const a = Math.cos(h) * c;
|
var a = Math.cos(h) * c;
|
||||||
const b = Math.sin(h) * c;
|
var b = Math.sin(h) * c;
|
||||||
|
|
||||||
let y = (l + 16) / 116;
|
var y = (l + 16) / 116;
|
||||||
let x = isNaN(a) ? y : y + a / 500;
|
var x = isNaN(a) ? y : y + a / 500;
|
||||||
let z = isNaN(b) ? y : y - b / 200;
|
var z = isNaN(b) ? y : y - b / 200;
|
||||||
|
|
||||||
y = Yn * lab2xyz(y);
|
y = Yn * lab2xyz(y);
|
||||||
x = Xn * lab2xyz(x);
|
x = Xn * lab2xyz(x);
|
||||||
@@ -100,15 +100,14 @@ function xyz2rgb(x) {
|
|||||||
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
||||||
}
|
}
|
||||||
|
|
||||||
const raster = new RasterSource({
|
var raster = new ol.source.Raster({
|
||||||
sources: [new Stamen({
|
sources: [new ol.source.Stamen({
|
||||||
layer: 'watercolor',
|
layer: 'watercolor'
|
||||||
transition: 0
|
|
||||||
})],
|
})],
|
||||||
operation: function(pixels, data) {
|
operation: function(pixels, data) {
|
||||||
const hcl = rgb2hcl(pixels[0]);
|
var hcl = rgb2hcl(pixels[0]);
|
||||||
|
|
||||||
let h = hcl[0] + Math.PI * data.hue / 180;
|
var h = hcl[0] + Math.PI * data.hue / 180;
|
||||||
if (h < 0) {
|
if (h < 0) {
|
||||||
h += twoPi;
|
h += twoPi;
|
||||||
} else if (h > twoPi) {
|
} else if (h > twoPi) {
|
||||||
@@ -139,33 +138,33 @@ const raster = new RasterSource({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const controls = {};
|
var controls = {};
|
||||||
|
|
||||||
raster.on('beforeoperations', function(event) {
|
raster.on('beforeoperations', function(event) {
|
||||||
const data = event.data;
|
var data = event.data;
|
||||||
for (const id in controls) {
|
for (var id in controls) {
|
||||||
data[id] = Number(controls[id].value);
|
data[id] = Number(controls[id].value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new ImageLayer({
|
new ol.layer.Image({
|
||||||
source: raster
|
source: raster
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 2500000],
|
center: [0, 2500000],
|
||||||
zoom: 2,
|
zoom: 2,
|
||||||
maxZoom: 18
|
maxZoom: 18
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const controlIds = ['hue', 'chroma', 'lightness'];
|
var controlIds = ['hue', 'chroma', 'lightness'];
|
||||||
controlIds.forEach(function(id) {
|
controlIds.forEach(function(id) {
|
||||||
const control = document.getElementById(id);
|
var control = document.getElementById(id);
|
||||||
const output = document.getElementById(id + 'Out');
|
var output = document.getElementById(id + 'Out');
|
||||||
control.addEventListener('input', function() {
|
control.addEventListener('input', function() {
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
raster.changed();
|
raster.changed();
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import {inherits} from '../src/ol/index.js';
|
goog.require('ol');
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import Control from '../src/ol/control/Control.js';
|
goog.require('ol.control.Control');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a namespace for the application.
|
* Define a namespace for the application.
|
||||||
*/
|
*/
|
||||||
window.app = {};
|
window.app = {};
|
||||||
const app = window.app;
|
var app = window.app;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -21,35 +21,35 @@ const app = window.app;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {module:ol/control/Control~Control}
|
* @extends {ol.control.Control}
|
||||||
* @param {Object=} opt_options Control options.
|
* @param {Object=} opt_options Control options.
|
||||||
*/
|
*/
|
||||||
app.RotateNorthControl = function(opt_options) {
|
app.RotateNorthControl = function(opt_options) {
|
||||||
|
|
||||||
const options = opt_options || {};
|
var options = opt_options || {};
|
||||||
|
|
||||||
const button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
button.innerHTML = 'N';
|
button.innerHTML = 'N';
|
||||||
|
|
||||||
const this_ = this;
|
var this_ = this;
|
||||||
const handleRotateNorth = function() {
|
var handleRotateNorth = function() {
|
||||||
this_.getMap().getView().setRotation(0);
|
this_.getMap().getView().setRotation(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
button.addEventListener('click', handleRotateNorth, false);
|
button.addEventListener('click', handleRotateNorth, false);
|
||||||
button.addEventListener('touchstart', handleRotateNorth, false);
|
button.addEventListener('touchstart', handleRotateNorth, false);
|
||||||
|
|
||||||
const element = document.createElement('div');
|
var element = document.createElement('div');
|
||||||
element.className = 'rotate-north ol-unselectable ol-control';
|
element.className = 'rotate-north ol-unselectable ol-control';
|
||||||
element.appendChild(button);
|
element.appendChild(button);
|
||||||
|
|
||||||
Control.call(this, {
|
ol.control.Control.call(this, {
|
||||||
element: element,
|
element: element,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
inherits(app.RotateNorthControl, Control);
|
ol.inherits(app.RotateNorthControl, ol.control.Control);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -57,21 +57,21 @@ inherits(app.RotateNorthControl, Control);
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}).extend([
|
}).extend([
|
||||||
new app.RotateNorthControl()
|
new app.RotateNorthControl()
|
||||||
]),
|
]),
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 3,
|
zoom: 3,
|
||||||
rotation: 1
|
rotation: 1
|
||||||
|
|||||||
9
examples/custom-icon.html
Normal file
9
examples/custom-icon.html
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
layout: example.html
|
||||||
|
title: Custom Icon
|
||||||
|
shortdesc: Example using a custom attribution icon object
|
||||||
|
docs: >
|
||||||
|
This example creates a custom element for the attribution icon
|
||||||
|
tags: "icon, element"
|
||||||
|
---
|
||||||
|
<div id="map" class="map"><div id="popup"></div></div>
|
||||||
27
examples/custom-icon.js
Normal file
27
examples/custom-icon.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.layer.Tile');
|
||||||
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
|
var logoElement = document.createElement('a');
|
||||||
|
logoElement.href = 'https://www.osgeo.org/';
|
||||||
|
logoElement.target = '_blank';
|
||||||
|
|
||||||
|
var logoImage = document.createElement('img');
|
||||||
|
logoImage.src = 'https://www.osgeo.org/sites/all/themes/osgeo/logo.png';
|
||||||
|
|
||||||
|
logoElement.appendChild(logoImage);
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Tile({
|
||||||
|
source: new ol.source.OSM()
|
||||||
|
})
|
||||||
|
],
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 2
|
||||||
|
}),
|
||||||
|
logo: logoElement
|
||||||
|
});
|
||||||
@@ -1,26 +1,26 @@
|
|||||||
import {inherits} from '../src/ol/index.js';
|
goog.require('ol');
|
||||||
import Feature from '../src/ol/Feature.js';
|
goog.require('ol.Feature');
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import LineString from '../src/ol/geom/LineString.js';
|
goog.require('ol.geom.LineString');
|
||||||
import Point from '../src/ol/geom/Point.js';
|
goog.require('ol.geom.Point');
|
||||||
import Polygon from '../src/ol/geom/Polygon.js';
|
goog.require('ol.geom.Polygon');
|
||||||
import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
goog.require('ol.interaction');
|
||||||
import PointerInteraction from '../src/ol/interaction/Pointer.js';
|
goog.require('ol.interaction.Pointer');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import TileJSON from '../src/ol/source/TileJSON.js';
|
goog.require('ol.source.TileJSON');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Icon from '../src/ol/style/Icon.js';
|
goog.require('ol.style.Icon');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a namespace for the application.
|
* Define a namespace for the application.
|
||||||
*/
|
*/
|
||||||
const app = {};
|
var app = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +29,7 @@ const app = {};
|
|||||||
*/
|
*/
|
||||||
app.Drag = function() {
|
app.Drag = function() {
|
||||||
|
|
||||||
PointerInteraction.call(this, {
|
ol.interaction.Pointer.call(this, {
|
||||||
handleDownEvent: app.Drag.prototype.handleDownEvent,
|
handleDownEvent: app.Drag.prototype.handleDownEvent,
|
||||||
handleDragEvent: app.Drag.prototype.handleDragEvent,
|
handleDragEvent: app.Drag.prototype.handleDragEvent,
|
||||||
handleMoveEvent: app.Drag.prototype.handleMoveEvent,
|
handleMoveEvent: app.Drag.prototype.handleMoveEvent,
|
||||||
@@ -49,7 +49,7 @@ app.Drag = function() {
|
|||||||
this.cursor_ = 'pointer';
|
this.cursor_ = 'pointer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {module:ol/Feature~Feature}
|
* @type {ol.Feature}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.feature_ = null;
|
this.feature_ = null;
|
||||||
@@ -61,17 +61,17 @@ app.Drag = function() {
|
|||||||
this.previousCursor_ = undefined;
|
this.previousCursor_ = undefined;
|
||||||
|
|
||||||
};
|
};
|
||||||
inherits(app.Drag, PointerInteraction);
|
ol.inherits(app.Drag, ol.interaction.Pointer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt Map browser event.
|
* @param {ol.MapBrowserEvent} evt Map browser event.
|
||||||
* @return {boolean} `true` to start the drag sequence.
|
* @return {boolean} `true` to start the drag sequence.
|
||||||
*/
|
*/
|
||||||
app.Drag.prototype.handleDownEvent = function(evt) {
|
app.Drag.prototype.handleDownEvent = function(evt) {
|
||||||
const map = evt.map;
|
var map = evt.map;
|
||||||
|
|
||||||
const feature = map.forEachFeatureAtPixel(evt.pixel,
|
var feature = map.forEachFeatureAtPixel(evt.pixel,
|
||||||
function(feature) {
|
function(feature) {
|
||||||
return feature;
|
return feature;
|
||||||
});
|
});
|
||||||
@@ -86,13 +86,14 @@ app.Drag.prototype.handleDownEvent = function(evt) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt Map browser event.
|
* @param {ol.MapBrowserEvent} evt Map browser event.
|
||||||
*/
|
*/
|
||||||
app.Drag.prototype.handleDragEvent = function(evt) {
|
app.Drag.prototype.handleDragEvent = function(evt) {
|
||||||
const deltaX = evt.coordinate[0] - this.coordinate_[0];
|
var deltaX = evt.coordinate[0] - this.coordinate_[0];
|
||||||
const deltaY = evt.coordinate[1] - this.coordinate_[1];
|
var deltaY = evt.coordinate[1] - this.coordinate_[1];
|
||||||
|
|
||||||
const geometry = this.feature_.getGeometry();
|
var geometry = /** @type {ol.geom.SimpleGeometry} */
|
||||||
|
(this.feature_.getGeometry());
|
||||||
geometry.translate(deltaX, deltaY);
|
geometry.translate(deltaX, deltaY);
|
||||||
|
|
||||||
this.coordinate_[0] = evt.coordinate[0];
|
this.coordinate_[0] = evt.coordinate[0];
|
||||||
@@ -101,16 +102,16 @@ app.Drag.prototype.handleDragEvent = function(evt) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt Event.
|
* @param {ol.MapBrowserEvent} evt Event.
|
||||||
*/
|
*/
|
||||||
app.Drag.prototype.handleMoveEvent = function(evt) {
|
app.Drag.prototype.handleMoveEvent = function(evt) {
|
||||||
if (this.cursor_) {
|
if (this.cursor_) {
|
||||||
const map = evt.map;
|
var map = evt.map;
|
||||||
const feature = map.forEachFeatureAtPixel(evt.pixel,
|
var feature = map.forEachFeatureAtPixel(evt.pixel,
|
||||||
function(feature) {
|
function(feature) {
|
||||||
return feature;
|
return feature;
|
||||||
});
|
});
|
||||||
const element = evt.map.getTargetElement();
|
var element = evt.map.getTargetElement();
|
||||||
if (feature) {
|
if (feature) {
|
||||||
if (element.style.cursor != this.cursor_) {
|
if (element.style.cursor != this.cursor_) {
|
||||||
this.previousCursor_ = element.style.cursor;
|
this.previousCursor_ = element.style.cursor;
|
||||||
@@ -134,48 +135,48 @@ app.Drag.prototype.handleUpEvent = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const pointFeature = new Feature(new Point([0, 0]));
|
var pointFeature = new ol.Feature(new ol.geom.Point([0, 0]));
|
||||||
|
|
||||||
const lineFeature = new Feature(
|
var lineFeature = new ol.Feature(
|
||||||
new LineString([[-1e7, 1e6], [-1e6, 3e6]]));
|
new ol.geom.LineString([[-1e7, 1e6], [-1e6, 3e6]]));
|
||||||
|
|
||||||
const polygonFeature = new Feature(
|
var polygonFeature = new ol.Feature(
|
||||||
new Polygon([[[-3e6, -1e6], [-3e6, 1e6],
|
new ol.geom.Polygon([[[-3e6, -1e6], [-3e6, 1e6],
|
||||||
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
|
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
interactions: defaultInteractions().extend([new app.Drag()]),
|
interactions: ol.interaction.defaults().extend([new app.Drag()]),
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new TileJSON({
|
source: new ol.source.TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure'
|
url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
new VectorLayer({
|
new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
features: [pointFeature, lineFeature, polygonFeature]
|
features: [pointFeature, lineFeature, polygonFeature]
|
||||||
}),
|
}),
|
||||||
style: new Style({
|
style: new ol.style.Style({
|
||||||
image: new Icon(/** @type {olx.style.IconOptions} */ ({
|
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
|
||||||
anchor: [0.5, 46],
|
anchor: [0.5, 46],
|
||||||
anchorXUnits: 'fraction',
|
anchorXUnits: 'fraction',
|
||||||
anchorYUnits: 'pixels',
|
anchorYUnits: 'pixels',
|
||||||
opacity: 0.95,
|
opacity: 0.95,
|
||||||
src: 'data/icon.png'
|
src: 'data/icon.png'
|
||||||
})),
|
})),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
width: 3,
|
width: 3,
|
||||||
color: [255, 0, 0, 1]
|
color: [255, 0, 0, 1]
|
||||||
}),
|
}),
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: [0, 0, 255, 0.6]
|
color: [0, 0, 255, 0.6]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ docs: >
|
|||||||
<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>
|
<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"
|
tags: "d3"
|
||||||
resources:
|
resources:
|
||||||
- https://unpkg.com/d3@4.12.0/build/d3.js
|
- https://d3js.org/d3.v3.min.js
|
||||||
- https://unpkg.com/topojson@3.0.2/dist/topojson.js
|
- https://d3js.org/topojson.v1.min.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
83
examples/d3.js
vendored
83
examples/d3.js
vendored
@@ -1,25 +1,26 @@
|
|||||||
// NOCOMPILE
|
// NOCOMPILE
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.Map');
|
||||||
import {getWidth, getCenter} from '../src/ol/extent.js';
|
goog.require('ol.View');
|
||||||
import ImageLayer from '../src/ol/layer/Image.js';
|
goog.require('ol.extent');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Image');
|
||||||
import {fromLonLat, toLonLat} from '../src/ol/proj.js';
|
goog.require('ol.layer.Tile');
|
||||||
import ImageCanvasSource from '../src/ol/source/ImageCanvas.js';
|
goog.require('ol.proj');
|
||||||
import Stamen from '../src/ol/source/Stamen.js';
|
goog.require('ol.source.ImageCanvas');
|
||||||
|
goog.require('ol.source.Stamen');
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new Stamen({
|
source: new ol.source.Stamen({
|
||||||
layer: 'watercolor'
|
layer: 'watercolor'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: fromLonLat([-97, 38]),
|
center: ol.proj.fromLonLat([-97, 38]),
|
||||||
zoom: 4
|
zoom: 4
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -29,7 +30,7 @@ const map = new Map({
|
|||||||
* Load the topojson data and create an ol.layer.Image for that data.
|
* Load the topojson data and create an ol.layer.Image for that data.
|
||||||
*/
|
*/
|
||||||
d3.json('data/topojson/us.json', function(error, us) {
|
d3.json('data/topojson/us.json', function(error, us) {
|
||||||
const features = topojson.feature(us, us.objects.counties);
|
var features = topojson.feature(us, us.objects.counties);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function uses d3 to render the topojson features to a canvas.
|
* This function uses d3 to render the topojson features to a canvas.
|
||||||
@@ -37,51 +38,55 @@ d3.json('data/topojson/us.json', function(error, us) {
|
|||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.Size} size Size.
|
* @param {ol.Size} size Size.
|
||||||
* @param {module:ol/proj/Projection~Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
* @return {HTMLCanvasElement} A canvas element.
|
* @return {HTMLCanvasElement} A canvas element.
|
||||||
*/
|
*/
|
||||||
const canvasFunction = function(extent, resolution, pixelRatio, size, projection) {
|
var canvasFunction = function(extent, resolution, pixelRatio,
|
||||||
const canvasWidth = size[0];
|
size, projection) {
|
||||||
const canvasHeight = size[1];
|
var canvasWidth = size[0];
|
||||||
|
var canvasHeight = size[1];
|
||||||
|
|
||||||
const canvas = d3.select(document.createElement('canvas'));
|
var canvas = d3.select(document.createElement('canvas'));
|
||||||
canvas.attr('width', canvasWidth).attr('height', canvasHeight);
|
canvas.attr('width', canvasWidth).attr('height', canvasHeight);
|
||||||
|
|
||||||
const context = canvas.node().getContext('2d');
|
var context = canvas.node().getContext('2d');
|
||||||
|
|
||||||
const d3Projection = d3.geoMercator().scale(1).translate([0, 0]);
|
var d3Projection = d3.geo.mercator().scale(1).translate([0, 0]);
|
||||||
let d3Path = d3.geoPath().projection(d3Projection);
|
var d3Path = d3.geo.path().projection(d3Projection);
|
||||||
|
|
||||||
const pixelBounds = d3Path.bounds(features);
|
var pixelBounds = d3Path.bounds(features);
|
||||||
const pixelBoundsWidth = pixelBounds[1][0] - pixelBounds[0][0];
|
var pixelBoundsWidth = pixelBounds[1][0] - pixelBounds[0][0];
|
||||||
const pixelBoundsHeight = pixelBounds[1][1] - pixelBounds[0][1];
|
var pixelBoundsHeight = pixelBounds[1][1] - pixelBounds[0][1];
|
||||||
|
|
||||||
const geoBounds = d3.geoBounds(features);
|
var geoBounds = d3.geo.bounds(features);
|
||||||
const geoBoundsLeftBottom = fromLonLat(geoBounds[0], projection);
|
var geoBoundsLeftBottom = ol.proj.transform(
|
||||||
const geoBoundsRightTop = fromLonLat(geoBounds[1], projection);
|
geoBounds[0], 'EPSG:4326', projection);
|
||||||
let geoBoundsWidth = geoBoundsRightTop[0] - geoBoundsLeftBottom[0];
|
var geoBoundsRightTop = ol.proj.transform(
|
||||||
|
geoBounds[1], 'EPSG:4326', projection);
|
||||||
|
var geoBoundsWidth = geoBoundsRightTop[0] - geoBoundsLeftBottom[0];
|
||||||
if (geoBoundsWidth < 0) {
|
if (geoBoundsWidth < 0) {
|
||||||
geoBoundsWidth += getWidth(projection.getExtent());
|
geoBoundsWidth += ol.extent.getWidth(projection.getExtent());
|
||||||
}
|
}
|
||||||
const geoBoundsHeight = geoBoundsRightTop[1] - geoBoundsLeftBottom[1];
|
var geoBoundsHeight = geoBoundsRightTop[1] - geoBoundsLeftBottom[1];
|
||||||
|
|
||||||
const widthResolution = geoBoundsWidth / pixelBoundsWidth;
|
var widthResolution = geoBoundsWidth / pixelBoundsWidth;
|
||||||
const heightResolution = geoBoundsHeight / pixelBoundsHeight;
|
var heightResolution = geoBoundsHeight / pixelBoundsHeight;
|
||||||
const r = Math.max(widthResolution, heightResolution);
|
var r = Math.max(widthResolution, heightResolution);
|
||||||
const scale = r / (resolution / pixelRatio);
|
var scale = r / (resolution / pixelRatio);
|
||||||
|
|
||||||
const center = toLonLat(getCenter(extent), projection);
|
var center = ol.proj.transform(ol.extent.getCenter(extent),
|
||||||
|
projection, 'EPSG:4326');
|
||||||
d3Projection.scale(scale).center(center)
|
d3Projection.scale(scale).center(center)
|
||||||
.translate([canvasWidth / 2, canvasHeight / 2]);
|
.translate([canvasWidth / 2, canvasHeight / 2]);
|
||||||
d3Path = d3Path.projection(d3Projection).context(context);
|
d3Path = d3Path.projection(d3Projection).context(context);
|
||||||
d3Path(features);
|
d3Path(features);
|
||||||
context.stroke();
|
context.stroke();
|
||||||
|
|
||||||
return canvas.node();
|
return canvas[0][0];
|
||||||
};
|
};
|
||||||
|
|
||||||
const layer = new ImageLayer({
|
var layer = new ol.layer.Image({
|
||||||
source: new ImageCanvasSource({
|
source: new ol.source.ImageCanvas({
|
||||||
canvasFunction: canvasFunction,
|
canvasFunction: canvasFunction,
|
||||||
projection: 'EPSG:3857'
|
projection: 'EPSG:3857'
|
||||||
})
|
})
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -4,15 +4,16 @@ title: Device Orientation
|
|||||||
shortdesc: Listen to DeviceOrientation events.
|
shortdesc: Listen to DeviceOrientation events.
|
||||||
docs: >
|
docs: >
|
||||||
This example shows how to track changes in device orientation.
|
This example shows how to track changes in device orientation.
|
||||||
[gyronorm.js](https://github.com/dorukeker/gyronorm.js) library is used to access and
|
tags: "orientation, openstreetmap"
|
||||||
normalize the events from the browser.
|
|
||||||
tags: "device, orientation, gyronorm"
|
|
||||||
resources:
|
|
||||||
- https://cdn.rawgit.com/dorukeker/gyronorm.js/v2.0.6/dist/gyronorm.complete.min.js
|
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
<label>
|
||||||
|
track changes
|
||||||
|
<input id="track" type="checkbox"/>
|
||||||
|
</label>
|
||||||
<p>
|
<p>
|
||||||
<div>α : <code id="alpha"></code></div>
|
α : <code id="alpha"></code>
|
||||||
<div>β : <code id="beta"></code></div>
|
β : <code id="beta"></code>
|
||||||
<div>γ : <code id="gamma"></code></div>
|
γ : <code id="gamma"></code>
|
||||||
|
heading : <code id="heading"></code>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,52 +1,59 @@
|
|||||||
// NOCOMPILE
|
goog.require('ol.DeviceOrientation');
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import {toRadians} from '../src/ol/math.js';
|
goog.require('ol.proj');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
const view = new View({
|
var projection = ol.proj.get('EPSG:3857');
|
||||||
|
var view = new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
|
projection: projection,
|
||||||
|
extent: projection.getExtent(),
|
||||||
zoom: 2
|
zoom: 2
|
||||||
});
|
});
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}),
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var deviceOrientation = new ol.DeviceOrientation();
|
||||||
|
|
||||||
function el(id) {
|
function el(id) {
|
||||||
return document.getElementById(id);
|
return document.getElementById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
el('track').addEventListener('change', function() {
|
||||||
|
deviceOrientation.setTracking(this.checked);
|
||||||
|
});
|
||||||
|
|
||||||
const gn = new GyroNorm();
|
deviceOrientation.on('change', function() {
|
||||||
|
el('alpha').innerText = deviceOrientation.getAlpha() + ' [rad]';
|
||||||
|
el('beta').innerText = deviceOrientation.getBeta() + ' [rad]';
|
||||||
|
el('gamma').innerText = deviceOrientation.getGamma() + ' [rad]';
|
||||||
|
el('heading').innerText = deviceOrientation.getHeading() + ' [rad]';
|
||||||
|
});
|
||||||
|
|
||||||
gn.init().then(function() {
|
// tilt the map
|
||||||
gn.start(function(event) {
|
deviceOrientation.on(['change:beta', 'change:gamma'], function(event) {
|
||||||
const center = view.getCenter();
|
var center = view.getCenter();
|
||||||
const resolution = view.getResolution();
|
var resolution = view.getResolution();
|
||||||
const alpha = toRadians(event.do.beta);
|
var beta = event.target.getBeta() || 0;
|
||||||
const beta = toRadians(event.do.beta);
|
var gamma = event.target.getGamma() || 0;
|
||||||
const gamma = toRadians(event.do.gamma);
|
|
||||||
|
|
||||||
el('alpha').innerText = alpha + ' [rad]';
|
|
||||||
el('beta').innerText = beta + ' [rad]';
|
|
||||||
el('gamma').innerText = gamma + ' [rad]';
|
|
||||||
|
|
||||||
center[0] -= resolution * gamma * 25;
|
center[0] -= resolution * gamma * 25;
|
||||||
center[1] += resolution * beta * 25;
|
center[1] += resolution * beta * 25;
|
||||||
|
|
||||||
view.setCenter(view.constrainCenter(center));
|
view.setCenter(view.constrainCenter(center));
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
layout: example.html
|
layout: example.html
|
||||||
title: Drag-and-Drop Image Vector
|
title: Drag-and-Drop Image Vector
|
||||||
shortdesc: Example of using the drag-and-drop interaction with image vector rendering.
|
shortdesc: Example of using the drag-and-drop interaction with a ol.source.ImageVector.
|
||||||
docs: >
|
docs: >
|
||||||
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.
|
Example of using the drag-and-drop interaction with a ol.source.ImageVector. 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"
|
tags: "drag-and-drop-image-vector, gpx, geojson, igc, kml, topojson, vector, image"
|
||||||
cloak:
|
cloak:
|
||||||
As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5: Your Bing Maps Key from http://www.bingmapsportal.com/ here
|
As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5: Your Bing Maps Key from http://www.bingmapsportal.com/ here
|
||||||
|
|||||||
@@ -1,81 +1,82 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import GPX from '../src/ol/format/GPX.js';
|
goog.require('ol.format.GPX');
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
goog.require('ol.format.GeoJSON');
|
||||||
import IGC from '../src/ol/format/IGC.js';
|
goog.require('ol.format.IGC');
|
||||||
import KML from '../src/ol/format/KML.js';
|
goog.require('ol.format.KML');
|
||||||
import TopoJSON from '../src/ol/format/TopoJSON.js';
|
goog.require('ol.format.TopoJSON');
|
||||||
import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
goog.require('ol.interaction');
|
||||||
import DragAndDrop from '../src/ol/interaction/DragAndDrop.js';
|
goog.require('ol.interaction.DragAndDrop');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Image');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
goog.require('ol.source.BingMaps');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.ImageVector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.source.Vector');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Circle');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Fill');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Stroke');
|
||||||
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
const defaultStyle = {
|
var defaultStyle = {
|
||||||
'Point': new Style({
|
'Point': new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255,255,0,0.5)'
|
color: 'rgba(255,255,0,0.5)'
|
||||||
}),
|
}),
|
||||||
radius: 5,
|
radius: 5,
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#ff0',
|
color: '#ff0',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'LineString': new Style({
|
'LineString': new ol.style.Style({
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#f00',
|
color: '#f00',
|
||||||
width: 3
|
width: 3
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'Polygon': new Style({
|
'Polygon': new ol.style.Style({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,255,255,0.5)'
|
color: 'rgba(0,255,255,0.5)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#0ff',
|
color: '#0ff',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'MultiPoint': new Style({
|
'MultiPoint': new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255,0,255,0.5)'
|
color: 'rgba(255,0,255,0.5)'
|
||||||
}),
|
}),
|
||||||
radius: 5,
|
radius: 5,
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#f0f',
|
color: '#f0f',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'MultiLineString': new Style({
|
'MultiLineString': new ol.style.Style({
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#0f0',
|
color: '#0f0',
|
||||||
width: 3
|
width: 3
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'MultiPolygon': new Style({
|
'MultiPolygon': new ol.style.Style({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,0,255,0.5)'
|
color: 'rgba(0,0,255,0.5)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#00f',
|
color: '#00f',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
const styleFunction = function(feature, resolution) {
|
var styleFunction = function(feature, resolution) {
|
||||||
const featureStyleFunction = feature.getStyleFunction();
|
var featureStyleFunction = feature.getStyleFunction();
|
||||||
if (featureStyleFunction) {
|
if (featureStyleFunction) {
|
||||||
return featureStyleFunction.call(feature, resolution);
|
return featureStyleFunction.call(feature, resolution);
|
||||||
} else {
|
} else {
|
||||||
@@ -83,53 +84,54 @@ const styleFunction = function(feature, resolution) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const dragAndDropInteraction = new DragAndDrop({
|
var dragAndDropInteraction = new ol.interaction.DragAndDrop({
|
||||||
formatConstructors: [
|
formatConstructors: [
|
||||||
GPX,
|
ol.format.GPX,
|
||||||
GeoJSON,
|
ol.format.GeoJSON,
|
||||||
IGC,
|
ol.format.IGC,
|
||||||
KML,
|
ol.format.KML,
|
||||||
TopoJSON
|
ol.format.TopoJSON
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
interactions: defaultInteractions().extend([dragAndDropInteraction]),
|
interactions: ol.interaction.defaults().extend([dragAndDropInteraction]),
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new BingMaps({
|
source: new ol.source.BingMaps({
|
||||||
imagerySet: 'Aerial',
|
imagerySet: 'Aerial',
|
||||||
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
dragAndDropInteraction.on('addfeatures', function(event) {
|
dragAndDropInteraction.on('addfeatures', function(event) {
|
||||||
const vectorSource = new VectorSource({
|
var vectorSource = new ol.source.Vector({
|
||||||
features: event.features
|
features: event.features
|
||||||
});
|
});
|
||||||
map.addLayer(new VectorLayer({
|
map.addLayer(new ol.layer.Image({
|
||||||
renderMode: 'image',
|
source: new ol.source.ImageVector({
|
||||||
source: vectorSource,
|
source: vectorSource,
|
||||||
style: styleFunction
|
style: styleFunction
|
||||||
|
})
|
||||||
}));
|
}));
|
||||||
map.getView().fit(vectorSource.getExtent());
|
map.getView().fit(vectorSource.getExtent());
|
||||||
});
|
});
|
||||||
|
|
||||||
const displayFeatureInfo = function(pixel) {
|
var displayFeatureInfo = function(pixel) {
|
||||||
const features = [];
|
var features = [];
|
||||||
map.forEachFeatureAtPixel(pixel, function(feature) {
|
map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||||
features.push(feature);
|
features.push(feature);
|
||||||
});
|
});
|
||||||
if (features.length > 0) {
|
if (features.length > 0) {
|
||||||
const info = [];
|
var info = [];
|
||||||
let i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||||
info.push(features[i].get('name'));
|
info.push(features[i].get('name'));
|
||||||
}
|
}
|
||||||
@@ -143,7 +145,7 @@ map.on('pointermove', function(evt) {
|
|||||||
if (evt.dragging) {
|
if (evt.dragging) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pixel = map.getEventPixel(evt.originalEvent);
|
var pixel = map.getEventPixel(evt.originalEvent);
|
||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,81 +1,81 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import GPX from '../src/ol/format/GPX.js';
|
goog.require('ol.format.GPX');
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
goog.require('ol.format.GeoJSON');
|
||||||
import IGC from '../src/ol/format/IGC.js';
|
goog.require('ol.format.IGC');
|
||||||
import KML from '../src/ol/format/KML.js';
|
goog.require('ol.format.KML');
|
||||||
import TopoJSON from '../src/ol/format/TopoJSON.js';
|
goog.require('ol.format.TopoJSON');
|
||||||
import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
goog.require('ol.interaction');
|
||||||
import DragAndDrop from '../src/ol/interaction/DragAndDrop.js';
|
goog.require('ol.interaction.DragAndDrop');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
goog.require('ol.source.BingMaps');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
const defaultStyle = {
|
var defaultStyle = {
|
||||||
'Point': new Style({
|
'Point': new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255,255,0,0.5)'
|
color: 'rgba(255,255,0,0.5)'
|
||||||
}),
|
}),
|
||||||
radius: 5,
|
radius: 5,
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#ff0',
|
color: '#ff0',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'LineString': new Style({
|
'LineString': new ol.style.Style({
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#f00',
|
color: '#f00',
|
||||||
width: 3
|
width: 3
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'Polygon': new Style({
|
'Polygon': new ol.style.Style({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,255,255,0.5)'
|
color: 'rgba(0,255,255,0.5)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#0ff',
|
color: '#0ff',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'MultiPoint': new Style({
|
'MultiPoint': new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(255,0,255,0.5)'
|
color: 'rgba(255,0,255,0.5)'
|
||||||
}),
|
}),
|
||||||
radius: 5,
|
radius: 5,
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#f0f',
|
color: '#f0f',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'MultiLineString': new Style({
|
'MultiLineString': new ol.style.Style({
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#0f0',
|
color: '#0f0',
|
||||||
width: 3
|
width: 3
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'MultiPolygon': new Style({
|
'MultiPolygon': new ol.style.Style({
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: 'rgba(0,0,255,0.5)'
|
color: 'rgba(0,0,255,0.5)'
|
||||||
}),
|
}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: '#00f',
|
color: '#00f',
|
||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
const styleFunction = function(feature, resolution) {
|
var styleFunction = function(feature, resolution) {
|
||||||
const featureStyleFunction = feature.getStyleFunction();
|
var featureStyleFunction = feature.getStyleFunction();
|
||||||
if (featureStyleFunction) {
|
if (featureStyleFunction) {
|
||||||
return featureStyleFunction.call(feature, resolution);
|
return featureStyleFunction.call(feature, resolution);
|
||||||
} else {
|
} else {
|
||||||
@@ -83,52 +83,52 @@ const styleFunction = function(feature, resolution) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const dragAndDropInteraction = new DragAndDrop({
|
var dragAndDropInteraction = new ol.interaction.DragAndDrop({
|
||||||
formatConstructors: [
|
formatConstructors: [
|
||||||
GPX,
|
ol.format.GPX,
|
||||||
GeoJSON,
|
ol.format.GeoJSON,
|
||||||
IGC,
|
ol.format.IGC,
|
||||||
KML,
|
ol.format.KML,
|
||||||
TopoJSON
|
ol.format.TopoJSON
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
interactions: defaultInteractions().extend([dragAndDropInteraction]),
|
interactions: ol.interaction.defaults().extend([dragAndDropInteraction]),
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new BingMaps({
|
source: new ol.source.BingMaps({
|
||||||
imagerySet: 'Aerial',
|
imagerySet: 'Aerial',
|
||||||
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
dragAndDropInteraction.on('addfeatures', function(event) {
|
dragAndDropInteraction.on('addfeatures', function(event) {
|
||||||
const vectorSource = new VectorSource({
|
var vectorSource = new ol.source.Vector({
|
||||||
features: event.features
|
features: event.features
|
||||||
});
|
});
|
||||||
map.addLayer(new VectorLayer({
|
map.addLayer(new ol.layer.Vector({
|
||||||
source: vectorSource,
|
source: vectorSource,
|
||||||
style: styleFunction
|
style: styleFunction
|
||||||
}));
|
}));
|
||||||
map.getView().fit(vectorSource.getExtent());
|
map.getView().fit(vectorSource.getExtent());
|
||||||
});
|
});
|
||||||
|
|
||||||
const displayFeatureInfo = function(pixel) {
|
var displayFeatureInfo = function(pixel) {
|
||||||
const features = [];
|
var features = [];
|
||||||
map.forEachFeatureAtPixel(pixel, function(feature) {
|
map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||||
features.push(feature);
|
features.push(feature);
|
||||||
});
|
});
|
||||||
if (features.length > 0) {
|
if (features.length > 0) {
|
||||||
const info = [];
|
var info = [];
|
||||||
let i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||||
info.push(features[i].get('name'));
|
info.push(features[i].get('name'));
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ map.on('pointermove', function(evt) {
|
|||||||
if (evt.dragging) {
|
if (evt.dragging) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pixel = map.getEventPixel(evt.originalEvent);
|
var pixel = map.getEventPixel(evt.originalEvent);
|
||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
goog.require('ol.interaction');
|
||||||
import DragRotateAndZoom from '../src/ol/interaction/DragRotateAndZoom.js';
|
goog.require('ol.interaction.DragRotateAndZoom');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
interactions: defaultInteractions().extend([
|
interactions: ol.interaction.defaults().extend([
|
||||||
new DragRotateAndZoom()
|
new ol.interaction.DragRotateAndZoom()
|
||||||
]),
|
]),
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,74 +1,82 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Collection');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.Map');
|
||||||
import Draw from '../src/ol/interaction/Draw.js';
|
goog.require('ol.View');
|
||||||
import Modify from '../src/ol/interaction/Modify.js';
|
goog.require('ol.events.condition');
|
||||||
import Snap from '../src/ol/interaction/Snap.js';
|
goog.require('ol.interaction.Draw');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.interaction.Modify');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.layer.Vector');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.OSM');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.source.Vector');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Circle');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Fill');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Stroke');
|
||||||
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
|
|
||||||
const source = new VectorSource();
|
var map = new ol.Map({
|
||||||
const vector = new VectorLayer({
|
layers: [raster],
|
||||||
source: source,
|
|
||||||
style: new Style({
|
|
||||||
fill: new Fill({
|
|
||||||
color: 'rgba(255, 255, 255, 0.2)'
|
|
||||||
}),
|
|
||||||
stroke: new Stroke({
|
|
||||||
color: '#ffcc33',
|
|
||||||
width: 2
|
|
||||||
}),
|
|
||||||
image: new CircleStyle({
|
|
||||||
radius: 7,
|
|
||||||
fill: new Fill({
|
|
||||||
color: '#ffcc33'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const map = new Map({
|
|
||||||
layers: [raster, vector],
|
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-11000000, 4600000],
|
center: [-11000000, 4600000],
|
||||||
zoom: 4
|
zoom: 4
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const modify = new Modify({source: source});
|
var features = new ol.Collection();
|
||||||
|
var featureOverlay = new ol.layer.Vector({
|
||||||
|
source: new ol.source.Vector({features: features}),
|
||||||
|
style: new ol.style.Style({
|
||||||
|
fill: new ol.style.Fill({
|
||||||
|
color: 'rgba(255, 255, 255, 0.2)'
|
||||||
|
}),
|
||||||
|
stroke: new ol.style.Stroke({
|
||||||
|
color: '#ffcc33',
|
||||||
|
width: 2
|
||||||
|
}),
|
||||||
|
image: new ol.style.Circle({
|
||||||
|
radius: 7,
|
||||||
|
fill: new ol.style.Fill({
|
||||||
|
color: '#ffcc33'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
featureOverlay.setMap(map);
|
||||||
|
|
||||||
|
var modify = new ol.interaction.Modify({
|
||||||
|
features: features,
|
||||||
|
// the SHIFT key must be pressed to delete vertices, so
|
||||||
|
// that new vertices can be drawn at the same position
|
||||||
|
// of existing vertices
|
||||||
|
deleteCondition: function(event) {
|
||||||
|
return ol.events.condition.shiftKeyOnly(event) &&
|
||||||
|
ol.events.condition.singleClick(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
map.addInteraction(modify);
|
map.addInteraction(modify);
|
||||||
|
|
||||||
let draw, snap; // global so we can remove them later
|
var draw; // global so we can remove it later
|
||||||
const typeSelect = document.getElementById('type');
|
var typeSelect = document.getElementById('type');
|
||||||
|
|
||||||
function addInteractions() {
|
function addInteraction() {
|
||||||
draw = new Draw({
|
draw = new ol.interaction.Draw({
|
||||||
source: source,
|
features: features,
|
||||||
type: typeSelect.value
|
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
|
||||||
});
|
});
|
||||||
map.addInteraction(draw);
|
map.addInteraction(draw);
|
||||||
snap = new Snap({source: source});
|
|
||||||
map.addInteraction(snap);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle change event.
|
* Handle change event.
|
||||||
*/
|
*/
|
||||||
typeSelect.onchange = function() {
|
typeSelect.onchange = function() {
|
||||||
map.removeInteraction(draw);
|
map.removeInteraction(draw);
|
||||||
map.removeInteraction(snap);
|
addInteraction();
|
||||||
addInteractions();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
addInteractions();
|
addInteraction();
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import Draw from '../src/ol/interaction/Draw.js';
|
goog.require('ol.interaction.Draw');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
|
|
||||||
const source = new VectorSource({wrapX: false});
|
var source = new ol.source.Vector({wrapX: false});
|
||||||
|
|
||||||
const vector = new VectorLayer({
|
var vector = new ol.layer.Vector({
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-11000000, 4600000],
|
center: [-11000000, 4600000],
|
||||||
zoom: 4
|
zoom: 4
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const typeSelect = document.getElementById('type');
|
var typeSelect = document.getElementById('type');
|
||||||
|
|
||||||
let draw; // global so we can remove it later
|
var draw; // global so we can remove it later
|
||||||
function addInteraction() {
|
function addInteraction() {
|
||||||
const value = typeSelect.value;
|
var value = typeSelect.value;
|
||||||
if (value !== 'None') {
|
if (value !== 'None') {
|
||||||
draw = new Draw({
|
draw = new ol.interaction.Draw({
|
||||||
source: source,
|
source: source,
|
||||||
type: typeSelect.value
|
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
|
||||||
});
|
});
|
||||||
map.addInteraction(draw);
|
map.addInteraction(draw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import Draw from '../src/ol/interaction/Draw.js';
|
goog.require('ol.interaction.Draw');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
|
|
||||||
const source = new VectorSource({wrapX: false});
|
var source = new ol.source.Vector({wrapX: false});
|
||||||
|
|
||||||
const vector = new VectorLayer({
|
var vector = new ol.layer.Vector({
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-11000000, 4600000],
|
center: [-11000000, 4600000],
|
||||||
zoom: 4
|
zoom: 4
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const typeSelect = document.getElementById('type');
|
var typeSelect = document.getElementById('type');
|
||||||
|
|
||||||
let draw; // global so we can remove it later
|
var draw; // global so we can remove it later
|
||||||
function addInteraction() {
|
function addInteraction() {
|
||||||
const value = typeSelect.value;
|
var value = typeSelect.value;
|
||||||
if (value !== 'None') {
|
if (value !== 'None') {
|
||||||
draw = new Draw({
|
draw = new ol.interaction.Draw({
|
||||||
source: source,
|
source: source,
|
||||||
type: typeSelect.value,
|
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value),
|
||||||
freehand: true
|
freehand: true
|
||||||
});
|
});
|
||||||
map.addInteraction(draw);
|
map.addInteraction(draw);
|
||||||
|
|||||||
@@ -1,63 +1,63 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import Polygon from '../src/ol/geom/Polygon.js';
|
goog.require('ol.geom.Polygon');
|
||||||
import Draw, {createRegularPolygon, createBox} from '../src/ol/interaction/Draw.js';
|
goog.require('ol.interaction.Draw');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
|
|
||||||
const source = new VectorSource({wrapX: false});
|
var source = new ol.source.Vector({wrapX: false});
|
||||||
|
|
||||||
const vector = new VectorLayer({
|
var vector = new ol.layer.Vector({
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [-11000000, 4600000],
|
center: [-11000000, 4600000],
|
||||||
zoom: 4
|
zoom: 4
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const typeSelect = document.getElementById('type');
|
var typeSelect = document.getElementById('type');
|
||||||
|
|
||||||
let draw; // global so we can remove it later
|
var draw; // global so we can remove it later
|
||||||
function addInteraction() {
|
function addInteraction() {
|
||||||
let value = typeSelect.value;
|
var value = typeSelect.value;
|
||||||
if (value !== 'None') {
|
if (value !== 'None') {
|
||||||
let geometryFunction;
|
var geometryFunction;
|
||||||
if (value === 'Square') {
|
if (value === 'Square') {
|
||||||
value = 'Circle';
|
value = 'Circle';
|
||||||
geometryFunction = createRegularPolygon(4);
|
geometryFunction = ol.interaction.Draw.createRegularPolygon(4);
|
||||||
} else if (value === 'Box') {
|
} else if (value === 'Box') {
|
||||||
value = 'Circle';
|
value = 'Circle';
|
||||||
geometryFunction = createBox();
|
geometryFunction = ol.interaction.Draw.createBox();
|
||||||
} else if (value === 'Star') {
|
} else if (value === 'Star') {
|
||||||
value = 'Circle';
|
value = 'Circle';
|
||||||
geometryFunction = function(coordinates, geometry) {
|
geometryFunction = function(coordinates, geometry) {
|
||||||
if (!geometry) {
|
if (!geometry) {
|
||||||
geometry = new Polygon(null);
|
geometry = new ol.geom.Polygon(null);
|
||||||
}
|
}
|
||||||
const center = coordinates[0];
|
var center = coordinates[0];
|
||||||
const last = coordinates[1];
|
var last = coordinates[1];
|
||||||
const dx = center[0] - last[0];
|
var dx = center[0] - last[0];
|
||||||
const dy = center[1] - last[1];
|
var dy = center[1] - last[1];
|
||||||
const radius = Math.sqrt(dx * dx + dy * dy);
|
var radius = Math.sqrt(dx * dx + dy * dy);
|
||||||
const rotation = Math.atan2(dy, dx);
|
var rotation = Math.atan2(dy, dx);
|
||||||
const newCoordinates = [];
|
var newCoordinates = [];
|
||||||
const numPoints = 12;
|
var numPoints = 12;
|
||||||
for (let i = 0; i < numPoints; ++i) {
|
for (var i = 0; i < numPoints; ++i) {
|
||||||
const angle = rotation + i * 2 * Math.PI / numPoints;
|
var angle = rotation + i * 2 * Math.PI / numPoints;
|
||||||
const fraction = i % 2 === 0 ? 1 : 0.5;
|
var fraction = i % 2 === 0 ? 1 : 0.5;
|
||||||
const offsetX = radius * fraction * Math.cos(angle);
|
var offsetX = radius * fraction * Math.cos(angle);
|
||||||
const offsetY = radius * fraction * Math.sin(angle);
|
var offsetY = radius * fraction * Math.sin(angle);
|
||||||
newCoordinates.push([center[0] + offsetX, center[1] + offsetY]);
|
newCoordinates.push([center[0] + offsetX, center[1] + offsetY]);
|
||||||
}
|
}
|
||||||
newCoordinates.push(newCoordinates[0].slice());
|
newCoordinates.push(newCoordinates[0].slice());
|
||||||
@@ -65,9 +65,9 @@ function addInteraction() {
|
|||||||
return geometry;
|
return geometry;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
draw = new Draw({
|
draw = new ol.interaction.Draw({
|
||||||
source: source,
|
source: source,
|
||||||
type: value,
|
type: /** @type {ol.geom.GeometryType} */ (value),
|
||||||
geometryFunction: geometryFunction
|
geometryFunction: geometryFunction
|
||||||
});
|
});
|
||||||
map.addInteraction(draw);
|
map.addInteraction(draw);
|
||||||
|
|||||||
@@ -1,74 +1,74 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import MultiPoint from '../src/ol/geom/MultiPoint.js';
|
goog.require('ol.geom.MultiPoint');
|
||||||
import Point from '../src/ol/geom/Point.js';
|
goog.require('ol.geom.Point');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const imageStyle = new Style({
|
var imageStyle = new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: 5,
|
radius: 5,
|
||||||
snapToPixel: false,
|
snapToPixel: false,
|
||||||
fill: new Fill({color: 'yellow'}),
|
fill: new ol.style.Fill({color: 'yellow'}),
|
||||||
stroke: new Stroke({color: 'red', width: 1})
|
stroke: new ol.style.Stroke({color: 'red', width: 1})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const headInnerImageStyle = new Style({
|
var headInnerImageStyle = new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: 2,
|
radius: 2,
|
||||||
snapToPixel: false,
|
snapToPixel: false,
|
||||||
fill: new Fill({color: 'blue'})
|
fill: new ol.style.Fill({color: 'blue'})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const headOuterImageStyle = new Style({
|
var headOuterImageStyle = new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: 5,
|
radius: 5,
|
||||||
snapToPixel: false,
|
snapToPixel: false,
|
||||||
fill: new Fill({color: 'black'})
|
fill: new ol.style.Fill({color: 'black'})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const n = 200;
|
var n = 200;
|
||||||
const omegaTheta = 30000; // Rotation period in ms
|
var omegaTheta = 30000; // Rotation period in ms
|
||||||
const R = 7e6;
|
var R = 7e6;
|
||||||
const r = 2e6;
|
var r = 2e6;
|
||||||
const p = 2e6;
|
var p = 2e6;
|
||||||
map.on('postcompose', function(event) {
|
map.on('postcompose', function(event) {
|
||||||
const vectorContext = event.vectorContext;
|
var vectorContext = event.vectorContext;
|
||||||
const frameState = event.frameState;
|
var frameState = event.frameState;
|
||||||
const theta = 2 * Math.PI * frameState.time / omegaTheta;
|
var theta = 2 * Math.PI * frameState.time / omegaTheta;
|
||||||
const coordinates = [];
|
var coordinates = [];
|
||||||
let i;
|
var i;
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
const t = theta + 2 * Math.PI * i / n;
|
var t = theta + 2 * Math.PI * i / n;
|
||||||
const x = (R + r) * Math.cos(t) + p * Math.cos((R + r) * t / r);
|
var x = (R + r) * Math.cos(t) + p * Math.cos((R + r) * t / r);
|
||||||
const y = (R + r) * Math.sin(t) + p * Math.sin((R + r) * t / r);
|
var y = (R + r) * Math.sin(t) + p * Math.sin((R + r) * t / r);
|
||||||
coordinates.push([x, y]);
|
coordinates.push([x, y]);
|
||||||
}
|
}
|
||||||
vectorContext.setStyle(imageStyle);
|
vectorContext.setStyle(imageStyle);
|
||||||
vectorContext.drawGeometry(new MultiPoint(coordinates));
|
vectorContext.drawGeometry(new ol.geom.MultiPoint(coordinates));
|
||||||
|
|
||||||
const headPoint = new Point(coordinates[coordinates.length - 1]);
|
var headPoint = new ol.geom.Point(coordinates[coordinates.length - 1]);
|
||||||
|
|
||||||
vectorContext.setStyle(headOuterImageStyle);
|
vectorContext.setStyle(headOuterImageStyle);
|
||||||
vectorContext.drawGeometry(headPoint);
|
vectorContext.drawGeometry(headPoint);
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {createEmpty, getWidth, getHeight, extend} from '../src/ol/extent.js';
|
goog.require('ol.extent');
|
||||||
import KML from '../src/ol/format/KML.js';
|
goog.require('ol.format.KML');
|
||||||
import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
goog.require('ol.interaction');
|
||||||
import Select from '../src/ol/interaction/Select.js';
|
goog.require('ol.interaction.Select');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import Cluster from '../src/ol/source/Cluster.js';
|
goog.require('ol.source.Cluster');
|
||||||
import Stamen from '../src/ol/source/Stamen.js';
|
goog.require('ol.source.Stamen');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import RegularShape from '../src/ol/style/RegularShape.js';
|
goog.require('ol.style.RegularShape');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
import Text from '../src/ol/style/Text.js';
|
goog.require('ol.style.Text');
|
||||||
|
|
||||||
|
|
||||||
const earthquakeFill = new Fill({
|
var earthquakeFill = new ol.style.Fill({
|
||||||
color: 'rgba(255, 153, 0, 0.8)'
|
color: 'rgba(255, 153, 0, 0.8)'
|
||||||
});
|
});
|
||||||
const earthquakeStroke = new Stroke({
|
var earthquakeStroke = new ol.style.Stroke({
|
||||||
color: 'rgba(255, 204, 0, 0.2)',
|
color: 'rgba(255, 204, 0, 0.2)',
|
||||||
width: 1
|
width: 1
|
||||||
});
|
});
|
||||||
const textFill = new Fill({
|
var textFill = new ol.style.Fill({
|
||||||
color: '#fff'
|
color: '#fff'
|
||||||
});
|
});
|
||||||
const textStroke = new Stroke({
|
var textStroke = new ol.style.Stroke({
|
||||||
color: 'rgba(0, 0, 0, 0.6)',
|
color: 'rgba(0, 0, 0, 0.6)',
|
||||||
width: 3
|
width: 3
|
||||||
});
|
});
|
||||||
const invisibleFill = new Fill({
|
var invisibleFill = new ol.style.Fill({
|
||||||
color: 'rgba(255, 255, 255, 0.01)'
|
color: 'rgba(255, 255, 255, 0.01)'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -39,13 +39,13 @@ function createEarthquakeStyle(feature) {
|
|||||||
// 2012_Earthquakes_Mag5.kml stores the magnitude of each earthquake in a
|
// 2012_Earthquakes_Mag5.kml stores the magnitude of each earthquake in a
|
||||||
// standards-violating <magnitude> tag in each Placemark. We extract it
|
// standards-violating <magnitude> tag in each Placemark. We extract it
|
||||||
// from the Placemark's name instead.
|
// from the Placemark's name instead.
|
||||||
const name = feature.get('name');
|
var name = feature.get('name');
|
||||||
const magnitude = parseFloat(name.substr(2));
|
var magnitude = parseFloat(name.substr(2));
|
||||||
const radius = 5 + 20 * (magnitude - 5);
|
var radius = 5 + 20 * (magnitude - 5);
|
||||||
|
|
||||||
return new Style({
|
return new ol.style.Style({
|
||||||
geometry: feature.getGeometry(),
|
geometry: feature.getGeometry(),
|
||||||
image: new RegularShape({
|
image: new ol.style.RegularShape({
|
||||||
radius1: radius,
|
radius1: radius,
|
||||||
radius2: 3,
|
radius2: 3,
|
||||||
points: 5,
|
points: 5,
|
||||||
@@ -56,78 +56,77 @@ function createEarthquakeStyle(feature) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let maxFeatureCount;
|
var maxFeatureCount, vector;
|
||||||
let vector = null;
|
function calculateClusterInfo(resolution) {
|
||||||
const calculateClusterInfo = function(resolution) {
|
|
||||||
maxFeatureCount = 0;
|
maxFeatureCount = 0;
|
||||||
const features = vector.getSource().getFeatures();
|
var features = vector.getSource().getFeatures();
|
||||||
let feature, radius;
|
var feature, radius;
|
||||||
for (let i = features.length - 1; i >= 0; --i) {
|
for (var i = features.length - 1; i >= 0; --i) {
|
||||||
feature = features[i];
|
feature = features[i];
|
||||||
const originalFeatures = feature.get('features');
|
var originalFeatures = feature.get('features');
|
||||||
const extent = createEmpty();
|
var extent = ol.extent.createEmpty();
|
||||||
let j, jj;
|
var j, jj;
|
||||||
for (j = 0, jj = originalFeatures.length; j < jj; ++j) {
|
for (j = 0, jj = originalFeatures.length; j < jj; ++j) {
|
||||||
extend(extent, originalFeatures[j].getGeometry().getExtent());
|
ol.extent.extend(extent, originalFeatures[j].getGeometry().getExtent());
|
||||||
}
|
}
|
||||||
maxFeatureCount = Math.max(maxFeatureCount, jj);
|
maxFeatureCount = Math.max(maxFeatureCount, jj);
|
||||||
radius = 0.25 * (getWidth(extent) + getHeight(extent)) /
|
radius = 0.25 * (ol.extent.getWidth(extent) + ol.extent.getHeight(extent)) /
|
||||||
resolution;
|
resolution;
|
||||||
feature.set('radius', radius);
|
feature.set('radius', radius);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
let currentResolution;
|
var currentResolution;
|
||||||
function styleFunction(feature, resolution) {
|
function styleFunction(feature, resolution) {
|
||||||
if (resolution != currentResolution) {
|
if (resolution != currentResolution) {
|
||||||
calculateClusterInfo(resolution);
|
calculateClusterInfo(resolution);
|
||||||
currentResolution = resolution;
|
currentResolution = resolution;
|
||||||
}
|
}
|
||||||
let style;
|
var style;
|
||||||
const size = feature.get('features').length;
|
var size = feature.get('features').length;
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
style = new Style({
|
style = new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: feature.get('radius'),
|
radius: feature.get('radius'),
|
||||||
fill: new Fill({
|
fill: new ol.style.Fill({
|
||||||
color: [255, 153, 0, Math.min(0.8, 0.4 + (size / maxFeatureCount))]
|
color: [255, 153, 0, Math.min(0.8, 0.4 + (size / maxFeatureCount))]
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
text: new Text({
|
text: new ol.style.Text({
|
||||||
text: size.toString(),
|
text: size.toString(),
|
||||||
fill: textFill,
|
fill: textFill,
|
||||||
stroke: textStroke
|
stroke: textStroke
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const originalFeature = feature.get('features')[0];
|
var originalFeature = feature.get('features')[0];
|
||||||
style = createEarthquakeStyle(originalFeature);
|
style = createEarthquakeStyle(originalFeature);
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectStyleFunction(feature) {
|
function selectStyleFunction(feature) {
|
||||||
const styles = [new Style({
|
var styles = [new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: feature.get('radius'),
|
radius: feature.get('radius'),
|
||||||
fill: invisibleFill
|
fill: invisibleFill
|
||||||
})
|
})
|
||||||
})];
|
})];
|
||||||
const originalFeatures = feature.get('features');
|
var originalFeatures = feature.get('features');
|
||||||
let originalFeature;
|
var originalFeature;
|
||||||
for (let i = originalFeatures.length - 1; i >= 0; --i) {
|
for (var i = originalFeatures.length - 1; i >= 0; --i) {
|
||||||
originalFeature = originalFeatures[i];
|
originalFeature = originalFeatures[i];
|
||||||
styles.push(createEarthquakeStyle(originalFeature));
|
styles.push(createEarthquakeStyle(originalFeature));
|
||||||
}
|
}
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector = new VectorLayer({
|
vector = new ol.layer.Vector({
|
||||||
source: new Cluster({
|
source: new ol.source.Cluster({
|
||||||
distance: 40,
|
distance: 40,
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
url: 'data/kml/2012_Earthquakes_Mag5.kml',
|
url: 'data/kml/2012_Earthquakes_Mag5.kml',
|
||||||
format: new KML({
|
format: new ol.format.KML({
|
||||||
extractStyles: false
|
extractStyles: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -135,23 +134,23 @@ vector = new VectorLayer({
|
|||||||
style: styleFunction
|
style: styleFunction
|
||||||
});
|
});
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new Stamen({
|
source: new ol.source.Stamen({
|
||||||
layer: 'toner'
|
layer: 'toner'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
interactions: defaultInteractions().extend([new Select({
|
interactions: ol.interaction.defaults().extend([new ol.interaction.Select({
|
||||||
condition: function(evt) {
|
condition: function(evt) {
|
||||||
return evt.type == 'pointermove' ||
|
return evt.originalEvent.type == 'mousemove' ||
|
||||||
evt.type == 'singleclick';
|
evt.type == 'singleclick';
|
||||||
},
|
},
|
||||||
style: selectStyleFunction
|
style: selectStyleFunction
|
||||||
})]),
|
})]),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,46 +1,47 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import KML from '../src/ol/format/KML.js';
|
goog.require('ol.format.KML');
|
||||||
import Polygon from '../src/ol/geom/Polygon.js';
|
goog.require('ol.geom.Polygon');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import {toContext} from '../src/ol/render.js';
|
goog.require('ol.render');
|
||||||
import Stamen from '../src/ol/source/Stamen.js';
|
goog.require('ol.source.Stamen');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Icon from '../src/ol/style/Icon.js';
|
goog.require('ol.style.Icon');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
const symbol = [[0, 0], [4, 2], [6, 0], [10, 5], [6, 3], [4, 5], [0, 0]];
|
var symbol = [[0, 0], [4, 2], [6, 0], [10, 5], [6, 3], [4, 5], [0, 0]];
|
||||||
let scale;
|
var scale;
|
||||||
const scaleFunction = function(coordinate) {
|
var scaleFunction = function(coordinate) {
|
||||||
return [coordinate[0] * scale, coordinate[1] * scale];
|
return [coordinate[0] * scale, coordinate[1] * scale];
|
||||||
};
|
};
|
||||||
|
|
||||||
const styleCache = {};
|
var styleCache = {};
|
||||||
const styleFunction = function(feature) {
|
var styleFunction = function(feature) {
|
||||||
// 2012_Earthquakes_Mag5.kml stores the magnitude of each earthquake in a
|
// 2012_Earthquakes_Mag5.kml stores the magnitude of each earthquake in a
|
||||||
// standards-violating <magnitude> tag in each Placemark. We extract it from
|
// standards-violating <magnitude> tag in each Placemark. We extract it from
|
||||||
// the Placemark's name instead.
|
// the Placemark's name instead.
|
||||||
const name = feature.get('name');
|
var name = feature.get('name');
|
||||||
const magnitude = parseFloat(name.substr(2));
|
var magnitude = parseFloat(name.substr(2));
|
||||||
const size = parseInt(10 + 40 * (magnitude - 5), 10);
|
var size = parseInt(10 + 40 * (magnitude - 5), 10);
|
||||||
scale = size / 10;
|
scale = size / 10;
|
||||||
let style = styleCache[size];
|
var style = styleCache[size];
|
||||||
if (!style) {
|
if (!style) {
|
||||||
const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('canvas'));
|
var canvas =
|
||||||
const vectorContext = toContext(
|
/** @type {HTMLCanvasElement} */ (document.createElement('canvas'));
|
||||||
|
var vectorContext = ol.render.toContext(
|
||||||
/** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')),
|
/** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')),
|
||||||
{size: [size, size], pixelRatio: 1});
|
{size: [size, size], pixelRatio: 1});
|
||||||
vectorContext.setStyle(new Style({
|
vectorContext.setStyle(new ol.style.Style({
|
||||||
fill: new Fill({color: 'rgba(255, 153, 0, 0.4)'}),
|
fill: new ol.style.Fill({color: 'rgba(255, 153, 0, 0.4)'}),
|
||||||
stroke: new Stroke({color: 'rgba(255, 204, 0, 0.2)', width: 2})
|
stroke: new ol.style.Stroke({color: 'rgba(255, 204, 0, 0.2)', width: 2})
|
||||||
}));
|
}));
|
||||||
vectorContext.drawGeometry(new Polygon([symbol.map(scaleFunction)]));
|
vectorContext.drawGeometry(new ol.geom.Polygon([symbol.map(scaleFunction)]));
|
||||||
style = new Style({
|
style = new ol.style.Style({
|
||||||
image: new Icon({
|
image: new ol.style.Icon({
|
||||||
img: canvas,
|
img: canvas,
|
||||||
imgSize: [size, size],
|
imgSize: [size, size],
|
||||||
rotation: 1.2
|
rotation: 1.2
|
||||||
@@ -51,26 +52,26 @@ const styleFunction = function(feature) {
|
|||||||
return style;
|
return style;
|
||||||
};
|
};
|
||||||
|
|
||||||
const vector = new VectorLayer({
|
var vector = new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
url: 'data/kml/2012_Earthquakes_Mag5.kml',
|
url: 'data/kml/2012_Earthquakes_Mag5.kml',
|
||||||
format: new KML({
|
format: new ol.format.KML({
|
||||||
extractStyles: false
|
extractStyles: false
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
style: styleFunction
|
style: styleFunction
|
||||||
});
|
});
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new Stamen({
|
source: new ol.source.Stamen({
|
||||||
layer: 'toner'
|
layer: 'toner'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import ScaleLine from '../src/ol/control/ScaleLine.js';
|
goog.require('ol.control.ScaleLine');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import TileWMS from '../src/ol/source/TileWMS.js';
|
goog.require('ol.source.TileWMS');
|
||||||
|
|
||||||
|
|
||||||
const layers = [
|
var layers = [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new TileWMS({
|
source: new ol.source.TileWMS({
|
||||||
url: 'https://ahocevar.com/geoserver/wms',
|
url: 'https://ahocevar.com/geoserver/wms',
|
||||||
params: {
|
params: {
|
||||||
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
|
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',
|
||||||
@@ -18,15 +18,15 @@ const layers = [
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
controls: defaultControls().extend([
|
controls: ol.control.defaults().extend([
|
||||||
new ScaleLine({
|
new ol.control.ScaleLine({
|
||||||
units: 'degrees'
|
units: 'degrees'
|
||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
layers: layers,
|
layers: layers,
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
projection: 'EPSG:4326',
|
projection: 'EPSG:4326',
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
// NOCOMPILE
|
// NOCOMPILE
|
||||||
// this example uses FileSaver.js for which we don't have an externs file.
|
// this example uses FileSaver.js for which we don't have an externs file.
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
goog.require('ol.format.GeoJSON');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
}),
|
}),
|
||||||
new VectorLayer({
|
new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
url: 'data/geojson/countries.geojson',
|
url: 'data/geojson/countries.geojson',
|
||||||
format: new GeoJSON()
|
format: new ol.format.GeoJSON()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}),
|
}),
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
@@ -35,7 +35,7 @@ const map = new Map({
|
|||||||
|
|
||||||
document.getElementById('export-png').addEventListener('click', function() {
|
document.getElementById('export-png').addEventListener('click', function() {
|
||||||
map.once('postcompose', function(event) {
|
map.once('postcompose', function(event) {
|
||||||
const canvas = event.context.canvas;
|
var canvas = event.context.canvas;
|
||||||
if (navigator.msSaveBlob) {
|
if (navigator.msSaveBlob) {
|
||||||
navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
|
navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,48 +1,47 @@
|
|||||||
// NOCOMPILE
|
// NOCOMPILE
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import WKT from '../src/ol/format/WKT.js';
|
goog.require('ol.format.WKT');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import {unByKey} from '../src/ol/Observable.js';
|
goog.require('ol.source.OSM');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.Vector');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
|
||||||
|
|
||||||
const raster = new TileLayer({
|
var raster = new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
});
|
});
|
||||||
|
|
||||||
const format = new WKT();
|
var format = new ol.format.WKT();
|
||||||
const feature = format.readFeature(
|
var feature = format.readFeature(
|
||||||
'POLYGON((10.689697265625 -25.0927734375, 34.595947265625 ' +
|
'POLYGON((10.689697265625 -25.0927734375, 34.595947265625 ' +
|
||||||
'-20.1708984375, 38.814697265625 -35.6396484375, 13.502197265625 ' +
|
'-20.1708984375, 38.814697265625 -35.6396484375, 13.502197265625 ' +
|
||||||
'-39.1552734375, 10.689697265625 -25.0927734375))');
|
'-39.1552734375, 10.689697265625 -25.0927734375))');
|
||||||
feature.getGeometry().transform('EPSG:4326', 'EPSG:3857');
|
feature.getGeometry().transform('EPSG:4326', 'EPSG:3857');
|
||||||
|
|
||||||
const vector = new VectorLayer({
|
var vector = new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
features: [feature]
|
features: [feature]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}),
|
}),
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const dims = {
|
var dims = {
|
||||||
a0: [1189, 841],
|
a0: [1189, 841],
|
||||||
a1: [841, 594],
|
a1: [841, 594],
|
||||||
a2: [594, 420],
|
a2: [594, 420],
|
||||||
@@ -51,75 +50,61 @@ const dims = {
|
|||||||
a5: [210, 148]
|
a5: [210, 148]
|
||||||
};
|
};
|
||||||
|
|
||||||
let loading = 0;
|
var loading = 0;
|
||||||
let loaded = 0;
|
var loaded = 0;
|
||||||
|
|
||||||
const exportButton = document.getElementById('export-pdf');
|
var exportButton = document.getElementById('export-pdf');
|
||||||
|
|
||||||
exportButton.addEventListener('click', function() {
|
exportButton.addEventListener('click', function() {
|
||||||
|
|
||||||
exportButton.disabled = true;
|
exportButton.disabled = true;
|
||||||
document.body.style.cursor = 'progress';
|
document.body.style.cursor = 'progress';
|
||||||
|
|
||||||
const format = document.getElementById('format').value;
|
var format = document.getElementById('format').value;
|
||||||
const resolution = document.getElementById('resolution').value;
|
var resolution = document.getElementById('resolution').value;
|
||||||
const dim = dims[format];
|
var dim = dims[format];
|
||||||
const width = Math.round(dim[0] * resolution / 25.4);
|
var width = Math.round(dim[0] * resolution / 25.4);
|
||||||
const height = Math.round(dim[1] * resolution / 25.4);
|
var height = Math.round(dim[1] * resolution / 25.4);
|
||||||
const size = /** @type {ol.Size} */ (map.getSize());
|
var size = /** @type {ol.Size} */ (map.getSize());
|
||||||
const extent = map.getView().calculateExtent(size);
|
var extent = map.getView().calculateExtent(size);
|
||||||
|
|
||||||
const source = raster.getSource();
|
var source = raster.getSource();
|
||||||
|
|
||||||
const tileLoadStart = function() {
|
var tileLoadStart = function() {
|
||||||
++loading;
|
++loading;
|
||||||
};
|
};
|
||||||
|
|
||||||
let timer;
|
var tileLoadEnd = function() {
|
||||||
let keys = [];
|
|
||||||
|
|
||||||
function tileLoadEndFactory(canvas) {
|
|
||||||
return () => {
|
|
||||||
++loaded;
|
++loaded;
|
||||||
if (timer) {
|
|
||||||
clearTimeout(timer);
|
|
||||||
timer = null;
|
|
||||||
}
|
|
||||||
if (loading === loaded) {
|
if (loading === loaded) {
|
||||||
timer = window.setTimeout(() => {
|
var canvas = this;
|
||||||
|
window.setTimeout(function() {
|
||||||
loading = 0;
|
loading = 0;
|
||||||
loaded = 0;
|
loaded = 0;
|
||||||
const data = canvas.toDataURL('image/jpeg');
|
var data = canvas.toDataURL('image/png');
|
||||||
const pdf = new jsPDF('landscape', undefined, format);
|
var pdf = new jsPDF('landscape', undefined, format);
|
||||||
pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
|
pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
|
||||||
pdf.save('map.pdf');
|
pdf.save('map.pdf');
|
||||||
keys.forEach(unByKey);
|
source.un('tileloadstart', tileLoadStart);
|
||||||
keys = [];
|
source.un('tileloadend', tileLoadEnd, canvas);
|
||||||
|
source.un('tileloaderror', tileLoadEnd, canvas);
|
||||||
map.setSize(size);
|
map.setSize(size);
|
||||||
map.getView().fit(extent, {size});
|
map.getView().fit(extent);
|
||||||
map.renderSync();
|
map.renderSync();
|
||||||
exportButton.disabled = false;
|
exportButton.disabled = false;
|
||||||
document.body.style.cursor = 'auto';
|
document.body.style.cursor = 'auto';
|
||||||
}, 500);
|
}, 100);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
map.once('postcompose', function(event) {
|
map.once('postcompose', function(event) {
|
||||||
const canvas = event.context.canvas;
|
source.on('tileloadstart', tileLoadStart);
|
||||||
const tileLoadEnd = tileLoadEndFactory(canvas);
|
source.on('tileloadend', tileLoadEnd, event.context.canvas);
|
||||||
keys = [
|
source.on('tileloaderror', tileLoadEnd, event.context.canvas);
|
||||||
source.on('tileloadstart', tileLoadStart),
|
|
||||||
source.on('tileloadend', tileLoadEnd),
|
|
||||||
source.on('tileloaderror', tileLoadEnd)
|
|
||||||
];
|
|
||||||
tileLoadEnd();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const printSize = [width, height];
|
map.setSize([width, height]);
|
||||||
map.setSize(printSize);
|
map.getView().fit(extent);
|
||||||
map.getView().fit(extent, {size: printSize});
|
|
||||||
loaded = -1;
|
|
||||||
map.renderSync();
|
map.renderSync();
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|||||||
@@ -1,36 +1,36 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {platformModifierKeyOnly} from '../src/ol/events/condition.js';
|
goog.require('ol.events.condition');
|
||||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
goog.require('ol.format.GeoJSON');
|
||||||
import ExtentInteraction from '../src/ol/interaction/Extent.js';
|
goog.require('ol.interaction.Extent');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
|
|
||||||
const vectorSource = new VectorSource({
|
var vectorSource = new ol.source.Vector({
|
||||||
url: 'data/geojson/countries.geojson',
|
url: 'data/geojson/countries.geojson',
|
||||||
format: new GeoJSON()
|
format: new ol.format.GeoJSON()
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM()
|
source: new ol.source.OSM()
|
||||||
}),
|
}),
|
||||||
new VectorLayer({
|
new ol.layer.Vector({
|
||||||
source: vectorSource
|
source: vectorSource
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const extent = new ExtentInteraction({
|
var extent = new ol.interaction.Extent({
|
||||||
condition: platformModifierKeyOnly
|
condition: ol.events.condition.platformModifierKeyOnly
|
||||||
});
|
});
|
||||||
map.addInteraction(extent);
|
map.addInteraction(extent);
|
||||||
extent.setActive(false);
|
extent.setActive(false);
|
||||||
|
|||||||
@@ -1,76 +1,77 @@
|
|||||||
import Feature from '../src/ol/Feature.js';
|
goog.require('ol.Feature');
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import {unByKey} from '../src/ol/Observable.js';
|
goog.require('ol.Observable');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
goog.require('ol.control');
|
||||||
import {easeOut} from '../src/ol/easing.js';
|
goog.require('ol.easing');
|
||||||
import Point from '../src/ol/geom/Point.js';
|
goog.require('ol.geom.Point');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
goog.require('ol.proj');
|
||||||
import OSM from '../src/ol/source/OSM.js';
|
goog.require('ol.source.OSM');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new OSM({
|
source: new ol.source.OSM({
|
||||||
wrapX: false
|
wrapX: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
controls: defaultControls({
|
controls: ol.control.defaults({
|
||||||
attributionOptions: {
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
collapsible: false
|
collapsible: false
|
||||||
}
|
})
|
||||||
}),
|
}),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 1
|
zoom: 1
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const source = new VectorSource({
|
var source = new ol.source.Vector({
|
||||||
wrapX: false
|
wrapX: false
|
||||||
});
|
});
|
||||||
const vector = new VectorLayer({
|
var vector = new ol.layer.Vector({
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
map.addLayer(vector);
|
map.addLayer(vector);
|
||||||
|
|
||||||
function addRandomFeature() {
|
function addRandomFeature() {
|
||||||
const x = Math.random() * 360 - 180;
|
var x = Math.random() * 360 - 180;
|
||||||
const y = Math.random() * 180 - 90;
|
var y = Math.random() * 180 - 90;
|
||||||
const geom = new Point(fromLonLat([x, y]));
|
var geom = new ol.geom.Point(ol.proj.transform([x, y],
|
||||||
const feature = new Feature(geom);
|
'EPSG:4326', 'EPSG:3857'));
|
||||||
|
var feature = new ol.Feature(geom);
|
||||||
source.addFeature(feature);
|
source.addFeature(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
const duration = 3000;
|
var duration = 3000;
|
||||||
function flash(feature) {
|
function flash(feature) {
|
||||||
const start = new Date().getTime();
|
var start = new Date().getTime();
|
||||||
const listenerKey = map.on('postcompose', animate);
|
var listenerKey;
|
||||||
|
|
||||||
function animate(event) {
|
function animate(event) {
|
||||||
const vectorContext = event.vectorContext;
|
var vectorContext = event.vectorContext;
|
||||||
const frameState = event.frameState;
|
var frameState = event.frameState;
|
||||||
const flashGeom = feature.getGeometry().clone();
|
var flashGeom = feature.getGeometry().clone();
|
||||||
const elapsed = frameState.time - start;
|
var elapsed = frameState.time - start;
|
||||||
const elapsedRatio = elapsed / duration;
|
var elapsedRatio = elapsed / duration;
|
||||||
// radius will be 5 at start and 30 at end.
|
// radius will be 5 at start and 30 at end.
|
||||||
const radius = easeOut(elapsedRatio) * 25 + 5;
|
var radius = ol.easing.easeOut(elapsedRatio) * 25 + 5;
|
||||||
const opacity = easeOut(1 - elapsedRatio);
|
var opacity = ol.easing.easeOut(1 - elapsedRatio);
|
||||||
|
|
||||||
const style = new Style({
|
var style = new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: radius,
|
radius: radius,
|
||||||
snapToPixel: false,
|
snapToPixel: false,
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgba(255, 0, 0, ' + opacity + ')',
|
color: 'rgba(255, 0, 0, ' + opacity + ')',
|
||||||
width: 0.25 + opacity
|
width: 0.25 + opacity
|
||||||
})
|
})
|
||||||
@@ -80,12 +81,13 @@ function flash(feature) {
|
|||||||
vectorContext.setStyle(style);
|
vectorContext.setStyle(style);
|
||||||
vectorContext.drawGeometry(flashGeom);
|
vectorContext.drawGeometry(flashGeom);
|
||||||
if (elapsed > duration) {
|
if (elapsed > duration) {
|
||||||
unByKey(listenerKey);
|
ol.Observable.unByKey(listenerKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// tell OpenLayers to continue postcompose animation
|
// tell OpenLayers to continue postcompose animation
|
||||||
map.render();
|
map.render();
|
||||||
}
|
}
|
||||||
|
listenerKey = map.on('postcompose', animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
source.on('addfeature', function(e) {
|
source.on('addfeature', function(e) {
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import Feature from '../src/ol/Feature.js';
|
goog.require('ol.Feature');
|
||||||
import Map from '../src/ol/Map.js';
|
goog.require('ol.Map');
|
||||||
import View from '../src/ol/View.js';
|
goog.require('ol.View');
|
||||||
import Polyline from '../src/ol/format/Polyline.js';
|
goog.require('ol.format.Polyline');
|
||||||
import Point from '../src/ol/geom/Point.js';
|
goog.require('ol.geom.Point');
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
goog.require('ol.layer.Tile');
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
goog.require('ol.layer.Vector');
|
||||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
goog.require('ol.source.BingMaps');
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
goog.require('ol.source.Vector');
|
||||||
import CircleStyle from '../src/ol/style/Circle.js';
|
goog.require('ol.style.Circle');
|
||||||
import Fill from '../src/ol/style/Fill.js';
|
goog.require('ol.style.Fill');
|
||||||
import Icon from '../src/ol/style/Icon.js';
|
goog.require('ol.style.Icon');
|
||||||
import Stroke from '../src/ol/style/Stroke.js';
|
goog.require('ol.style.Stroke');
|
||||||
import Style from '../src/ol/style/Style.js';
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
// This long string is placed here due to jsFiddle limitations.
|
// This long string is placed here due to jsFiddle limitations.
|
||||||
// It is usually loaded with AJAX.
|
// It is usually loaded with AJAX.
|
||||||
const polyline = [
|
var polyline = [
|
||||||
'hldhx@lnau`BCG_EaC??cFjAwDjF??uBlKMd@}@z@??aC^yk@z_@se@b[wFdE??wFfE}N',
|
'hldhx@lnau`BCG_EaC??cFjAwDjF??uBlKMd@}@z@??aC^yk@z_@se@b[wFdE??wFfE}N',
|
||||||
'fIoGxB_I\\gG}@eHoCyTmPqGaBaHOoD\\??yVrGotA|N??o[N_STiwAtEmHGeHcAkiA}^',
|
'fIoGxB_I\\gG}@eHoCyTmPqGaBaHOoD\\??yVrGotA|N??o[N_STiwAtEmHGeHcAkiA}^',
|
||||||
'aMyBiHOkFNoI`CcVvM??gG^gF_@iJwC??eCcA]OoL}DwFyCaCgCcCwDcGwHsSoX??wI_E',
|
'aMyBiHOkFNoI`CcVvM??gG^gF_@iJwC??eCcA]OoL}DwFyCaCgCcCwDcGwHsSoX??wI_E',
|
||||||
@@ -57,64 +57,64 @@ const polyline = [
|
|||||||
'~@ym@yjA??a@cFd@kBrCgDbAUnAcBhAyAdk@et@??kF}D??OL'
|
'~@ym@yjA??a@cFd@kBrCgDbAUnAcBhAyAdk@et@??kF}D??OL'
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
const route = /** @type {module:ol/geom/LineString~LineString} */ (new Polyline({
|
var route = /** @type {ol.geom.LineString} */ (new ol.format.Polyline({
|
||||||
factor: 1e6
|
factor: 1e6
|
||||||
}).readGeometry(polyline, {
|
}).readGeometry(polyline, {
|
||||||
dataProjection: 'EPSG:4326',
|
dataProjection: 'EPSG:4326',
|
||||||
featureProjection: 'EPSG:3857'
|
featureProjection: 'EPSG:3857'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const routeCoords = route.getCoordinates();
|
var routeCoords = route.getCoordinates();
|
||||||
const routeLength = routeCoords.length;
|
var routeLength = routeCoords.length;
|
||||||
|
|
||||||
const routeFeature = new Feature({
|
var routeFeature = new ol.Feature({
|
||||||
type: 'route',
|
type: 'route',
|
||||||
geometry: route
|
geometry: route
|
||||||
});
|
});
|
||||||
const geoMarker = new Feature({
|
var geoMarker = new ol.Feature({
|
||||||
type: 'geoMarker',
|
type: 'geoMarker',
|
||||||
geometry: new Point(routeCoords[0])
|
geometry: new ol.geom.Point(routeCoords[0])
|
||||||
});
|
});
|
||||||
const startMarker = new Feature({
|
var startMarker = new ol.Feature({
|
||||||
type: 'icon',
|
type: 'icon',
|
||||||
geometry: new Point(routeCoords[0])
|
geometry: new ol.geom.Point(routeCoords[0])
|
||||||
});
|
});
|
||||||
const endMarker = new Feature({
|
var endMarker = new ol.Feature({
|
||||||
type: 'icon',
|
type: 'icon',
|
||||||
geometry: new Point(routeCoords[routeLength - 1])
|
geometry: new ol.geom.Point(routeCoords[routeLength - 1])
|
||||||
});
|
});
|
||||||
|
|
||||||
const styles = {
|
var styles = {
|
||||||
'route': new Style({
|
'route': new ol.style.Style({
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
width: 6, color: [237, 212, 0, 0.8]
|
width: 6, color: [237, 212, 0, 0.8]
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'icon': new Style({
|
'icon': new ol.style.Style({
|
||||||
image: new Icon({
|
image: new ol.style.Icon({
|
||||||
anchor: [0.5, 1],
|
anchor: [0.5, 1],
|
||||||
src: 'data/icon.png'
|
src: 'data/icon.png'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
'geoMarker': new Style({
|
'geoMarker': new ol.style.Style({
|
||||||
image: new CircleStyle({
|
image: new ol.style.Circle({
|
||||||
radius: 7,
|
radius: 7,
|
||||||
snapToPixel: false,
|
snapToPixel: false,
|
||||||
fill: new Fill({color: 'black'}),
|
fill: new ol.style.Fill({color: 'black'}),
|
||||||
stroke: new Stroke({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'white', width: 2
|
color: 'white', width: 2
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
let animating = false;
|
var animating = false;
|
||||||
let speed, now;
|
var speed, now;
|
||||||
const speedInput = document.getElementById('speed');
|
var speedInput = document.getElementById('speed');
|
||||||
const startButton = document.getElementById('start-animation');
|
var startButton = document.getElementById('start-animation');
|
||||||
|
|
||||||
const vectorLayer = new VectorLayer({
|
var vectorLayer = new ol.layer.Vector({
|
||||||
source: new VectorSource({
|
source: new ol.source.Vector({
|
||||||
features: [routeFeature, geoMarker, startMarker, endMarker]
|
features: [routeFeature, geoMarker, startMarker, endMarker]
|
||||||
}),
|
}),
|
||||||
style: function(feature) {
|
style: function(feature) {
|
||||||
@@ -126,19 +126,19 @@ const vectorLayer = new VectorLayer({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const center = [-5639523.95, -3501274.52];
|
var center = [-5639523.95, -3501274.52];
|
||||||
const map = new Map({
|
var map = new ol.Map({
|
||||||
target: document.getElementById('map'),
|
target: document.getElementById('map'),
|
||||||
loadTilesWhileAnimating: true,
|
loadTilesWhileAnimating: true,
|
||||||
view: new View({
|
view: new ol.View({
|
||||||
center: center,
|
center: center,
|
||||||
zoom: 10,
|
zoom: 10,
|
||||||
minZoom: 2,
|
minZoom: 2,
|
||||||
maxZoom: 19
|
maxZoom: 19
|
||||||
}),
|
}),
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new ol.layer.Tile({
|
||||||
source: new BingMaps({
|
source: new ol.source.BingMaps({
|
||||||
imagerySet: 'AerialWithLabels',
|
imagerySet: 'AerialWithLabels',
|
||||||
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
||||||
})
|
})
|
||||||
@@ -147,23 +147,23 @@ const map = new Map({
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const moveFeature = function(event) {
|
var moveFeature = function(event) {
|
||||||
const vectorContext = event.vectorContext;
|
var vectorContext = event.vectorContext;
|
||||||
const frameState = event.frameState;
|
var frameState = event.frameState;
|
||||||
|
|
||||||
if (animating) {
|
if (animating) {
|
||||||
const elapsedTime = frameState.time - now;
|
var elapsedTime = frameState.time - now;
|
||||||
// here the trick to increase speed is to jump some indexes
|
// here the trick to increase speed is to jump some indexes
|
||||||
// on lineString coordinates
|
// on lineString coordinates
|
||||||
const index = Math.round(speed * elapsedTime / 1000);
|
var index = Math.round(speed * elapsedTime / 1000);
|
||||||
|
|
||||||
if (index >= routeLength) {
|
if (index >= routeLength) {
|
||||||
stopAnimation(true);
|
stopAnimation(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentPoint = new Point(routeCoords[index]);
|
var currentPoint = new ol.geom.Point(routeCoords[index]);
|
||||||
const feature = new Feature(currentPoint);
|
var feature = new ol.Feature(currentPoint);
|
||||||
vectorContext.drawFeature(feature, styles.geoMarker);
|
vectorContext.drawFeature(feature, styles.geoMarker);
|
||||||
}
|
}
|
||||||
// tell OpenLayers to continue the postcompose animation
|
// tell OpenLayers to continue the postcompose animation
|
||||||
@@ -196,8 +196,8 @@ function stopAnimation(ended) {
|
|||||||
startButton.textContent = 'Start Animation';
|
startButton.textContent = 'Start Animation';
|
||||||
|
|
||||||
// if animation cancelled set the marker at the beginning
|
// if animation cancelled set the marker at the beginning
|
||||||
const coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
|
var coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
|
||||||
/** @type {module:ol/geom/Point~Point} */ (geoMarker.getGeometry())
|
/** @type {ol.geom.Point} */ (geoMarker.getGeometry())
|
||||||
.setCoordinates(coord);
|
.setCoordinates(coord);
|
||||||
//remove listener
|
//remove listener
|
||||||
map.un('postcompose', moveFeature);
|
map.un('postcompose', moveFeature);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user