Compare commits
300 Commits
v3.0.0-gam
...
v3.0.0-gam
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f468239e71 | ||
|
|
4b8ceca8eb | ||
|
|
10ffc8953b | ||
|
|
d846fbc0b4 | ||
|
|
f5bb790509 | ||
|
|
9fd5c1370e | ||
|
|
caa0b568ad | ||
|
|
7bbd27e68e | ||
|
|
2b0284a342 | ||
|
|
234cff4de5 | ||
|
|
1daf36956c | ||
|
|
42f953d08d | ||
|
|
e5a0e736ca | ||
|
|
2365e73bef | ||
|
|
9bd1ab78fc | ||
|
|
9c70a49fb0 | ||
|
|
9f19569144 | ||
|
|
9de010c791 | ||
|
|
c25b1e939e | ||
|
|
d50f40dcce | ||
|
|
280a7c520f | ||
|
|
31c9f5806e | ||
|
|
ba8077010a | ||
|
|
c1f7db9611 | ||
|
|
a314203e12 | ||
|
|
a43c546667 | ||
|
|
a71714e8b6 | ||
|
|
16cdd35f6d | ||
|
|
c1d49a8cef | ||
|
|
b945147950 | ||
|
|
b29195639f | ||
|
|
b2e345c407 | ||
|
|
7fbc4e3bff | ||
|
|
d3e575339b | ||
|
|
9bcafc0fab | ||
|
|
8b7f80c64e | ||
|
|
64c03d0f9c | ||
|
|
e81e030dcd | ||
|
|
288c997322 | ||
|
|
1d22113420 | ||
|
|
962b94444c | ||
|
|
a8961877e8 | ||
|
|
8cf48eac4f | ||
|
|
7b7788973b | ||
|
|
ddfe11042b | ||
|
|
8e106a2c98 | ||
|
|
8d805c6403 | ||
|
|
3f1f450d5c | ||
|
|
a9d68a1899 | ||
|
|
e593e5fb60 | ||
|
|
74dbd2b3e5 | ||
|
|
aa4ee80033 | ||
|
|
fa7ff506fc | ||
|
|
eb71e8e92d | ||
|
|
82b921ff06 | ||
|
|
fee4c79757 | ||
|
|
73951394f9 | ||
|
|
434bf0bf42 | ||
|
|
9838687d88 | ||
|
|
cee5b81ec2 | ||
|
|
71b2bf73de | ||
|
|
02a2c5aceb | ||
|
|
dbb72f5080 | ||
|
|
b4f6baa613 | ||
|
|
e9c6e58663 | ||
|
|
737e063937 | ||
|
|
4dc601f30d | ||
|
|
28a23a11b5 | ||
|
|
3ac7cb58af | ||
|
|
346ff9c186 | ||
|
|
4dccb32545 | ||
|
|
ad272a1b3a | ||
|
|
b0c0d077c9 | ||
|
|
12d94e1405 | ||
|
|
10aa2019e7 | ||
|
|
2b1c96a7ea | ||
|
|
c9d44fe842 | ||
|
|
e56f759574 | ||
|
|
6a0d08eafd | ||
|
|
b77af6d416 | ||
|
|
b7b5de659b | ||
|
|
60f1874766 | ||
|
|
0b9936107d | ||
|
|
7ca069de39 | ||
|
|
8383f60fcf | ||
|
|
aa9dab092a | ||
|
|
38b36a09bd | ||
|
|
b96fb6ad3a | ||
|
|
1cbedadf48 | ||
|
|
1657ed2d23 | ||
|
|
7a26966c8d | ||
|
|
685265e1db | ||
|
|
9e3b46762b | ||
|
|
1e7dc5cd32 | ||
|
|
4abc887f5d | ||
|
|
fe8a72dce5 | ||
|
|
0bd9be547d | ||
|
|
aecaa52cb1 | ||
|
|
4f7073d7aa | ||
|
|
4de2520109 | ||
|
|
4aa76977d2 | ||
|
|
fe1131b850 | ||
|
|
a2e7432e42 | ||
|
|
d7f4a06f61 | ||
|
|
f57a364534 | ||
|
|
bd08bfe6c8 | ||
|
|
313e313f7a | ||
|
|
9131512598 | ||
|
|
307ee09988 | ||
|
|
3e2350b2a0 | ||
|
|
29d581bbee | ||
|
|
aa85318d78 | ||
|
|
97f9527f41 | ||
|
|
4c03b3b35c | ||
|
|
621aafbdde | ||
|
|
cc9acef01f | ||
|
|
5cd202d50b | ||
|
|
be09368359 | ||
|
|
3259b1078c | ||
|
|
7286c29fbc | ||
|
|
847440f30a | ||
|
|
f5830cc8e5 | ||
|
|
5010596ec0 | ||
|
|
db431ebdc6 | ||
|
|
df2c14b7af | ||
|
|
c93e80a14a | ||
|
|
543250c88a | ||
|
|
59fe635b46 | ||
|
|
753727c15f | ||
|
|
96ec96c4d5 | ||
|
|
046ae42b38 | ||
|
|
a6f921d443 | ||
|
|
3e23da7c83 | ||
|
|
aa4dbde841 | ||
|
|
8c1ad54bd8 | ||
|
|
3b8e182856 | ||
|
|
b8c39bd62c | ||
|
|
b518466968 | ||
|
|
5fb78fb352 | ||
|
|
1a933febcd | ||
|
|
2b4b2dadf7 | ||
|
|
aafa578805 | ||
|
|
e707e918aa | ||
|
|
1c8fc8358a | ||
|
|
f0f9291161 | ||
|
|
4f087f1b84 | ||
|
|
6744713a54 | ||
|
|
d5d5f58809 | ||
|
|
4d150e6b84 | ||
|
|
da74fbf529 | ||
|
|
aeaa172abe | ||
|
|
5a1e92830f | ||
|
|
521cbfb1b0 | ||
|
|
121d19e0ba | ||
|
|
1d26c1faaf | ||
|
|
512c2032ed | ||
|
|
31fa59c996 | ||
|
|
19757ae3e0 | ||
|
|
7c22d8ffd4 | ||
|
|
ea7c32ff6e | ||
|
|
60c7564268 | ||
|
|
d57a35ffcb | ||
|
|
9dc17230c2 | ||
|
|
a02d21d4b5 | ||
|
|
9640a08c0e | ||
|
|
a737cf0d99 | ||
|
|
7789bff3da | ||
|
|
8e2a12bfc1 | ||
|
|
4541019ff4 | ||
|
|
49b91998f9 | ||
|
|
193adf4401 | ||
|
|
1ae82b054c | ||
|
|
1bb5705b55 | ||
|
|
8f1fdde26e | ||
|
|
4cf8383820 | ||
|
|
fc3ed93080 | ||
|
|
0a01f8ef7e | ||
|
|
90c745006d | ||
|
|
a22d7e4d22 | ||
|
|
20e903f8d9 | ||
|
|
f1bdaed15a | ||
|
|
4bcbda61c6 | ||
|
|
b396773183 | ||
|
|
17d059f7bb | ||
|
|
9915bb873c | ||
|
|
befcc4ceea | ||
|
|
88ab1ac61a | ||
|
|
8b2277cdda | ||
|
|
0c62469f50 | ||
|
|
dfe92da58d | ||
|
|
b5bdd0d4bb | ||
|
|
8b89f5b689 | ||
|
|
dc09b0a27f | ||
|
|
971c1137bc | ||
|
|
d215696154 | ||
|
|
38bf0b439a | ||
|
|
82604ff60b | ||
|
|
3a0d0c7290 | ||
|
|
8e555fad5b | ||
|
|
570a0c23a7 | ||
|
|
8d991bd638 | ||
|
|
9b1e9dbc8e | ||
|
|
1933d809e2 | ||
|
|
5fdb380fb6 | ||
|
|
9c6cb9db6d | ||
|
|
26e6260446 | ||
|
|
d0301805c7 | ||
|
|
1f88015db0 | ||
|
|
21878ebad3 | ||
|
|
7e8551a767 | ||
|
|
93716fc7f0 | ||
|
|
d8ca8e7341 | ||
|
|
264a01cfd4 | ||
|
|
8a3f1a8f34 | ||
|
|
70cb7a4a0a | ||
|
|
6f398f93dd | ||
|
|
94ba9aeea9 | ||
|
|
4e0d48386b | ||
|
|
76584c3291 | ||
|
|
b452e04e08 | ||
|
|
f18dbcdb97 | ||
|
|
fa25f2a477 | ||
|
|
043cd0ff41 | ||
|
|
489096e40b | ||
|
|
1951c385a8 | ||
|
|
5a24d022cf | ||
|
|
d99a61545c | ||
|
|
fd659d63e9 | ||
|
|
10f4d0c3d7 | ||
|
|
8b29b52e95 | ||
|
|
4cf5ab4620 | ||
|
|
297503e7c9 | ||
|
|
207e23099a | ||
|
|
0666dee697 | ||
|
|
e0a8bb045a | ||
|
|
c6138edbcb | ||
|
|
52294519bc | ||
|
|
07b02c2a55 | ||
|
|
46149ff6f9 | ||
|
|
a4e923cf4b | ||
|
|
d1820fbce5 | ||
|
|
1626399c08 | ||
|
|
2064d08602 | ||
|
|
1129e0d934 | ||
|
|
234dd91ff2 | ||
|
|
f54398eda3 | ||
|
|
a157ecd788 | ||
|
|
167d13b4f6 | ||
|
|
8c4a55cc65 | ||
|
|
35888d1dc6 | ||
|
|
0ae1cd7cf5 | ||
|
|
152b434f1b | ||
|
|
992e0fa218 | ||
|
|
f89abb53a9 | ||
|
|
4e8c9c5470 | ||
|
|
3ea304f5bf | ||
|
|
04e60a9d37 | ||
|
|
064f95f530 | ||
|
|
18462a2af3 | ||
|
|
76e1ca67a4 | ||
|
|
4fed441eda | ||
|
|
067345a4b0 | ||
|
|
6abba32707 | ||
|
|
d8cc019184 | ||
|
|
b8ab6fd771 | ||
|
|
2e541b43d1 | ||
|
|
abe953e4e5 | ||
|
|
b0a1444da0 | ||
|
|
450d42a4cc | ||
|
|
90f2f96797 | ||
|
|
49aabda1b9 | ||
|
|
f8ba6758a2 | ||
|
|
ef1414c508 | ||
|
|
355ca67b86 | ||
|
|
67c2e46c19 | ||
|
|
a93f7b8190 | ||
|
|
700a0b15b3 | ||
|
|
fdf0525c71 | ||
|
|
17bb8d8ca1 | ||
|
|
927513e1f0 | ||
|
|
fe776b0d1a | ||
|
|
54ea8dc52b | ||
|
|
2e1957c42c | ||
|
|
97e59f0976 | ||
|
|
3e49ea2ba0 | ||
|
|
5adb3a6a8e | ||
|
|
242787da45 | ||
|
|
6b230d3711 | ||
|
|
d3234f1b6a | ||
|
|
4b57f7798f | ||
|
|
203df11c96 | ||
|
|
a3e332c0c2 | ||
|
|
70548b4704 | ||
|
|
00fd5caa92 | ||
|
|
07b41f84d0 | ||
|
|
3bbf9ae720 | ||
|
|
97985934e1 | ||
|
|
60f283d5c0 | ||
|
|
29370a04aa | ||
|
|
c1c98b45b9 |
@@ -3,9 +3,6 @@ before_install:
|
|||||||
- "npm install -g npm && npm install"
|
- "npm install -g npm && npm install"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- "./build.py plovr"
|
|
||||||
- "./build.py serve-integration-test &"
|
|
||||||
- "rm src/ol/renderer/webgl/*shader.js"
|
- "rm src/ol/renderer/webgl/*shader.js"
|
||||||
- "sleep 3"
|
|
||||||
|
|
||||||
script: "./build.py integration-test"
|
script: "./build.py ci"
|
||||||
|
|||||||
307
CONTRIBUTING.md
307
CONTRIBUTING.md
@@ -4,18 +4,301 @@ Thanks for your interest in contributing to OpenLayers 3.
|
|||||||
|
|
||||||
## Contributing Code
|
## Contributing Code
|
||||||
|
|
||||||
Our preferred means of receiving contributions is through [pull
|
Our preferred means of receiving contributions is through [pull requests](https://help.github.com/articles/using-pull-requests). Make sure
|
||||||
requests](https://help.github.com/articles/using-pull-requests).
|
that your pull request follows our pull request guidelines below before submitting it.
|
||||||
|
|
||||||
See the [Developer
|
This page describes what you need to know to contribute code to ol3 as a developer.
|
||||||
Guide](https://github.com/openlayers/ol3/wiki/Developer-Guide) to get started
|
|
||||||
with OpenLayers 3 development. This guide provides information you should know
|
|
||||||
before creating pull requests.
|
|
||||||
|
|
||||||
Note that, before accepting a contribution, we ask that you provide us
|
## Contributor License Agreement
|
||||||
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
|
Before accepting a contribution, we ask that you provide us a Contributor
|
||||||
Contributor License Agreement](http://www.openlayers.org/ccla.txt). If you are
|
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
|
making your contribution as an individual, you can submit a digital [Individual
|
||||||
Contributor License
|
Contributor License Agreement](https://docs.google.com/spreadsheet/viewform?formkey=dGNNVUJEMXF2dERTU0FXM3JjNVBQblE6MQ).
|
||||||
Agreement](https://docs.google.com/spreadsheet/viewform?formkey=dGNNVUJEMXF2dERTU0FXM3JjNVBQblE6MQ).
|
|
||||||
|
## Setting up development environment
|
||||||
|
|
||||||
|
You will obviously start by
|
||||||
|
[forking](https://github.com/openlayers/ol3/fork_select) the ol3 repository.
|
||||||
|
|
||||||
|
### Travis CI
|
||||||
|
|
||||||
|
The Travis CI hook is enabled on the Github repository. This means every pull request
|
||||||
|
is run through a full test suite to ensure it compiles and passes the tests. Failing
|
||||||
|
pull requests will not be merged.
|
||||||
|
|
||||||
|
Although not mandatory, it is also recommended to set up Travis CI for your ol3 fork.
|
||||||
|
For that go to your ol3 fork's Service Hooks page and set up the Travis hook.
|
||||||
|
Then every time you push to your fork, the test suite will be run. This means
|
||||||
|
errors can be caught before creating a pull request. For those making
|
||||||
|
small or occasional contributions, this may be enough to check that your contributions
|
||||||
|
are ok; in this case, you do not need to install the build tools on your local environment
|
||||||
|
as described below.
|
||||||
|
|
||||||
|
### Development dependencies
|
||||||
|
|
||||||
|
The minimum requirements are:
|
||||||
|
|
||||||
|
* Git
|
||||||
|
* [Node.js](http://nodejs.org/)
|
||||||
|
* Python 2.6 or 2.7 with a couple of extra modules (see below)
|
||||||
|
* Java 7 (JRE and JDK)
|
||||||
|
|
||||||
|
The executables `git`, `java`, `jar`, and `python` should be in your `PATH`.
|
||||||
|
|
||||||
|
You can check your configuration by running:
|
||||||
|
|
||||||
|
$ ./build.py checkdeps
|
||||||
|
|
||||||
|
To install the Node.js dependencies run
|
||||||
|
|
||||||
|
$ npm install
|
||||||
|
|
||||||
|
To install the extra Python modules, run:
|
||||||
|
|
||||||
|
$ sudo pip install -r requirements.txt
|
||||||
|
or
|
||||||
|
|
||||||
|
$ cat requirements.txt | sudo xargs easy_install
|
||||||
|
|
||||||
|
depending on your OS and Python installation.
|
||||||
|
|
||||||
|
## Working with the build tool
|
||||||
|
|
||||||
|
As an ol3 developer you will need to use the `build.py` Python script. This is
|
||||||
|
the script to use to run the linter, the compiler, the tests, etc. Windows users
|
||||||
|
can use `build.cmd` which is a thin wrapper around `build.py`.
|
||||||
|
|
||||||
|
The `build.py` script is equivalent to a Makefile. It is actually based on
|
||||||
|
[pake](https://github.com/twpayne/pake/), which is a simple implementation of
|
||||||
|
`make` in Python.
|
||||||
|
|
||||||
|
The usage of the script is:
|
||||||
|
|
||||||
|
$ ./build.py <target>
|
||||||
|
|
||||||
|
where `<target>` is the name of the build target you want to execute. For
|
||||||
|
example:
|
||||||
|
|
||||||
|
$ ./build.py 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 ol3's [Travis configuration file](https://github.com/openlayers/ol3/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:
|
||||||
|
|
||||||
|
$ ./build.py check
|
||||||
|
|
||||||
|
If you want to run the full suite of integration tests, see "Running the integration
|
||||||
|
tests" below.
|
||||||
|
|
||||||
|
## Running examples
|
||||||
|
|
||||||
|
To run the examples you first need to start the dev server:
|
||||||
|
|
||||||
|
$ ./build.py serve
|
||||||
|
|
||||||
|
Then, just point your browser <http://localhost:3000/examples> in your browser. For example <http://localhost:3000/examples/side-by-side.html>.
|
||||||
|
|
||||||
|
Run examples against the `ol.js` standalone build:
|
||||||
|
|
||||||
|
The examples can also be run against the `ol.js` standalone lib, just like the examples
|
||||||
|
[hosted](http://openlayers.github.com/ol3/master/examples/) on GitHub. Start by
|
||||||
|
executing the `host-examples` build target:
|
||||||
|
|
||||||
|
$ ./build.py host-examples
|
||||||
|
|
||||||
|
After running `host-examples` you can now open the examples index page in the browser, for example: <http://localhost/~elemoine/ol3/build/hosted/master/examples/>. (This assumes that the `hosted` directory is a web directory, served by Apache for example.)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
To run the tests in a browser start the dev server (`./build.py serve`) and open <http://localhost:3000/test/index.html> in the browser.
|
||||||
|
|
||||||
|
To run the tests on the console (headless testing with PhantomJS) use the `test` target:
|
||||||
|
|
||||||
|
$ ./build.py test
|
||||||
|
|
||||||
|
See also the test-specific [README](../blob/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:
|
||||||
|
|
||||||
|
$ ./build.py 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 functionality often implies adding one or several examples. This
|
||||||
|
section provides explanations related to adding examples.
|
||||||
|
|
||||||
|
The examples are located in the `examples` directory. Adding a new example
|
||||||
|
implies creating two files in this directory, an `.html` file and a `.js` file.
|
||||||
|
See `examples/simple.html` and `examples/simple.js` for instance.
|
||||||
|
|
||||||
|
The `.html` file needs to include a script tag with
|
||||||
|
`loader.js?id=<example_name>` as its `src`. For example, if the two files for
|
||||||
|
the example are `myexample.js` and `myexample.html` then the script tag's `src`
|
||||||
|
should be set to `myexample`.
|
||||||
|
|
||||||
|
You can use `simple.js` and `simple.html` as templates for new examples.
|
||||||
|
|
||||||
|
### Use of the `goog` namespace in examples
|
||||||
|
|
||||||
|
Short story: the ol3 examples should not use the `goog` namespace, except
|
||||||
|
for `goog.require`.
|
||||||
|
|
||||||
|
Longer story: we want that the ol3 examples work in multiple modes, with the
|
||||||
|
standalone lib (which has implications of the symbols and properties we
|
||||||
|
export), and compiled together with the ol3 library.
|
||||||
|
|
||||||
|
Compiling the examples together with the library makes it mandatory to declare dependencies with `goog.require` statements.
|
||||||
|
|
||||||
|
## Pull request guidelines
|
||||||
|
|
||||||
|
Your pull request must:
|
||||||
|
|
||||||
|
* Follow OpenLayers 3's coding style.
|
||||||
|
|
||||||
|
* Pass the integration tests run automatically by the Travis Continuous
|
||||||
|
Integration system.
|
||||||
|
|
||||||
|
* Address a single issue or add a single item of functionality.
|
||||||
|
|
||||||
|
* Contain a clean history of small, incremental, logically separate commits,
|
||||||
|
with no merge commits.
|
||||||
|
|
||||||
|
* Use clear commit messages.
|
||||||
|
|
||||||
|
* Be possible to merge automatically.
|
||||||
|
|
||||||
|
|
||||||
|
### The `check` build target
|
||||||
|
|
||||||
|
It is strongly recommended that you run
|
||||||
|
|
||||||
|
$ ./build.py 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 3's coding style
|
||||||
|
|
||||||
|
OpenLayers 3 follows [Google's JavaScript Style
|
||||||
|
Guide](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml).
|
||||||
|
This is checked using the [Closure
|
||||||
|
Linter](https://developers.google.com/closure/utilities/) in strict mode. You
|
||||||
|
can run the linter locally on your machine before committing using the `lint`
|
||||||
|
target to `build.py`:
|
||||||
|
|
||||||
|
$ ./build.py lint
|
||||||
|
|
||||||
|
In addition to fixing problems identified by the linter, please also follow the
|
||||||
|
style of the existing OpenLayers 3 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.
|
||||||
|
|
||||||
|
|
||||||
|
### 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 3 style and does not break tests or examples. You
|
||||||
|
can run the integration tests locally using the `ci` target:
|
||||||
|
|
||||||
|
$ ./build.py ci
|
||||||
|
|
||||||
|
|
||||||
|
### Address a single issue or add a single item of functionality
|
||||||
|
|
||||||
|
Please submit separate pull requests for separate issues. This allows each to
|
||||||
|
be reviewed on its own merits.
|
||||||
|
|
||||||
|
|
||||||
|
### Contain a clean history of small, incremental, logically separate commits, with no merge commits
|
||||||
|
|
||||||
|
The commit history explains to the reviewer the series of modifications to the
|
||||||
|
code that you have made and breaks the overall contribution into a series of
|
||||||
|
easily-understandable chunks. Any individual commit should not add more than
|
||||||
|
one new class or one new function. Do not submit commits that change thousands
|
||||||
|
of lines or that contain more than one distinct logical change. Trivial
|
||||||
|
commits, e.g. to fix lint errors, should be merged into the commit that
|
||||||
|
introduced the error. See the [Atomic Commit Convention on Wikipedia](http://en.wikipedia.org/wiki/Atomic_commit#Atomic_Commit_Convention) for more detail.
|
||||||
|
|
||||||
|
`git apply --patch` and `git rebase` can help you create a clean commit
|
||||||
|
history.
|
||||||
|
[Reviewboard.org](http://www.reviewboard.org/docs/codebase/dev/git/clean-commits/)
|
||||||
|
and [Pro GIT](http://git-scm.com/book/en/Git-Tools-Rewriting-History) have
|
||||||
|
explain how to use them.
|
||||||
|
|
||||||
|
|
||||||
|
### Use clear commit messages
|
||||||
|
|
||||||
|
Commit messages should be short, begin with a verb in the imperative, and
|
||||||
|
contain no trailing punctuation. We follow
|
||||||
|
http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
||||||
|
for the formatting of commit messages.
|
||||||
|
|
||||||
|
Git commit message should look like:
|
||||||
|
|
||||||
|
Header line: explaining the commit in one line
|
||||||
|
|
||||||
|
Body of commit message is a few lines of text, explaining things
|
||||||
|
in more detail, possibly giving some background about the issue
|
||||||
|
being fixed, etc etc.
|
||||||
|
|
||||||
|
The body of the commit message can be several paragraphs, and
|
||||||
|
please do proper word-wrap and keep columns shorter than about
|
||||||
|
74 characters or so. That way "git log" will show things
|
||||||
|
nicely even when it's indented.
|
||||||
|
|
||||||
|
Further paragraphs come after blank lines.
|
||||||
|
|
||||||
|
Please keep the header line short, no more than 50 characters.
|
||||||
|
|
||||||
|
### Be possible to merge automatically
|
||||||
|
|
||||||
|
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
|
||||||
|
more recent `master`, resolve any conflicts, and `git push --force` to update
|
||||||
|
your branch so that it can be merged automatically.
|
||||||
|
|||||||
@@ -9,9 +9,6 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"includePattern": ".+\\.js(doc)?$",
|
"includePattern": ".+\\.js(doc)?$",
|
||||||
"excludePattern": "(^|\\/|\\\\)_",
|
"excludePattern": "(^|\\/|\\\\)_",
|
||||||
"exclude": [
|
|
||||||
"src/googx/dom/fullscreen.js"
|
|
||||||
],
|
|
||||||
"include": [
|
"include": [
|
||||||
"src",
|
"src",
|
||||||
"externs/oli.js",
|
"externs/oli.js",
|
||||||
@@ -23,7 +20,6 @@
|
|||||||
"apidoc/plugins/inheritdoc",
|
"apidoc/plugins/inheritdoc",
|
||||||
"apidoc/plugins/interface",
|
"apidoc/plugins/interface",
|
||||||
"apidoc/plugins/typedefs",
|
"apidoc/plugins/typedefs",
|
||||||
"apidoc/plugins/todo",
|
|
||||||
"apidoc/plugins/events",
|
"apidoc/plugins/events",
|
||||||
"apidoc/plugins/observable",
|
"apidoc/plugins/observable",
|
||||||
"apidoc/plugins/api"
|
"apidoc/plugins/api"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ Interactions for [vector features](ol.Feature.html)
|
|||||||
<br>[Formats](ol.format.Feature.html) for reading/writing vector data
|
<br>[Formats](ol.format.Feature.html) for reading/writing vector data
|
||||||
<br>[ol.format.WMSCapabilities](ol.format.WMSCapabilities.html)</td></tr>
|
<br>[ol.format.WMSCapabilities](ol.format.WMSCapabilities.html)</td></tr>
|
||||||
<tr><th>Projections</th><th>2-way bindings</th><th>Other components</th></tr>
|
<tr><th>Projections</th><th>2-way bindings</th><th>Other components</th></tr>
|
||||||
<tr><td><p>All coordinates and extents need to be provided in view projection (default: [EPSG:3857](ol.proj.EPSG3857.html)). To transform, use [ol.proj.transform()](ol.proj.html#transform) and [ol.extent.applyTransform()](ol.extent.html#applyTransform).</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>[Objects](ol.Object.html) can be kept in sync using the [bindTo()](ol.Object.html#bindTo) method.</p>
|
<td><p>[Objects](ol.Object.html) can be kept in sync using the [bindTo()](ol.Object.html#bindTo) method.</p>
|
||||||
<p>A [DOM Input](ol.dom.Input.html) class is available to bind Object properties to HTML Input elements.</p></td>
|
<p>A [DOM Input](ol.dom.Input.html) class is available to bind Object properties to HTML Input elements.</p></td>
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ function includeAugments(doclet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var api = [];
|
var api = [];
|
||||||
var augments = {};
|
|
||||||
var classes = {};
|
var classes = {};
|
||||||
|
|
||||||
exports.handlers = {
|
exports.handlers = {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ exports.handlers = {
|
|||||||
|
|
||||||
parseComplete: function(e) {
|
parseComplete: function(e) {
|
||||||
var doclets = e.doclets;
|
var doclets = e.doclets;
|
||||||
var eventClass, doclet, i, ii, j, jj, event, fires;
|
var doclet, i, ii, j, jj, event, fires;
|
||||||
for (i = 0, ii = doclets.length - 1; i < ii; ++i) {
|
for (i = 0, ii = doclets.length - 1; i < ii; ++i) {
|
||||||
doclet = doclets[i];
|
doclet = doclets[i];
|
||||||
if (doclet.fires) {
|
if (doclet.fires) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ exports.handlers = {
|
|||||||
for (l = candidates.length - 1; l >= 0; --l) {
|
for (l = candidates.length - 1; l >= 0; --l) {
|
||||||
candidate = candidates[l];
|
candidate = candidates[l];
|
||||||
if (candidate && !candidate.inheritdoc) {
|
if (candidate && !candidate.inheritdoc) {
|
||||||
stability = candidate.stability || incompleteDoclet.stability
|
stability = candidate.stability || incompleteDoclet.stability;
|
||||||
if (stability) {
|
if (stability) {
|
||||||
incompleteDoclet.stability = stability;
|
incompleteDoclet.stability = stability;
|
||||||
for (key in candidate) {
|
for (key in candidate) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
var util = require('util');
|
|
||||||
exports.defineTags = function(dictionary) {
|
exports.defineTags = function(dictionary) {
|
||||||
|
|
||||||
var classTag = dictionary.lookUp('class');
|
var classTag = dictionary.lookUp('class');
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ exports.handlers = {
|
|||||||
if (!cls.fires) {
|
if (!cls.fires) {
|
||||||
cls.fires = [];
|
cls.fires = [];
|
||||||
}
|
}
|
||||||
var event = 'ol.ObjectEvent#event:change:' + name.toLowerCase();
|
event = 'ol.ObjectEvent#event:change:' + name.toLowerCase();
|
||||||
if (cls.fires.indexOf(event) == -1) {
|
if (cls.fires.indexOf(event) == -1) {
|
||||||
cls.fires.push(event);
|
cls.fires.push(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
var util = require('util');
|
|
||||||
exports.defineTags = function(dictionary) {
|
|
||||||
dictionary.defineTag('todo', {
|
|
||||||
mustHaveValue: true,
|
|
||||||
canHaveType: true,
|
|
||||||
canHaveName: true,
|
|
||||||
onTagged: function(doclet, tag) {
|
|
||||||
var parts = tag.text.split(' ');
|
|
||||||
if (parts[0] === 'api') {
|
|
||||||
doclet.stability = parts.slice(1).join(' ') || 'experimental';
|
|
||||||
} else if (parts[0] === 'observable') {
|
|
||||||
doclet.observable = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -11,7 +11,7 @@ In the simplest case, a JSDoc block can look like this:
|
|||||||
/**
|
/**
|
||||||
* Add the given control to the map.
|
* Add the given control to the map.
|
||||||
* @param {ol.control.Control} control Control.
|
* @param {ol.control.Control} control Control.
|
||||||
* @todo api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.addControl = function(control) {
|
ol.Map.prototype.addControl = function(control) {
|
||||||
// ...
|
// ...
|
||||||
@@ -22,7 +22,7 @@ contain Markdown.
|
|||||||
|
|
||||||
The second line tells the Closure compiler the type of the argument.
|
The second line tells the Closure compiler the type of the argument.
|
||||||
|
|
||||||
The third line (`@todo api`) marks the method as part of the api and thus exportable. The stability can be added as value, e.g. `@todo api stable`. Once the documentation story is fully settled, we will remove the `todo ` and just write `@api` or `@api stable`. Without such an api annotation, the method will not be documented in the generated API documentation. Symbols without an api annotation will also not be exportable (unless they are explicitly exported with a `goog.exportProperty` call).
|
The third line (`@api`) marks the method as part of the api and thus exportable. The stability can be added as value, e.g. `@api stable`. Without such an api annotation, the method will not be documented in the generated API documentation. Symbols without an api annotation will also not be exportable (unless they are explicitly exported with a `goog.exportProperty` call).
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ ol.MapBrowserEvent.EventType = {
|
|||||||
* A true single click with no dragging and no double click. Note that this
|
* A true single click with no dragging and no double click. Note that this
|
||||||
* event is delayed by 250 ms to ensure that it is not a double click.
|
* event is delayed by 250 ms to ensure that it is not a double click.
|
||||||
* @event ol.MapBrowserEvent#singleclick
|
* @event ol.MapBrowserEvent#singleclick
|
||||||
* @todo api
|
* @api
|
||||||
*/
|
*/
|
||||||
SINGLECLICK: 'singleclick',
|
SINGLECLICK: 'singleclick',
|
||||||
// ...
|
// ...
|
||||||
@@ -52,7 +52,7 @@ oli.MapBrowserEvent;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Coordinate}
|
* @type {ol.Coordinate}
|
||||||
* @todo api
|
* @api
|
||||||
*/
|
*/
|
||||||
oli.MapBrowserEvent.prototype.coordinate;
|
oli.MapBrowserEvent.prototype.coordinate;
|
||||||
|
|
||||||
|
|||||||
@@ -79,14 +79,6 @@ function addSignatureTypes(f) {
|
|||||||
f.signature = (f.signature || '') + '<span class="type-signature">'+(types.length? ' :'+types.join('|') : '')+' </span>';
|
f.signature = (f.signature || '') + '<span class="type-signature">'+(types.length? ' :'+types.join('|') : '')+' </span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAttribs(f) {
|
|
||||||
var attribs = helper.getAttribs(f);
|
|
||||||
|
|
||||||
if (attribs.length) {
|
|
||||||
f.attribs = '<span class="type-signature ' + (attribs[0] === 'static' ? 'static' : '') + '">' + htmlsafe(attribs.length ? attribs.join(',') : '') + ' </span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shortenPaths(files, commonPrefix) {
|
function shortenPaths(files, commonPrefix) {
|
||||||
// always use forward slashes
|
// always use forward slashes
|
||||||
var regexp = new RegExp('\\\\', 'g');
|
var regexp = new RegExp('\\\\', 'g');
|
||||||
@@ -198,11 +190,19 @@ function attachModuleSymbols(doclets, modules) {
|
|||||||
*/
|
*/
|
||||||
function buildNav(members) {
|
function buildNav(members) {
|
||||||
var nav = [];
|
var nav = [];
|
||||||
|
// merge namespaces and classes, then sort
|
||||||
if (members.namespaces.length) {
|
var merged = members.namespaces.concat(members.classes);
|
||||||
_.each(members.namespaces, function (v) {
|
merged.sort(function (a, b) {
|
||||||
// exclude 'olx' from sidebar
|
if (a.longname > b.longname)
|
||||||
if (v.longname.indexOf('olx') !== 0) {
|
return 1;
|
||||||
|
if (a.longname < b.longname)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
_.each(merged, function (v) {
|
||||||
|
// exclude 'olx' and interfaces from sidebar
|
||||||
|
if (v.longname.indexOf('olx') !== 0 && v.interface !== true) {
|
||||||
|
if (v.kind == 'namespace') {
|
||||||
nav.push({
|
nav.push({
|
||||||
type: 'namespace',
|
type: 'namespace',
|
||||||
longname: v.longname,
|
longname: v.longname,
|
||||||
@@ -225,13 +225,7 @@ function buildNav(members) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
if (v.kind == 'class') {
|
||||||
}
|
|
||||||
|
|
||||||
if (members.classes.length) {
|
|
||||||
_.each(members.classes, function (v) {
|
|
||||||
// ignore interfaces
|
|
||||||
if (v.interface !== true) {
|
|
||||||
nav.push({
|
nav.push({
|
||||||
type: 'class',
|
type: 'class',
|
||||||
longname: v.longname,
|
longname: v.longname,
|
||||||
@@ -255,9 +249,8 @@ function buildNav(members) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
return nav;
|
return nav;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,7 +397,6 @@ exports.publish = function(taffyData, opts, tutorials) {
|
|||||||
if ( needsSignature(doclet) ) {
|
if ( needsSignature(doclet) ) {
|
||||||
addSignatureParams(doclet);
|
addSignatureParams(doclet);
|
||||||
addSignatureReturns(doclet);
|
addSignatureReturns(doclet);
|
||||||
addAttribs(doclet);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -414,12 +406,10 @@ exports.publish = function(taffyData, opts, tutorials) {
|
|||||||
|
|
||||||
if (doclet.kind === 'member') {
|
if (doclet.kind === 'member') {
|
||||||
addSignatureTypes(doclet);
|
addSignatureTypes(doclet);
|
||||||
addAttribs(doclet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doclet.kind === 'constant') {
|
if (doclet.kind === 'constant') {
|
||||||
addSignatureTypes(doclet);
|
addSignatureTypes(doclet);
|
||||||
addAttribs(doclet);
|
|
||||||
doclet.kind = 'member';
|
doclet.kind = 'member';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ var self = this;
|
|||||||
<?js if (item.type === 'namespace' &&
|
<?js if (item.type === 'namespace' &&
|
||||||
(item.members.length + item.typedefs.length + item.methods.length +
|
(item.members.length + item.typedefs.length + item.methods.length +
|
||||||
item.events.length > 0)) { ?>
|
item.events.length > 0)) { ?>
|
||||||
<span class="static">static</span>
|
|
||||||
<?js } ?>
|
<?js } ?>
|
||||||
</span>
|
</span>
|
||||||
<ul class="members itemMembers">
|
<ul class="members itemMembers">
|
||||||
|
|||||||
@@ -1,202 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
#
|
|
||||||
# Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS-IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
"""Generates out a Closure deps.js file given a list of JavaScript sources.
|
|
||||||
|
|
||||||
Paths can be specified as arguments or (more commonly) specifying trees
|
|
||||||
with the flags (call with --help for descriptions).
|
|
||||||
|
|
||||||
Usage: depswriter.py [path/to/js1.js [path/to/js2.js] ...]
|
|
||||||
"""
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import optparse
|
|
||||||
import os
|
|
||||||
import posixpath
|
|
||||||
import shlex
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import source
|
|
||||||
import treescan
|
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'nnaze@google.com (Nathan Naze)'
|
|
||||||
|
|
||||||
|
|
||||||
def MakeDepsFile(source_map):
|
|
||||||
"""Make a generated deps file.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
source_map: A dict map of the source path to source.Source object.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str, A generated deps file source.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Write in path alphabetical order
|
|
||||||
paths = sorted(source_map.keys())
|
|
||||||
|
|
||||||
lines = []
|
|
||||||
|
|
||||||
for path in paths:
|
|
||||||
js_source = source_map[path]
|
|
||||||
|
|
||||||
# We don't need to add entries that don't provide anything.
|
|
||||||
if js_source.provides:
|
|
||||||
lines.append(_GetDepsLine(path, js_source))
|
|
||||||
|
|
||||||
return ''.join(lines)
|
|
||||||
|
|
||||||
|
|
||||||
def _GetDepsLine(path, js_source):
|
|
||||||
"""Get a deps.js file string for a source."""
|
|
||||||
|
|
||||||
provides = sorted(js_source.provides)
|
|
||||||
requires = sorted(js_source.requires)
|
|
||||||
|
|
||||||
return 'goog.addDependency(\'%s\', %s, %s);\n' % (path, provides, requires)
|
|
||||||
|
|
||||||
|
|
||||||
def _GetOptionsParser():
|
|
||||||
"""Get the options parser."""
|
|
||||||
|
|
||||||
parser = optparse.OptionParser(__doc__)
|
|
||||||
|
|
||||||
parser.add_option('--output_file',
|
|
||||||
dest='output_file',
|
|
||||||
action='store',
|
|
||||||
help=('If specified, write output to this path instead of '
|
|
||||||
'writing to standard output.'))
|
|
||||||
parser.add_option('--root',
|
|
||||||
dest='roots',
|
|
||||||
default=[],
|
|
||||||
action='append',
|
|
||||||
help='A root directory to scan for JS source files. '
|
|
||||||
'Paths of JS files in generated deps file will be '
|
|
||||||
'relative to this path. This flag may be specified '
|
|
||||||
'multiple times.')
|
|
||||||
parser.add_option('--root_with_prefix',
|
|
||||||
dest='roots_with_prefix',
|
|
||||||
default=[],
|
|
||||||
action='append',
|
|
||||||
help='A root directory to scan for JS source files, plus '
|
|
||||||
'a prefix (if either contains a space, surround with '
|
|
||||||
'quotes). Paths in generated deps file will be relative '
|
|
||||||
'to the root, but preceded by the prefix. This flag '
|
|
||||||
'may be specified multiple times.')
|
|
||||||
parser.add_option('--path_with_depspath',
|
|
||||||
dest='paths_with_depspath',
|
|
||||||
default=[],
|
|
||||||
action='append',
|
|
||||||
help='A path to a source file and an alternate path to '
|
|
||||||
'the file in the generated deps file (if either contains '
|
|
||||||
'a space, surround with whitespace). This flag may be '
|
|
||||||
'specified multiple times.')
|
|
||||||
return parser
|
|
||||||
|
|
||||||
|
|
||||||
def _NormalizePathSeparators(path):
|
|
||||||
"""Replaces OS-specific path separators with POSIX-style slashes.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
path: str, A file path.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str, The path with any OS-specific path separators (such as backslash on
|
|
||||||
Windows) replaced with URL-compatible forward slashes. A no-op on systems
|
|
||||||
that use POSIX paths.
|
|
||||||
"""
|
|
||||||
return path.replace(os.sep, posixpath.sep)
|
|
||||||
|
|
||||||
|
|
||||||
def _GetRelativePathToSourceDict(root, prefix=''):
|
|
||||||
"""Scans a top root directory for .js sources.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
root: str, Root directory.
|
|
||||||
prefix: str, Prefix for returned paths.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict, A map of relative paths (with prefix, if given), to source.Source
|
|
||||||
objects.
|
|
||||||
"""
|
|
||||||
# Remember and restore the cwd when we're done. We work from the root so
|
|
||||||
# that paths are relative from the root.
|
|
||||||
start_wd = os.getcwd()
|
|
||||||
os.chdir(root)
|
|
||||||
|
|
||||||
path_to_source = {}
|
|
||||||
for path in treescan.ScanTreeForJsFiles('.'):
|
|
||||||
prefixed_path = _NormalizePathSeparators(os.path.join(prefix, path))
|
|
||||||
path_to_source[prefixed_path] = source.Source(source.GetFileContents(path))
|
|
||||||
|
|
||||||
os.chdir(start_wd)
|
|
||||||
|
|
||||||
return path_to_source
|
|
||||||
|
|
||||||
|
|
||||||
def _GetPair(s):
|
|
||||||
"""Return a string as a shell-parsed tuple. Two values expected."""
|
|
||||||
try:
|
|
||||||
# shlex uses '\' as an escape character, so they must be escaped.
|
|
||||||
s = s.replace('\\', '\\\\')
|
|
||||||
first, second = shlex.split(s)
|
|
||||||
return (first, second)
|
|
||||||
except:
|
|
||||||
raise Exception('Unable to parse input line as a pair: %s' % s)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""CLI frontend to MakeDepsFile."""
|
|
||||||
logging.basicConfig(format=(sys.argv[0] + ': %(message)s'),
|
|
||||||
level=logging.INFO)
|
|
||||||
options, args = _GetOptionsParser().parse_args()
|
|
||||||
|
|
||||||
path_to_source = {}
|
|
||||||
|
|
||||||
# Roots without prefixes
|
|
||||||
for root in options.roots:
|
|
||||||
path_to_source.update(_GetRelativePathToSourceDict(root))
|
|
||||||
|
|
||||||
# Roots with prefixes
|
|
||||||
for root_and_prefix in options.roots_with_prefix:
|
|
||||||
root, prefix = _GetPair(root_and_prefix)
|
|
||||||
path_to_source.update(_GetRelativePathToSourceDict(root, prefix=prefix))
|
|
||||||
|
|
||||||
# Source paths
|
|
||||||
for path in args:
|
|
||||||
path_to_source[path] = source.Source(source.GetFileContents(path))
|
|
||||||
|
|
||||||
# Source paths with alternate deps paths
|
|
||||||
for path_with_depspath in options.paths_with_depspath:
|
|
||||||
srcpath, depspath = _GetPair(path_with_depspath)
|
|
||||||
path_to_source[depspath] = source.Source(source.GetFileContents(srcpath))
|
|
||||||
|
|
||||||
# Make our output pipe.
|
|
||||||
if options.output_file:
|
|
||||||
out = open(options.output_file, 'w')
|
|
||||||
else:
|
|
||||||
out = sys.stdout
|
|
||||||
|
|
||||||
out.write('// This file was autogenerated by %s.\n' % sys.argv[0])
|
|
||||||
out.write('// Please do not edit.\n')
|
|
||||||
|
|
||||||
out.write(MakeDepsFile(path_to_source))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
# Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS-IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
"""Scans a source JS file for its provided and required namespaces.
|
|
||||||
|
|
||||||
Simple class to scan a JavaScript file and express its dependencies.
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = 'nnaze@google.com'
|
|
||||||
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
_BASE_REGEX_STRING = '^\s*goog\.%s\(\s*[\'"](.+)[\'"]\s*\)'
|
|
||||||
_PROVIDE_REGEX = re.compile(_BASE_REGEX_STRING % 'provide')
|
|
||||||
_REQUIRES_REGEX = re.compile(_BASE_REGEX_STRING % 'require')
|
|
||||||
|
|
||||||
# This line identifies base.js and should match the line in that file.
|
|
||||||
_GOOG_BASE_LINE = (
|
|
||||||
'var goog = goog || {}; // Identifies this file as the Closure base.')
|
|
||||||
|
|
||||||
|
|
||||||
class Source(object):
|
|
||||||
"""Scans a JavaScript source for its provided and required namespaces."""
|
|
||||||
|
|
||||||
# Matches a "/* ... */" comment.
|
|
||||||
# Note: We can't definitively distinguish a "/*" in a string literal without a
|
|
||||||
# state machine tokenizer. We'll assume that a line starting with whitespace
|
|
||||||
# and "/*" is a comment.
|
|
||||||
_COMMENT_REGEX = re.compile(
|
|
||||||
r"""
|
|
||||||
^\s* # Start of a new line and whitespace
|
|
||||||
/\* # Opening "/*"
|
|
||||||
.*? # Non greedy match of any characters (including newlines)
|
|
||||||
\*/ # Closing "*/""",
|
|
||||||
re.MULTILINE | re.DOTALL | re.VERBOSE)
|
|
||||||
|
|
||||||
def __init__(self, source):
|
|
||||||
"""Initialize a source.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
source: str, The JavaScript source.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.provides = set()
|
|
||||||
self.requires = set()
|
|
||||||
|
|
||||||
self._source = source
|
|
||||||
self._ScanSource()
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return 'Source %s' % self._path
|
|
||||||
|
|
||||||
def GetSource(self):
|
|
||||||
"""Get the source as a string."""
|
|
||||||
return self._source
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _StripComments(cls, source):
|
|
||||||
return cls._COMMENT_REGEX.sub('', source)
|
|
||||||
|
|
||||||
def _ScanSource(self):
|
|
||||||
"""Fill in provides and requires by scanning the source."""
|
|
||||||
|
|
||||||
source = self._StripComments(self.GetSource())
|
|
||||||
|
|
||||||
source_lines = source.splitlines()
|
|
||||||
for line in source_lines:
|
|
||||||
match = _PROVIDE_REGEX.match(line)
|
|
||||||
if match:
|
|
||||||
self.provides.add(match.group(1))
|
|
||||||
match = _REQUIRES_REGEX.match(line)
|
|
||||||
if match:
|
|
||||||
self.requires.add(match.group(1))
|
|
||||||
|
|
||||||
# Closure's base file implicitly provides 'goog'.
|
|
||||||
for line in source_lines:
|
|
||||||
if line == _GOOG_BASE_LINE:
|
|
||||||
if len(self.provides) or len(self.requires):
|
|
||||||
raise Exception(
|
|
||||||
'Base files should not provide or require namespaces.')
|
|
||||||
self.provides.add('goog')
|
|
||||||
|
|
||||||
|
|
||||||
def GetFileContents(path):
|
|
||||||
"""Get a file's contents as a string.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
path: str, Path to file.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str, Contents of file.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
IOError: An error occurred opening or reading the file.
|
|
||||||
|
|
||||||
"""
|
|
||||||
fileobj = open(path)
|
|
||||||
try:
|
|
||||||
return fileobj.read()
|
|
||||||
finally:
|
|
||||||
fileobj.close()
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
#
|
|
||||||
# Copyright 2010 The Closure Library Authors. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS-IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
"""Shared utility functions for scanning directory trees."""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'nnaze@google.com (Nathan Naze)'
|
|
||||||
|
|
||||||
|
|
||||||
# Matches a .js file path.
|
|
||||||
_JS_FILE_REGEX = re.compile(r'^.+\.js$')
|
|
||||||
|
|
||||||
|
|
||||||
def ScanTreeForJsFiles(root):
|
|
||||||
"""Scans a directory tree for JavaScript files.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
root: str, Path to a root directory.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
An iterable of paths to JS files, relative to cwd.
|
|
||||||
"""
|
|
||||||
return ScanTree(root, path_filter=_JS_FILE_REGEX)
|
|
||||||
|
|
||||||
|
|
||||||
def ScanTree(root, path_filter=None, ignore_hidden=True):
|
|
||||||
"""Scans a directory tree for files.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
root: str, Path to a root directory.
|
|
||||||
path_filter: A regular expression filter. If set, only paths matching
|
|
||||||
the path_filter are returned.
|
|
||||||
ignore_hidden: If True, do not follow or return hidden directories or files
|
|
||||||
(those starting with a '.' character).
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
A string path to files, relative to cwd.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def OnError(os_error):
|
|
||||||
raise os_error
|
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk(root, onerror=OnError):
|
|
||||||
# os.walk allows us to modify dirnames to prevent decent into particular
|
|
||||||
# directories. Avoid hidden directories.
|
|
||||||
for dirname in dirnames:
|
|
||||||
if ignore_hidden and dirname.startswith('.'):
|
|
||||||
dirnames.remove(dirname)
|
|
||||||
|
|
||||||
for filename in filenames:
|
|
||||||
|
|
||||||
# nothing that starts with '.'
|
|
||||||
if ignore_hidden and filename.startswith('.'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
fullpath = os.path.join(dirpath, filename)
|
|
||||||
|
|
||||||
if path_filter and not path_filter.match(fullpath):
|
|
||||||
continue
|
|
||||||
|
|
||||||
yield os.path.normpath(fullpath)
|
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
* This loader is used for the hosted examples. It is used in place of the
|
* This loader is used for the hosted examples. It is used in place of the
|
||||||
* development loader (examples/loader.js).
|
* development loader (examples/loader.js).
|
||||||
*
|
*
|
||||||
* ol.js, ol-simple.js, ol-whitespace.js, and ol-deps.js are built
|
* The ol.js, ol-debug.js, and ol-deps.js scripts are built by OL3's
|
||||||
* by OL3's build.py script. They are located in the ../build/ directory,
|
* build.py script. They are located in the ../build/ directory, relative to
|
||||||
* relatively to this script.
|
* this script.
|
||||||
*
|
*
|
||||||
* The script must be named loader.js.
|
* The script must be named loader.js.
|
||||||
*
|
*
|
||||||
@@ -54,20 +54,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var oljs = 'ol.js', mode;
|
var raw = pageParams.mode && pageParams.mode.toLowerCase() === 'raw';
|
||||||
if ('mode' in pageParams) {
|
|
||||||
mode = pageParams.mode.toLowerCase();
|
|
||||||
if (mode == 'debug') {
|
|
||||||
mode = 'raw';
|
|
||||||
}
|
|
||||||
if (mode != 'advanced' && mode != 'raw') {
|
|
||||||
oljs = 'ol-' + mode + '.js';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var scriptId = encodeURIComponent(scriptParams.id);
|
var scriptId = encodeURIComponent(scriptParams.id);
|
||||||
if (mode != 'raw') {
|
if (!raw) {
|
||||||
document.write('<scr' + 'ipt type="text/javascript" src="../build/' + oljs + '"></scr' + 'ipt>');
|
document.write('<scr' + 'ipt type="text/javascript" src="../build/ol.js"></scr' + 'ipt>');
|
||||||
} else {
|
} else {
|
||||||
window.CLOSURE_NO_DEPS = true; // we've got our own deps file
|
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="../closure-library/closure/goog/base.js"></scr' + 'ipt>');
|
||||||
|
|||||||
307
build.py
307
build.py
@@ -16,10 +16,9 @@ from pake import ifind, main, output, rule, target, variables, virtual, which
|
|||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
|
|
||||||
win = {
|
win = {
|
||||||
|
'CLEANCSS': './node_modules/.bin/cleancss',
|
||||||
'GIT': 'git.exe',
|
'GIT': 'git.exe',
|
||||||
'GJSLINT': 'gjslint.exe',
|
'GJSLINT': 'gjslint.exe',
|
||||||
'JAVA': 'java.exe',
|
|
||||||
'JAR': 'jar.exe',
|
|
||||||
'JSDOC': './node_modules/.bin/jsdoc',
|
'JSDOC': './node_modules/.bin/jsdoc',
|
||||||
'JSHINT': './node_modules/.bin/jshint',
|
'JSHINT': './node_modules/.bin/jshint',
|
||||||
'PYTHON': 'python.exe',
|
'PYTHON': 'python.exe',
|
||||||
@@ -28,24 +27,6 @@ if sys.platform == 'win32':
|
|||||||
|
|
||||||
sys_dir = os.environ.get('SYSTEMDRIVE')
|
sys_dir = os.environ.get('SYSTEMDRIVE')
|
||||||
program_files = os.environ.get('PROGRAMFILES')
|
program_files = os.environ.get('PROGRAMFILES')
|
||||||
java_home = os.environ.get('JAVA_HOME')
|
|
||||||
|
|
||||||
if not java_home:
|
|
||||||
# Following lines choose sensible defaults to guess JAVA_HOME in
|
|
||||||
# 32/64bit Program Files folder opting for the most current version.
|
|
||||||
search_term = os.path.join(sys_dir, os.sep, 'Program Files*', 'Java', 'jdk*')
|
|
||||||
found_jdks = sorted(glob.glob(search_term), key=lambda x: x[-8:])
|
|
||||||
if found_jdks:
|
|
||||||
java_home = found_jdks[-1]
|
|
||||||
|
|
||||||
if java_home:
|
|
||||||
if not which(win['JAVA']):
|
|
||||||
win['JAVA'] = os.path.join(java_home, 'bin', 'java.exe')
|
|
||||||
if not which(win['JAR']):
|
|
||||||
win['JAR'] = os.path.join(java_home, 'bin', 'jar.exe')
|
|
||||||
elif not which(win['JAVA']):
|
|
||||||
win['JAVA'] = os.path.join(program_files,
|
|
||||||
'Java', 'jre7', 'bin', 'java.exe')
|
|
||||||
|
|
||||||
if not which(win['GIT']):
|
if not which(win['GIT']):
|
||||||
win['GIT'] = os.path.join(program_files, 'Git', 'cmd', 'git.exe')
|
win['GIT'] = os.path.join(program_files, 'Git', 'cmd', 'git.exe')
|
||||||
@@ -70,11 +51,10 @@ if sys.platform == 'win32':
|
|||||||
setattr(variables, program, path)
|
setattr(variables, program, path)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
variables.CLEANCSS = './node_modules/.bin/cleancss'
|
||||||
variables.GIT = 'git'
|
variables.GIT = 'git'
|
||||||
variables.GJSLINT = 'gjslint'
|
variables.GJSLINT = 'gjslint'
|
||||||
variables.JSHINT = './node_modules/.bin/jshint'
|
variables.JSHINT = './node_modules/.bin/jshint'
|
||||||
variables.JAVA = 'java'
|
|
||||||
variables.JAR = 'jar'
|
|
||||||
variables.JSDOC = './node_modules/.bin/jsdoc'
|
variables.JSDOC = './node_modules/.bin/jsdoc'
|
||||||
variables.PYTHON = 'python'
|
variables.PYTHON = 'python'
|
||||||
variables.PHANTOMJS = './node_modules/.bin/phantomjs'
|
variables.PHANTOMJS = './node_modules/.bin/phantomjs'
|
||||||
@@ -82,12 +62,10 @@ else:
|
|||||||
variables.BRANCH = output(
|
variables.BRANCH = output(
|
||||||
'%(GIT)s', 'rev-parse', '--abbrev-ref', 'HEAD').strip()
|
'%(GIT)s', 'rev-parse', '--abbrev-ref', 'HEAD').strip()
|
||||||
|
|
||||||
EXECUTABLES = [variables.GIT, variables.GJSLINT, variables.JAVA, variables.JAR,
|
EXECUTABLES = [variables.CLEANCSS, variables.GIT, variables.GJSLINT,
|
||||||
variables.JSDOC, variables.JSHINT, variables.PYTHON,
|
variables.JSDOC, variables.JSHINT, variables.PYTHON,
|
||||||
variables.PHANTOMJS]
|
variables.PHANTOMJS]
|
||||||
|
|
||||||
EXPORTS = 'build/exports.js'
|
|
||||||
|
|
||||||
EXAMPLES = [path
|
EXAMPLES = [path
|
||||||
for path in ifind('examples')
|
for path in ifind('examples')
|
||||||
if path.endswith('.html')
|
if path.endswith('.html')
|
||||||
@@ -100,7 +78,6 @@ EXAMPLES_SRC = [path
|
|||||||
if not path.startswith('examples/bootstrap')
|
if not path.startswith('examples/bootstrap')
|
||||||
if path != 'examples/Jugl.js'
|
if path != 'examples/Jugl.js'
|
||||||
if path != 'examples/jquery.min.js'
|
if path != 'examples/jquery.min.js'
|
||||||
if path != 'examples/loader.js'
|
|
||||||
if path != 'examples/example-list.js']
|
if path != 'examples/example-list.js']
|
||||||
|
|
||||||
EXAMPLES_JSON = ['build/' + example.replace('.html', '.json')
|
EXAMPLES_JSON = ['build/' + example.replace('.html', '.json')
|
||||||
@@ -129,17 +106,6 @@ SRC = [path
|
|||||||
if path.endswith('.js')
|
if path.endswith('.js')
|
||||||
if path not in SHADER_SRC]
|
if path not in SHADER_SRC]
|
||||||
|
|
||||||
LIBTESS_JS_SRC = [path
|
|
||||||
for path in ifind('src/libtess.js')
|
|
||||||
if path.endswith('.js')]
|
|
||||||
|
|
||||||
PLOVR_JAR = 'build/plovr-81ed862.jar'
|
|
||||||
PLOVR_JAR_MD5 = '1c752daaf11ad6220b298e7d2ee2b87d'
|
|
||||||
|
|
||||||
PROJ4JS = 'build/proj4js/lib/proj4js-combined.js'
|
|
||||||
PROJ4JS_ZIP = 'build/proj4js-1.1.0.zip'
|
|
||||||
PROJ4JS_ZIP_MD5 = '17caad64cf6ebc6e6fe62f292b134897'
|
|
||||||
|
|
||||||
|
|
||||||
def report_sizes(t):
|
def report_sizes(t):
|
||||||
stringio = StringIO()
|
stringio = StringIO()
|
||||||
@@ -157,66 +123,36 @@ def report_sizes(t):
|
|||||||
virtual('default', 'build')
|
virtual('default', 'build')
|
||||||
|
|
||||||
|
|
||||||
virtual('integration-test', 'lint', 'jshint', 'build', 'build-all',
|
virtual('ci', 'lint', 'jshint', 'build', 'test',
|
||||||
'test', 'build/examples/all.combined.js', 'check-examples', 'apidoc')
|
'build/examples/all.combined.js', 'check-examples', 'apidoc')
|
||||||
|
|
||||||
|
|
||||||
virtual('build', 'build/ol.css', 'build/ol.js',
|
virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js')
|
||||||
'build/ol-simple.js', 'build/ol-whitespace.js')
|
|
||||||
|
|
||||||
|
|
||||||
virtual('check', 'lint', 'jshint', 'build/ol-all.js', 'test')
|
virtual('check', 'lint', 'jshint', 'test')
|
||||||
|
|
||||||
|
|
||||||
virtual('todo', 'fixme')
|
virtual('todo', 'fixme')
|
||||||
|
|
||||||
|
|
||||||
@target('build/ol.css', 'build/ol.js')
|
@target('build/ol.css', 'css/ol.css')
|
||||||
def build_ol_css(t):
|
def build_ol_css(t):
|
||||||
t.touch()
|
t.output('%(CLEANCSS)s', 'css/ol.css')
|
||||||
|
|
||||||
|
|
||||||
@target('build/ol.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC, LIBTESS_JS_SRC,
|
@target('build/ol.js', SRC, SHADER_SRC, 'buildcfg/ol.json')
|
||||||
'buildcfg/base.json', 'buildcfg/ol.json')
|
def build_ol_new_js(t):
|
||||||
def build_ol_js(t):
|
t.run('node', 'tasks/build.js', 'buildcfg/ol.json', 'build/ol.js')
|
||||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
|
||||||
PLOVR_JAR, 'build', 'buildcfg/ol.json')
|
|
||||||
report_sizes(t)
|
report_sizes(t)
|
||||||
|
|
||||||
|
|
||||||
@target('build/ol-simple.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC,
|
@target('build/ol-debug.js', SRC, SHADER_SRC, 'buildcfg/ol-debug.json')
|
||||||
LIBTESS_JS_SRC, 'buildcfg/base.json', 'buildcfg/ol.json',
|
def build_ol_debug_js(t):
|
||||||
'buildcfg/ol-simple.json')
|
t.run('node', 'tasks/build.js', 'buildcfg/ol-debug.json', 'build/ol-debug.js')
|
||||||
def build_ol_simple_js(t):
|
|
||||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
|
||||||
PLOVR_JAR, 'build', 'buildcfg/ol-simple.json')
|
|
||||||
report_sizes(t)
|
report_sizes(t)
|
||||||
|
|
||||||
|
|
||||||
@target('build/ol-whitespace.js', PLOVR_JAR, SRC, EXPORTS,
|
|
||||||
SHADER_SRC, LIBTESS_JS_SRC, 'buildcfg/base.json', 'buildcfg/ol.json',
|
|
||||||
'buildcfg/ol-whitespace.json')
|
|
||||||
def build_ol_whitespace_js(t):
|
|
||||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
|
||||||
PLOVR_JAR, 'build', 'buildcfg/ol-whitespace.json')
|
|
||||||
report_sizes(t)
|
|
||||||
|
|
||||||
|
|
||||||
virtual('build-all', 'build/ol-all.js')
|
|
||||||
|
|
||||||
|
|
||||||
@target('build/ol-all.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC, LIBTESS_JS_SRC,
|
|
||||||
'buildcfg/base.json', 'buildcfg/ol-all.json')
|
|
||||||
def build_ol_all_js(t):
|
|
||||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
|
||||||
PLOVR_JAR, 'build', 'buildcfg/ol-all.json')
|
|
||||||
|
|
||||||
|
|
||||||
@target(EXPORTS, SRC)
|
|
||||||
def build_exports_js(t):
|
|
||||||
t.run('node', 'tasks/generate-exports.js', EXPORTS)
|
|
||||||
|
|
||||||
|
|
||||||
for glsl_src in GLSL_SRC:
|
for glsl_src in GLSL_SRC:
|
||||||
def shader_src_helper(glsl_src):
|
def shader_src_helper(glsl_src):
|
||||||
@target(glsl_src.replace('.glsl', 'shader.js'), glsl_src,
|
@target(glsl_src.replace('.glsl', 'shader.js'), glsl_src,
|
||||||
@@ -259,12 +195,11 @@ def examples_examples_list_js(t):
|
|||||||
t.run('%(PYTHON)s', 'bin/exampleparser.py', 'examples', 'examples')
|
t.run('%(PYTHON)s', 'bin/exampleparser.py', 'examples', 'examples')
|
||||||
|
|
||||||
|
|
||||||
@target('build/examples/all.combined.js', 'build/examples/all.js', PLOVR_JAR,
|
@target('build/examples/all.combined.js', 'build/examples/all.js',
|
||||||
SRC, SHADER_SRC, LIBTESS_JS_SRC,
|
SRC, SHADER_SRC, 'buildcfg/examples-all.json')
|
||||||
'buildcfg/base.json', 'build/examples/all.json')
|
|
||||||
def build_examples_all_combined_js(t):
|
def build_examples_all_combined_js(t):
|
||||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
t.run('node', 'tasks/build.js', 'buildcfg/examples-all.json',
|
||||||
PLOVR_JAR, 'build', 'buildcfg/examples-all.json')
|
'build/examples/all.combined.js')
|
||||||
report_sizes(t)
|
report_sizes(t)
|
||||||
|
|
||||||
|
|
||||||
@@ -282,77 +217,105 @@ def examples_star_json(name, match):
|
|||||||
# Note that we use the proper way in buildcfg/examples-all.json, which
|
# Note that we use the proper way in buildcfg/examples-all.json, which
|
||||||
# is only used to check the examples code using the compiler.
|
# is only used to check the examples code using the compiler.
|
||||||
content = json.dumps({
|
content = json.dumps({
|
||||||
'id': match.group('id'),
|
"exports": [],
|
||||||
'inherits': '../../buildcfg/base.json',
|
"src": ["src/**/*.js", "examples/%(id)s.js" % match.groupdict()],
|
||||||
'inputs': [
|
"compile": {
|
||||||
'../examples/%(id)s.js' % match.groupdict()
|
"externs": [
|
||||||
|
"externs/bingmaps.js",
|
||||||
|
"externs/bootstrap.js",
|
||||||
|
"externs/closure-compiler.js",
|
||||||
|
"externs/example.js",
|
||||||
|
"externs/geojson.js",
|
||||||
|
"externs/jquery-1.7.js",
|
||||||
|
"externs/oli.js",
|
||||||
|
"externs/olx.js",
|
||||||
|
"externs/proj4js.js",
|
||||||
|
"externs/tilejson.js",
|
||||||
|
"externs/topojson.js",
|
||||||
|
"externs/vbarray.js"
|
||||||
],
|
],
|
||||||
'externs': [
|
"define": [
|
||||||
'//jquery-1.7.js',
|
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||||
'../externs/bingmaps.js',
|
"goog.DEBUG=false"
|
||||||
'../externs/bootstrap.js',
|
|
||||||
'../externs/closure-compiler.js',
|
|
||||||
'../externs/example.js',
|
|
||||||
'../externs/geojson.js',
|
|
||||||
'../externs/oli.js',
|
|
||||||
'../externs/olx.js',
|
|
||||||
'../externs/proj4js.js',
|
|
||||||
'../externs/tilejson.js',
|
|
||||||
'../externs/topojson.js',
|
|
||||||
'../externs/vbarray.js',
|
|
||||||
],
|
],
|
||||||
|
"jscomp_error": [
|
||||||
|
"accessControls",
|
||||||
|
"ambiguousFunctionDecl",
|
||||||
|
"checkDebuggerStatement",
|
||||||
|
"checkEventfulObjectDisposal",
|
||||||
|
"checkProvides",
|
||||||
|
"checkRegExp",
|
||||||
|
"checkStructDictInheritance",
|
||||||
|
"checkTypes",
|
||||||
|
"checkVars",
|
||||||
|
"const",
|
||||||
|
"constantProperty",
|
||||||
|
"deprecated",
|
||||||
|
"duplicate",
|
||||||
|
"duplicateMessage",
|
||||||
|
"es3",
|
||||||
|
"externsValidation",
|
||||||
|
"fileoverviewTags",
|
||||||
|
"globalThis",
|
||||||
|
"internetExplorerChecks",
|
||||||
|
"invalidCasts",
|
||||||
|
"misplacedTypeAnnotation",
|
||||||
|
"missingProperties",
|
||||||
|
"nonStandardJsDocs",
|
||||||
|
"strictModuleDepCheck",
|
||||||
|
"suspiciousCode",
|
||||||
|
"typeInvalidation",
|
||||||
|
"tweakValidation",
|
||||||
|
"undefinedNames",
|
||||||
|
"undefinedVars",
|
||||||
|
"unknownDefines",
|
||||||
|
"uselessCode",
|
||||||
|
"violatedModuleDep",
|
||||||
|
"visibility"
|
||||||
|
],
|
||||||
|
"extra_annotation_name": [
|
||||||
|
"api", "observable"
|
||||||
|
],
|
||||||
|
"jscomp_off": [
|
||||||
|
"es5Strict"
|
||||||
|
],
|
||||||
|
"compilation_level": "ADVANCED",
|
||||||
|
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
||||||
|
"use_types_for_optimization": True,
|
||||||
|
"manage_closure_dependencies": True
|
||||||
|
}
|
||||||
})
|
})
|
||||||
with open(t.name, 'wb') as f:
|
with open(t.name, 'wb') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
dependencies = [__file__, 'buildcfg/base.json']
|
return Target(name, action=action, dependencies=[__file__])
|
||||||
return Target(name, action=action, dependencies=dependencies)
|
|
||||||
|
|
||||||
|
|
||||||
@rule(r'\Abuild/examples/(?P<id>.*).combined.js\Z')
|
@rule(r'\Abuild/examples/(?P<id>.*).combined.js\Z')
|
||||||
def examples_star_combined_js(name, match):
|
def examples_star_combined_js(name, match):
|
||||||
def action(t):
|
def action(t):
|
||||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
config = 'build/examples/%(id)s.json' % match.groupdict()
|
||||||
PLOVR_JAR, 'build', 'build/examples/%(id)s.json' %
|
t.run('node', 'tasks/build.js', config, name)
|
||||||
match.groupdict())
|
|
||||||
report_sizes(t)
|
report_sizes(t)
|
||||||
dependencies = [PLOVR_JAR, SRC, SHADER_SRC, LIBTESS_JS_SRC,
|
dependencies = [SRC, SHADER_SRC,
|
||||||
'buildcfg/base.json',
|
|
||||||
'examples/%(id)s.js' % match.groupdict(),
|
'examples/%(id)s.js' % match.groupdict(),
|
||||||
'build/examples/%(id)s.json' % match.groupdict()]
|
'build/examples/%(id)s.json' % match.groupdict()]
|
||||||
return Target(name, action=action, dependencies=dependencies)
|
return Target(name, action=action, dependencies=dependencies)
|
||||||
|
|
||||||
|
|
||||||
@target('serve', PLOVR_JAR, 'test-deps', 'examples')
|
@target('serve', 'examples')
|
||||||
def serve(t):
|
def serve(t):
|
||||||
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'buildcfg/ol.json',
|
t.run('node', 'tasks/serve.js')
|
||||||
'buildcfg/ol-all.json', EXAMPLES_JSON, 'buildcfg/test.json')
|
|
||||||
|
|
||||||
|
|
||||||
@target('serve-integration-test', PLOVR_JAR)
|
virtual('lint', 'build/lint-timestamp', 'build/check-requires-timestamp',
|
||||||
def serve_precommit(t):
|
'build/check-whitespace-timestamp')
|
||||||
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve',
|
|
||||||
'buildcfg/ol-all.json', 'buildcfg/test.json')
|
|
||||||
|
|
||||||
|
|
||||||
virtual('lint', 'build/lint-timestamp', 'build/lint-libtess.js-timestamp',
|
@target('build/lint-timestamp', SRC, EXAMPLES_SRC, SPEC, precious=True)
|
||||||
'build/check-requires-timestamp', 'build/check-whitespace-timestamp')
|
|
||||||
|
|
||||||
|
|
||||||
@target('build/lint-timestamp', SRC, EXPORTS, EXAMPLES_SRC, SPEC, precious=True)
|
|
||||||
def build_lint_src_timestamp(t):
|
def build_lint_src_timestamp(t):
|
||||||
t.run('%(GJSLINT)s',
|
t.run('%(GJSLINT)s',
|
||||||
'--jslint_error=all',
|
'--jslint_error=all',
|
||||||
'--custom_jsdoc_tags=event,fires,todo,function,classdesc',
|
'--custom_jsdoc_tags=event,fires,function,classdesc,api,observable',
|
||||||
'--strict',
|
|
||||||
t.newer(t.dependencies))
|
|
||||||
t.touch()
|
|
||||||
|
|
||||||
|
|
||||||
@target('build/lint-libtess.js-timestamp', LIBTESS_JS_SRC, precious=True)
|
|
||||||
def build_lint_libtess_js_timestamp(t):
|
|
||||||
t.run('%(GJSLINT)s',
|
|
||||||
'--jslint_error=all',
|
|
||||||
'--disable=110',
|
|
||||||
'--strict',
|
'--strict',
|
||||||
t.newer(t.dependencies))
|
t.newer(t.dependencies))
|
||||||
t.touch()
|
t.touch()
|
||||||
@@ -360,7 +323,7 @@ def build_lint_libtess_js_timestamp(t):
|
|||||||
|
|
||||||
virtual('jshint', 'build/jshint-timestamp')
|
virtual('jshint', 'build/jshint-timestamp')
|
||||||
|
|
||||||
@target('build/jshint-timestamp', SRC, EXPORTS, EXAMPLES_SRC, SPEC,
|
@target('build/jshint-timestamp', SRC, EXAMPLES_SRC, SPEC,
|
||||||
precious=True)
|
precious=True)
|
||||||
def build_jshint_timestamp(t):
|
def build_jshint_timestamp(t):
|
||||||
t.run(variables.JSHINT, '--verbose', t.newer(t.dependencies))
|
t.run(variables.JSHINT, '--verbose', t.newer(t.dependencies))
|
||||||
@@ -390,22 +353,21 @@ def _strip_comments(lines):
|
|||||||
yield lineno, line
|
yield lineno, line
|
||||||
|
|
||||||
|
|
||||||
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC,
|
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC, SHADER_SRC, SPEC)
|
||||||
SHADER_SRC, LIBTESS_JS_SRC, SPEC)
|
|
||||||
def build_check_requires_timestamp(t):
|
def build_check_requires_timestamp(t):
|
||||||
from zipfile import ZipFile
|
|
||||||
unused_count = 0
|
unused_count = 0
|
||||||
all_provides = set()
|
all_provides = set()
|
||||||
zf = ZipFile(PLOVR_JAR)
|
closure_lib_path = output('node', '-e',
|
||||||
for zi in zf.infolist():
|
'process.stdout.write(require("closure-util").getLibraryPath())')
|
||||||
if zi.filename.endswith('.js'):
|
for filename in ifind(closure_lib_path):
|
||||||
if not zi.filename.startswith('closure/goog/'):
|
if filename.endswith('.js'):
|
||||||
|
if not re.match(r'.*/closure/goog/', filename):
|
||||||
continue
|
continue
|
||||||
# Skip goog.i18n because it contains so many modules that it causes
|
# Skip goog.i18n because it contains so many modules that it causes
|
||||||
# the generated regular expression to exceed Python's limits
|
# the generated regular expression to exceed Python's limits
|
||||||
if zi.filename.startswith('closure/goog/i18n/'):
|
if re.match(r'.*/closure/goog/i18n/', filename):
|
||||||
continue
|
continue
|
||||||
for line in zf.open(zi, 'rU'):
|
for line in open(filename, 'rU'):
|
||||||
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
|
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
|
||||||
if m:
|
if m:
|
||||||
all_provides.add(m.group(1))
|
all_provides.add(m.group(1))
|
||||||
@@ -531,8 +493,8 @@ def build_check_requires_timestamp(t):
|
|||||||
t.touch()
|
t.touch()
|
||||||
|
|
||||||
|
|
||||||
@target('build/check-whitespace-timestamp', SRC, EXPORTS, EXAMPLES_SRC,
|
@target('build/check-whitespace-timestamp', SRC, EXAMPLES_SRC,
|
||||||
SPEC, JSDOC_SRC, LIBTESS_JS_SRC, precious=True)
|
SPEC, JSDOC_SRC, precious=True)
|
||||||
def build_check_whitespace_timestamp(t):
|
def build_check_whitespace_timestamp(t):
|
||||||
CR_RE = re.compile(r'\r')
|
CR_RE = re.compile(r'\r')
|
||||||
LEADING_WHITESPACE_RE = re.compile(r'\s+')
|
LEADING_WHITESPACE_RE = re.compile(r'\s+')
|
||||||
@@ -564,23 +526,11 @@ def build_check_whitespace_timestamp(t):
|
|||||||
t.touch()
|
t.touch()
|
||||||
|
|
||||||
|
|
||||||
virtual('plovr', PLOVR_JAR)
|
|
||||||
|
|
||||||
|
|
||||||
@target(PLOVR_JAR, clean=False)
|
|
||||||
def plovr_jar(t):
|
|
||||||
t.info('downloading %r', t.name)
|
|
||||||
t.download('https://plovr.googlecode.com/files/' +
|
|
||||||
os.path.basename(PLOVR_JAR), md5=PLOVR_JAR_MD5)
|
|
||||||
t.info('downloaded %r', t.name)
|
|
||||||
|
|
||||||
|
|
||||||
virtual('apidoc', 'build/jsdoc-%(BRANCH)s-timestamp' % vars(variables))
|
virtual('apidoc', 'build/jsdoc-%(BRANCH)s-timestamp' % vars(variables))
|
||||||
|
|
||||||
|
|
||||||
@target('build/jsdoc-%(BRANCH)s-timestamp' % vars(variables), 'host-resources',
|
@target('build/jsdoc-%(BRANCH)s-timestamp' % vars(variables), 'host-resources',
|
||||||
EXPORTS, SRC, SHADER_SRC,
|
SRC, SHADER_SRC, ifind('apidoc/template'))
|
||||||
ifind('apidoc/template'))
|
|
||||||
def jsdoc_BRANCH_timestamp(t):
|
def jsdoc_BRANCH_timestamp(t):
|
||||||
t.run('%(JSDOC)s', 'apidoc/index.md', '-c', 'apidoc/conf.json',
|
t.run('%(JSDOC)s', 'apidoc/index.md', '-c', 'apidoc/conf.json',
|
||||||
'-d', 'build/hosted/%(BRANCH)s/apidoc')
|
'-d', 'build/hosted/%(BRANCH)s/apidoc')
|
||||||
@@ -631,6 +581,8 @@ def host_examples(t):
|
|||||||
examples_dir = 'build/hosted/%(BRANCH)s/examples'
|
examples_dir = 'build/hosted/%(BRANCH)s/examples'
|
||||||
build_dir = 'build/hosted/%(BRANCH)s/build'
|
build_dir = 'build/hosted/%(BRANCH)s/build'
|
||||||
css_dir = 'build/hosted/%(BRANCH)s/css'
|
css_dir = 'build/hosted/%(BRANCH)s/css'
|
||||||
|
closure_lib_path = output('node', '-e',
|
||||||
|
'process.stdout.write(require("closure-util").getLibraryPath())')
|
||||||
t.rm_rf(examples_dir)
|
t.rm_rf(examples_dir)
|
||||||
t.makedirs(examples_dir)
|
t.makedirs(examples_dir)
|
||||||
t.rm_rf(build_dir)
|
t.rm_rf(build_dir)
|
||||||
@@ -642,21 +594,17 @@ def host_examples(t):
|
|||||||
split_example_file(example, examples_dir % vars(variables))
|
split_example_file(example, examples_dir % vars(variables))
|
||||||
t.cp_r('examples/data', examples_dir + '/data')
|
t.cp_r('examples/data', examples_dir + '/data')
|
||||||
t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
|
t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
|
||||||
t.cp('build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js',
|
t.cp('build/ol.js', 'build/ol-debug.js', build_dir)
|
||||||
build_dir)
|
|
||||||
t.cp('build/ol.css', css_dir)
|
t.cp('build/ol.css', css_dir)
|
||||||
t.cp('examples/index.html', 'examples/example-list.js',
|
t.cp('examples/index.html', 'examples/example-list.js',
|
||||||
'examples/example-list.xml', 'examples/Jugl.js',
|
'examples/example-list.xml', 'examples/Jugl.js',
|
||||||
'examples/jquery.min.js', examples_dir)
|
'examples/jquery.min.js', examples_dir)
|
||||||
t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
|
t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
|
||||||
t.makedirs('build/hosted/%(BRANCH)s/closure-library')
|
t.cp_r(closure_lib_path, 'build/hosted/%(BRANCH)s/closure-library')
|
||||||
with t.chdir('build/hosted/%(BRANCH)s/closure-library'):
|
|
||||||
t.run('%(JAR)s', 'xf', '../../../../' + PLOVR_JAR, 'closure')
|
|
||||||
t.run('%(JAR)s', 'xf', '../../../../' + PLOVR_JAR, 'third_party')
|
|
||||||
t.rm_rf('build/hosted/%(BRANCH)s/ol')
|
t.rm_rf('build/hosted/%(BRANCH)s/ol')
|
||||||
t.makedirs('build/hosted/%(BRANCH)s/ol')
|
t.makedirs('build/hosted/%(BRANCH)s/ol')
|
||||||
t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
|
t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
|
||||||
t.run('%(PYTHON)s', 'bin/closure/depswriter.py',
|
t.run('%(PYTHON)s', closure_lib_path + '/closure/bin/build/depswriter.py',
|
||||||
'--root_with_prefix', 'src ../../../ol',
|
'--root_with_prefix', 'src ../../../ol',
|
||||||
'--root', 'build/hosted/%(BRANCH)s/closure-library/closure/goog',
|
'--root', 'build/hosted/%(BRANCH)s/closure-library/closure/goog',
|
||||||
'--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
|
'--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
|
||||||
@@ -675,29 +623,9 @@ def check_examples(t):
|
|||||||
t.run('%(PHANTOMJS)s', 'bin/check-example.js', example)
|
t.run('%(PHANTOMJS)s', 'bin/check-example.js', example)
|
||||||
|
|
||||||
|
|
||||||
@target(PROJ4JS, PROJ4JS_ZIP)
|
@target('test', phony=True)
|
||||||
def proj4js(t):
|
|
||||||
from zipfile import ZipFile
|
|
||||||
zf = ZipFile(PROJ4JS_ZIP)
|
|
||||||
contents = zf.open('proj4js/lib/proj4js-combined.js').read()
|
|
||||||
with open(t.name, 'wb') as f:
|
|
||||||
f.write(contents)
|
|
||||||
|
|
||||||
|
|
||||||
@target(PROJ4JS_ZIP, clean=False)
|
|
||||||
def proj4js_zip(t):
|
|
||||||
t.info('downloading %r', t.name)
|
|
||||||
t.download('http://download.osgeo.org/proj4js/' +
|
|
||||||
os.path.basename(t.name), md5=PROJ4JS_ZIP_MD5)
|
|
||||||
t.info('downloaded %r', t.name)
|
|
||||||
|
|
||||||
|
|
||||||
virtual('test-deps', PROJ4JS, 'build/test/requireall.js')
|
|
||||||
|
|
||||||
|
|
||||||
@target('test', 'test-deps', phony=True)
|
|
||||||
def test(t):
|
def test(t):
|
||||||
t.run('%(PHANTOMJS)s', 'test/mocha-phantomjs.js', 'test/ol.html')
|
t.run('node', 'tasks/test.js')
|
||||||
|
|
||||||
|
|
||||||
@target('fixme', phony=True)
|
@target('fixme', phony=True)
|
||||||
@@ -758,7 +686,7 @@ There is one option:
|
|||||||
-c - Cleans up the repository from previous builds.
|
-c - Cleans up the repository from previous builds.
|
||||||
|
|
||||||
The most common targets are:
|
The most common targets are:
|
||||||
serve - Serves files through plovr, usually on port 9810.
|
serve - Serves files, on port 3000.
|
||||||
lint - Runs gjslint on all sourcefiles to enforce specific syntax.
|
lint - Runs gjslint on all sourcefiles to enforce specific syntax.
|
||||||
build - Builds singlefile versions of OpenLayers JavaScript and
|
build - Builds singlefile versions of OpenLayers JavaScript and
|
||||||
CSS. This is also the default build target which runs when
|
CSS. This is also the default build target which runs when
|
||||||
@@ -771,18 +699,17 @@ The most common targets are:
|
|||||||
|
|
||||||
Other less frequently used targets are:
|
Other less frequently used targets are:
|
||||||
apidoc - Builds the API-Documentation using JSDoc3.
|
apidoc - Builds the API-Documentation using JSDoc3.
|
||||||
integration-test - Builds all examples in various modes and usually takes a
|
ci - Builds all examples in various modes and usually takes a
|
||||||
long time to finish. This target calls the following
|
long time to finish. This target calls the following
|
||||||
targets: lint, build, build-all, test, build-examples,
|
targets: lint, build, build-all, test, build-examples,
|
||||||
check-examples and apidoc.
|
check-examples and apidoc. This is the target run on
|
||||||
|
Travis CI.
|
||||||
reallyclean - Remove untracked files from the repository.
|
reallyclean - Remove untracked files from the repository.
|
||||||
checkdeps - Checks whether all required development software is
|
checkdeps - Checks whether all required development software is
|
||||||
installed on your machine.
|
installed on your machine.
|
||||||
fixme - Will print a list of parts of the code that are marked
|
fixme - Will print a list of parts of the code that are marked
|
||||||
with either TODO or FIXME.
|
with either TODO or FIXME.
|
||||||
todo - This is an alias for the fixme-target (see above).
|
todo - This is an alias for the fixme-target (see above).
|
||||||
plovr - Fetches the required plovr.jar. Usually called by other
|
|
||||||
targets that depend on plovr.
|
|
||||||
|
|
||||||
If no target is given, the build-target will be executed.
|
If no target is given, the build-target will be executed.
|
||||||
|
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
{
|
|
||||||
|
|
||||||
"ambiguate-properties": true,
|
|
||||||
|
|
||||||
"checks": {
|
|
||||||
"accessControls": "ERROR",
|
|
||||||
"ambiguousFunctionDecl": "ERROR",
|
|
||||||
"checkDebuggerStatement": "WARNING",
|
|
||||||
"checkEventfulObjectDisposal": "ERROR",
|
|
||||||
"checkProvides": "ERROR",
|
|
||||||
"checkRegExp": "ERROR",
|
|
||||||
"checkStructDictInheritance": "ERROR",
|
|
||||||
"checkTypes": "ERROR",
|
|
||||||
"checkVars": "ERROR",
|
|
||||||
"const": "ERROR",
|
|
||||||
"constantProperty": "ERROR",
|
|
||||||
"deprecated": "ERROR",
|
|
||||||
"duplicate": "ERROR",
|
|
||||||
"duplicateMessage": "ERROR",
|
|
||||||
"es3": "ERROR",
|
|
||||||
"es5Strict": "ERROR",
|
|
||||||
"externsValidation": "ERROR",
|
|
||||||
"fileoverviewTags": "ERROR",
|
|
||||||
"globalThis": "ERROR",
|
|
||||||
"internetExplorerChecks": "ERROR",
|
|
||||||
"invalidCasts": "ERROR",
|
|
||||||
"misplacedTypeAnnotation": "ERROR",
|
|
||||||
"missingProperties": "ERROR",
|
|
||||||
"nonStandardJsDocs": "ERROR",
|
|
||||||
"strictModuleDepCheck": "ERROR",
|
|
||||||
"suspiciousCode": "ERROR",
|
|
||||||
"typeInvalidation": "ERROR",
|
|
||||||
"tweakValidation": "ERROR",
|
|
||||||
"undefinedNames": "ERROR",
|
|
||||||
"undefinedVars": "ERROR",
|
|
||||||
"unknownDefines": "ERROR",
|
|
||||||
"uselessCode": "ERROR",
|
|
||||||
"violatedModuleDep": "ERROR",
|
|
||||||
"visibility": "ERROR"
|
|
||||||
},
|
|
||||||
|
|
||||||
"define": {
|
|
||||||
"goog.dom.ASSUME_STANDARDS_MODE": true,
|
|
||||||
"goog.DEBUG": false
|
|
||||||
},
|
|
||||||
|
|
||||||
"disambiguate-properties": true,
|
|
||||||
|
|
||||||
"externs": [
|
|
||||||
"../externs/bingmaps.js",
|
|
||||||
"../externs/closure-compiler.js",
|
|
||||||
"../externs/geojson.js",
|
|
||||||
"../externs/oli.js",
|
|
||||||
"../externs/olx.js",
|
|
||||||
"../externs/proj4js.js",
|
|
||||||
"../externs/tilejson.js",
|
|
||||||
"../externs/topojson.js",
|
|
||||||
"../externs/vbarray.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
"level": "VERBOSE",
|
|
||||||
|
|
||||||
"mode": "ADVANCED",
|
|
||||||
|
|
||||||
"name-suffixes-to-strip": [
|
|
||||||
"logger",
|
|
||||||
"logger_"
|
|
||||||
],
|
|
||||||
|
|
||||||
"paths": [
|
|
||||||
"../src"
|
|
||||||
],
|
|
||||||
|
|
||||||
"treat-warnings-as-errors": false,
|
|
||||||
|
|
||||||
"type-prefixes-to-strip": [
|
|
||||||
"goog.asserts",
|
|
||||||
"goog.debug.Console",
|
|
||||||
"goog.debug.DebugWindow",
|
|
||||||
"goog.debug.DevCss",
|
|
||||||
"goog.debug.DivConsole",
|
|
||||||
"goog.debug.EntryPointMonitor",
|
|
||||||
"goog.debug.ErrorHandler",
|
|
||||||
"goog.debug.ErrorReporter",
|
|
||||||
"goog.debug.FancyWindow",
|
|
||||||
"goog.debug.Formatter",
|
|
||||||
"goog.debug.FpsDisplay",
|
|
||||||
"goog.debug.GcDiagnostics",
|
|
||||||
"goog.debug.HtmlFormatter",
|
|
||||||
"goog.debug.LogBuffer",
|
|
||||||
"goog.debug.LogManager",
|
|
||||||
"goog.debug.LogRecord",
|
|
||||||
"goog.debug.Logger",
|
|
||||||
"goog.debug.RelativeTimeProvider",
|
|
||||||
"goog.debug.TextFormatter",
|
|
||||||
"goog.debug.Trace",
|
|
||||||
"goog.debug.catchErrors",
|
|
||||||
"goog.debug.deepExpose",
|
|
||||||
"goog.debug.enhanceError",
|
|
||||||
"goog.debug.entryPointRegistry",
|
|
||||||
"goog.debug.errorHandlerWeakDep",
|
|
||||||
"goog.debug.expose",
|
|
||||||
"goog.debug.exposeArray",
|
|
||||||
"goog.debug.exposeException",
|
|
||||||
"goog.debug.getFunctionName",
|
|
||||||
"goog.debug.getStacktrace",
|
|
||||||
"goog.debug.getStacktraceSimple",
|
|
||||||
"goog.debug.logRecordSerializer",
|
|
||||||
"goog.debug.makeWhitespaceVisible",
|
|
||||||
"goog.debug.normalizeErrorObject",
|
|
||||||
"goog.debug.reflect",
|
|
||||||
"goog.log"
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,70 @@
|
|||||||
{
|
{
|
||||||
|
"exports": [],
|
||||||
|
"src": ["src/**/*.js", "build/examples/all.js"],
|
||||||
|
"compile": {
|
||||||
"externs": [
|
"externs": [
|
||||||
"//jquery-1.7.js",
|
"externs/bingmaps.js",
|
||||||
"../externs/bingmaps.js",
|
"externs/bootstrap.js",
|
||||||
"../externs/bootstrap.js",
|
"externs/closure-compiler.js",
|
||||||
"../externs/closure-compiler.js",
|
"externs/example.js",
|
||||||
"../externs/example.js",
|
"externs/geojson.js",
|
||||||
"../externs/geojson.js",
|
"externs/jquery-1.7.js",
|
||||||
"../externs/oli.js",
|
"externs/oli.js",
|
||||||
"../externs/proj4js.js",
|
"externs/olx.js",
|
||||||
"../externs/tilejson.js",
|
"externs/proj4js.js",
|
||||||
"../externs/topojson.js",
|
"externs/tilejson.js",
|
||||||
"../externs/vbarray.js"
|
"externs/topojson.js",
|
||||||
|
"externs/vbarray.js"
|
||||||
],
|
],
|
||||||
"id": "simple",
|
"define": [
|
||||||
"inherits": "base.json",
|
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||||
"inputs": [
|
"goog.DEBUG=false"
|
||||||
"../build/examples/all.js",
|
],
|
||||||
"../externs/olx.js"
|
"jscomp_error": [
|
||||||
]
|
"accessControls",
|
||||||
|
"ambiguousFunctionDecl",
|
||||||
|
"checkEventfulObjectDisposal",
|
||||||
|
"checkRegExp",
|
||||||
|
"checkStructDictInheritance",
|
||||||
|
"checkTypes",
|
||||||
|
"checkVars",
|
||||||
|
"const",
|
||||||
|
"constantProperty",
|
||||||
|
"deprecated",
|
||||||
|
"duplicateMessage",
|
||||||
|
"es3",
|
||||||
|
"externsValidation",
|
||||||
|
"fileoverviewTags",
|
||||||
|
"globalThis",
|
||||||
|
"internetExplorerChecks",
|
||||||
|
"invalidCasts",
|
||||||
|
"misplacedTypeAnnotation",
|
||||||
|
"missingGetCssName",
|
||||||
|
"missingProperties",
|
||||||
|
"missingProvide",
|
||||||
|
"missingRequire",
|
||||||
|
"missingReturn",
|
||||||
|
"newCheckTypes",
|
||||||
|
"nonStandardJsDocs",
|
||||||
|
"suspiciousCode",
|
||||||
|
"strictModuleDepCheck",
|
||||||
|
"typeInvalidation",
|
||||||
|
"undefinedNames",
|
||||||
|
"undefinedVars",
|
||||||
|
"unknownDefines",
|
||||||
|
"uselessCode",
|
||||||
|
"visibility"
|
||||||
|
],
|
||||||
|
"extra_annotation_name": [
|
||||||
|
"api", "observable"
|
||||||
|
],
|
||||||
|
"jscomp_off": [
|
||||||
|
"es5Strict"
|
||||||
|
],
|
||||||
|
"compilation_level": "ADVANCED",
|
||||||
|
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
||||||
|
"use_types_for_optimization": true,
|
||||||
|
"manage_closure_dependencies": true
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
buildcfg/jsdoc/info/api-plugin.js
Normal file
15
buildcfg/jsdoc/info/api-plugin.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the api annotation.
|
||||||
|
* @param {Object} dictionary The tag dictionary.
|
||||||
|
*/
|
||||||
|
exports.defineTags = function(dictionary) {
|
||||||
|
|
||||||
|
dictionary.defineTag('api', {
|
||||||
|
onTagged: function(doclet, tag) {
|
||||||
|
doclet.api = tag.text || 'experimental';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"includePattern": "\\.js$"
|
"includePattern": "\\.js$"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"buildcfg/jsdoc/info/define-plugin",
|
"buildcfg/jsdoc/info/api-plugin",
|
||||||
"buildcfg/jsdoc/info/todo-plugin"
|
"buildcfg/jsdoc/info/define-plugin"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ exports.publish = function(data, opts) {
|
|||||||
name: doc.longname,
|
name: doc.longname,
|
||||||
kind: doc.kind,
|
kind: doc.kind,
|
||||||
description: doc.classdesc || doc.description,
|
description: doc.classdesc || doc.description,
|
||||||
extends: doc.augments,
|
|
||||||
path: path.join(doc.meta.path, doc.meta.filename)
|
path: path.join(doc.meta.path, doc.meta.filename)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fileoverview This plugin should go away when we get rid of Plovr and can
|
|
||||||
* use Closure Compiler's extra_annotation_name option. Until then, we hijack
|
|
||||||
* the todo tag to add doclet properties for other tags we eventually want to
|
|
||||||
* support. For example, the "todo api" tag can eventually be replaced with
|
|
||||||
* the "api" tag.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Our hook to define new tags.
|
|
||||||
* @param {Object} dictionary The tag dictionary.
|
|
||||||
*/
|
|
||||||
exports.defineTags = function(dictionary) {
|
|
||||||
|
|
||||||
dictionary.defineTag('todo', {
|
|
||||||
mustHaveValue: true,
|
|
||||||
onTagged: function(doclet, tag) {
|
|
||||||
var parts = tag.text.split(' ');
|
|
||||||
if (parts[0] === 'api') {
|
|
||||||
doclet.api = parts.slice(1).join(' ').trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
|
|
||||||
"id": "ol-all",
|
|
||||||
|
|
||||||
"externs": [
|
|
||||||
"../externs/bingmaps.js",
|
|
||||||
"../externs/closure-compiler.js",
|
|
||||||
"../externs/geojson.js",
|
|
||||||
"../externs/oli.js",
|
|
||||||
"../externs/olx.js",
|
|
||||||
"../externs/proj4js.js",
|
|
||||||
"../externs/tilejson.js",
|
|
||||||
"../externs/topojson.js",
|
|
||||||
"../externs/vbarray.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
"inherits": "base.json",
|
|
||||||
|
|
||||||
"inputs": [
|
|
||||||
"../build/exports.js"
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
3
buildcfg/ol-debug.json
Normal file
3
buildcfg/ol-debug.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"exports": ["*"]
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
{
|
|
||||||
|
|
||||||
// If ambiguate-properties and disambiguate-properties are set to true
|
|
||||||
// we get function names like "ol_control_Control_prototype$setMap" in
|
|
||||||
// the compiled code when using the SIMPLE compilation. It looks like
|
|
||||||
// "ambiguate-properties" and "disambiguate-properties" are only
|
|
||||||
// appropriate for ADVANCED compilation.
|
|
||||||
|
|
||||||
"ambiguate-properties": false,
|
|
||||||
|
|
||||||
"disambiguate-properties": false,
|
|
||||||
|
|
||||||
"id": "ol-simple",
|
|
||||||
|
|
||||||
"externs": [
|
|
||||||
"../externs/bingmaps.js",
|
|
||||||
"../externs/closure-compiler.js",
|
|
||||||
"../externs/geojson.js",
|
|
||||||
"../externs/oli.js",
|
|
||||||
"../externs/olx.js",
|
|
||||||
"../externs/proj4js.js",
|
|
||||||
"../externs/tilejson.js",
|
|
||||||
"../externs/topojson.js",
|
|
||||||
"../externs/vbarray.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
"inherits": "ol.json",
|
|
||||||
|
|
||||||
"inputs": [
|
|
||||||
"../build/exports.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
"mode": "SIMPLE",
|
|
||||||
|
|
||||||
// Note: we can't have a (function(){%output%})() output wrapper with
|
|
||||||
// WHITESPACE and SIMPLE modes. See this link for explanations:
|
|
||||||
// https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
|
|
||||||
"output-wrapper": "%output%"
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
|
|
||||||
"id": "ol-whitespace",
|
|
||||||
|
|
||||||
// If ambiguate-properties and disambiguate-properties are set to true
|
|
||||||
// we get function names like "ol_control_Control_prototype$setMap" in
|
|
||||||
// the compiled code when using the SIMPLE compilation. It looks like
|
|
||||||
// "ambiguate-properties" and "disambiguate-properties" are only
|
|
||||||
// appropriate for ADVANCED compilation. To be sure we also don't
|
|
||||||
// set them for WHITESPACE.
|
|
||||||
|
|
||||||
"ambiguate-properties": false,
|
|
||||||
|
|
||||||
"disambiguate-properties": false,
|
|
||||||
|
|
||||||
"externs": [
|
|
||||||
"../externs/bingmaps.js",
|
|
||||||
"../externs/closure-compiler.js",
|
|
||||||
"../externs/geojson.js",
|
|
||||||
"../externs/oli.js",
|
|
||||||
"../externs/olx.js",
|
|
||||||
"../externs/proj4js.js",
|
|
||||||
"../externs/tilejson.js",
|
|
||||||
"../externs/topojson.js",
|
|
||||||
"../externs/vbarray.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
"inherits": "ol.json",
|
|
||||||
|
|
||||||
"inputs": [
|
|
||||||
"../build/exports.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
"mode": "WHITESPACE",
|
|
||||||
|
|
||||||
"output-wrapper": [
|
|
||||||
"var CLOSURE_NO_DEPS = true;\n",
|
|
||||||
"%output%"
|
|
||||||
],
|
|
||||||
|
|
||||||
"pretty-print": true
|
|
||||||
}
|
|
||||||
100
buildcfg/ol.json
100
buildcfg/ol.json
@@ -1,39 +1,65 @@
|
|||||||
{
|
{
|
||||||
|
"exports": ["*"],
|
||||||
"id": "ol",
|
"compile": {
|
||||||
|
"externs": [
|
||||||
"css-allowed-unrecognized-properties": [
|
"externs/bingmaps.js",
|
||||||
"user-select"
|
"externs/closure-compiler.js",
|
||||||
],
|
"externs/geojson.js",
|
||||||
|
"externs/oli.js",
|
||||||
"css-inputs": [
|
"externs/olx.js",
|
||||||
"../css/ol.css"
|
"externs/proj4js.js",
|
||||||
],
|
"externs/tilejson.js",
|
||||||
|
"externs/topojson.js",
|
||||||
"css-output-file": "../build/ol.css",
|
"externs/vbarray.js"
|
||||||
|
],
|
||||||
"externs": [
|
"define": [
|
||||||
"../externs/bingmaps.js",
|
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||||
"../externs/closure-compiler.js",
|
"goog.DEBUG=false"
|
||||||
"../externs/geojson.js",
|
],
|
||||||
"../externs/oli.js",
|
"jscomp_error": [
|
||||||
"../externs/olx.js",
|
"accessControls",
|
||||||
"../externs/proj4js.js",
|
"ambiguousFunctionDecl",
|
||||||
"../externs/tilejson.js",
|
"checkEventfulObjectDisposal",
|
||||||
"../externs/topojson.js",
|
"checkRegExp",
|
||||||
"../externs/vbarray.js"
|
"checkStructDictInheritance",
|
||||||
],
|
"checkTypes",
|
||||||
|
"checkVars",
|
||||||
"inherits": "base.json",
|
"const",
|
||||||
|
"constantProperty",
|
||||||
"inputs": [
|
"deprecated",
|
||||||
"../build/exports.js"
|
"duplicateMessage",
|
||||||
],
|
"es3",
|
||||||
|
"externsValidation",
|
||||||
"output-wrapper": "// OpenLayers 3. see http://ol3js.org/\n(function(){%output%})();",
|
"fileoverviewTags",
|
||||||
|
"globalThis",
|
||||||
"paths": [
|
"internetExplorerChecks",
|
||||||
"../src"
|
"invalidCasts",
|
||||||
]
|
"misplacedTypeAnnotation",
|
||||||
|
"missingGetCssName",
|
||||||
|
"missingProperties",
|
||||||
|
"missingProvide",
|
||||||
|
"missingRequire",
|
||||||
|
"missingReturn",
|
||||||
|
"newCheckTypes",
|
||||||
|
"nonStandardJsDocs",
|
||||||
|
"suspiciousCode",
|
||||||
|
"strictModuleDepCheck",
|
||||||
|
"typeInvalidation",
|
||||||
|
"undefinedNames",
|
||||||
|
"undefinedVars",
|
||||||
|
"unknownDefines",
|
||||||
|
"uselessCode",
|
||||||
|
"visibility"
|
||||||
|
],
|
||||||
|
"extra_annotation_name": [
|
||||||
|
"api", "observable"
|
||||||
|
],
|
||||||
|
"jscomp_off": [
|
||||||
|
"es5Strict"
|
||||||
|
],
|
||||||
|
"compilation_level": "ADVANCED",
|
||||||
|
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
||||||
|
"use_types_for_optimization": true,
|
||||||
|
"manage_closure_dependencies": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
buildcfg/readme.md
Normal file
3
buildcfg/readme.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Build configs
|
||||||
|
|
||||||
|
This directory includes configuration files (json) for the build scripts in tasks/.
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
|
|
||||||
"id": "test",
|
|
||||||
|
|
||||||
"inherits": "base.json",
|
|
||||||
|
|
||||||
"inputs": [
|
|
||||||
"../build/test/requireall.js"
|
|
||||||
],
|
|
||||||
|
|
||||||
"paths": [
|
|
||||||
"../src",
|
|
||||||
"../test"
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
3
closure-util.json
Normal file
3
closure-util.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"library_url": "https://github.com/google/closure-library/archive/ab89cf45c216615d73a2f5dea720afb9d3415d1f.zip"
|
||||||
|
}
|
||||||
114
css/ol.css
114
css/ol.css
@@ -1,53 +1,3 @@
|
|||||||
.ol-attribution {
|
|
||||||
position: absolute;
|
|
||||||
text-align: right;
|
|
||||||
bottom: 0;
|
|
||||||
right: 0;
|
|
||||||
padding: 6px;
|
|
||||||
color: #000000;
|
|
||||||
color: rgba(238,238,238,1);
|
|
||||||
background: rgba(0,60,136,0.3);
|
|
||||||
}
|
|
||||||
.ol-attribution a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: #7b98bc;
|
|
||||||
color: rgba(255,255,255,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ol-attribution ul {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-size: 10px;
|
|
||||||
line-height: 12px;
|
|
||||||
}
|
|
||||||
.ol-attribution li {
|
|
||||||
display: inline;
|
|
||||||
list-style: none;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
.ol-attribution li:not(:last-child):after {
|
|
||||||
content: "\2003";
|
|
||||||
}
|
|
||||||
.ol-attribution-bing-tos {
|
|
||||||
float:right;
|
|
||||||
padding-top: 2px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ol-logo {
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
padding: 2px;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
.ol-logo ul {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
.ol-logo ul li {
|
|
||||||
display: inline;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ol-mouse-position {
|
.ol-mouse-position {
|
||||||
top: 8px;
|
top: 8px;
|
||||||
@@ -226,11 +176,75 @@ button.ol-full-screen-true:after {
|
|||||||
}
|
}
|
||||||
.ol-rotate .ol-has-tooltip:hover [role=tooltip],
|
.ol-rotate .ol-has-tooltip:hover [role=tooltip],
|
||||||
.ol-rotate .ol-has-tooltip:focus [role=tooltip],
|
.ol-rotate .ol-has-tooltip:focus [role=tooltip],
|
||||||
|
.ol-attribution .ol-has-tooltip:hover [role=tooltip],
|
||||||
|
.ol-attribution .ol-has-tooltip:focus [role=tooltip],
|
||||||
.ol-full-screen .ol-has-tooltip:hover [role=tooltip],
|
.ol-full-screen .ol-has-tooltip:hover [role=tooltip],
|
||||||
.ol-full-screen .ol-has-tooltip:focus [role=tooltip] {
|
.ol-full-screen .ol-has-tooltip:focus [role=tooltip] {
|
||||||
right: 2.2em;
|
right: 2.2em;
|
||||||
left: auto;
|
left: auto;
|
||||||
border-radius: 4px 0 0 4px;
|
border-radius: 4px 0 0 4px;
|
||||||
|
border-left-width: 3px;
|
||||||
|
border-right-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ol-attribution {
|
||||||
|
text-align: right;
|
||||||
|
bottom: .5em;
|
||||||
|
right: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ol-attribution ul {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 .5em;
|
||||||
|
font-size: .7rem;
|
||||||
|
line-height: 1.375em;
|
||||||
|
color: #000;
|
||||||
|
text-shadow: 0 0 2px #fff;
|
||||||
|
}
|
||||||
|
.ol-attribution li {
|
||||||
|
display: inline;
|
||||||
|
list-style: none;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
.ol-attribution li:not(:last-child):after {
|
||||||
|
content: " ";
|
||||||
|
}
|
||||||
|
.ol-attribution img {
|
||||||
|
max-height: 2em;
|
||||||
|
}
|
||||||
|
.ol-attribution ul, .ol-attribution button {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.ol-attribution:not(.ol-collapsed) button:hover [role=tooltip],
|
||||||
|
.ol-attribution.ol-collapsed ul {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.ol-attribution.ol-logo-only ul {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.ol-attribution:not(.ol-collapsed) {
|
||||||
|
background: rgba(255,255,255,0.8);
|
||||||
|
}
|
||||||
|
.ol-attribution.ol-uncollapsible {
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
border-radius: 4px 0 0;
|
||||||
|
height: 1.1em;
|
||||||
|
line-height: 1em;
|
||||||
|
}
|
||||||
|
.ol-attribution.ol-logo-only {
|
||||||
|
background: transparent;
|
||||||
|
bottom: .4em;
|
||||||
|
height: 1.1em;
|
||||||
|
line-height: 1em;
|
||||||
|
}
|
||||||
|
.ol-attribution.ol-uncollapsible img {
|
||||||
|
margin-top: -.2em;
|
||||||
|
max-height: 1.6em;
|
||||||
|
}
|
||||||
|
.ol-attribution.ol-logo-only button,
|
||||||
|
.ol-attribution.ol-uncollapsible button {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ol-zoomslider {
|
.ol-zoomslider {
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ layout: doc.hbs
|
|||||||
|
|
||||||
# Tutorials
|
# Tutorials
|
||||||
|
|
||||||
We'll be putting together a more comprehensive set of tutorials here. For now, you can take a look at the [basic concepts](concepts.html) tutorial. Stay tuned for more!
|
We'll be putting together a more comprehensive set of tutorials here. For now, you can take a look at the [introduction](introduction.html) and [basic concepts](concepts.html) tutorial. Stay tuned for more!
|
||||||
|
|||||||
44
doc/tutorials/introduction.md
Normal file
44
doc/tutorials/introduction.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
title: Introduction
|
||||||
|
layout: doc.hbs
|
||||||
|
---
|
||||||
|
|
||||||
|
# Introduction
|
||||||
|
|
||||||
|
## Objectives
|
||||||
|
OpenLayers 3 (OL3) is a fundamental redesign of the OpenLayers web mapping library. Version 2 is widely used, but dates from the early days of Javascript development, and is increasingly showing its age. OL3 has been rewritten from the ground up to use modern design patterns.
|
||||||
|
|
||||||
|
The initial release aims to support much of the functionality provided by version 2, with support for a wide range of commercial and free tile sources, and the most popular open-source vector data formats. As with version 2, data can be in any projection. The initial release also adds some additional functionality, such as the ability to easily rotate or animate maps.
|
||||||
|
|
||||||
|
It is also designed such that major new features, such as displaying 3D maps, or using WebGL to quickly display large vector data sets, can be added in later releases.
|
||||||
|
|
||||||
|
## Closure Tools
|
||||||
|
OL3 is based on Google's Closure Tools. It makes heavy use of parts of the [__Closure Library__](https://developers.google.com/closure/library/). Using this to handle basics like DOM or event handling means the developers can concentrate on mapping functionality, and be sure that the underlying software is well-tested and cross-browser. Closure Library is specially designed to be optimized by the [__Closure Compiler__](https://developers.google.com/closure/compiler/). The 'advanced' optimizations that this provides offers a level of compression that far exceeds anything else available. OL3 has been designed to make full use of this.
|
||||||
|
|
||||||
|
## Public API
|
||||||
|
Using the advanced optimizations of the Closure Compiler means that properties and methods are renamed – `longMeaningfulName` might become `xB` – and so are effectively unusable in applications using the library. To be usable, they have to be explicitly `exported`. This means the exported names, those not renamed, effectively become the public API of the library. These __exportable__ properties and methods are marked in the source, and documented in the [API docs](../../apidoc). This is the officially supported API of the library. A build containing all these exportable names is known as a __full build__. A hosted version of this is available, which can be used by any application.
|
||||||
|
|
||||||
|
Although Closure library functions are widely used within OL3, none of them are exported. You will see references to them (they are all in the `goog` namespace) in the API docs, but these are for information only. You can use the Closure library in your own applications if you like, but this is not required.
|
||||||
|
|
||||||
|
## Custom Builds
|
||||||
|
Unlike in, say, Node, where a module's exports are fixed in the source, with Closure Compiler, exports can be defined at compile time. This makes it easy to create builds that are customized to the needs of a particular site or application: a __custom build__ only exports those properties and methods needed by the site or application. As the full build is large, and will probably become larger as new features are added to the API, it's recommended that sites create a custom build for production software.
|
||||||
|
|
||||||
|
## Renderers and Browser Support
|
||||||
|
The library currently includes three renderers: Canvas, DOM, and WebGL. All three support raster data from tile/image servers, but only the Canvas renderer currently supports vector data. This means that only those browsers that [support Canvas](http://caniuse.com/canvas) can handle vector data. In particular, this excludes Internet Explorer versions before 9, though there is some support for those in the DOM renderer. Clearly, the WebGL renderer can only be used on those devices and browsers supporting WebGL.
|
||||||
|
|
||||||
|
The library is intended for use on both desktop/laptop and mobile devices.
|
||||||
|
|
||||||
|
## Objects and Naming Conventions
|
||||||
|
OL3 uses a similar object hierarchy to the Closure library. There is a top-level `ol` namespace (basically, `var ol = {};`). Subdivisions of this are:
|
||||||
|
|
||||||
|
* further namespaces, such as `ol.layer`; these have a lower-case initial
|
||||||
|
* simple objects containing static properties and methods, such as `ol.animation`; these also have a lower-case initial
|
||||||
|
* types, which have an upper-case initial. These are mainly 'classes', which here means a constructor function with prototypal inheritance, such as `ol.Map` or `ol.layer.Vector` (the Vector class within the layer namespace). There are however other, simpler, types, such as `ol.Extent`, which is an array.
|
||||||
|
|
||||||
|
Class namespaces, such as `ol.layer` have a base class type with the same name, such as `ol.layer.Layer`. These are mainly abstract classes, from which the other subclasses inherit.
|
||||||
|
|
||||||
|
Source files are similarly organised, with a directory for each class namespace. Names are however all lower-case, and the subclasses repeat the superclass type in their name, for example, `ol/layer/vectorlayer.js`.
|
||||||
|
|
||||||
|
The naming structure means that there are sometimes 2 objects with the same name but different initial, such as `ol.feature`, a simple object with static functions to be used with features, and `ol.Feature`, a class used to instantiate new features. These two objects are however stored in the same file, in this case, `ol/feature.js`
|
||||||
|
|
||||||
|
OL3 follows the convention that the names of private properties and methods, that is, those that are not part of the API, end in an underscore. In general, instance properties are private and accessed using accessors.
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -12,6 +13,11 @@ var map = new ol.Map({
|
|||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
goog.require('ol.animation');
|
goog.require('ol.animation');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
@@ -55,6 +56,11 @@ var map = new ol.Map({
|
|||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<title>Style with rules example</title>
|
<title>Attributions example</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -31,20 +31,21 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Style with rules example</h4>
|
<h4 id="title">Attributions example</h4>
|
||||||
<p id="shortdesc">Draws features with rule based styles.</p>
|
<p id="shortdesc">Example of a attributions visibily change on map resize, to collapse them on small maps.</p>
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
<p>See the <a href="style-rules.js" target="_blank">style-rules.js source</a> to see how this is done.</p>
|
<p>See the <a href="attributions.js" target="_blank">attributions.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">vector, geojson, style</div>
|
<div id="tags">attributions, openstreetmap</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="loader.js?id=style-rules" type="text/javascript"></script>
|
<script src="jquery.min.js" type="text/javascript"></script>
|
||||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
|
<script src="loader.js?id=attributions" type="text/javascript"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
33
examples/attributions.js
Normal file
33
examples/attributions.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
|
goog.require('ol.control.Attribution');
|
||||||
|
goog.require('ol.layer.Tile');
|
||||||
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
|
var attribution = new ol.control.Attribution({
|
||||||
|
collapsible: false
|
||||||
|
});
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Tile({
|
||||||
|
source: new ol.source.OSM()
|
||||||
|
})
|
||||||
|
],
|
||||||
|
controls: ol.control.defaults({ attribution: false }).extend([attribution]),
|
||||||
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 2
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
function checkSize() {
|
||||||
|
var small = map.getSize()[0] < 600;
|
||||||
|
attribution.setCollapsible(small);
|
||||||
|
attribution.setCollapsed(small);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(window).on('resize', checkSize);
|
||||||
|
checkSize();
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.BrowserFeature');
|
goog.require('ol.BrowserFeature');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.dom.Input');
|
goog.require('ol.dom.Input');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
@@ -29,6 +30,11 @@ var map = new ol.Map({
|
|||||||
layers: [layer],
|
layers: [layer],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
@@ -23,6 +24,11 @@ var map = new ol.Map({
|
|||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: ol.proj.transform(
|
center: ol.proj.transform(
|
||||||
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),
|
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),
|
||||||
|
|||||||
@@ -21,10 +21,6 @@
|
|||||||
top: 178px;
|
top: 178px;
|
||||||
left: 158px;
|
left: 158px;
|
||||||
}
|
}
|
||||||
div.ol-logo {
|
|
||||||
left: 150px;
|
|
||||||
bottom: 30px;
|
|
||||||
}
|
|
||||||
div.ol-attribution {
|
div.ol-attribution {
|
||||||
bottom: 30px;
|
bottom: 30px;
|
||||||
right: 50px;
|
right: 50px;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.geom.SimpleGeometry');
|
goog.require('ol.geom.SimpleGeometry');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
@@ -50,6 +51,11 @@ var map = new ol.Map({
|
|||||||
vectorLayer
|
vectorLayer
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ ol.inherits(app.RotateNorthControl, ol.control.Control);
|
|||||||
|
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
controls: ol.control.defaults().extend([
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}).extend([
|
||||||
new app.RotateNorthControl()
|
new app.RotateNorthControl()
|
||||||
]),
|
]),
|
||||||
layers: [
|
layers: [
|
||||||
|
|||||||
176
examples/data/geojson/countries-110m.geojson
Normal file
176
examples/data/geojson/countries-110m.geojson
Normal file
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.DeviceOrientation');
|
goog.require('ol.DeviceOrientation');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.dom.Input');
|
goog.require('ol.dom.Input');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
@@ -21,6 +22,11 @@ var map = new ol.Map({
|
|||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -11,6 +12,11 @@ var map = new ol.Map({
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
@@ -25,7 +31,7 @@ if ('download' in exportPNGElement) {
|
|||||||
var canvas = event.context.canvas;
|
var canvas = event.context.canvas;
|
||||||
exportPNGElement.href = canvas.toDataURL('image/png');
|
exportPNGElement.href = canvas.toDataURL('image/png');
|
||||||
});
|
});
|
||||||
map.render();
|
map.renderSync();
|
||||||
}, false);
|
}, false);
|
||||||
} else {
|
} else {
|
||||||
var info = document.getElementById('no-download');
|
var info = document.getElementById('no-download');
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.geom.Circle');
|
goog.require('ol.geom.Circle');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
@@ -144,7 +145,7 @@ var vectorSource = new ol.source.GeoJSON(
|
|||||||
'type': 'MultiPolygon',
|
'type': 'MultiPolygon',
|
||||||
'coordinates': [
|
'coordinates': [
|
||||||
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]],
|
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]],
|
||||||
[[[-2e6, 6e6], [-2e6, 8e6], [0e6, 8e6], [0e6, 6e6]]],
|
[[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6], [0, 6e6]]],
|
||||||
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]]
|
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -156,7 +157,7 @@ var vectorSource = new ol.source.GeoJSON(
|
|||||||
'geometries': [
|
'geometries': [
|
||||||
{
|
{
|
||||||
'type': 'LineString',
|
'type': 'LineString',
|
||||||
'coordinates': [[-5e6, -5e6], [0e6, -5e6]]
|
'coordinates': [[-5e6, -5e6], [0, -5e6]]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'type': 'Point',
|
'type': 'Point',
|
||||||
@@ -188,6 +189,11 @@ var map = new ol.Map({
|
|||||||
vectorLayer
|
vectorLayer
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ goog.require('ol.Geolocation');
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.Overlay');
|
goog.require('ol.Overlay');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
@@ -21,6 +22,11 @@ var map = new ol.Map({
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.require('ol.FeatureOverlay');
|
|||||||
goog.require('ol.Geolocation');
|
goog.require('ol.Geolocation');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.dom.Input');
|
goog.require('ol.dom.Input');
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
@@ -21,6 +22,11 @@ var map = new ol.Map({
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,6 @@
|
|||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
div.ol-logo {
|
|
||||||
left: 65px;
|
|
||||||
}
|
|
||||||
div.fill {
|
div.fill {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
@@ -25,6 +25,12 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
<div id="no-download" class="alert alert-error" style="display: none">
|
||||||
|
The "Export GPX" functionality requires a browser that supports the
|
||||||
|
<a href="http://caniuse.com/#feat=download">link download</a> attribute.
|
||||||
|
</div>
|
||||||
|
<a id="export-gpx" class="btn" download="map.gpx"><i class="icon-download"></i>Export GPX</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.format.GPX');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.BingMaps');
|
goog.require('ol.source.BingMaps');
|
||||||
goog.require('ol.source.GPX');
|
goog.require('ol.source.GPX');
|
||||||
goog.require('ol.style.Circle');
|
goog.require('ol.style.Circle');
|
||||||
@@ -9,6 +11,8 @@ goog.require('ol.style.Fill');
|
|||||||
goog.require('ol.style.Stroke');
|
goog.require('ol.style.Stroke');
|
||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
var projection = ol.proj.get('EPSG:3857');
|
||||||
|
|
||||||
var raster = new ol.layer.Tile({
|
var raster = new ol.layer.Tile({
|
||||||
source: new ol.source.BingMaps({
|
source: new ol.source.BingMaps({
|
||||||
imagerySet: 'Aerial',
|
imagerySet: 'Aerial',
|
||||||
@@ -45,7 +49,7 @@ var style = {
|
|||||||
|
|
||||||
var vector = new ol.layer.Vector({
|
var vector = new ol.layer.Vector({
|
||||||
source: new ol.source.GPX({
|
source: new ol.source.GPX({
|
||||||
projection: 'EPSG:3857',
|
projection: projection,
|
||||||
url: 'data/gpx/fells_loop.gpx'
|
url: 'data/gpx/fells_loop.gpx'
|
||||||
}),
|
}),
|
||||||
style: function(feature, resolution) {
|
style: function(feature, resolution) {
|
||||||
@@ -89,3 +93,30 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
map.on('click', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var exportGPXElement = document.getElementById('export-gpx');
|
||||||
|
if ('download' in exportGPXElement) {
|
||||||
|
var vectorSource = /** @type {ol.source.Vector} */ (vector.getSource());
|
||||||
|
exportGPXElement.addEventListener('click', function(e) {
|
||||||
|
if (!exportGPXElement.href) {
|
||||||
|
var features = [];
|
||||||
|
vectorSource.forEachFeature(function(feature) {
|
||||||
|
var clone = feature.clone();
|
||||||
|
clone.getGeometry().transform(projection, 'EPSG:4326');
|
||||||
|
features.push(clone);
|
||||||
|
});
|
||||||
|
var node = new ol.format.GPX().writeFeatures(features);
|
||||||
|
var string = new XMLSerializer().serializeToString(
|
||||||
|
/** @type {Node} */ (node));
|
||||||
|
var base64 = exampleNS.strToBase64(string);
|
||||||
|
exportGPXElement.href =
|
||||||
|
'data:gpx+xml;base64,' + base64;
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
} else {
|
||||||
|
var info = document.getElementById('no-download');
|
||||||
|
/**
|
||||||
|
* display error message
|
||||||
|
*/
|
||||||
|
info.style.display = '';
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<title>Synthetic data example</title>
|
<title>Graticule example</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -31,20 +31,21 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Synthetic data example</h4>
|
<h4 id="title">Graticule example</h4>
|
||||||
<p id="shortdesc">Synthetic data example.</p>
|
<p id="shortdesc">This example shows how to add a graticule overlay to a map.</p>
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
<p>See the <a href="synthetic-data.js" target="_blank">synthetic-data.js source</a> to see how this is done.</p>
|
<p>See the <a href="graticule.js" target="_blank">graticule.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">vector</div>
|
<div id="tags">graticule</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="loader.js?id=synthetic-data" type="text/javascript"></script>
|
<script src="jquery.min.js" type="text/javascript"></script>
|
||||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
|
<script src="loader.js?id=graticule" type="text/javascript"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
25
examples/graticule.js
Normal file
25
examples/graticule.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
goog.require('ol.Graticule');
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.layer.Tile');
|
||||||
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Tile({
|
||||||
|
source: new ol.source.OSM()
|
||||||
|
})
|
||||||
|
],
|
||||||
|
renderer: 'canvas',
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View({
|
||||||
|
center: ol.proj.transform([4.8, 47.75], 'EPSG:4326', 'EPSG:3857'),
|
||||||
|
zoom: 5
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the graticule component
|
||||||
|
var graticule = new ol.Graticule();
|
||||||
|
graticule.setMap(map);
|
||||||
@@ -3,6 +3,7 @@ goog.require('ol.Feature');
|
|||||||
goog.require('ol.FeatureOverlay');
|
goog.require('ol.FeatureOverlay');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
@@ -83,6 +84,11 @@ var map = new ol.Map({
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [703365.7089403362, 5714629.865071137],
|
center: [703365.7089403362, 5714629.865071137],
|
||||||
zoom: 9
|
zoom: 9
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.BrowserFeature');
|
goog.require('ol.BrowserFeature');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -20,6 +21,11 @@ if (!ol.BrowserFeature.HAS_WEBGL) {
|
|||||||
layers: [osm],
|
layers: [osm],
|
||||||
renderer: 'webgl',
|
renderer: 'webgl',
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -10,6 +11,11 @@ var osm = new ol.layer.Tile({
|
|||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [osm],
|
layers: [osm],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.BingMaps');
|
goog.require('ol.source.BingMaps');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
@@ -17,6 +18,11 @@ var bing = new ol.layer.Tile({
|
|||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [osm, bing],
|
layers: [osm, bing],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loader to add the plovr generated script to the document.
|
|
||||||
*
|
|
||||||
* The following default values may be overridden with query string
|
|
||||||
* parameters:
|
|
||||||
*
|
|
||||||
* * hostname - the current hostname (window.location.hostname)
|
|
||||||
* * port - 9810
|
|
||||||
* * mode - RAW
|
|
||||||
* * id - id param in loader.js query string; defaults to 'ol' if not set
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
*
|
|
||||||
* <script src="loader.js?id=myexample"></script>
|
|
||||||
*/
|
|
||||||
(function() {
|
|
||||||
var scripts = document.getElementsByTagName('script');
|
|
||||||
var params = {
|
|
||||||
hostname: window.location.hostname,
|
|
||||||
port: '9810',
|
|
||||||
mode: 'RAW',
|
|
||||||
id: 'ol'
|
|
||||||
};
|
|
||||||
if (window.location.protocol === 'file:' && !params.hostname) {
|
|
||||||
params.hostname = 'localhost';
|
|
||||||
}
|
|
||||||
var chunks, search, pair;
|
|
||||||
|
|
||||||
var src, index, id, i;
|
|
||||||
for (i = scripts.length - 1; i >= 0; --i) {
|
|
||||||
src = scripts[i].getAttribute('src');
|
|
||||||
if (~(index = src.indexOf('loader.js?'))) {
|
|
||||||
// script params
|
|
||||||
search = src.substr(index + 10);
|
|
||||||
chunks = search ? search.split('&') : [];
|
|
||||||
for (i = chunks.length - 1; i >= 0; --i) {
|
|
||||||
pair = chunks[i].split('=');
|
|
||||||
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// url params
|
|
||||||
search = window.location.search.substring(1);
|
|
||||||
chunks = search ? search.split('&') : [];
|
|
||||||
for (i = chunks.length - 1; i >= 0; --i) {
|
|
||||||
pair = chunks[i].split('=');
|
|
||||||
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var host = params.hostname + ':' + params.port;
|
|
||||||
delete params.hostname;
|
|
||||||
delete params.port;
|
|
||||||
|
|
||||||
var pairs = [];
|
|
||||||
for (var key in params) {
|
|
||||||
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
|
|
||||||
}
|
|
||||||
|
|
||||||
var url = 'http://' + host + '/compile?' + pairs.join('&');
|
|
||||||
document.write('<script type="text/javascript" src="' + url + '"></script>');
|
|
||||||
}());
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -42,6 +43,11 @@ var map = new ol.Map({
|
|||||||
openSeaMapLayer
|
openSeaMapLayer
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
maxZoom: 18,
|
maxZoom: 18,
|
||||||
center: [-244780.24508882355, 5986452.183179816],
|
center: [-244780.24508882355, 5986452.183179816],
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var bounds = [
|
|||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Image({
|
new ol.layer.Image({
|
||||||
|
extent: bounds,
|
||||||
source: new ol.source.MapGuide({
|
source: new ol.source.MapGuide({
|
||||||
projection: 'EPSG:4326',
|
projection: 'EPSG:4326',
|
||||||
url: agentUrl,
|
url: agentUrl,
|
||||||
@@ -24,8 +25,7 @@ var map = new ol.Map({
|
|||||||
MAPDEFINITION: mdf,
|
MAPDEFINITION: mdf,
|
||||||
FORMAT: 'PNG'
|
FORMAT: 'PNG'
|
||||||
},
|
},
|
||||||
ratio: 2,
|
ratio: 2
|
||||||
extent: bounds
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
goog.require('ol.source.TileJSON');
|
goog.require('ol.source.TileJSON');
|
||||||
@@ -27,6 +28,11 @@ var map = new ol.Map({
|
|||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [653600, 5723680],
|
center: [653600, 5723680],
|
||||||
zoom: 5
|
zoom: 5
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ var source = new ol.source.GeoJSON(
|
|||||||
'coordinates': [
|
'coordinates': [
|
||||||
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
|
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
|
||||||
[-3e6, 6e6], [-5e6, 6e6]]],
|
[-3e6, 6e6], [-5e6, 6e6]]],
|
||||||
[[[-2e6, 6e6], [-2e6, 8e6], [0e6, 8e6],
|
[[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6],
|
||||||
[0e6, 6e6], [-2e6, 6e6]]],
|
[0, 6e6], [-2e6, 6e6]]],
|
||||||
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
|
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
|
||||||
[3e6, 6e6], [1e6, 6e6]]]
|
[3e6, 6e6], [1e6, 6e6]]]
|
||||||
]
|
]
|
||||||
@@ -141,7 +141,7 @@ var source = new ol.source.GeoJSON(
|
|||||||
'geometries': [
|
'geometries': [
|
||||||
{
|
{
|
||||||
'type': 'LineString',
|
'type': 'LineString',
|
||||||
'coordinates': [[-5e6, -5e6], [0e6, -5e6]]
|
'coordinates': [[-5e6, -5e6], [0, -5e6]]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'type': 'Point',
|
'type': 'Point',
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ var mousePositionControl = new ol.control.MousePosition({
|
|||||||
});
|
});
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
controls: ol.control.defaults().extend([mousePositionControl]),
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}).extend([mousePositionControl]),
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
source: new ol.source.OSM()
|
source: new ol.source.OSM()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
@@ -14,6 +15,11 @@ var map = new ol.Map({
|
|||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ goog.require('ol.source.OSM');
|
|||||||
|
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
controls: ol.control.defaults().extend([
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}).extend([
|
||||||
new ol.control.ZoomToExtent({
|
new ol.control.ZoomToExtent({
|
||||||
extent: [
|
extent: [
|
||||||
813079.7791264898, 5929220.284081122,
|
813079.7791264898, 5929220.284081122,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -12,6 +13,11 @@ var map = new ol.Map({
|
|||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [-25860000, 4130000],
|
center: [-25860000, 4130000],
|
||||||
rotation: Math.PI / 6,
|
rotation: Math.PI / 6,
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ goog.require('ol.source.OSM');
|
|||||||
var scaleLineControl = new ol.control.ScaleLine();
|
var scaleLineControl = new ol.control.ScaleLine();
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
controls: ol.control.defaults().extend([
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}).extend([
|
||||||
scaleLineControl
|
scaleLineControl
|
||||||
]),
|
]),
|
||||||
layers: [
|
layers: [
|
||||||
|
|||||||
@@ -33,7 +33,17 @@
|
|||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Select features example</h4>
|
<h4 id="title">Select features example</h4>
|
||||||
<p id="shortdesc">Example of using the Select interaction. Select features by clicking polygons. Hold the Shift-key to toggle the feature in the selection.</p>
|
<p id="shortdesc">Example of using the Select interaction. Choose between <code>Single-click</code>, <code>Click</code> and <code>Hover</code> as the event type for selection in the combobox below. When using <code>Single-click</code> or <code>Click</code> you can hold do <code>Shift</code> key to toggle the feature in the selection.</p>
|
||||||
|
<p>Note: when <code>Single-click</code> is used double-clicks won't select features. This in contrast to <code>Click</code>, where a double-click will both select the feature and zoom the map (because of the <code>DoubleClickZoom</code> interaction). Note that <code>Single-click</code> is less responsive than <code>Click</code> because of the delay it uses to detect double-clicks.</p>
|
||||||
|
<form class="form-inline">
|
||||||
|
<label>Action type </label>
|
||||||
|
<select id="type">
|
||||||
|
<option value="none" selected>None</option>
|
||||||
|
<option value="singleclick">Single-click</option>
|
||||||
|
<option value="click">Click</option>
|
||||||
|
<option value="mousemove">Hover</option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
<p>See the <a href="select-features.js" target="_blank">select-features.js source</a> to see how this is done.</p>
|
<p>See the <a href="select-features.js" target="_blank">select-features.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.interaction');
|
goog.require('ol.interaction');
|
||||||
goog.require('ol.interaction.Select');
|
goog.require('ol.interaction.Select');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
@@ -18,10 +19,7 @@ var vector = new ol.layer.Vector({
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
var select = new ol.interaction.Select();
|
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
interactions: ol.interaction.defaults().extend([select]),
|
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
@@ -29,3 +27,46 @@ var map = new ol.Map({
|
|||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var select = null; // ref to currently selected interaction
|
||||||
|
|
||||||
|
// select interaction working on "singleclick"
|
||||||
|
var selectSingleClick = new ol.interaction.Select();
|
||||||
|
|
||||||
|
// select interaction working on "click"
|
||||||
|
var selectClick = new ol.interaction.Select({
|
||||||
|
condition: ol.events.condition.click
|
||||||
|
});
|
||||||
|
|
||||||
|
// select interaction working on "mousemove"
|
||||||
|
var selectMouseMove = new ol.interaction.Select({
|
||||||
|
condition: ol.events.condition.mouseMove
|
||||||
|
});
|
||||||
|
|
||||||
|
var selectElement = document.getElementById('type');
|
||||||
|
|
||||||
|
var changeInteraction = function() {
|
||||||
|
if (select !== null) {
|
||||||
|
map.removeInteraction(select);
|
||||||
|
}
|
||||||
|
var value = selectElement.value;
|
||||||
|
if (value == 'singleclick') {
|
||||||
|
select = selectSingleClick;
|
||||||
|
} else if (value == 'click') {
|
||||||
|
select = selectClick;
|
||||||
|
} else if (value == 'mousemove') {
|
||||||
|
select = selectMouseMove;
|
||||||
|
} else {
|
||||||
|
select = null;
|
||||||
|
}
|
||||||
|
if (select !== null) {
|
||||||
|
map.addInteraction(select);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onchange callback on the select element.
|
||||||
|
*/
|
||||||
|
selectElement.onchange = changeInteraction;
|
||||||
|
changeInteraction();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -10,6 +11,11 @@ var map = new ol.Map({
|
|||||||
source: new ol.source.OSM()
|
source: new ol.source.OSM()
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<title>WMTS from capabilities example</title>
|
<title>Sphere Mollweide example</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -31,20 +31,22 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">WMTS from capabilities example</h4>
|
<h4 id="title">Sphere Mollweide example</h4>
|
||||||
<p id="shortdesc">Example of a WMTS source built from a WMTS getCapabilities response.</p>
|
<p id="shortdesc">Example of a Sphere Mollweide map with a Graticule component.</p>
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
<p>See the <a href="wmts-from-capabilities.js" target="_blank">wmts-from-capabilities.js source</a> to see how this is done.</p>
|
<p>See the <a href="sphere-mollweide.js" target="_blank">sphere-mollweide.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">wmts</div>
|
<div id="tags">graticule, Mollweide, projection, proj4js</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="loader.js?id=wmts-from-capabilities" type="text/javascript"></script>
|
<script src="jquery.min.js" type="text/javascript"></script>
|
||||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
|
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
|
||||||
|
<script src="loader.js?id=sphere-mollweide" type="text/javascript"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
42
examples/sphere-mollweide.js
Normal file
42
examples/sphere-mollweide.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
goog.require('ol.Graticule');
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.layer.Vector');
|
||||||
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.source.GeoJSON');
|
||||||
|
|
||||||
|
|
||||||
|
proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' +
|
||||||
|
'+b=6371000 +units=m +no_defs');
|
||||||
|
|
||||||
|
// Configure the Sphere Mollweide projection object with an extent,
|
||||||
|
// and a world extent. These are required for the Graticule.
|
||||||
|
var sphereMollweideProjection = ol.proj.get('ESRI:53009');
|
||||||
|
sphereMollweideProjection.setExtent([
|
||||||
|
-9009954.605703328, -9009954.605703328,
|
||||||
|
9009954.605703328, 9009954.605703328]);
|
||||||
|
sphereMollweideProjection.setWorldExtent([-179, -90, 179, 90]);
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
keyboardEventTarget: document,
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Vector({
|
||||||
|
source: new ol.source.GeoJSON({
|
||||||
|
projection: sphereMollweideProjection,
|
||||||
|
url: 'data/geojson/countries-110m.geojson'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
],
|
||||||
|
renderer: 'canvas',
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View({
|
||||||
|
center: [0, 0],
|
||||||
|
projection: sphereMollweideProjection,
|
||||||
|
resolutions: [65536, 32768, 16384, 8192, 4096, 2048],
|
||||||
|
zoom: 0
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
var graticule = new ol.Graticule({
|
||||||
|
map: map
|
||||||
|
});
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -11,6 +12,11 @@ var map = new ol.Map({
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 2
|
zoom: 2
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.format.OSMXML');
|
goog.require('ol.format.OSMXML');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
@@ -90,8 +91,8 @@ var styles = {
|
|||||||
var vectorSource = new ol.source.ServerVector({
|
var vectorSource = new ol.source.ServerVector({
|
||||||
format: new ol.format.OSMXML(),
|
format: new ol.format.OSMXML(),
|
||||||
loader: function(extent, resolution, projection) {
|
loader: function(extent, resolution, projection) {
|
||||||
var transform = ol.proj.getTransform(projection, 'EPSG:4326');
|
var epsg4326Extent =
|
||||||
var epsg4326Extent = transform(extent, []);
|
ol.proj.transformExtent(extent, projection, 'EPSG:4326');
|
||||||
var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
|
var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
|
||||||
epsg4326Extent.join(',');
|
epsg4326Extent.join(',');
|
||||||
$.ajax(url).then(function(response) {
|
$.ajax(url).then(function(response) {
|
||||||
@@ -131,6 +132,11 @@ var raster = new ol.layer.Tile({
|
|||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [raster, vector],
|
layers: [raster, vector],
|
||||||
target: document.getElementById('map'),
|
target: document.getElementById('map'),
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [739218, 5906096],
|
center: [739218, 5906096],
|
||||||
maxZoom: 19,
|
maxZoom: 19,
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ goog.require('ol.style.Stroke');
|
|||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
goog.require('ol.tilegrid.XYZ');
|
goog.require('ol.tilegrid.XYZ');
|
||||||
|
|
||||||
var loadFeatures = function(response) {
|
|
||||||
vectorSource.addFeatures(vectorSource.readFeatures(response));
|
|
||||||
};
|
|
||||||
|
|
||||||
var vectorSource = new ol.source.ServerVector({
|
var vectorSource = new ol.source.ServerVector({
|
||||||
format: new ol.format.GeoJSON(),
|
format: new ol.format.GeoJSON(),
|
||||||
loader: function(extent, resolution, projection) {
|
loader: function(extent, resolution, projection) {
|
||||||
@@ -32,6 +28,10 @@ var vectorSource = new ol.source.ServerVector({
|
|||||||
projection: 'EPSG:3857'
|
projection: 'EPSG:3857'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var loadFeatures = function(response) {
|
||||||
|
vectorSource.addFeatures(vectorSource.readFeatures(response));
|
||||||
|
};
|
||||||
|
|
||||||
var vector = new ol.layer.Vector({
|
var vector = new ol.layer.Vector({
|
||||||
source: vectorSource,
|
source: vectorSource,
|
||||||
style: new ol.style.Style({
|
style: new ol.style.Style({
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<title>Tiled WMS with Proj4js projection example</title>
|
<title>Tiled WMS with custom projection example</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -31,21 +31,18 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Tiled WMS with Proj4js projection example</h4>
|
<h4 id="title">Tiled WMS with custom projection example</h4>
|
||||||
<p id="shortdesc">Example of two tiled WMS layers (Pixelmap 1:1'000'000 and national parks) using the projection EPSG:21781.</p>
|
<p id="shortdesc">Example of two tiled WMS layers (Pixelmap 1:1'000'000 and national parks) using the projection EPSG:21781.</p>
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
<p>See the <a href="wms-custom-proj.js" target="_blank">wms-custom-proj.js source</a> to see how this is done.</p>
|
<p>See the <a href="wms-custom-proj.js" target="_blank">wms-custom-proj.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">wms, tile, tilelayer, proj4js, projection</div>
|
<div id="tags">wms, tile, tilelayer, projection</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="jquery.min.js" type="text/javascript"></script>
|
<script src="jquery.min.js" type="text/javascript"></script>
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/defs/EPSG21781.js" type="text/javascript"></script>
|
|
||||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
<script src="loader.js?id=wms-custom-proj" type="text/javascript"></script>
|
<script src="loader.js?id=wms-custom-proj" type="text/javascript"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -5,17 +5,46 @@ goog.require('ol.control');
|
|||||||
goog.require('ol.control.ScaleLine');
|
goog.require('ol.control.ScaleLine');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.source.TileWMS');
|
goog.require('ol.source.TileWMS');
|
||||||
|
|
||||||
|
|
||||||
var projection = ol.proj.configureProj4jsProjection({
|
|
||||||
|
// By default OpenLayers does not know about the EPSG:21781 (Swiss) projection.
|
||||||
|
// So we create a projection instance for EPSG:21781 and pass it to
|
||||||
|
// ol.proj.addProjection to make it available to the library.
|
||||||
|
|
||||||
|
var projection = new ol.proj.Projection({
|
||||||
code: 'EPSG:21781',
|
code: 'EPSG:21781',
|
||||||
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
|
// The extent is used to determine zoom level 0. Recommended values for a
|
||||||
|
// projection's validity extent can be found at http://epsg.io/.
|
||||||
|
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
|
||||||
|
units: 'm'
|
||||||
});
|
});
|
||||||
|
ol.proj.addProjection(projection);
|
||||||
|
|
||||||
|
// We also declare EPSG:21781/EPSG:4326 transform functions. These functions
|
||||||
|
// are necessary for the ScaleLine control and when calling ol.proj.transform
|
||||||
|
// for setting the view's initial center (see below).
|
||||||
|
|
||||||
|
ol.proj.addCoordinateTransforms('EPSG:4326', projection,
|
||||||
|
function(coordinate) {
|
||||||
|
return [
|
||||||
|
WGStoCHy(coordinate[1], coordinate[0]),
|
||||||
|
WGStoCHx(coordinate[1], coordinate[0])
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function(coordinate) {
|
||||||
|
return [
|
||||||
|
CHtoWGSlng(coordinate[0], coordinate[1]),
|
||||||
|
CHtoWGSlat(coordinate[0], coordinate[1])
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
var extent = [420000, 30000, 900000, 350000];
|
var extent = [420000, 30000, 900000, 350000];
|
||||||
var layers = [
|
var layers = [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
|
extent: extent,
|
||||||
source: new ol.source.TileWMS({
|
source: new ol.source.TileWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
@@ -29,11 +58,11 @@ var layers = [
|
|||||||
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
||||||
'FORMAT': 'image/jpeg'
|
'FORMAT': 'image/jpeg'
|
||||||
},
|
},
|
||||||
extent: extent,
|
|
||||||
serverType: 'mapserver'
|
serverType: 'mapserver'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
|
extent: extent,
|
||||||
source: new ol.source.TileWMS({
|
source: new ol.source.TileWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
@@ -44,7 +73,6 @@ var layers = [
|
|||||||
'National parks / geo.admin.ch</a>'
|
'National parks / geo.admin.ch</a>'
|
||||||
})],
|
})],
|
||||||
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
||||||
extent: extent,
|
|
||||||
serverType: 'mapserver'
|
serverType: 'mapserver'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -61,8 +89,160 @@ var map = new ol.Map({
|
|||||||
target: 'map',
|
target: 'map',
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
projection: projection,
|
projection: projection,
|
||||||
center: [660000, 190000],
|
center: ol.proj.transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'),
|
||||||
extent: extent,
|
extent: extent,
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swiss projection transform functions downloaded from
|
||||||
|
* http://www.swisstopo.admin.ch/internet/swisstopo/en/home/products/software/products/skripts.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Convert WGS lat/long (° dec) to CH y
|
||||||
|
function WGStoCHy(lat, lng) {
|
||||||
|
|
||||||
|
// Converts degrees dec to sex
|
||||||
|
lat = DECtoSEX(lat);
|
||||||
|
lng = DECtoSEX(lng);
|
||||||
|
|
||||||
|
// Converts degrees to seconds (sex)
|
||||||
|
lat = DEGtoSEC(lat);
|
||||||
|
lng = DEGtoSEC(lng);
|
||||||
|
|
||||||
|
// Axiliary values (% Bern)
|
||||||
|
var lat_aux = (lat - 169028.66) / 10000;
|
||||||
|
var lng_aux = (lng - 26782.5) / 10000;
|
||||||
|
|
||||||
|
// Process Y
|
||||||
|
var y = 600072.37 +
|
||||||
|
211455.93 * lng_aux -
|
||||||
|
10938.51 * lng_aux * lat_aux -
|
||||||
|
0.36 * lng_aux * Math.pow(lat_aux, 2) -
|
||||||
|
44.54 * Math.pow(lng_aux, 3);
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert WGS lat/long (° dec) to CH x
|
||||||
|
function WGStoCHx(lat, lng) {
|
||||||
|
|
||||||
|
// Converts degrees dec to sex
|
||||||
|
lat = DECtoSEX(lat);
|
||||||
|
lng = DECtoSEX(lng);
|
||||||
|
|
||||||
|
// Converts degrees to seconds (sex)
|
||||||
|
lat = DEGtoSEC(lat);
|
||||||
|
lng = DEGtoSEC(lng);
|
||||||
|
|
||||||
|
// Axiliary values (% Bern)
|
||||||
|
var lat_aux = (lat - 169028.66) / 10000;
|
||||||
|
var lng_aux = (lng - 26782.5) / 10000;
|
||||||
|
|
||||||
|
// Process X
|
||||||
|
var x = 200147.07 +
|
||||||
|
308807.95 * lat_aux +
|
||||||
|
3745.25 * Math.pow(lng_aux, 2) +
|
||||||
|
76.63 * Math.pow(lat_aux, 2) -
|
||||||
|
194.56 * Math.pow(lng_aux, 2) * lat_aux +
|
||||||
|
119.79 * Math.pow(lat_aux, 3);
|
||||||
|
|
||||||
|
return x;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert CH y/x to WGS lat
|
||||||
|
function CHtoWGSlat(y, x) {
|
||||||
|
|
||||||
|
// Converts militar to civil and to unit = 1000km
|
||||||
|
// Axiliary values (% Bern)
|
||||||
|
var y_aux = (y - 600000) / 1000000;
|
||||||
|
var x_aux = (x - 200000) / 1000000;
|
||||||
|
|
||||||
|
// Process lat
|
||||||
|
var lat = 16.9023892 +
|
||||||
|
3.238272 * x_aux -
|
||||||
|
0.270978 * Math.pow(y_aux, 2) -
|
||||||
|
0.002528 * Math.pow(x_aux, 2) -
|
||||||
|
0.0447 * Math.pow(y_aux, 2) * x_aux -
|
||||||
|
0.0140 * Math.pow(x_aux, 3);
|
||||||
|
|
||||||
|
// Unit 10000" to 1 " and converts seconds to degrees (dec)
|
||||||
|
lat = lat * 100 / 36;
|
||||||
|
|
||||||
|
return lat;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert CH y/x to WGS long
|
||||||
|
function CHtoWGSlng(y, x) {
|
||||||
|
|
||||||
|
// Converts militar to civil and to unit = 1000km
|
||||||
|
// Axiliary values (% Bern)
|
||||||
|
var y_aux = (y - 600000) / 1000000;
|
||||||
|
var x_aux = (x - 200000) / 1000000;
|
||||||
|
|
||||||
|
// Process long
|
||||||
|
var lng = 2.6779094 +
|
||||||
|
4.728982 * y_aux +
|
||||||
|
0.791484 * y_aux * x_aux +
|
||||||
|
0.1306 * y_aux * Math.pow(x_aux, 2) -
|
||||||
|
0.0436 * Math.pow(y_aux, 3);
|
||||||
|
|
||||||
|
// Unit 10000" to 1 " and converts seconds to degrees (dec)
|
||||||
|
lng = lng * 100 / 36;
|
||||||
|
|
||||||
|
return lng;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert SEX DMS angle to DEC
|
||||||
|
function SEXtoDEC(angle) {
|
||||||
|
|
||||||
|
// Extract DMS
|
||||||
|
var deg = parseInt(angle, 10);
|
||||||
|
var min = parseInt((angle - deg) * 100, 10);
|
||||||
|
var sec = (((angle - deg) * 100) - min) * 100;
|
||||||
|
|
||||||
|
// Result in degrees sex (dd.mmss)
|
||||||
|
return deg + (sec / 60 + min) / 60;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert DEC angle to SEX DMS
|
||||||
|
function DECtoSEX(angle) {
|
||||||
|
|
||||||
|
// Extract DMS
|
||||||
|
var deg = parseInt(angle, 10);
|
||||||
|
var min = parseInt((angle - deg) * 60, 10);
|
||||||
|
var sec = (((angle - deg) * 60) - min) * 60;
|
||||||
|
|
||||||
|
// Result in degrees sex (dd.mmss)
|
||||||
|
return deg + min / 100 + sec / 10000;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert Degrees angle to seconds
|
||||||
|
function DEGtoSEC(angle) {
|
||||||
|
|
||||||
|
// Extract DMS
|
||||||
|
var deg = parseInt(angle, 10);
|
||||||
|
var min = parseInt((angle - deg) * 100, 10);
|
||||||
|
var sec = (((angle - deg) * 100) - min) * 100;
|
||||||
|
|
||||||
|
// Avoid rounding problems with seconds=0
|
||||||
|
var parts = String(angle).split('.');
|
||||||
|
if (parts.length == 2 && parts[1].length == 2) {
|
||||||
|
min = Number(parts[1]);
|
||||||
|
sec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Result in degrees sex (dd.mmss)
|
||||||
|
return sec + min * 60 + deg * 3600;
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<title>Single image WMS with custom projection example</title>
|
<title>Single image WMS with Proj4js projection example</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -31,13 +31,13 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Single image WMS with custom projection example</h4>
|
<h4 id="title">Single image WMS with Proj4js projection example</h4>
|
||||||
<p id="shortdesc">Example of two single image WMS layers.</p>
|
<p id="shortdesc">Example of two single image WMS layers.</p>
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
<p>Pixelmap 1:1'000'000 with National Parks overlay using the projection EPSG:21781.</p>
|
<p>Pixelmap 1:1'000'000 with National Parks overlay using the projection EPSG:21781.</p>
|
||||||
<p>See the <a href="wms-image-custom-proj.js" target="_blank">wms-image-custom-proj.js source</a> to see how this is done.</p>
|
<p>See the <a href="wms-image-custom-proj.js" target="_blank">wms-image-custom-proj.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">wms, single image, projection</div>
|
<div id="tags">wms, single image, proj4js, projection</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="jquery.min.js" type="text/javascript"></script>
|
<script src="jquery.min.js" type="text/javascript"></script>
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/defs/EPSG21781.js" type="text/javascript"></script>
|
<script src="http://epsg.io/21781.js" type="text/javascript"></script>
|
||||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
<script src="loader.js?id=wms-image-custom-proj" type="text/javascript"></script>
|
<script src="loader.js?id=wms-image-custom-proj" type="text/javascript"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,30 @@
|
|||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
|
goog.require('ol.control.ScaleLine');
|
||||||
goog.require('ol.layer.Image');
|
goog.require('ol.layer.Image');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.ImageWMS');
|
goog.require('ol.source.ImageWMS');
|
||||||
|
|
||||||
|
|
||||||
var projection = ol.proj.configureProj4jsProjection({
|
// Transparent Proj4js support: ol.proj.get() creates and returns a projection
|
||||||
code: 'EPSG:21781',
|
// known to Proj4js if it is unknown to OpenLayers, and registers functions to
|
||||||
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
|
// transform between all registered projections.
|
||||||
});
|
// EPSG:21781 is known to Proj4js because its definition was loaded in the html.
|
||||||
|
// Note that we are getting the projection object here to set the extent. If
|
||||||
|
// you do not need this, you do not have to use ol.proj.get(); simply use the
|
||||||
|
// string code in the view projection below and the transforms will be
|
||||||
|
// registered transparently.
|
||||||
|
var projection = ol.proj.get('EPSG:21781');
|
||||||
|
// The extent is used to determine zoom level 0. Recommended values for a
|
||||||
|
// projection's validity extent can be found at http://epsg.io/.
|
||||||
|
projection.setExtent([485869.5728, 76443.1884, 837076.5648, 299941.7864]);
|
||||||
|
|
||||||
var extent = [420000, 30000, 900000, 350000];
|
var extent = [420000, 30000, 900000, 350000];
|
||||||
var layers = [
|
var layers = [
|
||||||
new ol.layer.Image({
|
new ol.layer.Image({
|
||||||
|
extent: extent,
|
||||||
source: new ol.source.ImageWMS({
|
source: new ol.source.ImageWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
@@ -27,11 +38,11 @@ var layers = [
|
|||||||
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
||||||
'FORMAT': 'image/jpeg'
|
'FORMAT': 'image/jpeg'
|
||||||
},
|
},
|
||||||
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver'),
|
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver')
|
||||||
extent: extent
|
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
new ol.layer.Image({
|
new ol.layer.Image({
|
||||||
|
extent: extent,
|
||||||
source: new ol.source.ImageWMS({
|
source: new ol.source.ImageWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
@@ -42,19 +53,21 @@ var layers = [
|
|||||||
'National parks / geo.admin.ch</a>'
|
'National parks / geo.admin.ch</a>'
|
||||||
})],
|
})],
|
||||||
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
||||||
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver'),
|
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver')
|
||||||
extent: extent
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
|
controls: ol.control.defaults().extend([
|
||||||
|
new ol.control.ScaleLine()
|
||||||
|
]),
|
||||||
layers: layers,
|
layers: layers,
|
||||||
renderer: exampleNS.getRendererFromQueryString(),
|
renderer: exampleNS.getRendererFromQueryString(),
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
projection: projection,
|
projection: projection,
|
||||||
center: [660000, 190000],
|
center: ol.proj.transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'),
|
||||||
extent: extent,
|
extent: extent,
|
||||||
zoom: 2
|
zoom: 2
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ var layers = [
|
|||||||
source: new ol.source.MapQuest({layer: 'sat'})
|
source: new ol.source.MapQuest({layer: 'sat'})
|
||||||
}),
|
}),
|
||||||
new ol.layer.Image({
|
new ol.layer.Image({
|
||||||
|
extent: [-13884991, 2870341, -7455066, 6338219],
|
||||||
source: new ol.source.ImageWMS({
|
source: new ol.source.ImageWMS({
|
||||||
url: 'http://demo.opengeo.org/geoserver/wms',
|
url: 'http://demo.opengeo.org/geoserver/wms',
|
||||||
params: {'LAYERS': 'topp:states'},
|
params: {'LAYERS': 'topp:states'},
|
||||||
serverType: 'geoserver',
|
serverType: 'geoserver'
|
||||||
extent: [-13884991, 2870341, -7455066, 6338219]
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -42,8 +42,10 @@ var layers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// A minimal projection object is configured with only the SRS code and the map
|
// A minimal projection object is configured with only the SRS code and the map
|
||||||
// units. No client side coordinate transforms are possible with such a
|
// units. No client-side coordinate transforms are possible with such a
|
||||||
// projection object.
|
// projection object. Requesting tiles only needs the code together with a
|
||||||
|
// tile grid of Cartesian coordinates; it does not matter how those
|
||||||
|
// coordinates relate to latitude or longitude.
|
||||||
var projection = new ol.proj.Projection({
|
var projection = new ol.proj.Projection({
|
||||||
code: 'EPSG:21781',
|
code: 'EPSG:21781',
|
||||||
units: 'm'
|
units: 'm'
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ var layers = [
|
|||||||
source: new ol.source.MapQuest({layer: 'sat'})
|
source: new ol.source.MapQuest({layer: 'sat'})
|
||||||
}),
|
}),
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
|
extent: [-13884991, 2870341, -7455066, 6338219],
|
||||||
source: new ol.source.TileWMS(/** @type {olx.source.TileWMSOptions} */ ({
|
source: new ol.source.TileWMS(/** @type {olx.source.TileWMSOptions} */ ({
|
||||||
url: 'http://demo.opengeo.org/geoserver/wms',
|
url: 'http://demo.opengeo.org/geoserver/wms',
|
||||||
params: {'LAYERS': 'topp:states', 'TILED': true},
|
params: {'LAYERS': 'topp:states', 'TILED': true},
|
||||||
extent: [-13884991, 2870341, -7455066, 6338219],
|
|
||||||
serverType: 'geoserver'
|
serverType: 'geoserver'
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<title>WMTS HiDPI example</title>
|
<title>WMTS HiDPI example</title>
|
||||||
|
<style>
|
||||||
|
.map {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ var urls = [
|
|||||||
var hiDPI = ol.BrowserFeature.DEVICE_PIXEL_RATIO > 1;
|
var hiDPI = ol.BrowserFeature.DEVICE_PIXEL_RATIO > 1;
|
||||||
|
|
||||||
var source = new ol.source.WMTS({
|
var source = new ol.source.WMTS({
|
||||||
extent: [977844.377599999, 5837774.6617, 1915609.8654, 6295560.8122],
|
|
||||||
projection: 'EPSG:3857',
|
projection: 'EPSG:3857',
|
||||||
layer: hiDPI ? 'bmaphidpi' : 'geolandbasemap',
|
layer: hiDPI ? 'bmaphidpi' : 'geolandbasemap',
|
||||||
tilePixelRatio: hiDPI ? 2 : 1,
|
tilePixelRatio: hiDPI ? 2 : 1,
|
||||||
@@ -64,6 +63,7 @@ var source = new ol.source.WMTS({
|
|||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
|
extent: [977844.377599999, 5837774.6617, 1915609.8654, 6295560.8122],
|
||||||
source: source
|
source: source
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
@@ -34,6 +35,7 @@ var map = new ol.Map({
|
|||||||
}),
|
}),
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
opacity: 0.7,
|
opacity: 0.7,
|
||||||
|
extent: projectionExtent,
|
||||||
source: new ol.source.WMTS({
|
source: new ol.source.WMTS({
|
||||||
attributions: [attribution],
|
attributions: [attribution],
|
||||||
url: 'http://services.arcgisonline.com/arcgis/rest/' +
|
url: 'http://services.arcgisonline.com/arcgis/rest/' +
|
||||||
@@ -47,12 +49,16 @@ var map = new ol.Map({
|
|||||||
resolutions: resolutions,
|
resolutions: resolutions,
|
||||||
matrixIds: matrixIds
|
matrixIds: matrixIds
|
||||||
}),
|
}),
|
||||||
extent: projectionExtent,
|
|
||||||
style: 'default'
|
style: 'default'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [-11158582, 4813697],
|
center: [-11158582, 4813697],
|
||||||
zoom: 4
|
zoom: 4
|
||||||
|
|||||||
@@ -8,12 +8,7 @@
|
|||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
<title>IGN WMTS example</title>
|
<title>XYZ Retina tiles example</title>
|
||||||
<style>
|
|
||||||
.ol-logo ul li {
|
|
||||||
margin-right: 3px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -36,24 +31,22 @@
|
|||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">IGN WMTS example</h4>
|
<h4 id="title">XYZ with Retina tiles example</h4>
|
||||||
<p id="shortdesc">Demonstrates displaying IGN (France) WMTS layers.</p>
|
<p id="shortdesc">Example of Retina / HiDPI mercator tiles (512x512px) available as XYZ.</p>
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
<p>In this example two IGN WMTS layers are displayed: <em>Ortho imagery and Cadastral parcels.</em>.
|
<p>The ol.source.XYZ must contain <code>tilePixelRatio</code> parameter. The tiles were prepared from a GeoTIFF file with <a href="http://www.maptiler.com/">MapTiler</a>.</p>
|
||||||
For more information on IGN's WMTS service see the
|
<p>See the <a href="xyz-retina.js" target="_blank">xyz-retina.js source</a> for details on how this is done.</p>
|
||||||
<a href="http://professionnels.ign.fr/api-sig">IGN Géoportail API web page</a> (french).</p>
|
|
||||||
<p>See the <a href="wmts-ign.js" target="_blank">wmts-ign.js source</a> to see how this is done.</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">french, ign, geoportail, wmts</div>
|
<div id="tags">retina, hidpi, xyz, maptiler, @2x, devicePixelRatio</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
<script src="jquery.min.js" type="text/javascript"></script>
|
||||||
<script src="loader.js?id=wmts-ign" type="text/javascript"></script>
|
|
||||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
|
<script src="loader.js?id=xyz-retina" type="text/javascript"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
41
examples/xyz-retina.js
Normal file
41
examples/xyz-retina.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
goog.require('ol.Attribution');
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.layer.Tile');
|
||||||
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.source.OSM');
|
||||||
|
goog.require('ol.source.XYZ');
|
||||||
|
|
||||||
|
|
||||||
|
var attribution = new ol.Attribution({
|
||||||
|
html: 'Tiles rendered with <a href="http://www.maptiler.com/"> © USGS'
|
||||||
|
});
|
||||||
|
|
||||||
|
var mapMinZoom = 1;
|
||||||
|
var mapMaxZoom = 15;
|
||||||
|
var mapExtent = [-112.261791, 35.983744, -112.113981, 36.132062];
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
target: 'map',
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Tile({
|
||||||
|
source: new ol.source.OSM()
|
||||||
|
}),
|
||||||
|
new ol.layer.Tile({
|
||||||
|
source: new ol.source.XYZ({
|
||||||
|
url: 'http://tileserver.maptiler.com/grandcanyon@2x/{z}/{x}/{y}.png',
|
||||||
|
tilePixelRatio: 2, // THIS IS IMPORTANT
|
||||||
|
maxExtent: ol.proj.transformExtent(
|
||||||
|
mapExtent, 'EPSG:4326', 'EPSG:3857'),
|
||||||
|
minZoom: mapMinZoom,
|
||||||
|
maxZoom: mapMaxZoom
|
||||||
|
})
|
||||||
|
})
|
||||||
|
],
|
||||||
|
view: new ol.View({
|
||||||
|
projection: 'EPSG:3857',
|
||||||
|
center: ol.proj.transform([-112.18688965, 36.057944835],
|
||||||
|
'EPSG:4326', 'EPSG:3857'),
|
||||||
|
zoom: 12
|
||||||
|
})
|
||||||
|
});
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
goog.require('ol.source.XYZ');
|
goog.require('ol.source.XYZ');
|
||||||
@@ -13,6 +14,11 @@ var attribution = new ol.Attribution({
|
|||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
target: 'map',
|
target: 'map',
|
||||||
|
controls: ol.control.defaults({
|
||||||
|
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||||
|
collapsible: false
|
||||||
|
})
|
||||||
|
}),
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
source: new ol.source.OSM({
|
source: new ol.source.OSM({
|
||||||
|
|||||||
@@ -8,63 +8,6 @@
|
|||||||
* @externs
|
* @externs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1060
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {Date} */
|
|
||||||
HTMLInputElement.prototype.valueAsDate;
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
|
||||||
HTMLInputElement.prototype.valueAsNumber;
|
|
||||||
|
|
||||||
|
|
||||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1084
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
|
||||||
DeviceRotationRate.prototype.alpha;
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
|
||||||
DeviceRotationRate.prototype.beta;
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
|
||||||
DeviceRotationRate.prototype.gamma;
|
|
||||||
|
|
||||||
|
|
||||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1088
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
|
||||||
DeviceOrientationEvent.prototype.webkitCompassAccuracy;
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
|
||||||
DeviceOrientationEvent.prototype.webkitCompassHeading;
|
|
||||||
|
|
||||||
|
|
||||||
// IE 11 fullscreen API
|
|
||||||
// http://msdn.microsoft.com/en-us/library/ie/dn265028(v=vs.85).aspx
|
|
||||||
|
|
||||||
|
|
||||||
/** @return {void} */
|
|
||||||
Element.prototype.msRequestFullscreen = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/** @return {void} */
|
|
||||||
Element.prototype.msExitFullscreen = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {boolean} */
|
|
||||||
Document.prototype.msFullscreenEnabled;
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {Element} */
|
|
||||||
Document.prototype.msFullscreenElement;
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
Touch.prototype.force;
|
Touch.prototype.force;
|
||||||
|
|
||||||
|
|||||||
2296
externs/jquery-1.7.js
vendored
Normal file
2296
externs/jquery-1.7.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
754
externs/olx.js
754
externs/olx.js
File diff suppressed because it is too large
Load Diff
@@ -1,92 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* @externs
|
* @externs
|
||||||
* @see http://trac.osgeo.org/proj4js/
|
* @see http://proj4js.org/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object}
|
* @param {...*} var_args
|
||||||
|
* @return {undefined|Array.<number>|Object.<{
|
||||||
|
* forward: function(Array.<number>): Array.<number>,
|
||||||
|
* inverse: function(Array.<number>): Array.<number>}>}
|
||||||
*/
|
*/
|
||||||
var Proj4js = {};
|
var proj4 = function(var_args) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<string, string>}
|
* @param {string} name
|
||||||
|
* @param {(string|Object)=} opt_def
|
||||||
|
* @return {undefined|Object.<string, Object.<{axis: string, units: string,
|
||||||
|
* to_meter: number}>>}
|
||||||
*/
|
*/
|
||||||
Proj4js.defs;
|
proj4.defs = function(name, opt_def) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {function(string)}
|
|
||||||
*/
|
|
||||||
Proj4js.reportError;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {number} x
|
|
||||||
* @param {number} y
|
|
||||||
*/
|
|
||||||
Proj4js.Point = function(x, y) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Proj4js.Point.prototype.x;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Proj4js.Point.prototype.y;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {string} srsCode
|
|
||||||
* @param {Function=} opt_callback
|
|
||||||
*/
|
|
||||||
Proj4js.Proj = function(srsCode, opt_callback) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Proj4js.Proj.prototype.axis;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Proj4js.Proj.prototype.title;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Proj4js.Proj.prototype.units;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Proj4js.Proj.prototype.srsCode;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Proj4js.Proj.prototype.to_meter;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @nosideeffects
|
|
||||||
* @param {Proj4js.Proj} source
|
|
||||||
* @param {Proj4js.Proj} dest
|
|
||||||
* @param {Proj4js.Point|{x:number, y:number}} point
|
|
||||||
* @return {Proj4js.Point}
|
|
||||||
*/
|
|
||||||
Proj4js.transform = function(source, dest, point) {return null;};
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Coordinate}
|
* @type {ol.Coordinate}
|
||||||
* @todo api
|
* @api
|
||||||
*/
|
*/
|
||||||
this.coordinate = map.getEventCoordinate(this.originalEvent);
|
this.coordinate = map.getEventCoordinate(this.originalEvent);
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ ol.control.Control = function(options) {
|
|||||||
/**
|
/**
|
||||||
* Application subclasses may override this.
|
* Application subclasses may override this.
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol.Map} map Map.
|
||||||
* @todo api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.control.Control.prototype.setMap = function(map) {
|
ol.control.Control.prototype.setMap = function(map) {
|
||||||
// ...
|
// ...
|
||||||
@@ -88,7 +88,7 @@ Object literals cannot be exported like classes. To make sure that their propert
|
|||||||
/**
|
/**
|
||||||
* @typedef {{element: (Element|undefined),
|
* @typedef {{element: (Element|undefined),
|
||||||
* target: (Element|string|undefined)}}
|
* target: (Element|string|undefined)}}
|
||||||
* @todo api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.control.ControlOptions;
|
olx.control.ControlOptions;
|
||||||
|
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
goog.require('ol.Feature');
|
|
||||||
goog.require('ol.Map');
|
|
||||||
goog.require('ol.RendererHint');
|
|
||||||
goog.require('ol.View2D');
|
|
||||||
goog.require('ol.control');
|
|
||||||
goog.require('ol.expr');
|
|
||||||
goog.require('ol.geom.LineString');
|
|
||||||
goog.require('ol.geom.Point');
|
|
||||||
goog.require('ol.layer.Vector');
|
|
||||||
goog.require('ol.source.Vector');
|
|
||||||
goog.require('ol.style.Fill');
|
|
||||||
goog.require('ol.style.Rule');
|
|
||||||
goog.require('ol.style.Shape');
|
|
||||||
goog.require('ol.style.Stroke');
|
|
||||||
goog.require('ol.style.Style');
|
|
||||||
goog.require('ol.style.Text');
|
|
||||||
|
|
||||||
|
|
||||||
var style = new ol.style.Style({rules: [
|
|
||||||
new ol.style.Rule({
|
|
||||||
filter: 'where == "outer"',
|
|
||||||
symbolizers: [
|
|
||||||
new ol.style.Stroke({
|
|
||||||
color: ol.expr.parse('color'),
|
|
||||||
width: 4,
|
|
||||||
opacity: 1,
|
|
||||||
zIndex: 1
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
new ol.style.Rule({
|
|
||||||
filter: 'where == "inner"',
|
|
||||||
symbolizers: [
|
|
||||||
new ol.style.Stroke({
|
|
||||||
color: '#013',
|
|
||||||
width: 4,
|
|
||||||
opacity: 1
|
|
||||||
}),
|
|
||||||
new ol.style.Stroke({
|
|
||||||
color: ol.expr.parse('color'),
|
|
||||||
width: 2,
|
|
||||||
opacity: 1
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
new ol.style.Rule({
|
|
||||||
filter: 'geometryType("Point")',
|
|
||||||
symbolizers: [
|
|
||||||
new ol.style.Shape({
|
|
||||||
size: 40,
|
|
||||||
fill: new ol.style.Fill({color: '#013'})
|
|
||||||
}),
|
|
||||||
new ol.style.Text({
|
|
||||||
color: '#bada55',
|
|
||||||
text: ol.expr.parse('label'),
|
|
||||||
fontFamily: 'Calibri,sans-serif',
|
|
||||||
fontSize: 14
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
]});
|
|
||||||
|
|
||||||
var vector = new ol.layer.Vector({
|
|
||||||
style: style,
|
|
||||||
source: new ol.source.Vector({
|
|
||||||
features: [
|
|
||||||
new ol.Feature({
|
|
||||||
color: '#BADA55',
|
|
||||||
where: 'inner',
|
|
||||||
geometry: new ol.geom.LineString(
|
|
||||||
[[-10000000, -10000000], [10000000, 10000000]])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
color: '#BADA55',
|
|
||||||
where: 'inner',
|
|
||||||
geometry: new ol.geom.LineString(
|
|
||||||
[[-10000000, 10000000], [10000000, -10000000]])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
color: '#013',
|
|
||||||
where: 'outer',
|
|
||||||
geometry: new ol.geom.LineString(
|
|
||||||
[[-10000000, -10000000], [-10000000, 10000000]])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
color: '#013',
|
|
||||||
where: 'outer',
|
|
||||||
geometry: new ol.geom.LineString(
|
|
||||||
[[-10000000, 10000000], [10000000, 10000000]])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
color: '#013',
|
|
||||||
where: 'outer',
|
|
||||||
geometry: new ol.geom.LineString(
|
|
||||||
[[10000000, 10000000], [10000000, -10000000]])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
color: '#013',
|
|
||||||
where: 'outer',
|
|
||||||
geometry: new ol.geom.LineString(
|
|
||||||
[[10000000, -10000000], [-10000000, -10000000]])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
label: 'South',
|
|
||||||
geometry: new ol.geom.Point([0, -6000000])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
label: 'West',
|
|
||||||
geometry: new ol.geom.Point([-6000000, 0])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
label: 'North',
|
|
||||||
geometry: new ol.geom.Point([0, 6000000])
|
|
||||||
}),
|
|
||||||
new ol.Feature({
|
|
||||||
label: 'East',
|
|
||||||
geometry: new ol.geom.Point([6000000, 0])
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
var map = new ol.Map({
|
|
||||||
layers: [vector],
|
|
||||||
controls: ol.control.defaults({
|
|
||||||
attribution: false
|
|
||||||
}),
|
|
||||||
renderer: ol.RendererHint.CANVAS,
|
|
||||||
target: 'map',
|
|
||||||
view: new ol.View2D({
|
|
||||||
center: [0, 0],
|
|
||||||
zoom: 1
|
|
||||||
})
|
|
||||||
});
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
goog.require('ol.Map');
|
|
||||||
goog.require('ol.Overlay');
|
|
||||||
goog.require('ol.RendererHint');
|
|
||||||
goog.require('ol.View2D');
|
|
||||||
goog.require('ol.expr');
|
|
||||||
goog.require('ol.layer.Tile');
|
|
||||||
goog.require('ol.layer.Vector');
|
|
||||||
goog.require('ol.parser.GeoJSON');
|
|
||||||
goog.require('ol.proj');
|
|
||||||
goog.require('ol.source.MapQuestOpenAerial');
|
|
||||||
goog.require('ol.source.Vector');
|
|
||||||
goog.require('ol.style.Fill');
|
|
||||||
goog.require('ol.style.Rule');
|
|
||||||
goog.require('ol.style.Shape');
|
|
||||||
goog.require('ol.style.ShapeType');
|
|
||||||
goog.require('ol.style.Stroke');
|
|
||||||
goog.require('ol.style.Style');
|
|
||||||
|
|
||||||
|
|
||||||
var raster = new ol.layer.Tile({
|
|
||||||
source: new ol.source.MapQuestOpenAerial()
|
|
||||||
});
|
|
||||||
|
|
||||||
// build up some GeoJSON features
|
|
||||||
var count = 20000;
|
|
||||||
var features = new Array(count);
|
|
||||||
var e = 18000000;
|
|
||||||
for (var i = 0; i < count; ++i) {
|
|
||||||
features[i] = {
|
|
||||||
type: 'Feature',
|
|
||||||
properties: {
|
|
||||||
i: i,
|
|
||||||
size: i % 2 ? 10 : 20
|
|
||||||
},
|
|
||||||
geometry: {
|
|
||||||
type: 'Point',
|
|
||||||
coordinates: [
|
|
||||||
2 * e * Math.random() - e, 2 * e * Math.random() - e
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var vector = new ol.layer.Vector({
|
|
||||||
source: new ol.source.Vector({
|
|
||||||
projection: ol.proj.get('EPSG:3857'),
|
|
||||||
parser: new ol.parser.GeoJSON(),
|
|
||||||
data: {
|
|
||||||
type: 'FeatureCollection',
|
|
||||||
features: features
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
style: new ol.style.Style({rules: [
|
|
||||||
new ol.style.Rule({
|
|
||||||
symbolizers: [
|
|
||||||
new ol.style.Shape({
|
|
||||||
type: ol.style.ShapeType.CIRCLE,
|
|
||||||
size: ol.expr.parse('size'),
|
|
||||||
stroke: new ol.style.Stroke({color: '#666666'}),
|
|
||||||
fill: new ol.style.Fill({color: '#bada55'})
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
]})
|
|
||||||
});
|
|
||||||
|
|
||||||
var popup = new ol.Overlay({
|
|
||||||
element: document.getElementById('popup')
|
|
||||||
});
|
|
||||||
|
|
||||||
var map = new ol.Map({
|
|
||||||
layers: [vector],
|
|
||||||
renderer: ol.RendererHint.CANVAS,
|
|
||||||
target: 'map',
|
|
||||||
view: new ol.View2D({
|
|
||||||
center: [0, 0],
|
|
||||||
zoom: 2
|
|
||||||
}),
|
|
||||||
overlays: [popup]
|
|
||||||
});
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
|
||||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
|
||||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
|
||||||
<title>Vector layer with styling from SLD example</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
|
||||||
<div class="navbar-inner">
|
|
||||||
<div class="container">
|
|
||||||
<a class="brand" href="./">OpenLayers 3 Examples</a>
|
|
||||||
<ul class="nav pull-right">
|
|
||||||
<li><iframe class="github-watch-button" src="http://ghbtns.com/github-btn.html?user=openlayers&repo=ol3&type=watch&count=true"
|
|
||||||
allowtransparency="true" frameborder="0" scrolling="0" height="20" width="90"></iframe></li>
|
|
||||||
<li><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-hashtags="openlayers"> </a></li>
|
|
||||||
<li><div class="g-plusone-wrapper"><div class="g-plusone" data-size="medium" data-annotation="none"></div></div></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
|
||||||
|
|
||||||
<div class="row-fluid">
|
|
||||||
<div class="span12">
|
|
||||||
<div id="map" class="map"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row-fluid">
|
|
||||||
|
|
||||||
<div class="span4">
|
|
||||||
<h4 id="title">Vector layer example</h4>
|
|
||||||
<p id="shortdesc">Example of a countries vector layer with country labels at higher zoom levels, styling info coming from SLD.</p>
|
|
||||||
<div id="docs">
|
|
||||||
<p>See the <a href="vector-layer-sld.js" target="_blank">vector-layer-sld.js source</a> to see how this is done.</p>
|
|
||||||
</div>
|
|
||||||
<div id="tags">vector, geojson, style, SLD, Styled Layer Descriptor</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="loader.js?id=vector-layer-sld" type="text/javascript"></script>
|
|
||||||
<script src="../resources/social-links.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
goog.require('ol.Map');
|
|
||||||
goog.require('ol.RendererHint');
|
|
||||||
goog.require('ol.View2D');
|
|
||||||
goog.require('ol.control');
|
|
||||||
goog.require('ol.control.ScaleLine');
|
|
||||||
goog.require('ol.layer.Tile');
|
|
||||||
goog.require('ol.layer.Vector');
|
|
||||||
goog.require('ol.parser.GeoJSON');
|
|
||||||
goog.require('ol.parser.ogc.SLD');
|
|
||||||
goog.require('ol.source.MapQuest');
|
|
||||||
goog.require('ol.source.Vector');
|
|
||||||
|
|
||||||
|
|
||||||
var raster = new ol.layer.Tile({
|
|
||||||
source: new ol.source.MapQuest({layer: 'sat'})
|
|
||||||
});
|
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open('GET', 'data/countries.sld', true);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* onload handler for the XHR request.
|
|
||||||
*/
|
|
||||||
xhr.onload = function() {
|
|
||||||
if (xhr.status == 200) {
|
|
||||||
var map = new ol.Map({
|
|
||||||
controls: ol.control.defaults().extend([
|
|
||||||
new ol.control.ScaleLine()
|
|
||||||
]),
|
|
||||||
layers: [raster],
|
|
||||||
renderer: ol.RendererHint.CANVAS,
|
|
||||||
target: 'map',
|
|
||||||
view: new ol.View2D({
|
|
||||||
center: [0, 0],
|
|
||||||
zoom: 1
|
|
||||||
})
|
|
||||||
});
|
|
||||||
var units = map.getView().getView2D().getProjection().getUnits();
|
|
||||||
var sld = new ol.parser.ogc.SLD().read(xhr.responseText, {
|
|
||||||
units: units
|
|
||||||
});
|
|
||||||
var style = sld.namedLayers['countries'].userStyles[0];
|
|
||||||
var vector = new ol.layer.Vector({
|
|
||||||
source: new ol.source.Vector({
|
|
||||||
parser: new ol.parser.GeoJSON(),
|
|
||||||
url: 'data/countries.geojson'
|
|
||||||
}),
|
|
||||||
style: style
|
|
||||||
});
|
|
||||||
map.getLayers().push(vector);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send();
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
|
||||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
|
||||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
|
||||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
|
||||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
|
||||||
<title>WMTS Capabilities parsing example</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
|
||||||
<div class="navbar-inner">
|
|
||||||
<div class="container">
|
|
||||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
|
||||||
|
|
||||||
<div class="row-fluid">
|
|
||||||
|
|
||||||
<div class="span4">
|
|
||||||
<h4 id="title">WMTS Capabilities parsing example</h4>
|
|
||||||
<p id="shortdesc">Example of parsing a WMTS Capabilities document.</p>
|
|
||||||
<div id="docs">
|
|
||||||
<p>See the <a href="wmts-capabilities.js" target="_blank">wmts-capabilities.js source</a> to see how this is done.</p>
|
|
||||||
</div>
|
|
||||||
<div id="tags">wmts, WMTSCapabilities</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="span8">
|
|
||||||
<pre id="log"></pre>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
|
||||||
<script src="loader.js?id=wmts-capabilities" type="text/javascript"></script>
|
|
||||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user