Compare commits

...

234 Commits

Author SHA1 Message Date
ahocevar
5cc1ff0f45 Use beta tag 2019-06-24 09:54:41 +02:00
ahocevar
2df5f85018 Set version to 6.0.0-beta.10 2019-06-24 09:52:07 +02:00
Andreas Hocevar
4a0d6ce43c Merge pull request #9705 from ahocevar/vectortile-render-optimizations
Vector tile renderer optimizations and fixes
2019-06-24 09:50:56 +02:00
Andreas Hocevar
187969cbb3 Merge pull request #9706 from ahocevar/non-browser-screen-check
Do not use self to check browser features
2019-06-24 09:48:59 +02:00
ahocevar
8cdfc6e17c Do not use self to check browser features 2019-06-23 14:26:40 +02:00
ahocevar
9cd35d67a9 Fix clipping and clearing 2019-06-23 14:23:32 +02:00
ahocevar
4d2fa476a3 Simpler z sort 2019-06-23 14:22:56 +02:00
ahocevar
f864c05070 Less frame budget restrictions 2019-06-23 14:07:22 +02:00
ahocevar
3557271e5a Use Image.prototype.decode also in Safari 2019-06-23 14:06:14 +02:00
Andreas Hocevar
8a49e06ebd Merge pull request #9704 from ahocevar/vectortile-reuse-issue
Handle container reuse properly when layers are added/removed
2019-06-22 19:33:59 +02:00
ahocevar
6783f6adb9 Handle container reuse properly when layers are added/removed 2019-06-22 19:12:39 +02:00
Tim Schaub
5eb27f7704 Merge pull request #9703 from openlayers/greenkeeper/eslint-6.0.0
Update eslint to the latest version 🚀
2019-06-22 07:13:34 -06:00
greenkeeper[bot]
df240fe905 chore(package): update eslint to version 6.0.0 2019-06-22 04:08:47 +00:00
Frédéric Junod
300522e3cc Merge pull request #9701 from fredj/overlay_will-change
Remove will-change CSS rule for Overlay container
2019-06-21 16:36:27 +02:00
Tim Schaub
3ede6e32be Merge pull request #9702 from lutzhelm/typecheck-iiif
Fix several TypeScript type check problems
2019-06-21 07:53:59 -06:00
Tim Schaub
ce45a10063 Merge pull request #9700 from KaiVolland/9692-typescript
Solves typescript related issues
2019-06-21 07:48:15 -06:00
Tim Schaub
2438ef167b Merge pull request #9699 from petrsloup/maptiler-url-fix
Fix MapTiler API usage
2019-06-21 07:46:42 -06:00
Lutz Helm
d6dc7a926d Fix several TypeScript type check problems 2019-06-21 15:26:28 +02:00
Frederic Junod
6e6a2cae06 Use version 4 TileJSON from mapbox 2019-06-21 14:33:26 +02:00
Frederic Junod
a6ebad008f Remove will-change CSS rule for Overlay container
Fixes #9467
Fixes #9139

Chrome doesn't force a composition if the `will-change` CSS rule is different from `transform` or `opacity`.
See https://bugs.chromium.org/p/chromium/issues/detail?id=960953
2019-06-21 14:22:46 +02:00
Kai Volland
ed5d4aaf6d Fixes typing issue in mat4.js 2019-06-21 13:35:40 +02:00
Kai Volland
f507efe77d Fixes typing issue in Composite.js 2019-06-21 13:31:27 +02:00
Kai Volland
83173cd385 Fixes typing issue in VectorTile.js 2019-06-21 13:30:35 +02:00
Kai Volland
b6b91abc27 Fixes typing issue in DragPan.js 2019-06-21 13:28:56 +02:00
Petr Sloup
05c791efcd Fix MapTiler API usage 2019-06-21 11:22:24 +02:00
Tim Schaub
2342626a57 Merge pull request #9698 from openlayers/greenkeeper/puppeteer-1.18.0
Update puppeteer to the latest version 🚀
2019-06-20 23:33:59 -06:00
greenkeeper[bot]
7c0a0a4786 chore(package): update puppeteer to version 1.18.0 2019-06-20 22:24:07 +00:00
Frédéric Junod
a35ca03e07 Merge pull request #9636 from fredj/rm_from_webgl
Remove and move code from ol/webgl
2019-06-20 16:16:27 +02:00
Tim Schaub
c522454af1 Merge pull request #9695 from openlayers/greenkeeper/webpack-4.35.0
Update webpack to the latest version 🚀
2019-06-20 07:16:29 -06:00
Frederic Junod
ef10834eb3 Remove unused constants from ol/webgl
And change the `EXTENSIONS` constant to a function
2019-06-20 10:25:22 +02:00
greenkeeper[bot]
8efad7bcff chore(package): update webpack to version 4.35.0 2019-06-20 05:08:42 +00:00
Andreas Hocevar
51c8886d60 Merge pull request #9684 from ahocevar/doc-nav
List complete classes in doc navigation
2019-06-17 15:37:19 +02:00
Frédéric Junod
34a8702202 Merge pull request #9685 from fredj/rm_glContext
Remove glContext from RenderEvent
2019-06-17 14:10:51 +02:00
Frederic Junod
1f00da8d83 Remove glContext from RenderEvent 2019-06-17 13:52:56 +02:00
ahocevar
8d793ad6ec List complete classes in doc navigation 2019-06-17 13:10:02 +02:00
Andreas Hocevar
bd8a7bff16 Merge pull request #9681 from ahocevar/apidoc-fixed-and-improved
Remove duplicates from api docs and make navigation more usable
2019-06-17 08:27:48 +02:00
ahocevar
d059689856 Index classes under modulues 2019-06-17 08:15:49 +02:00
ahocevar
4ea28333f8 Avoid duplicates in api docs 2019-06-17 08:15:17 +02:00
Andreas Hocevar
edebf35135 Merge pull request #9677 from ahocevar/featureformat-tilepixels
Add support for tile pixel projection in feature formats
2019-06-15 08:22:28 +02:00
Frédéric Junod
90b645daa5 Merge pull request #9679 from fredj/cleanup
Set pixelTransform and inversePixelTransform as protected
2019-06-15 07:53:15 +02:00
Andreas Hocevar
9eac927b45 Merge pull request #9678 from ahocevar/geography-class
Update geography class urls
2019-06-14 23:20:47 +02:00
Frederic Junod
ec5e8bfa50 Set pixelTransform and inversePixelTransform as protected
The variables are used in child classes
2019-06-14 14:52:28 +02:00
ahocevar
124e984a6d Fix and simplify geojson-vt example 2019-06-14 14:28:37 +02:00
ahocevar
76f44efbb6 Add support for tile pixels to feature formats 2019-06-14 14:28:37 +02:00
ahocevar
ddaaf6a860 Update geography class urls 2019-06-14 12:53:52 +02:00
Tim Schaub
92c16ecdf5 Merge pull request #9673 from openlayers/greenkeeper/webpack-4.34.0
Update webpack to the latest version 🚀
2019-06-12 19:15:28 -06:00
greenkeeper[bot]
635d7a9189 chore(package): update webpack to version 4.34.0 2019-06-12 23:40:39 +00:00
Tim Schaub
fc6ca5eaf3 Merge pull request #9660 from openlayers/greenkeeper/pixelmatch-5.0.0
Update pixelmatch to the latest version 🚀
2019-06-07 04:08:01 -06:00
greenkeeper[bot]
803f960ded chore(package): update pixelmatch to version 5.0.0 2019-06-07 07:52:43 +00:00
Frédéric Junod
ef1b672323 Merge pull request #9658 from fredj/f9628
Don't use HTMLImageElement.decode method on Safari
2019-06-06 16:34:57 +02:00
Frederic Junod
002dc34455 Don't use HTMLImageElement.decode method on Safari
The decode function is supported by Safari but not when the image is a svg file.
2019-06-06 16:15:36 +02:00
Frédéric Junod
cc8389d588 Merge pull request #9657 from fredj/getFeaturesInExtent_doc
Better documentation for getFeaturesInExtent function
2019-06-06 14:23:11 +02:00
Frederic Junod
a8e0e4e960 Better documentation for getFeaturesInExtent function 2019-06-06 14:08:25 +02:00
Olivier Guyot
9ae7256048 Merge pull request #9562 from jahow/webgl-worker
Optimize the WebGL points renderer using a worker
2019-06-06 08:48:29 +02:00
Frederic Junod
e036767746 Use version 4 TileJSON from mapbox 2019-06-06 08:34:31 +02:00
Frédéric Junod
9a49c91fdd Merge pull request #9653 from openlayers/greenkeeper/coveralls-3.0.4
Update coveralls to the latest version 🚀
2019-06-06 08:19:45 +02:00
greenkeeper[bot]
37ff7f547b chore(package): update coveralls to version 3.0.4 2019-06-06 00:10:14 +00:00
Marc Jansen
c97a728531 Merge pull request #9394 from KaiVolland/docs-import-functions
Introduces import snippets for static functions
2019-06-05 22:20:15 +02:00
Olivier Guyot
811bff0430 Merge pull request #9638 from agpixdev/translate-interaction-filter
#9625: Add filter function to translate interaction
2019-06-05 15:32:29 +02:00
Olivier Guyot
2412fe0211 Webgl / remove handling of element_index_uint extension
From now on we will assume this extension is always enabled.

An error message have been added in the unlikely scenario of a lack
of support.
2019-06-05 14:46:15 +02:00
Tim Schaub
32084a7fce Merge pull request #9649 from openlayers/greenkeeper/webpack-4.33.0
Update webpack to the latest version 🚀
2019-06-04 20:11:55 -07:00
André Garneau
7817cf31c6 Changes following code review
Add a type for FilterFunction and add tests for filter option.
2019-06-04 17:45:28 -04:00
greenkeeper[bot]
2e5aac8dba chore(package): update webpack to version 4.33.0 2019-06-04 20:02:28 +00:00
Frédéric Junod
8b08996703 Merge pull request #9644 from fredj/webgl_layer_compose
Use compose function from ol/transform
2019-06-04 15:35:05 +02:00
Andreas Hocevar
1fbbc56f93 Merge pull request #9645 from ahocevar/no-used-tiles
Handle case of no used tiles
2019-06-04 15:26:27 +02:00
ahocevar
8f77a300de Handle case of no used tiles 2019-06-04 14:07:23 +02:00
Frederic Junod
91d49b26b5 Round the transform values in makeProjectionTransform test 2019-06-04 14:00:39 +02:00
Frederic Junod
02ce2f4bec Use compose function from ol/transform 2019-06-04 13:23:12 +02:00
Andreas Hocevar
d4f98c8e59 Merge pull request #9640 from ahocevar/base-docs
Import options directly instead of importing a typedef
2019-06-04 09:30:38 +02:00
Andreas Hocevar
ab0860a22a Merge pull request #9641 from ahocevar/less-proj-imports
Only import what's needed from projections
2019-06-04 09:27:05 +02:00
ahocevar
dd478167a0 Only import what's needed from projections 2019-06-04 09:14:08 +02:00
ahocevar
2df911e0a8 Import options directly instead of importing a typedef 2019-06-04 08:41:08 +02:00
Andreas Hocevar
e9939ecc38 Merge pull request #9637 from ahocevar/detach-labelcache-on-settarget
Detach label cache on Map#setTarget()
2019-06-03 16:03:30 +02:00
Frédéric Junod
d058439756 Merge pull request #9633 from fredj/rm_typecast
Mark the `layers` property as optional in OverviewMap constructor
2019-06-03 15:46:23 +02:00
ahocevar
8c21c9196d Move label cache listener management to the renderer 2019-06-03 15:13:30 +02:00
ahocevar
68b7831daf Listen to label cache again when we have a target 2019-06-03 14:28:20 +02:00
ahocevar
153e06e4d5 Detach label cache on Map#setTarget() 2019-06-03 14:14:13 +02:00
Andreas Hocevar
9bedfb7cb0 Merge pull request #9634 from ahocevar/remove-old-android-workaround
Remove old Android workaround
2019-06-03 10:17:44 +02:00
ahocevar
1bd23a0c32 Remove old Android workaround 2019-06-03 10:03:53 +02:00
Frederic Junod
50343afa61 Remove unnecessary typecasts in constructors options 2019-06-03 09:08:41 +02:00
Frederic Junod
a9e1ebccd3 Mark the layers property as optional in OverviewMap constructor 2019-06-03 09:07:20 +02:00
Andreas Hocevar
9672142c1e Merge pull request #9629 from ahocevar/reuse-vectortile-overlay
Clear overlay canvas when reusing containers
2019-06-02 18:20:24 +02:00
ahocevar
6123be726a Handle layer removal on shared containers 2019-06-02 13:59:06 +02:00
ahocevar
05d8517686 Clear overlay canvas when reusing containers 2019-06-02 11:07:30 +02:00
Frederic Junod
87d5f4c8bc Use 'helper' from WebGLHelper in tests 2019-06-01 15:35:31 +02:00
Frederic Junod
06be00bbd5 Webgl Helper / add an API for OESElementIndexUint extension 2019-06-01 15:35:27 +02:00
Frederic Junod
7fb113c3dc Mark 'helper' variable protected 2019-06-01 15:33:36 +02:00
Olivier Guyot
98b0c65450 Rendering tests / add custom web worker loader
Also includes a change in the rollup-babel plugin to avoid
adding helpers as dependencies (which would give out errors).
2019-06-01 15:33:36 +02:00
Olivier Guyot
698816030e Webgl points / fix unit tests 2019-06-01 15:33:36 +02:00
Olivier Guyot
03e70bd10e Webgl points / handle using short instead of int for indices
This is controlled by the availability of the OES_element_index_uint
webgl extension.
2019-06-01 15:33:36 +02:00
Olivier Guyot
e0983cb1c6 Webgl worker / add tests, some typing and documentation
The worker currently works by receiving GENERATE_BUFFERS messages and
will send back the same kind of message, with the generated buffers
attached. All properties of the original message are kept, so that
when a GENERATE_BUFFERS message comes back to the main thread it
is possible to know what and how the buffers where generated.

This is typically used for the `projectionTransform` matrix, and
will also be necessary when working with tiles.
2019-06-01 15:33:36 +02:00
Olivier Guyot
a366803cdd Webgl / use the new buffer API in helper & the points renderer 2019-06-01 15:33:36 +02:00
Olivier Guyot
33d007ce01 Webgl buffer / now stores data in typed arrays
The `WebGLBuffer` class API was changed in order to allow populating
the internal array in different ways.
2019-06-01 15:33:31 +02:00
Olivier Guyot
8566cfc227 Webgl points / get back the instructions array from the worker
This means we won't have to recreate a binary buffer (through a typed array)
on every `rebuildBuffer` call.
2019-06-01 15:25:24 +02:00
Olivier Guyot
65be907095 Webgl points / shifts the buffer write logic in a worker
The worker receives a transferable array of instructions
and sends back two transferable arrays (vertex and index buffer).
The projection transform is also sent so that when the main thread
receives the buffers from the worker it also knows which projection to
apply when rendering the geometries.
2019-06-01 15:25:11 +02:00
Olivier Guyot
532b8194b1 Webgl points / use the new typed-array based utils for buffers
`rebuildBuffer` is still a very CPU intensive task and is blocking the
main thread.
2019-06-01 15:20:04 +02:00
Olivier Guyot
eb912d95ca Webgl / refactor utilities to work only on typed arrays
The base webgl renderer module now has two types of utilities:
* `writeXFeatureInstructions` will write a series of values in a given
typed array, which represent how a given feature will be rendered; for points,
this means position, size, color, etc.
* `writeXFeatureToBuffers` will fill up the given index & vertex buffers
with values based on the provided render instructions

As such, the logic for rendering features is:
user-input style > instructions array >(*) index/vertex buffers > draw

(*) this transformation is intended to be done on a worker.
2019-06-01 15:19:37 +02:00
Frédéric Junod
245ded43d4 Merge pull request #9626 from fredj/rm_from_has
Remove TOUCH, POINTER and MSPOINTER from ol/has
2019-06-01 12:09:40 +01:00
Frederic Junod
7c215b2532 Remove TOUCH, POINTER and MSPOINTER from ol/has 2019-06-01 07:18:23 +02:00
Frédéric Junod
579d05a0cb Merge pull request #9624 from fredj/cleanup
Remove typecasts in ol/control/OverviewMap
2019-06-01 06:13:02 +01:00
André Garneau
b42ee8ca0f Add filter function to translate interaction
Add a filter function to the translate interaction. This filter is similar to the one present in the select interaction options and provides the ability to dynamically filter which features to include in the translate interaction. Adding the existing "features" options allows further filtering to take place. In this case the filter is first applied, and features that are passing the filtering need to be present in the "features" options to be further kept. The default filter function always return true (no filtering).
2019-05-31 14:51:13 -04:00
Frederic Junod
ede864c823 Remove typecasts in ol/control/OverviewMap
The `options` type was not correctly detected by the typescript compiler.
2019-05-31 16:18:15 +02:00
ahocevar
a50ef05565 Set version to 6.0.0-beta.9 2019-05-30 15:55:09 +02:00
Tim Schaub
93a607d846 Merge pull request #9615 from tschaub/import-specifiers
Include full filename in import specifier
2019-05-29 09:35:34 -06:00
Tim Schaub
deb00f20fe Include full filename in import specifier 2019-05-29 08:51:10 -06:00
Frédéric Junod
c4e465dcf9 Merge pull request #9592 from fredj/f9587_layerIndex
Remove `layerState` param from `prepareFrame` and `renderFrame` function
2019-05-29 09:27:38 +02:00
Frederic Junod
bfea858306 Add missing extension in import 2019-05-29 09:19:17 +02:00
Frédéric Junod
c92bf29677 Fix spelling
Co-Authored-By: Tim Schaub <tschaub@users.noreply.github.com>
2019-05-29 09:07:05 +02:00
Andreas Hocevar
6675f9be57 Merge pull request #9289 from sbrunner/vector-source-geom
Vector source geom
2019-05-28 11:23:31 +02:00
Frédéric Junod
1a6d67776b Merge pull request #9608 from fredj/md_link
Use markdown link syntax in jsdoc
2019-05-27 14:17:18 +02:00
Stéphane Brunner
889b6a9f43 Removes unnecessary type cast 2019-05-27 11:34:33 +02:00
Stéphane Brunner
970c1bcb66 Make the vector source geometry generic 2019-05-27 11:34:31 +02:00
Frederic Junod
2db953ceb1 Use markdown link syntax in jsdoc 2019-05-27 11:06:12 +02:00
Olivier Guyot
051cc68f24 Merge pull request #9596 from jahow/fix-source-missing-event
Vector source / prevent adding features with duplicate id in the collection
2019-05-26 10:53:58 +02:00
Frederic Junod
40c49a9ce5 Remove layerState param from prepareFrame and renderFrame function 2019-05-25 07:19:10 +02:00
Olivier Guyot
442fa907ce Vector source / prevent adding features with duplicate id...
...in the collection.

Previously two features with the same id could be pushed manually in the
features collection and stay there.

This would cause an error when clearing the source.

Fixes #6183.
2019-05-24 23:29:48 +02:00
Bart van den Eijnden
7044e30529 Merge pull request #9604 from bartvde/window-global
Use window instead of global in addEventListener
2019-05-24 15:17:07 +02:00
Frédéric Junod
7cfe047feb Merge pull request #9599 from openlayers/github_funding
Create FUNDING.yml
2019-05-24 15:14:26 +02:00
Tim Schaub
796f20385d Merge pull request #9598 from openlayers/greenkeeper/puppeteer-1.17.0
Update puppeteer to the latest version 🚀
2019-05-24 06:58:00 -06:00
bartvde
c76aa76743 Use window instead of global in addEventListener 2019-05-24 14:51:32 +02:00
Bart van den Eijnden
2969c9e8fb Merge pull request #9601 from bartvde/fix-addeventlistener2
Use global addEventListener in PluggableMap
2019-05-24 14:11:26 +02:00
bartvde
119c24faa2 Use global addEventListener in PluggableMap 2019-05-24 13:45:19 +02:00
Frédéric Junod
93711ea806 Create FUNDING.yml 2019-05-24 11:19:37 +02:00
Andreas Hocevar
96331c5d95 Merge pull request #9584 from ahocevar/reuse-render-target
Reuse render target
2019-05-24 10:33:36 +02:00
ahocevar
d8f41a9d73 Only reuse target when className is the same 2019-05-24 10:16:20 +02:00
greenkeeper[bot]
311900e441 chore(package): update puppeteer to version 1.17.0 2019-05-24 00:18:21 +00:00
ahocevar
bdb87f06f9 Rework tile image render queue 2019-05-23 15:55:29 +02:00
Frédéric Junod
ddb7da3733 Merge pull request #6217 from fredj/dragpan_primary
Add primaryAction condition to DragPan
2019-05-23 09:50:55 +02:00
Tim Schaub
a358521b2b Merge pull request #9594 from openlayers/greenkeeper/webpack-4.32.2
Update webpack to the latest version 🚀
2019-05-22 21:12:52 -06:00
greenkeeper[bot]
4f833501d7 chore(package): update webpack to version 4.32.2 2019-05-22 23:39:55 +00:00
ahocevar
ace5c65ee5 Smarter opacity handling 2019-05-22 16:47:23 +02:00
ahocevar
ae47d3df58 Use opacity from layer state 2019-05-22 16:47:22 +02:00
ahocevar
4c8effe6fa No tile transition when layer opacity is set 2019-05-22 16:47:22 +02:00
ahocevar
c56ad4363d Canvas opacity instead of css 2019-05-22 16:47:22 +02:00
ahocevar
7895b16043 Reuse container for raster and vector image layers 2019-05-22 16:47:20 +02:00
ahocevar
a45e704be2 Smarter reuse detection 2019-05-22 16:46:46 +02:00
ahocevar
d1f1b468b1 Reuse target for image layers 2019-05-22 16:46:46 +02:00
ahocevar
a55505b36a Reuse containers for tile, vector and vector tile layers 2019-05-22 16:46:40 +02:00
ahocevar
930318ab7a Clip high res tiles out of low res tiles only once 2019-05-22 15:57:15 +02:00
ahocevar
5fe9e06535 Use clipping to not render high res tiles on top of low res 2019-05-22 15:57:15 +02:00
ahocevar
606443bc6d Pass render target of previous layer to next layer 2019-05-22 15:56:51 +02:00
Frederic Junod
ec811bfa1f Add primaryAction condition to DragPan interaction 2019-05-22 15:21:17 +02:00
Tim Schaub
5e8d7f666e Merge pull request #9589 from openlayers/greenkeeper/webpack-4.32.1
Update webpack to the latest version 🚀
2019-05-22 06:35:21 -06:00
greenkeeper[bot]
4f9057f066 chore(package): update webpack to version 4.32.1 2019-05-22 06:59:26 +00:00
Tim Schaub
4ed6413635 Merge pull request #9586 from openlayers/greenkeeper/rollup-plugin-terser-5.0.0
Update rollup-plugin-terser to the latest version 🚀
2019-05-21 18:34:20 -06:00
greenkeeper[bot]
bb5ebaa1ab chore(package): update rollup-plugin-terser to version 5.0.0 2019-05-21 22:32:01 +00:00
Tim Schaub
c9491ed023 Merge pull request #9569 from engsterhold/patch-1
Fix for change in Zoomify.js/CustomTile signature
2019-05-21 06:52:51 -06:00
Tim Schaub
3db13fa3bb Merge pull request #9582 from tschaub/stale
Add app to mark inactive issues as stale
2019-05-21 06:49:56 -06:00
robert
7e4e113ac9 lint fix
Signed-off-by: robert <24939343+engsterhold@users.noreply.github.com>
2019-05-21 12:32:30 +02:00
Tim Schaub
dc4ce62fab Merge pull request #9581 from tschaub/update-webpack
Update webpack and use mode in the loader
2019-05-20 19:43:37 -06:00
Tim Schaub
6288744d70 Configure Stale app
See https://github.com/organizations/openlayers/settings/installations/1008384
2019-05-20 17:56:30 -06:00
Tim Schaub
c0339f167b Use mode from the loader context
See https://github.com/webpack/webpack/pull/9140.
2019-05-20 10:33:59 -06:00
greenkeeper[bot]
60007d8e3c chore(package): update webpack to version 4.32.0 2019-05-20 10:33:20 -06:00
Frédéric Junod
2322131b01 Merge pull request #9576 from fredj/has-geolocation
Remove geolocation detection from ol/has
2019-05-18 09:40:21 +02:00
Frederic Junod
39bb6a8ffe Remove geolocation detection from ol/has 2019-05-18 08:50:33 +02:00
Tim Schaub
0631a121c3 Merge pull request #9575 from tschaub/untwisted-exports
Rework exports for getUid and control defaults
2019-05-17 13:03:14 -06:00
Tim Schaub
c860f15f91 Break the circular dependency by extending a pluggable map 2019-05-17 12:38:32 -06:00
Tim Schaub
c10fd7aaab Avoid overwriting longname for getUid 2019-05-17 12:00:10 -06:00
Andreas Hocevar
7ced251d19 Merge pull request #9574 from jumpinjackie/update-mapguide-demo-server
Update OL MapGuide example to point to my demo MapGuide Server.
2019-05-17 19:49:39 +02:00
Frédéric Junod
637c823fa6 Merge pull request #9571 from fredj/misc_examples
Small examples improvements
2019-05-17 17:00:58 +02:00
Frederic Junod
2d655143c3 Add an Overlay in the export-map example 2019-05-17 16:45:29 +02:00
Jackie Ng
fba95ea3f0 Update OL MapGuide example to point to my demo MapGuide Server.
Fixes #9573
2019-05-18 00:21:53 +10:00
Frédéric Junod
40393cd9a4 Merge pull request #9572 from fredj/upgrade-notes_css
Add a note about CSS removal in upgrade-notes.md
2019-05-17 15:44:31 +02:00
Frederic Junod
10527bd221 Remove margin in full screen
In only affects Safari, in Chrome `margin: 0;` is in the default browser's style sheet.
2019-05-17 15:41:03 +02:00
Frederic Junod
4c2b11f6d7 Add a note about CSS removal in upgrade-notes.md 2019-05-17 15:21:51 +02:00
Frédéric Junod
512a39bafd Merge pull request #9570 from fredj/rm_media_print
Remove CSS print rules in ol.css
2019-05-17 14:58:55 +02:00
Frederic Junod
78c09a0ff6 Add svg icon example 2019-05-17 14:48:03 +02:00
Frederic Junod
6dc00b75e0 Update d3 version in d3 example 2019-05-17 14:27:20 +02:00
Frederic Junod
6b50f1555b Add webgl tag to heatmap layer example 2019-05-17 14:25:34 +02:00
Frederic Junod
a6f098f78b Remove CSS print rules in ol.css
Fixes #7909
2019-05-17 14:21:19 +02:00
engsterhold
f77b0941b8 fixed styling 2019-05-17 13:52:10 +02:00
Tim Schaub
6d06f81ca7 Merge pull request #9563 from tschaub/fragile-docs
Fix @abstract and @module annotations
2019-05-16 16:27:09 -06:00
Tim Schaub
908ecb39e3 Description below @abstract trips up JSDoc 2019-05-16 16:10:30 -06:00
Tim Schaub
6cad19e9d5 Description below @module trips up JSDoc 2019-05-16 16:09:30 -06:00
ahocevar
b0fae46aa6 Do not use css z-index 2019-05-16 22:29:32 +02:00
Andreas Hocevar
17d26acb2f Merge pull request #9560 from ahocevar/simplify-loading
Simplify loading detection loop
2019-05-16 22:27:59 +02:00
Andreas Hocevar
579fadd797 Merge pull request #9561 from ahocevar/map-memory-leak
Remove memory leak caused by label cache listeners
2019-05-16 22:26:56 +02:00
Tim Schaub
9693336d99 Merge pull request #9559 from tschaub/minify-worker
Minify worker
2019-05-16 14:20:11 -06:00
ahocevar
335648d613 Remove memory leak caused by label cache listeners 2019-05-16 21:04:55 +02:00
ahocevar
dc906f79e1 Simplify loading detection loop 2019-05-16 20:19:32 +02:00
Tim Schaub
34a8a484c4 Merge pull request #9558 from tschaub/unlisten
Stop listening for image decoding
2019-05-16 11:46:15 -06:00
Tim Schaub
0d489f2ea9 Minify worker in examples for a production build 2019-05-16 10:41:33 -06:00
Tim Schaub
d49e166506 Minify worker source 2019-05-16 10:35:18 -06:00
Frederic Junod
a0e6af425e Add tests for listenImage function, fix private variables initialization 2019-05-16 16:42:37 +02:00
engsterhold
e69b15d33e Bandaid fix for change in Zoomify.js/CustomTile signature
The recent addition of tilePixelRatio to the Zoomify.js/CustomTile constructor broke parameter binding in IIIF.js/IIIF.
The fix mirrors the change in the  Zoomify.js/Zoomify constructor
2019-05-16 16:10:58 +02:00
Tim Schaub
ee9a0bcd05 Stop listening for image decoding 2019-05-16 08:06:12 -06:00
Tim Schaub
442fbb13d2 Merge pull request #9550 from tschaub/worker
Setup for building workers
2019-05-16 07:02:34 -06:00
Frédéric Junod
fddc5bcc5b Merge pull request #9555 from fredj/rm_unused
Remove unused roundUpToPowerOfTwo function
2019-05-16 13:57:19 +02:00
Frederic Junod
c2058af13a Remove unused roundUpToPowerOfTwo function 2019-05-16 12:11:58 +02:00
Frederic Junod
bb022050ed Add 'webworker' lib into the TypeScript's compilerOptions 2019-05-16 09:49:29 +02:00
Frédéric Junod
a8e5cb1e12 Merge pull request #9553 from openlayers/greenkeeper/ol-mapbox-style-5.0.0-beta.2
chore(package): update ol-mapbox-style to version 5.0.0-beta.2
2019-05-16 09:43:56 +02:00
Frédéric Junod
1628ce8729 Merge pull request #9551 from fredj/img_decode
Use HTMLImageElement.decode if available
2019-05-16 09:30:55 +02:00
greenkeeper[bot]
37f96ddcfa chore(package): update ol-mapbox-style to version 5.0.0-beta.2 2019-05-16 07:21:23 +00:00
Andreas Hocevar
1fc75fdc68 Merge pull request #9500 from edellucien/kml_extended_data
KML string validation with extendedData
2019-05-16 09:20:03 +02:00
lucien
10c4ec0b37 Only use 'pushSerializeAndPop' later in code to write extendedData after 2019-05-16 09:10:40 +02:00
Frederic Junod
2e34dd0faf Use HTMLImageElement.decode if available 2019-05-16 08:53:29 +02:00
Tim Schaub
b7b37f9548 Add worker loader to the tests 2019-05-15 16:49:54 -06:00
Tim Schaub
05f13bb363 Add worker loader to the examples 2019-05-15 16:49:38 -06:00
Tim Schaub
e307410301 A task to inline workers 2019-05-15 16:38:06 -06:00
Tim Schaub
5a4541dadb Merge pull request #9534 from tschaub/simpler-mapbox-layer-example
Remove unnecessary parts from the Mapbox layer example
2019-05-15 14:00:46 -06:00
Andreas Hocevar
56ec6b093e Merge pull request #9548 from ahocevar/italic-labels
Avoid cut off labels for italic fonts
2019-05-15 16:58:17 +02:00
Frédéric Junod
61d753c803 Merge pull request #9549 from fredj/rm_unused
Remove unused getReplayTransform_ function in VectorTileLayer
2019-05-15 16:31:09 +02:00
Tim Schaub
f312706269 Remove unnecessary parts from the Mapbox layer example 2019-05-15 08:26:43 -06:00
Frederic Junod
f33ad5e025 Remove unused getReplayTransform_ function in VectorTileLayer 2019-05-15 15:10:54 +02:00
ahocevar
2e31f716ed Avoid cut off labels for italic text 2019-05-15 15:01:12 +02:00
Tim Schaub
eafb657264 Merge pull request #9545 from tschaub/default-view-extent
Avoid panning off the edge of the world
2019-05-15 04:58:29 -06:00
Tim Schaub
0cee259d0b Merge pull request #9539 from tschaub/event-error
Document existing error event type
2019-05-15 04:53:57 -06:00
Tim Schaub
be8797f355 Merge pull request #9541 from tschaub/rbush-three
Upgrade to rbush@3
2019-05-15 04:53:15 -06:00
Tim Schaub
d652bfc4a7 Merge pull request #9543 from tschaub/upgrade-jsdoc-plugin
Update jsdoc-plugin-typescript to version 2.0.1
2019-05-15 04:52:26 -06:00
Andreas Hocevar
11607caa81 Merge pull request #9536 from ahocevar/font-cache-hits
More font cache hits
2019-05-15 12:13:40 +02:00
ahocevar
41e958ea1f Split text into single chars or don't split at all 2019-05-15 11:55:29 +02:00
Olivier Guyot
39de2451bc Merge pull request #9537 from jahow/webgl-geojson-refactoring
WebGL / Points renderer refactoring
2019-05-15 11:44:40 +02:00
Olivier Guyot
e11e3c5f6e Webgl / minor function renaming 2019-05-15 11:30:24 +02:00
Olivier Guyot
c705775d75 Linting 2019-05-15 10:20:31 +02:00
Olivier Guyot
9ca75e9d43 Webgl points / rebuild buffers when source change 2019-05-15 10:18:53 +02:00
Olivier Guyot
5d2b7fe4bb Webgl points / use the helper ton compute the projection transform
The `WebGLHelper` class now provides a `makeProjectionTransform` method
that updates a transform to match the projection for a given frame state.

This also means that the WebGLHelper does not set the projection matrix
uniform anymore, this is the responsibility of the renderer as
the rendered coordinates will not be in world space from now on.
2019-05-15 10:18:47 +02:00
Olivier Guyot
fb455891ce Webgl points / make coordinates in view space to avoid precision glitches
Fixes #9479
2019-05-15 10:18:47 +02:00
Olivier Guyot
3e2e45ce6d Webgl helper / add the possibility to use transforms as custom uniforms
These will be translated into 4x4 matrices in GLSL.
2019-05-15 10:18:47 +02:00
Olivier Guyot
75eb62363a WebGL points / rebuild buffers only when extent changed 2019-05-15 10:18:47 +02:00
Olivier Guyot
523097903a WebGL points / rebuild buffers on every non animation frame 2019-05-15 10:18:22 +02:00
Olivier Guyot
c6d214b585 Webgl / implement support for custom attributes in webgl buffers
Only numerical attributes can be pushed in webgl buffers.
2019-05-15 10:15:55 +02:00
Frédéric Junod
c9604dbd69 Merge pull request #9546 from fredj/canvas_optim
Lazily create the hit detection context
2019-05-15 10:15:02 +02:00
Frédéric Junod
df37519858 Initialize hitDetectionContext to null
Co-Authored-By: Andreas Hocevar <andreas.hocevar@gmail.com>
2019-05-15 10:03:43 +02:00
Frederic Junod
10c6009ffa Lazily create the hit detection context 2019-05-15 09:52:57 +02:00
Olivier Guyot
27e520add4 WebGL points / use pushFeatureInBuffer util
Feature objects are converted to geoJSON with the properties
set for rendering.
2019-05-15 09:47:00 +02:00
Olivier Guyot
3a429d3f6c Webgl / add utils for pushing geojson geometries in webgl buffers
For now only point geometries are handled.
2019-05-15 09:44:41 +02:00
Olivier Guyot
5e36468245 Webgl / add a simple Layer renderer for common logic
This will eventually provides utilities for manipulating & rendering data
2019-05-15 09:43:29 +02:00
Olivier Guyot
a2d83f5358 WebGL points / add minimal tests 2019-05-15 09:42:15 +02:00
Tim Schaub
217c6ba764 Avoid panning off the edge of the world 2019-05-14 20:15:51 -06:00
greenkeeper[bot]
039f21274b chore(package): update jsdoc-plugin-typescript to version 2.0.1 2019-05-14 18:59:50 -06:00
Tim Schaub
09fdd30876 Upgrade to rbush@3 2019-05-14 18:43:08 -06:00
Tim Schaub
811e5f60eb Document existing error event type 2019-05-14 14:28:00 -06:00
lucien
81f99f1579 Write placemark's ExtendedData tag after Style tag 2019-05-07 09:02:28 +02:00
Kai Volland
9860699d5f Introduces import snippets for static functions
Adds snippets for import of modules and their
exported functions to the API documentation.
2019-04-04 10:07:55 +02:00
164 changed files with 2879 additions and 1544 deletions

8
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: openlayers
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: # Replace with a single custom sponsorship URL

17
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- blocker
- regression
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View File

@@ -4,6 +4,38 @@
#### Backwards incompatible changes
#### Removal of `TOUCH` constant from `ol/has`
If you were previously using this constant, you can check if `'ontouchstart'` is defined in `window` instead.
```js
if ('ontouchstart' in window) {
// ...
}
```
#### Removal of `GEOLOCATION` constant from `ol/has`
If you were previously using this constant, you can check if `'geolocation'` is defined in `navigator` instead.
```js
if ('geolocation' in navigator) {
// ...
}
```
#### Removal of CSS print rules
The CSS media print rules were removed from the `ol.css` file. To get the previous behavior, use the following CSS:
```css
@media print {
.ol-control {
display: none;
}
}
```
#### Removal of optional this arguments
The optional this (i.e. opt_this) arguments were removed from the following methods.
@@ -32,9 +64,9 @@ Previously, this options only constrained the view *center*. This behaviour can
As a side effect, the view `rotate` method is gone and has been replaced with `adjustRotation` which takes a delta as input.
##### Zoom is constrained so only one world is visible
##### The view is constrained so only one world is visible
Previously, maps showed multiple worlds at low zoom levels. Now, the view is restricted to show only one world. To get the previous behavior, configure the `ol/View` with `multiWorld: true`.
Previously, maps showed multiple worlds at low zoom levels. In addition, it used to be possible to pan off the north or south edge of the world. Now, the view is restricted to show only one world, and you cannot pan off the edge. To get the previous behavior, configure the `ol/View` with `multiWorld: true`.
##### Removal of deprecated methods

View File

@@ -59,7 +59,9 @@ function includeAugments(doclet) {
});
}
cls._hideConstructor = true;
delete cls.undocumented;
if (!cls.undocumented) {
cls._documented = true;
}
}
}
}
@@ -150,6 +152,9 @@ exports.handlers = {
// Remove all other undocumented symbols
doclet.undocumented = true;
}
if (doclet._documented) {
delete doclet.undocumented;
}
}
}

View File

@@ -214,55 +214,39 @@ function buildNav(members) {
}
return 0;
});
function createEntry(type, v) {
return {
type: type,
longname: v.longname,
name: v.name,
classes: find({
kind: 'class',
memberof: v.longname
}).map(createEntry.bind(this, 'class')),
members: find({
kind: 'member',
memberof: v.longname
}),
methods: find({
kind: 'function',
memberof: v.longname
}),
typedefs: find({
kind: 'typedef',
memberof: v.longname
}),
events: find({
kind: 'event',
memberof: v.longname
})
};
}
_.each(merged, function(v) {
// exclude interfaces from sidebar
if (v.interface !== true) {
if (v.kind == 'module') {
nav.push({
type: 'module',
longname: v.longname,
name: v.name,
members: find({
kind: 'member',
memberof: v.longname
}),
methods: find({
kind: 'function',
memberof: v.longname
}),
typedefs: find({
kind: 'typedef',
memberof: v.longname
}),
events: find({
kind: 'event',
memberof: v.longname
})
});
}
if (v.kind == 'class') {
nav.push({
type: 'class',
longname: v.longname,
name: v.name,
members: find({
kind: 'member',
memberof: v.longname
}),
methods: find({
kind: 'function',
memberof: v.longname
}),
typedefs: find({
kind: 'typedef',
memberof: v.longname
}),
fires: v.fires,
events: find({
kind: 'event',
memberof: v.longname
})
});
nav.push(createEntry('module', v));
}
}
});

View File

@@ -12,13 +12,18 @@ $(function () {
var $item = $(v);
if ($item.data('name') && regexp.test($item.data('name'))) {
const container = $item.parent().parent().parent();
container.show();
container.closest('.itemMembers').show();
container.closest('.item').show();
$item.show();
$item.closest('.itemMembers').show();
$item.closest('.item').show();
}
});
} else {
$el.find('.item, .itemMembers').show();
$el.find('.item, .itemMembers').hide();
$('.navigation>ul>li').show();
}
$el.find('.list').scrollTop(0);

View File

@@ -18,7 +18,7 @@
<sup class="variation"><?js= doc.variation ?></sup>
<?js } ?></h2>
<br>
<?js if (doc.stability || doc.kind == 'namespace') {
<?js if (doc.stability || doc.kind == 'namespace' || doc.kind == 'module') {
var ancestors = doc.ancestors.map(a => a.replace(/>\./g, '>').replace(/\.</g, '<')).join('/');
var parts = [];
if (ancestors) {
@@ -26,7 +26,20 @@
}
var importPath = parts.join('/');
?>
<pre class="prettyprint source"><code>import <?js= doc.name ?> from '<?js= importPath ?>';</code></pre>
<?js
var nameParts = doc.name.split('/');
var moduleName = nameParts[nameParts.length - 1];
if(moduleName) {
var firstChar = moduleName.charAt(0);
moduleName = firstChar.toUpperCase() + moduleName.slice(1);
var isClassModule = firstChar.toUpperCase() === firstChar;
}
?>
<?js if (doc.kind == 'module' && !isClassModule && nameParts.length < 3) {?>
<pre class="prettyprint source"><code>import * as ol<?js= moduleName ?> from '<?js= doc.name ?>';</code></pre>
<?js } else if(doc.kind !== 'module') { ?>
<pre class="prettyprint source"><code>import <?js= doc.name ?> from '<?js= importPath ?>';</code></pre>
<?js } ?>
<?js } ?>
<?js if (doc.classdesc) { ?>
<div class="class-description"><?js= doc.classdesc ?></div>
@@ -143,6 +156,7 @@
<h3 class="subsection-title">Methods</h3>
<dl><?js methods.forEach(function(m) { ?>
<?js m.parent = doc ?>
<?js= self.partial('method.tmpl', m) ?>
<?js }); ?></dl>
<?js } ?>

View File

@@ -27,6 +27,10 @@ var self = this;
</dt>
<dd class="<?js= (data.stability && data.stability !== 'stable') ? 'unstable' : '' ?>">
<?js if (data.parent && data.parent.kind == 'module' && data.parent.name.split('ol/').length < 3) { ?>
<pre class="prettyprint source"><code>import {<?js= data.name ?>} from '<?js= data.parent.name ?>';</code></pre>
<?js } ?>
<?js if (data.description) { ?>
<div class="description">
<?js= data.description ?>

View File

@@ -10,11 +10,12 @@ function toShortName(name) {
</div>
<ul class="list">
<?js
this.nav.forEach(function (item) {
let navbuilder;
this.nav.forEach(navbuilder = function (item) {
?>
<li class="item" data-name="<?js= item.longname ?>">
<span class="title">
<?js= self.linkto(item.longname, item.longname.replace('module:', '')) ?>
<?js= self.linkto(item.longname, item.type === 'module' ? item.longname.replace('module:', '') : item.name) ?>
<?js if (item.type === 'namespace' &&
(item.members.length + item.typedefs.length + item.methods.length +
item.events.length > 0)) { ?>
@@ -22,6 +23,18 @@ function toShortName(name) {
</span>
<ul class="members itemMembers">
<?js
if (item.classes.length) {
?>
<span class="subtitle">Classes</span>
<?js
item.classes.forEach(function (v) {
navbuilder(v);
});
}
?>
</ul>
<ul class="members itemMembers">
<?js
if (item.members.length) {
?>
<span class="subtitle">Members</span>

View File

@@ -228,3 +228,11 @@ Missing or invalid `size`.
### 61
Cannot determine IIIF Image API version from provided image information JSON.
### 62
A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`.
### 63
Support for the `OES_element_index_uint` WebGL extension is mandatory for WebGL layers.

View File

@@ -5,6 +5,7 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
import {Circle as CircleStyle, Fill, Stroke, Style} from '../src/ol/style.js';
/** @type {VectorSource<import("../src/ol/geom/SimpleGeometry.js").default>} */
const source = new VectorSource({
url: 'data/geojson/switzerland.geojson',
format: new GeoJSON()
@@ -51,21 +52,21 @@ const zoomtoswitzerland =
document.getElementById('zoomtoswitzerland');
zoomtoswitzerland.addEventListener('click', function() {
const feature = source.getFeatures()[0];
const polygon = /** @type {import("../src/ol/geom/SimpleGeometry.js").default} */ (feature.getGeometry());
const polygon = feature.getGeometry();
view.fit(polygon, {padding: [170, 50, 30, 150]});
}, false);
const zoomtolausanne = document.getElementById('zoomtolausanne');
zoomtolausanne.addEventListener('click', function() {
const feature = source.getFeatures()[1];
const point = /** @type {import("../src/ol/geom/SimpleGeometry.js").default} */ (feature.getGeometry());
const point = feature.getGeometry();
view.fit(point, {padding: [170, 50, 30, 150], minResolution: 50});
}, false);
const centerlausanne = document.getElementById('centerlausanne');
centerlausanne.addEventListener('click', function() {
const feature = source.getFeatures()[1];
const point = /** @type {import("../src/ol/geom/Point.js").default} */ (feature.getGeometry());
const point = feature.getGeometry();
const size = map.getSize();
view.centerOn(point.getCoordinates(), size, [570, 500]);
}, false);

View File

@@ -129,7 +129,7 @@ const map = new Map({
layers: [
new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure'
url: 'https://a.tiles.mapbox.com/v3/aj.1x1-degrees.json'
})
}),
new VectorLayer({

View File

@@ -6,7 +6,7 @@ docs: >
The example loads TopoJSON geometries and uses d3 (<code>d3.geo.path</code>) to render these geometries to a SVG element.
tags: "d3"
resources:
- https://unpkg.com/d3@4.12.0/build/d3.js
- https://unpkg.com/d3@5.9.2/dist/d3.js
- https://unpkg.com/topojson@3.0.2/dist/topojson.js
---
<div id="map" class="map"></div>

4
examples/d3.js vendored
View File

@@ -2,7 +2,7 @@ import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import {getWidth, getCenter} from '../src/ol/extent.js';
import {Layer, Tile as TileLayer} from '../src/ol/layer.js';
import SourceState from '../src/ol/source/State';
import SourceState from '../src/ol/source/State.js';
import {fromLonLat, toLonLat} from '../src/ol/proj.js';
import Stamen from '../src/ol/source/Stamen.js';
@@ -85,7 +85,7 @@ const map = new Map({
/**
* Load the topojson data and create an ol/layer/Image for that data.
*/
d3.json('data/topojson/us.json', function(error, us) {
d3.json('data/topojson/us.json').then(function(us) {
const layer = new CanvasLayer({
features: topojson.feature(us, us.objects.counties)

7
examples/data/square.svg Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg">
<g>
<rect width="20" height="20" style="fill:#fff" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 194 B

6
examples/export-map.css Normal file
View File

@@ -0,0 +1,6 @@
.overlay {
background-color: yellow;
border-radius: 6px;
padding: 4px;
white-space: nowrap;
}

View File

@@ -8,5 +8,8 @@ docs: >
tags: "export, png, openstreetmap"
---
<div id="map" class="map"></div>
<div style="display: none;">
<div class="overlay" id="null">Null Island</div>
</div>
<a id="export-png" class="btn btn-default"><i class="fa fa-download"></i> Download PNG</a>
<a id="image-download" download="map.png"></a>

View File

@@ -1,5 +1,6 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import Overlay from '../src/ol/Overlay.js';
import GeoJSON from '../src/ol/format/GeoJSON.js';
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
@@ -25,11 +26,17 @@ const map = new Map({
})
});
map.addOverlay(new Overlay({
position: [0, 0],
element: document.getElementById('null')
}));
// export options for html-to-image.
// See: https://github.com/bubkoo/html-to-image#options
const exportOptions = {
filter: function(element) {
return element.className.indexOf('ol-control') === -1;
return element.className ? element.className.indexOf('ol-control') === -1 : true;
}
};

View File

@@ -2,8 +2,8 @@ import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import OSM from '../src/ol/source/OSM.js';
import {defaults as defaultControls} from '../src/ol/control/util';
import ZoomSlider from '../src/ol/control/ZoomSlider';
import {defaults as defaultControls} from '../src/ol/control.js';
import ZoomSlider from '../src/ol/control/ZoomSlider.js';
const view = new View({
center: [328627.563458, 5921296.662223],

View File

@@ -67,10 +67,10 @@ const routeFeature = new Feature({
type: 'route',
geometry: route
});
const geoMarker = new Feature({
const geoMarker = /** @type Feature<import("../src/ol/geom/Point").default> */(new Feature({
type: 'geoMarker',
geometry: new Point(routeCoords[0])
});
}));
const startMarker = new Feature({
type: 'icon',
geometry: new Point(routeCoords[0])
@@ -191,7 +191,7 @@ function stopAnimation(ended) {
// if animation cancelled set the marker at the beginning
const coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
const geometry = /** @type {import("../src/ol/geom/Point").default} */ (geoMarker.getGeometry());
const geometry = geoMarker.getGeometry();
geometry.setCoordinates(coord);
//remove listener
vectorLayer.un('postrender', moveFeature);

View File

@@ -1,17 +1,16 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import Feature from '../src/ol/Feature';
import Point from '../src/ol/geom/Point';
import VectorLayer from '../src/ol/layer/Vector';
import {Vector} from '../src/ol/source';
import {fromLonLat} from '../src/ol/proj';
import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer';
import {clamp, lerp} from '../src/ol/math';
import Stamen from '../src/ol/source/Stamen';
import Feature from '../src/ol/Feature.js';
import Point from '../src/ol/geom/Point.js';
import VectorLayer from '../src/ol/layer/Vector.js';
import {Vector} from '../src/ol/source.js';
import {fromLonLat} from '../src/ol/proj.js';
import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer.js';
import {clamp, lerp} from '../src/ol/math.js';
import Stamen from '../src/ol/source/Stamen.js';
const vectorSource = new Vector({
features: [],
attributions: 'NASA'
});

View File

@@ -1,5 +1,6 @@
.map:-webkit-full-screen {
height: 100%;
margin: 0;
}
.map:-ms-fullscreen {
height: 100%;

View File

@@ -1,5 +1,6 @@
.fullscreen:-webkit-full-screen {
height: 100%;
margin: 0;
}
.fullscreen:-ms-fullscreen {
height: 100%;

View File

@@ -1,5 +1,6 @@
.map:-webkit-full-screen {
height: 100%;
margin: 0;
}
.map:-ms-fullscreen {
height: 100%;

View File

@@ -6,7 +6,7 @@ import VectorTileSource from '../src/ol/source/VectorTile.js';
import {Tile as TileLayer, VectorTile as VectorTileLayer} from '../src/ol/layer.js';
import Projection from '../src/ol/proj/Projection.js';
// Converts geojson-vt data to GeoJSON
const replacer = function(key, value) {
if (value.geometry) {
let type;
@@ -46,11 +46,6 @@ const replacer = function(key, value) {
}
};
const tilePixels = new Projection({
code: 'TILE_PIXELS',
units: 'tile-pixels'
});
const map = new Map({
layers: [
new TileLayer({
@@ -73,23 +68,22 @@ fetch(url).then(function(response) {
debug: 1
});
const vectorSource = new VectorTileSource({
format: new GeoJSON(),
tileLoadFunction: function(tile) {
const format = tile.getFormat();
const tileCoord = tile.getTileCoord();
format: new GeoJSON({
// Data returned from geojson-vt is in tile pixel units
dataProjection: new Projection({
code: 'TILE_PIXELS',
units: 'tile-pixels',
extent: [0, 0, 4096, 4096]
})
}),
tileUrlFunction: function(tileCoord) {
const data = tileIndex.getTile(tileCoord[0], tileCoord[1], tileCoord[2]);
const features = format.readFeatures(
JSON.stringify({
type: 'FeatureCollection',
features: data ? data.features : []
}, replacer));
tile.setLoader(function() {
tile.setFeatures(features);
tile.setProjection(tilePixels);
});
},
url: 'data:' // arbitrary url, we don't use it in the tileLoadFunction
const geojson = JSON.stringify({
type: 'FeatureCollection',
features: data ? data.features : []
}, replacer);
return 'data:application/json;charset=UTF-8,' + geojson;
}
});
const vectorLayer = new VectorTileLayer({
source: vectorSource

View File

@@ -4,7 +4,7 @@ title: Earthquakes Heatmap
shortdesc: Demonstrates the use of a heatmap layer.
docs: >
This example parses a KML file and renders the features as a <code>ol/layer/Heatmap</code> layer.
tags: "heatmap, kml, vector, style"
tags: "heatmap, kml, vector, style, webgl"
---
<div id="map" class="map"></div>
<form>

View File

@@ -25,7 +25,7 @@ rome.setStyle(new Style({
image: new Icon({
color: '#8959A8',
crossOrigin: 'anonymous',
src: 'data/dot.png'
src: 'data/square.svg'
})
}));
@@ -56,7 +56,7 @@ const vectorLayer = new VectorLayer({
const rasterLayer = new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure',
url: 'https://a.tiles.mapbox.com/v3/aj.1x1-degrees.json',
crossOrigin: ''
})
});

View File

@@ -13,5 +13,8 @@ docs: >
The dataset contains around 80k points and can be found here: https://www.kaggle.com/NUFORC/ufo-sightings
tags: "webgl, icon, sprite, point, ufo"
cloak:
- key: pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg
value: Your Mapbox access token from https://mapbox.com/ here
---
<div id="map" class="map"></div>

View File

@@ -1,14 +1,16 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import TileJSON from '../src/ol/source/TileJSON';
import Feature from '../src/ol/Feature';
import Point from '../src/ol/geom/Point';
import VectorLayer from '../src/ol/layer/Vector';
import {Vector} from '../src/ol/source';
import {fromLonLat} from '../src/ol/proj';
import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer';
import {lerp} from '../src/ol/math';
import TileJSON from '../src/ol/source/TileJSON.js';
import Feature from '../src/ol/Feature.js';
import Point from '../src/ol/geom/Point.js';
import VectorLayer from '../src/ol/layer/Vector.js';
import {Vector} from '../src/ol/source.js';
import {fromLonLat} from '../src/ol/proj.js';
import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer.js';
import {lerp} from '../src/ol/math.js';
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
const vectorSource = new Vector({
features: [],
@@ -105,7 +107,7 @@ new Map({
layers: [
new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-dark.json?secure',
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-dark.json?access_token=' + key,
crossOrigin: 'anonymous'
})
}),

View File

@@ -37,7 +37,7 @@ const vectorLayer = new VectorLayer({
const rasterLayer = new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure',
url: 'https://a.tiles.mapbox.com/v3/aj.1x1-degrees.json',
crossOrigin: ''
})
});

View File

@@ -3,13 +3,13 @@ layout: example.html
title: Mapbox-gl Layer
shortdesc: Example of a Mapbox-gl-js layer integration.
docs: >
Show how to add a mapbox-gl-js layer in an openlayers map. **Note**: Make sure to get your own Mapbox API key when using this example. No map will be visible when the API key has expired.
tags: "simple, mapbox, vector, tiles"
Show how to add a mapbox-gl-js layer in an openlayers map. **Note**: Make sure to get your own API key at https://www.maptiler.com/cloud/ when using this example. No map will be visible when the API key has expired.
tags: "simple, mapbox, vector, tiles, maptiler"
resources:
- https://unpkg.com/mapbox-gl@0.54.0/dist/mapbox-gl.js
- https://unpkg.com/mapbox-gl@0.54.0/dist/mapbox-gl.css
cloak:
- key: ER67WIiPdCQvhgsUjoWK
value: Your Mapbox access token from https://mapbox.com/ here
value: Get your own API key at https://www.maptiler.com/cloud/
---
<div id="map" class="map"></div>

View File

@@ -1,12 +1,68 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import Layer from '../src/ol/layer/Layer';
import {toLonLat} from '../src/ol/proj';
import Layer from '../src/ol/layer/Layer.js';
import {toLonLat, fromLonLat} from '../src/ol/proj.js';
import {Stroke, Style} from '../src/ol/style.js';
import VectorLayer from '../src/ol/layer/Vector.js';
import VectorSource from '../src/ol/source/Vector.js';
import GeoJSON from '../src/ol/format/GeoJSON.js';
const center = [-98.8, 37.9];
const key = 'ER67WIiPdCQvhgsUjoWK';
const mbMap = new mapboxgl.Map({
style: 'https://api.maptiler.com/maps/bright/style.json?key=' + key,
attributionControl: false,
boxZoom: false,
center: center,
container: 'map',
doubleClickZoom: false,
dragPan: false,
dragRotate: false,
interactive: false,
keyboard: false,
pitchWithRotate: false,
scrollZoom: false,
touchZoomRotate: false
});
const mbLayer = new Layer({
render: function(frameState) {
const canvas = mbMap.getCanvas();
const viewState = frameState.viewState;
const visible = mbLayer.getVisible();
canvas.style.display = visible ? 'block' : 'none';
const opacity = mbLayer.getOpacity();
canvas.style.opacity = opacity;
// adjust view parameters in mapbox
const rotation = viewState.rotation;
if (rotation) {
mbMap.rotateTo(-rotation * 180 / Math.PI, {
animate: false
});
}
mbMap.jumpTo({
center: toLonLat(viewState.center),
zoom: viewState.zoom - 1,
animate: false
});
// cancel the scheduled update & trigger synchronous redraw
// see https://github.com/mapbox/mapbox-gl-js/issues/7893#issue-408992184
// NOTE: THIS MIGHT BREAK WHEN UPDATING MAPBOX
if (mbMap._frame) {
mbMap._frame.cancel();
mbMap._frame = null;
}
mbMap._render();
return canvas;
}
});
const style = new Style({
stroke: new Stroke({
color: '#319FD3',
@@ -25,80 +81,8 @@ const vectorLayer = new VectorLayer({
const map = new Map({
target: 'map',
view: new View({
center: [-10997148, 4569099],
zoom: 4,
minZoom: 1,
extent: [-Infinity, -20048966.10, Infinity, 20048966.10],
smoothExtentConstraint: false,
smoothResolutionConstraint: false
})
center: fromLonLat(center),
zoom: 4
}),
layers: [mbLayer, vectorLayer]
});
// init Mapbox object
const view = map.getView();
const center = toLonLat(view.getCenter(), view.getProjection());
const key = 'ER67WIiPdCQvhgsUjoWK';
const mbMap = new mapboxgl.Map({
style: 'https://maps.tilehosting.com/styles/bright/style.json?key=' + key,
attributionControl: false,
boxZoom: false,
center: center,
container: map.getTargetElement(),
doubleClickZoom: false,
dragPan: false,
dragRotate: false,
interactive: false,
keyboard: false,
pitchWithRotate: false,
scrollZoom: false,
touchZoomRotate: false,
zoom: view.getZoom() - 1
});
// init OL layers
const mbLayer = new Layer({
render: function(frameState) {
const canvas = mbMap.getCanvas();
const view = map.getView();
const visible = mbLayer.getVisible();
canvas.style.display = visible ? 'block' : 'none';
const opacity = mbLayer.getOpacity();
canvas.style.opacity = opacity;
// adjust view parameters in mapbox
const rotation = frameState.viewState.rotation;
if (rotation) {
mbMap.rotateTo(-rotation * 180 / Math.PI, {
animate: false
});
}
const center = toLonLat(view.getCenter(), view.getProjection());
const zoom = view.getZoom() - 1;
mbMap.jumpTo({
center: center,
zoom: zoom,
animate: false
});
// cancel the scheduled update & trigger synchronous redraw
// see https://github.com/mapbox/mapbox-gl-js/issues/7893#issue-408992184
// NOTE: THIS MIGHT BREAK WHEN UPDATING MAPBOX
if (mbMap._frame) {
mbMap._frame.cancel();
mbMap._frame = null;
}
mbMap._render();
return canvas;
}
});
map.addLayer(mbLayer);
map.addLayer(vectorLayer);

View File

@@ -2,10 +2,10 @@
layout: example-verbatim.html
title: Vector tiles created from a Mapbox Style object
shortdesc: Example of using ol-mapbox-style with tiles from tilehosting.com.
tags: "vector tiles, mapbox style, ol-mapbox-style"
tags: "vector tiles, mapbox style, ol-mapbox-style, maptiler"
cloak:
- key: lirfd6Fegsjkvs0lshxe
value: Your API key from http://tilehosting.com/ here
- key: ER67WIiPdCQvhgsUjoWK
value: Get your own API key at https://www.maptiler.com/cloud/
---
<!doctype html>
<html lang="en">

View File

@@ -1,3 +1,3 @@
import apply from 'ol-mapbox-style';
apply('map', 'https://maps.tilehosting.com/styles/topo/style.json?key=ER67WIiPdCQvhgsUjoWK');
apply('map', 'https://api.maptiler.com/maps/topo/style.json?key=ER67WIiPdCQvhgsUjoWK');

View File

@@ -3,9 +3,9 @@ import View from '../src/ol/View.js';
import ImageLayer from '../src/ol/layer/Image.js';
import ImageMapGuide from '../src/ol/source/ImageMapGuide.js';
const mdf = 'Library://Public/Samples/Sheboygan/Maps/Sheboygan.MapDefinition';
const mdf = 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition';
const agentUrl =
'http://www.buoyshark.com/mapguide/mapagent/mapagent.fcgi?';
'http://138.197.230.93:8008/mapguide/mapagent/mapagent.fcgi?';
const bounds = [
-87.865114442365922,
43.665065564837931,
@@ -24,8 +24,9 @@ const map = new Map({
params: {
MAPDEFINITION: mdf,
FORMAT: 'PNG',
USERNAME: 'OpenLayers',
PASSWORD: 'OpenLayers'
VERSION: '3.0.0',
USERNAME: 'OLGuest',
PASSWORD: 'olguest'
},
ratio: 2
})

View File

@@ -7,6 +7,9 @@ docs: >
Click on the map to get a popup. The popup is composed of a few basic elements: a container, a close button, and a place for the content. To anchor the popup to the map, an <code>ol/Overlay</code> is created with the popup container. A listener is registered for the map's <code>click</code> event to display the popup, and another listener is set as the <code>click</code> handler for the close button to hide the popup.
</p>
tags: "overlay, popup"
cloak:
- key: pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg
value: Your Mapbox access token from https://mapbox.com/ here
---
<div id="map" class="map"></div>
<div id="popup" class="ol-popup">

View File

@@ -6,6 +6,7 @@ import TileLayer from '../src/ol/layer/Tile.js';
import {toLonLat} from '../src/ol/proj.js';
import TileJSON from '../src/ol/source/TileJSON.js';
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
/**
* Elements that make up the popup.
@@ -45,7 +46,7 @@ const map = new Map({
layers: [
new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy.json?secure',
url: 'https://api.tiles.mapbox.com/v4/mapbox.natural-earth-hypso-bathy.json?access_token=' + key,
crossOrigin: 'anonymous'
})
})

View File

@@ -8,7 +8,7 @@ const map = new Map({
layers: [
new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure',
url: 'https://a.tiles.mapbox.com/v3/aj.1x1-degrees.json',
crossOrigin: 'anonymous'
})
})

View File

@@ -4,7 +4,7 @@ title: UTFGrid
shortdesc: This example shows how to read data from a UTFGrid source.
docs: >
<p>Point to a country to see its name and flag.</p>
Tiles made with [TileMill](http://tilemill.com). Hosting on MapBox.com or with open-source [TileServer](https://github.com/klokantech/tileserver-php/).
Tiles made with <a href="http://tilemill.com">TileMill</a>. Hosting on <a href="mapbox.com">mapbox.com</a> or with open-source <a href="https://github.com/klokantech/tileserver-php/">TileServer</a>.
tags: "utfgrid, tilejson"
cloak:
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q

View File

@@ -19,16 +19,25 @@ module.exports = {
context: src,
target: 'web',
entry: entry,
stats: 'minimal',
module: {
rules: [{
test: /\.js$/,
use: {
loader: 'buble-loader'
},
test: /\.js$/,
include: [
path.join(__dirname, '..', '..', 'src'),
path.join(__dirname, '..')
]
}, {
test: /\.js$/,
use: {
loader: path.join(__dirname, './worker-loader.js')
},
include: [
path.join(__dirname, '../../src/ol/worker')
]
}]
},
optimization: {

View File

@@ -0,0 +1,17 @@
const build = require('../../tasks/serialize-workers').build;
function loader() {
const callback = this.async();
const minify = this.mode === 'production';
build(this.resource, {minify})
.then(chunk => {
for (const filePath in chunk.modules) {
this.addDependency(filePath);
}
callback(null, chunk.code);
})
.catch(callback);
}
module.exports = loader;

10
examples/worker.html Normal file
View File

@@ -0,0 +1,10 @@
---
layout: example.html
title: Worker
shortdesc: This example should be deleted.
docs: >
When you move the map, a message is sent to a worker. In response, the woker sends a
message back with the version identifier.
tags: "worker"
---
<div id="map" class="map"></div>

35
examples/worker.js Normal file
View File

@@ -0,0 +1,35 @@
/* eslint-disable no-console */
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import OSM from '../src/ol/source/OSM.js';
import {create as createVersionWorker} from '../src/ol/worker/version.js';
const map = new Map({
layers: [
new TileLayer({
source: new OSM()
})
],
target: 'map',
view: new View({
center: [0, 0],
zoom: 2
})
});
const worker = createVersionWorker();
worker.addEventListener('error', function(error) {
console.error('worker error', error);
});
worker.addEventListener('message', function(event) {
console.log('message from worker:', event.data);
});
map.on('moveend', function(event) {
const state = event.frameState.viewState;
worker.postMessage({zoom: state.zoom, center: state.center});
});

View File

@@ -1,6 +1,6 @@
{
"name": "ol",
"version": "6.0.0-beta.8",
"version": "6.0.0-beta.10",
"description": "OpenLayers mapping library",
"keywords": [
"map",
@@ -22,7 +22,7 @@
"build-index": "npm run build-package && node tasks/generate-index",
"build-legacy": "shx rm -rf build && npm run build-index && webpack --config config/webpack-config-legacy-build.js && cleancss --source-map src/ol/ol.css -o build/legacy/ol.css",
"copy-css": "shx cp src/ol/ol.css build/ol/ol.css",
"transpile": "shx rm -rf build/ol && shx mkdir -p build/ol && shx cp -rf src/ol build/ol/src && tsc --project config/tsconfig-build.json",
"transpile": "shx rm -rf build/ol && shx mkdir -p build/ol && shx cp -rf src/ol build/ol/src && node tasks/serialize-workers && tsc --project config/tsconfig-build.json",
"typecheck": "tsc --pretty",
"apidoc": "jsdoc -R config/jsdoc/api/index.md -c config/jsdoc/api/conf.json -P package.json -d build/apidoc"
},
@@ -38,16 +38,15 @@
"dependencies": {
"pbf": "3.2.0",
"pixelworks": "1.1.0",
"rbush": "2.0.2"
"rbush": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/preset-env": "^7.4.4",
"@openlayers/eslint-plugin": "^4.0.0-beta.2",
"@types/arcgis-rest-api": "^10.4.4",
"@types/geojson": "^7946.0.7",
"@types/pbf": "^3.0.1",
"@types/rbush": "^2.0.2",
"@types/topojson-specification": "^1.0.1",
"babel-loader": "^8.0.5",
"buble": "^0.19.7",
@@ -55,9 +54,9 @@
"chaikin-smooth": "^1.0.4",
"clean-css-cli": "4.3.0",
"copy-webpack-plugin": "^5.0.3",
"coveralls": "3.0.3",
"eslint": "^5.16.0",
"eslint-config-openlayers": "^11.0.0",
"coveralls": "3.0.4",
"eslint": "^6.0.0",
"eslint-config-openlayers": "^12.0.0",
"expect.js": "0.3.1",
"front-matter": "^3.0.2",
"fs-extra": "^8.0.0",
@@ -69,7 +68,7 @@
"istanbul-instrumenter-loader": "^3.0.1",
"jquery": "3.4.1",
"jsdoc": "3.6.2",
"jsdoc-plugin-typescript": "^2.0.0",
"jsdoc-plugin-typescript": "^2.0.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "^1.1.2",
@@ -81,11 +80,16 @@
"loglevelnext": "^3.0.1",
"marked": "0.6.2",
"mocha": "6.1.4",
"ol-mapbox-style": "^5.0.0-beta.1",
"pixelmatch": "^4.0.2",
"ol-mapbox-style": "^5.0.0-beta.2",
"pixelmatch": "^5.0.0",
"pngjs": "^3.4.0",
"proj4": "2.5.0",
"puppeteer": "~1.16.0",
"puppeteer": "~1.18.0",
"rollup": "^1.12.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-terser": "^5.0.0",
"serve-static": "^1.14.0",
"shx": "^0.3.2",
"sinon": "^7.3.2",
@@ -93,7 +97,7 @@
"typescript": "^3.4.5",
"url-polyfill": "^1.1.5",
"walk": "^2.3.9",
"webpack": "4.31.0",
"webpack": "4.35.0",
"webpack-cli": "^3.3.2",
"webpack-dev-middleware": "^3.6.2",
"webpack-dev-server": "^3.3.1",

View File

@@ -1,10 +1,10 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import XYZ from '../../../src/ol/source/XYZ';
import {Heatmap as HeatmapLayer} from '../../../src/ol/layer';
import VectorSource from '../../../src/ol/source/Vector';
import KML from '../../../src/ol/format/KML';
import XYZ from '../../../src/ol/source/XYZ.js';
import {Heatmap as HeatmapLayer} from '../../../src/ol/layer.js';
import VectorSource from '../../../src/ol/source/Vector.js';
import KML from '../../../src/ol/format/KML.js';
const vector = new HeatmapLayer({
source: new VectorSource({

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -0,0 +1,30 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import {Group as LayerGroup, Tile as TileLayer} from '../../../src/ol/layer.js';
import XYZ from '../../../src/ol/source/XYZ.js';
new Map({
target: 'map',
view: new View({
center: [0, 0],
zoom: 3
}),
layers: new LayerGroup({
opacity: 0.75,
layers: [
new TileLayer({
opacity: 0.25,
source: new XYZ({
url: '/data/tiles/satellite/{z}/{x}/{y}.jpg'
})
}),
new TileLayer({
source: new XYZ({
url: '/data/tiles/stamen-labels/{z}/{x}/{y}.png'
})
})
]
})
});
render();

View File

@@ -5,7 +5,7 @@ import {
get as getProjection,
transform,
transformExtent
} from '../../../src/ol/proj';
} from '../../../src/ol/proj.js';
import ImageLayer from '../../../src/ol/layer/Image.js';
const center = transform([-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857');

View File

@@ -5,9 +5,9 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {fromLonLat} from '../../../src/ol/proj';
import {fromLonLat} from '../../../src/ol/proj.js';
import {transformExtent} from '../../../src/ol/proj.js';
import XYZ from '../../../src/ol/source/XYZ';
import XYZ from '../../../src/ol/source/XYZ.js';
const center = fromLonLat([7, 50]);
const extent = transformExtent([2, 47, 10, 53], 'EPSG:4326', 'EPSG:3857');

View File

@@ -1,7 +1,7 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import XYZ from '../../../src/ol/source/XYZ';
import XYZ from '../../../src/ol/source/XYZ.js';
import {createXYZ} from '../../../src/ol/tilegrid.js';
const center = [-10997148, 4569099];

View File

@@ -1,8 +1,8 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {fromLonLat} from '../../../src/ol/proj';
import XYZ from '../../../src/ol/source/XYZ';
import {fromLonLat} from '../../../src/ol/proj.js';
import XYZ from '../../../src/ol/source/XYZ.js';
const center = fromLonLat([8.6, 50.1]);

View File

@@ -1,8 +1,8 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {fromLonLat} from '../../../src/ol/proj';
import XYZ from '../../../src/ol/source/XYZ';
import {fromLonLat} from '../../../src/ol/proj.js';
import XYZ from '../../../src/ol/source/XYZ.js';
const center = fromLonLat([8.6, 50.1]);

View File

@@ -1,8 +1,8 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {fromLonLat} from '../../../src/ol/proj';
import XYZ from '../../../src/ol/source/XYZ';
import {fromLonLat} from '../../../src/ol/proj.js';
import XYZ from '../../../src/ol/source/XYZ.js';
const center = fromLonLat([8.6, 50.1]);

View File

@@ -1,8 +1,8 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {fromLonLat} from '../../../src/ol/proj';
import XYZ from '../../../src/ol/source/XYZ';
import {fromLonLat} from '../../../src/ol/proj.js';
import XYZ from '../../../src/ol/source/XYZ.js';
const center = fromLonLat([8.6, 50.1]);

View File

@@ -42,7 +42,8 @@ const layer = new VectorLayer({
const view = new View({
center: [-9.5, 78],
zoom: 2,
projection: 'EPSG:4326'
projection: 'EPSG:4326',
multiWorld: true
});
new Map({
pixelRatio: 1,

View File

@@ -1,9 +1,9 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import VectorTileSource from '../../../src/ol/source/VectorTile';
import MVT from '../../../src/ol/format/MVT';
import {createXYZ} from '../../../src/ol/tilegrid';
import VectorTileLayer from '../../../src/ol/layer/VectorTile';
import VectorTileSource from '../../../src/ol/source/VectorTile.js';
import MVT from '../../../src/ol/format/MVT.js';
import {createXYZ} from '../../../src/ol/tilegrid.js';
import VectorTileLayer from '../../../src/ol/layer/VectorTile.js';
const map = new Map({
pixelRatio: 2,

View File

@@ -1,16 +1,16 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import VectorTileSource from '../../../src/ol/source/VectorTile';
import MVT from '../../../src/ol/format/MVT';
import {createXYZ} from '../../../src/ol/tilegrid';
import VectorTileLayer from '../../../src/ol/layer/VectorTile';
import VectorSource from '../../../src/ol/source/Vector';
import Feature from '../../../src/ol/Feature';
import Point from '../../../src/ol/geom/Point';
import VectorLayer from '../../../src/ol/layer/Vector';
import Style from '../../../src/ol/style/Style';
import CircleStyle from '../../../src/ol/style/Circle';
import Fill from '../../../src/ol/style/Fill';
import VectorTileSource from '../../../src/ol/source/VectorTile.js';
import MVT from '../../../src/ol/format/MVT.js';
import {createXYZ} from '../../../src/ol/tilegrid.js';
import VectorTileLayer from '../../../src/ol/layer/VectorTile.js';
import VectorSource from '../../../src/ol/source/Vector.js';
import Feature from '../../../src/ol/Feature.js';
import Point from '../../../src/ol/geom/Point.js';
import VectorLayer from '../../../src/ol/layer/Vector.js';
import Style from '../../../src/ol/style/Style.js';
import CircleStyle from '../../../src/ol/style/Circle.js';
import Fill from '../../../src/ol/style/Fill.js';
const vectorSource = new VectorSource({
features: [

View File

@@ -1,9 +1,9 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import VectorTileSource from '../../../src/ol/source/VectorTile';
import MVT from '../../../src/ol/format/MVT';
import {createXYZ} from '../../../src/ol/tilegrid';
import VectorTileLayer from '../../../src/ol/layer/VectorTile';
import VectorTileSource from '../../../src/ol/source/VectorTile.js';
import MVT from '../../../src/ol/format/MVT.js';
import {createXYZ} from '../../../src/ol/tilegrid.js';
import VectorTileLayer from '../../../src/ol/layer/VectorTile.js';
const map = new Map({
layers: [

View File

@@ -1,9 +1,9 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import VectorTileSource from '../../../src/ol/source/VectorTile';
import MVT from '../../../src/ol/format/MVT';
import {createXYZ} from '../../../src/ol/tilegrid';
import VectorTileLayer from '../../../src/ol/layer/VectorTile';
import VectorTileSource from '../../../src/ol/source/VectorTile.js';
import MVT from '../../../src/ol/format/MVT.js';
import {createXYZ} from '../../../src/ol/tilegrid.js';
import VectorTileLayer from '../../../src/ol/layer/VectorTile.js';
new Map({
layers: [

View File

@@ -9,12 +9,6 @@ import Point from '../../../src/ol/geom/Point.js';
const map = new Map({
layers: [
new TileLayer({
source: new XYZ({
url: '/data/tiles/satellite/{z}/{x}/{y}.jpg',
maxZoom: 3
})
}),
new VectorLayer({
zIndex: 1,
style: new Style({
@@ -27,6 +21,12 @@ const map = new Map({
url: '/data/countries.json',
format: new GeoJSON()
})
}),
new TileLayer({
source: new XYZ({
url: '/data/tiles/satellite/{z}/{x}/{y}.jpg',
maxZoom: 3
})
})
],
target: 'map',

View File

@@ -1,11 +1,11 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import XYZ from '../../../src/ol/source/XYZ';
import {Vector as VectorLayer} from '../../../src/ol/layer';
import VectorSource from '../../../src/ol/source/Vector';
import KML from '../../../src/ol/format/KML';
import WebGLPointsLayerRenderer from '../../../src/ol/renderer/webgl/PointsLayer';
import XYZ from '../../../src/ol/source/XYZ.js';
import {Vector as VectorLayer} from '../../../src/ol/layer.js';
import VectorSource from '../../../src/ol/source/Vector.js';
import KML from '../../../src/ol/format/KML.js';
import WebGLPointsLayerRenderer from '../../../src/ol/renderer/webgl/PointsLayer.js';
class CustomLayer extends VectorLayer {
createRenderer() {

View File

@@ -22,5 +22,16 @@ module.exports = {
context: __dirname,
target: 'web',
entry: entry,
devtool: 'source-map'
devtool: 'source-map',
module: {
rules: [{
test: /\.js$/,
use: {
loader: path.join(__dirname, '../examples/webpack/worker-loader.js')
},
include: [
path.join(__dirname, '../src/ol/worker')
]
}]
}
};

View File

@@ -57,10 +57,11 @@ import BaseObject, {getChangeEventType} from './Object.js';
* ```
*
* @api
* @template {import("./geom/Geometry.js").default} Geometry
*/
class Feature extends BaseObject {
/**
* @param {import("./geom/Geometry.js").default|Object<string, *>=} opt_geometryOrProperties
* @param {Geometry|Object<string, *>=} opt_geometryOrProperties
* You may pass a Geometry object directly, or an object literal containing
* properties. If you pass an object literal, you may include a Geometry
* associated with a `geometry` key.
@@ -106,7 +107,7 @@ class Feature extends BaseObject {
if (opt_geometryOrProperties) {
if (typeof /** @type {?} */ (opt_geometryOrProperties).getSimplifiedGeometry === 'function') {
const geometry = /** @type {import("./geom/Geometry.js").default} */ (opt_geometryOrProperties);
const geometry = /** @type {Geometry} */ (opt_geometryOrProperties);
this.setGeometry(geometry);
} else {
/** @type {Object<string, *>} */
@@ -140,13 +141,13 @@ class Feature extends BaseObject {
* Get the feature's default geometry. A feature may have any number of named
* geometries. The "default" geometry (the one that is rendered by default) is
* set when calling {@link module:ol/Feature~Feature#setGeometry}.
* @return {import("./geom/Geometry.js").default|undefined} The default geometry for the feature.
* @return {Geometry|undefined} The default geometry for the feature.
* @api
* @observable
*/
getGeometry() {
return (
/** @type {import("./geom/Geometry.js").default|undefined} */ (this.get(this.geometryName_))
/** @type {Geometry|undefined} */ (this.get(this.geometryName_))
);
}
@@ -218,7 +219,7 @@ class Feature extends BaseObject {
/**
* Set the default geometry for the feature. This will update the property
* with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.
* @param {import("./geom/Geometry.js").default|undefined} geometry The new geometry.
* @param {Geometry|undefined} geometry The new geometry.
* @api
* @observable
*/

View File

@@ -6,7 +6,6 @@ import {listen} from './events.js';
import Event from './events/Event.js';
import EventType from './events/EventType.js';
import {circular as circularPolygon} from './geom/Polygon.js';
import {GEOLOCATION} from './has.js';
import {toRadians} from './math.js';
import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
@@ -83,7 +82,7 @@ class GeolocationError extends Event {
* window.console.log(geolocation.getPosition());
* });
*
* @fires error
* @fires module:ol/events/Event~Event#event:error
* @api
*/
class Geolocation extends BaseObject {
@@ -160,7 +159,7 @@ class Geolocation extends BaseObject {
* @private
*/
handleTrackingChanged_() {
if (GEOLOCATION) {
if ('geolocation' in navigator) {
const tracking = this.getTracking();
if (tracking && this.watchId_ === undefined) {
this.watchId_ = navigator.geolocation.watchPosition(
@@ -204,12 +203,6 @@ class Geolocation extends BaseObject {
this.changed();
}
/**
* Triggered when the Geolocation returns an error.
* @event error
* @api
*/
/**
* @private
* @param {PositionError} error error object.

View File

@@ -6,6 +6,7 @@ import ImageState from './ImageState.js';
import {listenOnce, unlistenByKey} from './events.js';
import EventType from './events/EventType.js';
import {getHeight} from './extent.js';
import {IMAGE_DECODE} from './has.js';
/**
@@ -58,9 +59,9 @@ class ImageWrapper extends ImageBase {
/**
* @private
* @type {Array<import("./events.js").EventsKey>}
* @type {function():void}
*/
this.imageListenerKeys_ = null;
this.unlisten_ = null;
/**
* @protected
@@ -120,13 +121,12 @@ class ImageWrapper extends ImageBase {
if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) {
this.state = ImageState.LOADING;
this.changed();
this.imageListenerKeys_ = [
listenOnce(this.image_, EventType.ERROR,
this.handleImageError_, this),
listenOnce(this.image_, EventType.LOAD,
this.handleImageLoad_, this)
];
this.imageLoadFunction_(this, this.src_);
this.unlisten_ = listenImage(
this.image_,
this.handleImageLoad_.bind(this),
this.handleImageError_.bind(this)
);
}
}
@@ -143,10 +143,54 @@ class ImageWrapper extends ImageBase {
* @private
*/
unlistenImage_() {
this.imageListenerKeys_.forEach(unlistenByKey);
this.imageListenerKeys_ = null;
if (this.unlisten_) {
this.unlisten_();
this.unlisten_ = null;
}
}
}
/**
* @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image element.
* @param {function():any} loadHandler Load callback function.
* @param {function():any} errorHandler Error callback function.
* @return {function():void} Callback to stop listening.
*/
export function listenImage(image, loadHandler, errorHandler) {
const img = /** @type {HTMLImageElement} */ (image);
if (IMAGE_DECODE) {
const promise = img.decode();
let listening = true;
const unlisten = function() {
listening = false;
};
promise.then(function() {
if (listening) {
loadHandler();
}
}).catch(function(error) {
if (listening) {
// FIXME: Unconditionally call errorHandler() when this bug is fixed upstream:
// https://bugs.webkit.org/show_bug.cgi?id=198527
if (error.name === 'EncodingError' && error.message === 'Invalid image type.') {
loadHandler();
} else {
errorHandler();
}
}
});
return unlisten;
}
const listenerKeys = [
listenOnce(img, EventType.LOAD, loadHandler),
listenOnce(img, EventType.ERROR, errorHandler)
];
return function unlisten() {
listenerKeys.forEach(unlistenByKey);
};
}
export default ImageWrapper;

View File

@@ -4,8 +4,7 @@
import Tile from './Tile.js';
import TileState from './TileState.js';
import {createCanvasContext2D} from './dom.js';
import {listenOnce, unlistenByKey} from './events.js';
import EventType from './events/EventType.js';
import {listenImage} from './Image.js';
class ImageTile extends Tile {
@@ -47,9 +46,9 @@ class ImageTile extends Tile {
/**
* @private
* @type {Array<import("./events.js").EventsKey>}
* @type {function():void}
*/
this.imageListenerKeys_ = null;
this.unlisten_ = null;
/**
* @private
@@ -134,13 +133,12 @@ class ImageTile extends Tile {
if (this.state == TileState.IDLE) {
this.state = TileState.LOADING;
this.changed();
this.imageListenerKeys_ = [
listenOnce(this.image_, EventType.ERROR,
this.handleImageError_, this),
listenOnce(this.image_, EventType.LOAD,
this.handleImageLoad_, this)
];
this.tileLoadFunction_(this, this.src_);
this.unlisten_ = listenImage(
this.image_,
this.handleImageLoad_.bind(this),
this.handleImageError_.bind(this)
);
}
}
@@ -150,8 +148,10 @@ class ImageTile extends Tile {
* @private
*/
unlistenImage_() {
this.imageListenerKeys_.forEach(unlistenByKey);
this.imageListenerKeys_ = null;
if (this.unlisten_) {
this.unlisten_();
this.unlisten_ = null;
}
}
}

View File

@@ -2,7 +2,7 @@
* @module ol/Map
*/
import PluggableMap from './PluggableMap.js';
import {defaults as defaultControls} from './control/util.js';
import {defaults as defaultControls} from './control.js';
import {defaults as defaultInteractions} from './interaction.js';
import {assign} from './obj.js';
import CompositeMapRenderer from './renderer/Composite.js';

View File

@@ -260,12 +260,6 @@ class MapBrowserEventHandler extends EventTarget {
this.dragging_);
this.dispatchEvent(newEvent);
}
// Some native android browser triggers mousemove events during small period
// of time. See: https://code.google.com/p/android/issues/detail?id=5491 or
// https://code.google.com/p/android/issues/detail?id=19827
// ex: Galaxy Tab P3110 + Android 4.1.1
pointerEvent.preventDefault();
}
/**

View File

@@ -22,7 +22,7 @@ import {listen, unlistenByKey, unlisten} from './events.js';
import EventType from './events/EventType.js';
import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
import {TRUE} from './functions.js';
import {DEVICE_PIXEL_RATIO, TOUCH} from './has.js';
import {DEVICE_PIXEL_RATIO, IMAGE_DECODE} from './has.js';
import LayerGroup from './layer/Group.js';
import {hasArea} from './size.js';
import {DROP} from './structs/PriorityQueue.js';
@@ -39,10 +39,11 @@ import {create as createTransform, apply as applyTransform} from './transform.js
* @property {boolean} animate
* @property {import("./transform.js").Transform} coordinateToPixelTransform
* @property {null|import("./extent.js").Extent} extent
* @property {Array<*>} declutterItems
* @property {Array<DeclutterItems>} declutterItems
* @property {import("./coordinate.js").Coordinate} focus
* @property {number} index
* @property {Array<import("./layer/Layer.js").State>} layerStatesArray
* @property {number} layerIndex
* @property {import("./transform.js").Transform} pixelToCoordinateTransform
* @property {Array<PostRenderFunction>} postRenderFunctions
* @property {import("./size.js").Size} size
@@ -54,6 +55,13 @@ import {create as createTransform, apply as applyTransform} from './transform.js
*/
/**
* @typedef {Object} DeclutterItems
* @property {Array<*>} items Declutter items of an executor.
* @property {number} opacity Layer opacity.
*/
/**
* @typedef {function(PluggableMap, ?FrameState): any} PostRenderFunction
*/
@@ -222,7 +230,7 @@ class PluggableMap extends BaseObject {
* @type {!HTMLElement}
*/
this.viewport_ = document.createElement('div');
this.viewport_.className = 'ol-viewport' + (TOUCH ? ' ol-touch' : '');
this.viewport_.className = 'ol-viewport' + ('ontouchstart' in window ? ' ol-touch' : '');
this.viewport_.style.position = 'relative';
this.viewport_.style.overflow = 'hidden';
this.viewport_.style.width = '100%';
@@ -293,6 +301,16 @@ class PluggableMap extends BaseObject {
*/
this.interactions = optionsInternal.interactions || new Collection();
/**
* @type {import("./events/Target.js").default}
*/
this.labelCache_ = null;
/**
* @type {import("./events.js").EventsKey}
*/
this.labelCacheListenerKey_;
/**
* @type {Collection<import("./Overlay.js").default>}
* @private
@@ -310,7 +328,7 @@ class PluggableMap extends BaseObject {
* @type {import("./renderer/Map.js").default}
* @private
*/
this.renderer_ = this.createRenderer();
this.renderer_ = null;
/**
* @type {function(Event): void|undefined}
@@ -511,10 +529,6 @@ class PluggableMap extends BaseObject {
removeEventListener(EventType.RESIZE, this.handleResize_, false);
this.handleResize_ = undefined;
}
if (this.animationDelayKey_) {
cancelAnimationFrame(this.animationDelayKey_);
this.animationDelayKey_ = undefined;
}
this.setTarget(null);
super.disposeInternal();
}
@@ -763,6 +777,21 @@ class PluggableMap extends BaseObject {
return layers;
}
/**
* @return {boolean} Layers have sources that are still loading.
*/
getLoading() {
const layerStatesArray = this.getLayerGroup().getLayerStatesArray();
for (let i = 0, ii = layerStatesArray.length; i < ii; ++i) {
const layer = layerStatesArray[i].layer;
const source = /** @type {import("./layer/Layer.js").default} */ (layer).getSource();
if (source && source.loading) {
return true;
}
}
return false;
}
/**
* Get the pixel for a coordinate. This takes a coordinate in the map view
* projection and returns the corresponding pixel.
@@ -938,7 +967,7 @@ class PluggableMap extends BaseObject {
if (frameState) {
const hints = frameState.viewHints;
if (hints[ViewHint.ANIMATING] || hints[ViewHint.INTERACTING]) {
const lowOnFrameBudget = Date.now() - frameState.time > 8;
const lowOnFrameBudget = !IMAGE_DECODE && Date.now() - frameState.time > 8;
maxTotalLoading = lowOnFrameBudget ? 0 : 8;
maxNewLoads = lowOnFrameBudget ? 0 : 2;
}
@@ -950,7 +979,7 @@ class PluggableMap extends BaseObject {
}
if (frameState && this.hasListener(RenderEventType.RENDERCOMPLETE) && !frameState.animate &&
!this.tileQueue_.getTilesLoading() && !getLoading(this.getLayers().getArray())) {
!this.tileQueue_.getTilesLoading() && !this.getLoading()) {
this.renderer_.dispatchRenderEvent(RenderEventType.RENDERCOMPLETE, frameState);
}
@@ -994,7 +1023,14 @@ class PluggableMap extends BaseObject {
}
if (!targetElement) {
this.renderer_.removeLayerRenderers();
if (this.renderer_) {
this.renderer_.dispose();
this.renderer_ = null;
}
if (this.animationDelayKey_) {
cancelAnimationFrame(this.animationDelayKey_);
this.animationDelayKey_ = undefined;
}
removeNode(this.viewport_);
if (this.handleResize_ !== undefined) {
removeEventListener(EventType.RESIZE, this.handleResize_, false);
@@ -1002,6 +1038,9 @@ class PluggableMap extends BaseObject {
}
} else {
targetElement.appendChild(this.viewport_);
if (!this.renderer_) {
this.renderer_ = this.createRenderer();
}
const keyboardEventTarget = !this.keyboardEventTarget_ ?
targetElement : this.keyboardEventTarget_;
@@ -1012,7 +1051,7 @@ class PluggableMap extends BaseObject {
if (!this.handleResize_) {
this.handleResize_ = this.updateSize.bind(this);
addEventListener(EventType.RESIZE, this.handleResize_, false);
window.addEventListener(EventType.RESIZE, this.handleResize_, false);
}
}
@@ -1102,12 +1141,25 @@ class PluggableMap extends BaseObject {
this.animationDelay_();
}
/**
* Redraws all text after new fonts have loaded
*/
redrawText() {
const layerStates = this.getLayerGroup().getLayerStatesArray();
for (let i = 0, ii = layerStates.length; i < ii; ++i) {
const layer = layerStates[i].layer;
if (layer.hasRenderer()) {
layer.getRenderer().handleFontsChanged();
}
}
}
/**
* Request a map rendering (at the next animation frame).
* @api
*/
render() {
if (this.animationDelayKey_ === undefined) {
if (this.renderer_ && this.animationDelayKey_ === undefined) {
this.animationDelayKey_ = requestAnimationFrame(this.animationDelay_);
}
}
@@ -1173,13 +1225,14 @@ class PluggableMap extends BaseObject {
if (size !== undefined && hasArea(size) && view && view.isDef()) {
const viewHints = view.getHints(this.frameState_ ? this.frameState_.viewHints : undefined);
viewState = view.getState(this.pixelRatio_);
frameState = /** @type {FrameState} */ ({
frameState = {
animate: false,
coordinateToPixelTransform: this.coordinateToPixelTransform_,
declutterItems: previousFrameState ? previousFrameState.declutterItems : [],
extent: extent,
focus: this.focus_ ? this.focus_ : viewState.center,
index: this.frameIndex_++,
layerIndex: 0,
layerStatesArray: this.getLayerGroup().getLayerStatesArray(),
pixelRatio: this.pixelRatio_,
pixelToCoordinateTransform: this.pixelToCoordinateTransform_,
@@ -1192,7 +1245,7 @@ class PluggableMap extends BaseObject {
viewState: viewState,
viewHints: viewHints,
wantedTiles: {}
});
};
}
if (frameState) {
@@ -1398,23 +1451,3 @@ function createOptionsInternal(options) {
}
export default PluggableMap;
/**
* @param {Array<import("./layer/Base.js").default>} layers Layers.
* @return {boolean} Layers have sources that are still loading.
*/
function getLoading(layers) {
for (let i = 0, ii = layers.length; i < ii; ++i) {
const layer = layers[i];
if (typeof /** @type {?} */ (layer).getLayers === 'function') {
return getLoading(/** @type {LayerGroup} */ (layer).getLayers().getArray());
} else {
const source = /** @type {import("./layer/Layer.js").default} */ (
layer).getSource();
if (source && source.loading) {
return true;
}
}
}
return false;
}

View File

@@ -21,9 +21,9 @@ import {clamp, modulo} from './math.js';
import {assign} from './obj.js';
import {createProjection, METERS_PER_UNIT} from './proj.js';
import Units from './proj/Units.js';
import {equals} from './coordinate';
import {easeOut} from './easing';
import {createMinMaxResolution} from './resolutionconstraint';
import {equals} from './coordinate.js';
import {easeOut} from './easing.js';
import {createMinMaxResolution} from './resolutionconstraint.js';
/**
@@ -1409,11 +1409,19 @@ function animationCallback(callback, returnValue) {
*/
export function createCenterConstraint(options) {
if (options.extent !== undefined) {
return createExtent(options.extent, options.constrainOnlyCenter,
options.smoothExtentConstraint !== undefined ? options.smoothExtentConstraint : true);
} else {
return centerNone;
const smooth = options.smoothExtentConstraint !== undefined ? options.smoothExtentConstraint : true;
return createExtent(options.extent, options.constrainOnlyCenter, smooth);
}
const projection = createProjection(options.projection, 'EPSG:3857');
if (options.multiWorld !== true && projection.isGlobal()) {
const extent = projection.getExtent().slice();
extent[0] = -Infinity;
extent[2] = Infinity;
return createExtent(extent, false, false);
}
return centerNone;
}

View File

@@ -1,6 +1,10 @@
/**
* @module ol/control
*/
import Collection from './Collection.js';
import Attribution from './control/Attribution.js';
import Rotate from './control/Rotate.js';
import Zoom from './control/Zoom.js';
export {default as Attribution} from './control/Attribution.js';
export {default as Control} from './control/Control.js';
@@ -12,4 +16,59 @@ export {default as ScaleLine} from './control/ScaleLine.js';
export {default as Zoom} from './control/Zoom.js';
export {default as ZoomSlider} from './control/ZoomSlider.js';
export {default as ZoomToExtent} from './control/ZoomToExtent.js';
export {defaults} from './control/util.js';
/**
* @typedef {Object} DefaultsOptions
* @property {boolean} [attribution=true] Include
* {@link module:ol/control/Attribution~Attribution}.
* @property {import("./control/Attribution.js").Options} [attributionOptions]
* Options for {@link module:ol/control/Attribution~Attribution}.
* @property {boolean} [rotate=true] Include
* {@link module:ol/control/Rotate~Rotate}.
* @property {import("./control/Rotate.js").Options} [rotateOptions] Options
* for {@link module:ol/control/Rotate~Rotate}.
* @property {boolean} [zoom] Include {@link module:ol/control/Zoom~Zoom}.
* @property {import("./control/Zoom.js").Options} [zoomOptions] Options for
* {@link module:ol/control/Zoom~Zoom}.
* @api
*/
/**
* Set of controls included in maps by default. Unless configured otherwise,
* this returns a collection containing an instance of each of the following
* controls:
* * {@link module:ol/control/Zoom~Zoom}
* * {@link module:ol/control/Rotate~Rotate}
* * {@link module:ol/control/Attribution~Attribution}
*
* @param {DefaultsOptions=} opt_options
* Defaults options.
* @return {Collection<import("./control/Control.js").default>}
* Controls.
* @api
*/
export function defaults(opt_options) {
const options = opt_options ? opt_options : {};
const controls = new Collection();
const zoomControl = options.zoom !== undefined ? options.zoom : true;
if (zoomControl) {
controls.push(new Zoom(options.zoomOptions));
}
const rotateControl = options.rotate !== undefined ? options.rotate : true;
if (rotateControl) {
controls.push(new Rotate(options.rotateOptions));
}
const attributionControl = options.attribution !== undefined ?
options.attribution : true;
if (attributionControl) {
controls.push(new Attribution(options.attributionOptions));
}
return controls;
}

View File

@@ -1,8 +1,8 @@
/**
* @module ol/control/OverviewMap
*/
import Collection from '../Collection.js';
import Map from '../Map.js';
import PluggableMap from '../PluggableMap.js';
import CompositeMapRenderer from '../renderer/Composite.js';
import MapEventType from '../MapEventType.js';
import MapProperty from '../MapProperty.js';
import {getChangeEventType} from '../Object.js';
@@ -35,6 +35,13 @@ const MAX_RATIO = 0.75;
const MIN_RATIO = 0.1;
class ControlledMap extends PluggableMap {
createRenderer() {
return new CompositeMapRenderer(this);
}
}
/**
* @typedef {Object} Options
* @property {string} [className='ol-overviewmap'] CSS class name.
@@ -44,8 +51,8 @@ const MIN_RATIO = 0.1;
* @property {boolean} [collapsible=true] Whether the control can be collapsed or not.
* @property {string|HTMLElement} [label='»'] Text label to use for the collapsed
* overviewmap button. Instead of text, also an element (e.g. a `span` element) can be used.
* @property {Array<import("../layer/Layer.js").default>|import("../Collection.js").default<import("../layer/Layer.js").default>} layers
* Layers for the overview map (mandatory).
* @property {Array<import("../layer/Layer.js").default>|import("../Collection.js").default<import("../layer/Layer.js").default>} [layers]
* Layers for the overview map.
* @property {function(import("../MapEvent.js").default)} [render] Function called when the control
* should be re-rendered. This is called in a `requestAnimationFrame` callback.
* @property {HTMLElement|string} [target] Specify a target if you want the control
@@ -143,24 +150,18 @@ class OverviewMap extends Control {
this.ovmapDiv_.className = 'ol-overviewmap-map';
/**
* @type {import("../Map.js").default}
* @type {ControlledMap}
* @private
*/
this.ovmap_ = new Map({
controls: new Collection(),
interactions: new Collection(),
this.ovmap_ = new ControlledMap({
view: options.view
});
const ovmap = this.ovmap_;
if (options.layers) {
/** @type {Array<import("../layer/Layer.js").default>} */ (options.layers).forEach(
/**
* @param {import("../layer/Layer.js").default} layer Layer.
*/
(function(layer) {
ovmap.addLayer(layer);
}).bind(this));
options.layers.forEach(function(layer) {
ovmap.addLayer(layer);
});
}
const box = document.createElement('div');

View File

@@ -1,65 +0,0 @@
/**
* @module ol/control/util
*/
import Collection from '../Collection.js';
import Attribution from './Attribution.js';
import Rotate from './Rotate.js';
import Zoom from './Zoom.js';
/**
* @typedef {Object} DefaultsOptions
* @property {boolean} [attribution=true] Include
* {@link module:ol/control/Attribution~Attribution}.
* @property {import("./Attribution.js").Options} [attributionOptions]
* Options for {@link module:ol/control/Attribution~Attribution}.
* @property {boolean} [rotate=true] Include
* {@link module:ol/control/Rotate~Rotate}.
* @property {import("./Rotate.js").Options} [rotateOptions] Options
* for {@link module:ol/control/Rotate~Rotate}.
* @property {boolean} [zoom] Include {@link module:ol/control/Zoom~Zoom}.
* @property {import("./Zoom.js").Options} [zoomOptions] Options for
* {@link module:ol/control/Zoom~Zoom}.
* @api
*/
/**
* Set of controls included in maps by default. Unless configured otherwise,
* this returns a collection containing an instance of each of the following
* controls:
* * {@link module:ol/control/Zoom~Zoom}
* * {@link module:ol/control/Rotate~Rotate}
* * {@link module:ol/control/Attribution~Attribution}
*
* @param {DefaultsOptions=} opt_options
* Defaults options.
* @return {Collection<import("./Control.js").default>}
* Controls.
* @function module:ol/control.defaults
* @api
*/
export function defaults(opt_options) {
const options = opt_options ? opt_options : {};
const controls = new Collection();
const zoomControl = options.zoom !== undefined ? options.zoom : true;
if (zoomControl) {
controls.push(new Zoom(options.zoomOptions));
}
const rotateControl = options.rotate !== undefined ? options.rotate : true;
if (rotateControl) {
controls.push(new Rotate(options.rotateOptions));
}
const attributionControl = options.attribution !== undefined ?
options.attribution : true;
if (attributionControl) {
controls.push(new Attribution(options.attributionOptions));
}
return controls;
}

View File

@@ -14,6 +14,13 @@ export default {
*/
CHANGE: 'change',
/**
* Generic error event. Triggered when an error occurs.
* @event module:ol/events/Event~Event#error
* @api
*/
ERROR: 'error',
CLEAR: 'clear',
CONTEXTMENU: 'contextmenu',
CLICK: 'click',
@@ -21,7 +28,6 @@ export default {
DRAGENTER: 'dragenter',
DRAGOVER: 'dragover',
DROP: 'drop',
ERROR: 'error',
KEYDOWN: 'keydown',
KEYPRESS: 'keypress',
LOAD: 'load',

View File

@@ -13,8 +13,10 @@ import {get as getProjection, equivalent as equivalentProjection, transformExten
* the `dataProjection` of the format is assigned (where set). If the projection
* can not be derived from the data and if no `dataProjection` is set for a format,
* the features will not be reprojected.
* @property {import("../extent.js").Extent} [extent] Tile extent of the tile being read. This is only used and
* required for {@link module:ol/format/MVT}.
* @property {import("../extent.js").Extent} [extent] Tile extent in map units of the tile being read.
* This is only required when reading data with tile pixels as geometry units. When configured,
* a `dataProjection` with `TILE_PIXELS` as `units` and the tile's pixel extent as `extent` needs to be
* provided.
* @property {import("../proj.js").ProjectionLike} [featureProjection] Projection of the feature geometries
* created by the format reader. If not provided, features will be returned in the
* `dataProjection`.
@@ -86,9 +88,14 @@ class FeatureFormat {
getReadOptions(source, opt_options) {
let options;
if (opt_options) {
let dataProjection = opt_options.dataProjection ?
opt_options.dataProjection : this.readProjection(source);
if (opt_options.extent) {
dataProjection = getProjection(dataProjection);
dataProjection.setWorldExtent(opt_options.extent);
}
options = {
dataProjection: opt_options.dataProjection ?
opt_options.dataProjection : this.readProjection(source),
dataProjection: dataProjection,
featureProjection: opt_options.featureProjection
};
}

View File

@@ -2684,13 +2684,6 @@ function writePlacemark(node, feature, objectStack) {
return !filter[v];
});
if (keys.length > 0) {
const sequence = makeSequence(properties, keys);
const namesAndValues = {names: keys, values: sequence};
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
EXTENDEDDATA_NODE_FACTORY, [namesAndValues], objectStack);
}
const styleFunction = feature.getStyleFunction();
if (styleFunction) {
// FIXME the styles returned by the style function are supposed to be
@@ -2713,6 +2706,13 @@ function writePlacemark(node, feature, objectStack) {
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
if (keys.length > 0) {
const sequence = makeSequence(properties, keys);
const namesAndValues = {names: keys, values: sequence};
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
EXTENDEDDATA_NODE_FACTORY, [namesAndValues], objectStack);
}
// serialize geometry
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
let geometry = feature.getGeometry();

View File

@@ -174,9 +174,8 @@ class Geometry extends BaseObject {
/**
* Create a simplified version of this geometry. For linestrings, this uses
* the the {@link
* https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
* Douglas Peucker} algorithm. For polygons, a quantization-based
* the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)
* algorithm. For polygons, a quantization-based
* simplification is used to preserve topology.
* @param {number} tolerance The tolerance distance for simplification.
* @return {Geometry} A new, simplified version of the original geometry.

View File

@@ -16,8 +16,8 @@ import {lerp} from '../../math.js';
* @param {function(string, string, Object<string, number>):number} measureAndCacheTextWidth Measure and cache text width.
* @param {string} font The font.
* @param {Object<string, number>} cache A cache of measured widths.
* @return {Array<Array<*>>} The result array of null if `maxAngle` was
* exceeded. Entries of the array are x, y, anchorX, angle, chunk.
* @return {Array<Array<*>>} The result array (or null if `maxAngle` was
* exceeded). Entries of the array are x, y, anchorX, angle, chunk.
*/
export function drawTextOnPath(
flatCoordinates, offset, end, stride, text, startM, maxAngle, scale, measureAndCacheTextWidth, font, cache) {
@@ -35,16 +35,13 @@ export function drawTextOnPath(
let y2 = flatCoordinates[offset + 1];
let segmentM = 0;
let segmentLength = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
let angleChanged = false;
let chunk = '';
let chunkLength = 0;
let data, index, previousAngle;
let index, previousAngle;
for (let i = 0; i < numChars; ++i) {
index = reverse ? numChars - i - 1 : i;
const char = text.charAt(index);
chunk = reverse ? char + chunk : chunk + char;
const charLength = scale * measureAndCacheTextWidth(font, chunk, cache) - chunkLength;
chunkLength += charLength;
const char = text[index];
const charLength = scale * measureAndCacheTextWidth(font, char, cache);
const charM = startM + charLength / 2;
while (offset < end - stride && segmentM + segmentLength < charM) {
x1 = x2;
@@ -62,33 +59,18 @@ export function drawTextOnPath(
}
if (previousAngle !== undefined) {
let delta = angle - previousAngle;
angleChanged = angleChanged || delta !== 0;
delta += (delta > Math.PI) ? -2 * Math.PI : (delta < -Math.PI) ? 2 * Math.PI : 0;
if (Math.abs(delta) > maxAngle) {
return null;
}
}
previousAngle = angle;
const interpolate = segmentPos / segmentLength;
const x = lerp(x1, x2, interpolate);
const y = lerp(y1, y2, interpolate);
if (previousAngle == angle) {
if (reverse) {
data[0] = x;
data[1] = y;
data[2] = charLength / 2;
}
data[4] = chunk;
} else {
chunk = char;
chunkLength = charLength;
data = [x, y, charLength / 2, angle, chunk];
if (reverse) {
result.unshift(data);
} else {
result.push(data);
}
previousAngle = angle;
}
result[index] = [x, y, charLength / 2, angle, char];
startM += charLength;
}
return result;
return angleChanged ? result : [[result[0][0], result[0][1], result[0][2], result[0][3], text]];
}

View File

@@ -39,39 +39,8 @@ export const MAC = ua.indexOf('macintosh') !== -1;
*/
export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
/**
* Is HTML5 geolocation supported in the current browser?
* @const
* @type {boolean}
* @api
*/
export const GEOLOCATION = 'geolocation' in navigator;
/**
* True if browser supports touch events.
* @const
* @type {boolean}
* @api
*/
export const TOUCH = 'ontouchstart' in window;
/**
* True if browser supports pointer events.
* @const
* Image.prototype.decode() is supported.
* @type {boolean}
*/
export const POINTER = 'PointerEvent' in window;
/**
* True if browser supports ms pointer events (IE 10).
* @const
* @type {boolean}
*/
export const MSPOINTER = !!(navigator.msPointerEnabled);
export {HAS as WEBGL} from './webgl.js';
export const IMAGE_DECODE = typeof Image !== 'undefined' && Image.prototype.decode;

View File

@@ -3,7 +3,7 @@
*/
import {scale as scaleCoordinate, rotate as rotateCoordinate} from '../coordinate.js';
import {easeOut} from '../easing.js';
import {noModifierKeys} from '../events/condition.js';
import {noModifierKeys, primaryAction} from '../events/condition.js';
import {FALSE} from '../functions.js';
import PointerInteraction, {centroid as centroidFromPointers} from './Pointer.js';
@@ -12,7 +12,7 @@ import PointerInteraction, {centroid as centroidFromPointers} from './Pointer.js
* @typedef {Object} Options
* @property {import("../events/condition.js").Condition} [condition] A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean
* to indicate whether that event should be handled.
* Default is {@link module:ol/events/condition~noModifierKeys}.
* Default is {@link module:ol/events/condition~noModifierKeys} and {@link module:ol/events/condition~primaryAction}.
* @property {import("../Kinetic.js").default} [kinetic] Kinetic inertia to apply to the pan.
*/
@@ -59,7 +59,7 @@ class DragPan extends PointerInteraction {
* @private
* @type {import("../events/condition.js").Condition}
*/
this.condition_ = options.condition ? options.condition : noModifierKeys;
this.condition_ = options.condition ? options.condition : defaultCondition;
/**
* @private
@@ -166,4 +166,12 @@ class DragPan extends PointerInteraction {
}
}
/**
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Browser event.
* @return {boolean} Combined condition result.
*/
function defaultCondition(mapBrowserEvent) {
return noModifierKeys(mapBrowserEvent) && primaryAction(mapBrowserEvent);
}
export default DragPan;

View File

@@ -373,7 +373,7 @@ class Draw extends PointerInteraction {
/**
* Sketch point.
* @type {Feature}
* @type {Feature<Point>}
* @private
*/
this.sketchPoint_ = null;
@@ -387,7 +387,7 @@ class Draw extends PointerInteraction {
/**
* Sketch line. Used when drawing polygon.
* @type {Feature}
* @type {Feature<LineString>}
* @private
*/
this.sketchLine_ = null;
@@ -669,7 +669,7 @@ class Draw extends PointerInteraction {
this.sketchPoint_ = new Feature(new Point(coordinates));
this.updateSketchFeatures_();
} else {
const sketchPointGeom = /** @type {Point} */ (this.sketchPoint_.getGeometry());
const sketchPointGeom = this.sketchPoint_.getGeometry();
sketchPointGeom.setCoordinates(coordinates);
}
}
@@ -711,7 +711,7 @@ class Draw extends PointerInteraction {
*/
modifyDrawing_(event) {
let coordinate = event.coordinate;
const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (this.sketchFeature_.getGeometry());
const geometry = this.sketchFeature_.getGeometry();
let coordinates, last;
if (this.mode_ === Mode.POINT) {
last = this.sketchCoords_;
@@ -730,7 +730,7 @@ class Draw extends PointerInteraction {
last[1] = coordinate[1];
this.geometryFunction_(/** @type {!LineCoordType} */ (this.sketchCoords_), geometry);
if (this.sketchPoint_) {
const sketchPointGeom = /** @type {Point} */ (this.sketchPoint_.getGeometry());
const sketchPointGeom = this.sketchPoint_.getGeometry();
sketchPointGeom.setCoordinates(coordinate);
}
/** @type {LineString} */
@@ -740,8 +740,8 @@ class Draw extends PointerInteraction {
if (!this.sketchLine_) {
this.sketchLine_ = new Feature();
}
const ring = /** @type {Polygon} */ (geometry).getLinearRing(0);
sketchLineGeom = /** @type {LineString} */ (this.sketchLine_.getGeometry());
const ring = geometry.getLinearRing(0);
sketchLineGeom = this.sketchLine_.getGeometry();
if (!sketchLineGeom) {
sketchLineGeom = new LineString(ring.getFlatCoordinates(), ring.getLayout());
this.sketchLine_.setGeometry(sketchLineGeom);
@@ -751,7 +751,7 @@ class Draw extends PointerInteraction {
sketchLineGeom.changed();
}
} else if (this.sketchLineCoords_) {
sketchLineGeom = /** @type {LineString} */ (this.sketchLine_.getGeometry());
sketchLineGeom = this.sketchLine_.getGeometry();
sketchLineGeom.setCoordinates(this.sketchLineCoords_);
}
this.updateSketchFeatures_();
@@ -764,7 +764,7 @@ class Draw extends PointerInteraction {
*/
addToDrawing_(event) {
const coordinate = event.coordinate;
const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (this.sketchFeature_.getGeometry());
const geometry = this.sketchFeature_.getGeometry();
let done;
let coordinates;
if (this.mode_ === Mode.LINE_STRING) {
@@ -808,7 +808,7 @@ class Draw extends PointerInteraction {
if (!this.sketchFeature_) {
return;
}
const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (this.sketchFeature_.getGeometry());
const geometry = this.sketchFeature_.getGeometry();
let coordinates;
/** @type {LineString} */
let sketchLineGeom;
@@ -822,7 +822,7 @@ class Draw extends PointerInteraction {
} else if (this.mode_ === Mode.POLYGON) {
coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0];
coordinates.splice(-2, 1);
sketchLineGeom = /** @type {LineString} */ (this.sketchLine_.getGeometry());
sketchLineGeom = this.sketchLine_.getGeometry();
sketchLineGeom.setCoordinates(coordinates);
this.geometryFunction_(this.sketchCoords_, geometry);
}
@@ -846,7 +846,7 @@ class Draw extends PointerInteraction {
return;
}
let coordinates = this.sketchCoords_;
const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (sketchFeature.getGeometry());
const geometry = sketchFeature.getGeometry();
if (this.mode_ === Mode.LINE_STRING) {
// remove the redundant last point
coordinates.pop();
@@ -900,12 +900,12 @@ class Draw extends PointerInteraction {
* Extend an existing geometry by adding additional points. This only works
* on features with `LineString` geometries, where the interaction will
* extend lines by adding points to the end of the coordinates array.
* @param {!Feature} feature Feature to be extended.
* @param {!Feature<LineString>} feature Feature to be extended.
* @api
*/
extend(feature) {
const geometry = feature.getGeometry();
const lineString = /** @type {LineString} */ (geometry);
const lineString = geometry;
this.sketchFeature_ = feature;
this.sketchCoords_ = lineString.getCoordinates();
const last = this.sketchCoords_[this.sketchCoords_.length - 1];

View File

@@ -126,7 +126,7 @@ class Extent extends PointerInteraction {
/**
* Feature for displaying the visible pointer
* @type {Feature}
* @type {Feature<Point>}
* @private
*/
this.vertexFeature_ = null;
@@ -265,7 +265,7 @@ class Extent extends PointerInteraction {
this.vertexFeature_ = vertexFeature;
this.vertexOverlay_.getSource().addFeature(vertexFeature);
} else {
const geometry = /** @type {Point} */ (vertexFeature.getGeometry());
const geometry = vertexFeature.getGeometry();
geometry.setCoordinates(vertex);
}
return vertexFeature;

View File

@@ -660,7 +660,7 @@ class Modify extends PointerInteraction {
this.vertexFeature_ = vertexFeature;
this.overlay_.getSource().addFeature(vertexFeature);
} else {
const geometry = /** @type {Point} */ (vertexFeature.getGeometry());
const geometry = vertexFeature.getGeometry();
geometry.setCoordinates(coordinates);
}
return vertexFeature;
@@ -785,7 +785,7 @@ class Modify extends PointerInteraction {
const vertexFeature = this.vertexFeature_;
if (vertexFeature) {
const insertVertices = [];
const geometry = /** @type {Point} */ (vertexFeature.getGeometry());
const geometry = vertexFeature.getGeometry();
const vertex = geometry.getCoordinates();
const vertexExtent = boundingExtent([vertex]);
const segmentDataMatches = this.rBush_.getInExtent(vertexExtent);

View File

@@ -35,6 +35,13 @@ const TranslateEventType = {
TRANSLATEEND: 'translateend'
};
/**
* A function that takes an {@link module:ol/Feature} or
* {@link module:ol/render/Feature} and an
* {@link module:ol/layer/Layer} and returns `true` if the feature may be
* translated or `false` otherwise.
* @typedef {function(import("../Feature.js").FeatureLike, import("../layer/Layer.js").default):boolean} FilterFunction
*/
/**
* @typedef {Object} Options
@@ -45,6 +52,10 @@ const TranslateEventType = {
* function will be called for each layer in the map and should return
* `true` for layers that you want to be translatable. If the option is
* absent, all visible layers will be considered translatable.
* @property {FilterFunction} [filter] A function
* that takes an {@link module:ol/Feature} and an
* {@link module:ol/layer/Layer} and returns `true` if the feature may be
* translated or `false` otherwise.
* @property {number} [hitTolerance=0] Hit-detection tolerance. Pixels inside the radius around the given position
* will be checked for features.
*/
@@ -136,6 +147,12 @@ class Translate extends PointerInteraction {
*/
this.layerFilter_ = layerFilter;
/**
* @private
* @type {FilterFunction}
*/
this.filter_ = options.filter ? options.filter : TRUE;
/**
* @private
* @type {number}
@@ -245,9 +262,11 @@ class Translate extends PointerInteraction {
*/
featuresAtPixel_(pixel, map) {
return map.forEachFeatureAtPixel(pixel,
function(feature) {
if (!this.features_ || includes(this.features_.getArray(), feature)) {
return feature;
function(feature, layer) {
if (this.filter_(feature, layer)) {
if (!this.features_ || includes(this.features_.getArray(), feature)) {
return feature;
}
}
}.bind(this), {
layerFilter: this.layerFilter_,

View File

@@ -83,6 +83,9 @@ class BaseLayer extends BaseObject {
}
/**
* This method is not meant to be called by layers or layer renderers because the state
* is incorrect if the layer is included in a layer group.
*
* @param {boolean=} opt_managed Layer is managed.
* @return {import("./Layer.js").State} Layer state.
*/
@@ -90,7 +93,8 @@ class BaseLayer extends BaseObject {
/** @type {import("./Layer.js").State} */
const state = this.state_ || /** @type {?} */ ({
layer: this,
managed: opt_managed === undefined ? true : opt_managed
managed: opt_managed === undefined ? true : opt_managed,
hasOverlay: false
});
state.opacity = clamp(Math.round(this.getOpacity() * 100) / 100, 0, 1);
state.sourceState = this.getSourceState();

View File

@@ -72,8 +72,7 @@ class BaseVectorLayer extends Layer {
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
const options = opt_options ?
opt_options : /** @type {Options} */ ({});
const options = opt_options ? opt_options : {};
const baseOptions = assign({}, options);

View File

@@ -3,27 +3,27 @@
*/
import VectorLayer from './Vector.js';
import {assign} from '../obj.js';
import {degreesToStringHDMS} from '../coordinate';
import Text from '../style/Text';
import Fill from '../style/Fill';
import Stroke from '../style/Stroke';
import {degreesToStringHDMS} from '../coordinate.js';
import Text from '../style/Text.js';
import Fill from '../style/Fill.js';
import Stroke from '../style/Stroke.js';
import LineString from '../geom/LineString.js';
import VectorSource from '../source/Vector';
import VectorSource from '../source/Vector.js';
import {
equivalent as equivalentProjection,
get as getProjection,
getTransform,
transformExtent
} from '../proj';
import {getCenter, intersects, equals, getIntersection, isEmpty} from '../extent';
import {clamp} from '../math';
import Style from '../style/Style';
import Feature from '../Feature';
import {bbox} from '../loadingstrategy';
import {meridian, parallel} from '../geom/flat/geodesic';
import GeometryLayout from '../geom/GeometryLayout';
import Point from '../geom/Point';
import Collection from '../Collection';
} from '../proj.js';
import {getCenter, intersects, equals, getIntersection, isEmpty} from '../extent.js';
import {clamp} from '../math.js';
import Style from '../style/Style.js';
import Feature from '../Feature.js';
import {bbox} from '../loadingstrategy.js';
import {meridian, parallel} from '../geom/flat/geodesic.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import Point from '../geom/Point.js';
import Collection from '../Collection.js';
/**

View File

@@ -6,7 +6,7 @@ import {getChangeEventType} from '../Object.js';
import {createCanvasContext2D} from '../dom.js';
import VectorLayer from './Vector.js';
import {assign} from '../obj.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
/**

View File

@@ -45,6 +45,7 @@ import SourceState from '../source/State.js';
* @property {SourceState} sourceState
* @property {boolean} visible
* @property {boolean} managed
* @property {boolean} hasOverlay Set by the renderer when an overlay for points and text is used.
* @property {import("../extent.js").Extent} [extent]
* @property {number} zIndex
* @property {number} maxResolution
@@ -189,13 +190,15 @@ class Layer extends BaseLayer {
* In charge to manage the rendering of the layer. One layer type is
* bounded with one layer renderer.
* @param {?import("../PluggableMap.js").FrameState} frameState Frame state.
* @param {HTMLElement} target Target which the renderer may (but need not) use
* for rendering its content.
* @return {HTMLElement} The rendered element.
*/
render(frameState) {
render(frameState, target) {
const layerRenderer = this.getRenderer();
const layerState = this.getLayerState();
if (layerRenderer.prepareFrame(frameState, layerState)) {
return layerRenderer.renderFrame(frameState, layerState);
if (layerRenderer.prepareFrame(frameState)) {
return layerRenderer.renderFrame(frameState, target);
}
}
@@ -254,6 +257,13 @@ class Layer extends BaseLayer {
return this.renderer_;
}
/**
* @return {boolean} The layer has a renderer.
*/
hasRenderer() {
return !!this.renderer_;
}
/**
* Create a renderer for this layer.
* @return {import("../renderer/Layer.js").default} A layer renderer.

View File

@@ -5,11 +5,6 @@ import BaseTileLayer from './BaseTile.js';
import CanvasTileLayerRenderer from '../renderer/canvas/TileLayer.js';
/**
* @typedef {import("./BaseTile.js").Options} Options
*/
/**
* @classdesc
* For layer sources that provide pre-rendered, tiled images in grids that are
@@ -23,7 +18,7 @@ import CanvasTileLayerRenderer from '../renderer/canvas/TileLayer.js';
class TileLayer extends BaseTileLayer {
/**
* @param {Options=} opt_options Tile layer options.
* @param {import("./BaseTile.js").Options=} opt_options Tile layer options.
*/
constructor(opt_options) {
super(opt_options);

View File

@@ -5,11 +5,6 @@ import BaseVectorLayer from './BaseVector.js';
import CanvasVectorLayerRenderer from '../renderer/canvas/VectorLayer.js';
/**
* @typedef {import("./BaseVector.js").Options} Options
*/
/**
* @classdesc
* Vector data that is rendered client-side.
@@ -22,7 +17,7 @@ import CanvasVectorLayerRenderer from '../renderer/canvas/VectorLayer.js';
*/
class VectorLayer extends BaseVectorLayer {
/**
* @param {Options=} opt_options Options.
* @param {import("./BaseVector.js").Options=} opt_options Options.
*/
constructor(opt_options) {
super(opt_options);

View File

@@ -60,7 +60,7 @@ class VectorImageLayer extends BaseVectorLayer {
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : /** @type {Options} */ ({});
const options = opt_options ? opt_options : {};
const baseOptions = assign({}, options);
delete baseOptions.imageRatio;

View File

@@ -86,12 +86,12 @@ class VectorTileLayer extends BaseVectorLayer {
delete baseOptions.preload;
delete baseOptions.useInterimTilesOnError;
super(/** @type {import("./Vector.js").Options} */ (baseOptions));
super(/** @type {import("./BaseVector.js").Options} */ (baseOptions));
const renderMode = options.renderMode || VectorTileRenderType.HYBRID;
assert(renderMode == undefined ||
renderMode == VectorTileRenderType.IMAGE ||
renderMode == VectorTileRenderType.HYBRID,
renderMode == VectorTileRenderType.IMAGE ||
renderMode == VectorTileRenderType.HYBRID,
28); // `renderMode` must be `'image'` or `'hybrid'`
/**

View File

@@ -1,7 +1,6 @@
/**
* @module ol/math
*/
import {assert} from './asserts.js';
/**
* Takes a number and clamps it to within the provided bounds.
@@ -43,16 +42,6 @@ export const cosh = (function() {
}());
/**
* @param {number} x X.
* @return {number} The smallest power of two greater than or equal to x.
*/
export function roundUpToPowerOfTwo(x) {
assert(0 < x, 29); // `x` must be greater than `0`
return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2));
}
/**
* Returns the square of the closest distance between the point (x, y) and the
* line segment (x1, y1) to (x2, y2).

View File

@@ -63,10 +63,6 @@
border: 1px solid black;
}
.ol-overlay-container {
will-change: left,right,top,bottom;
}
.ol-unsupported {
display: none;
}
@@ -127,11 +123,6 @@
right: .5em;
top: .5em;
}
@media print {
.ol-control {
display: none;
}
}
.ol-control button {
display: block;

View File

@@ -34,7 +34,6 @@
import {listen, unlisten} from '../events.js';
import EventTarget from '../events/Target.js';
import {POINTER, MSPOINTER, TOUCH} from '../has.js';
import PointerEventType from './EventType.js';
import MouseSource, {prepareEvent as prepareMouseEvent} from './MouseSource.js';
import MsSource from './MsSource.js';
@@ -124,15 +123,15 @@ class PointerEventHandler extends EventTarget {
* that generate pointer events.
*/
registerSources() {
if (POINTER) {
if ('PointerEvent' in window) {
this.registerSource('native', new NativeSource(this));
} else if (MSPOINTER) {
} else if (window.navigator.msPointerEnabled) {
this.registerSource('ms', new MsSource(this));
} else {
const mouseSource = new MouseSource(this);
this.registerSource('mouse', mouseSource);
if (TOUCH) {
if ('ontouchstart' in window) {
this.registerSource('touch', new TouchSource(this, mouseSource));
}
}

View File

@@ -60,8 +60,8 @@ import {toEPSG4326, fromEPSG4326, PROJECTIONS as EPSG3857_PROJECTIONS} from './p
import {PROJECTIONS as EPSG4326_PROJECTIONS} from './proj/epsg4326.js';
import Projection from './proj/Projection.js';
import Units, {METERS_PER_UNIT} from './proj/Units.js';
import * as projections from './proj/projections.js';
import {add as addTransformFunc, clear as clearTransformFuncs, get as getTransformFunc} from './proj/transforms.js';
import {add as addProj, clear as clearProj, get as getProj} from './proj/projections.js';
/**
@@ -133,7 +133,7 @@ export function identityTransform(input, opt_output, opt_dimension) {
* @api
*/
export function addProjection(projection) {
projections.add(projection.getCode(), projection);
addProj(projection.getCode(), projection);
addTransformFunc(projection, projection, cloneTransform);
}
@@ -157,7 +157,7 @@ export function addProjections(projections) {
*/
export function get(projectionLike) {
return typeof projectionLike === 'string' ?
projections.get(/** @type {string} */ (projectionLike)) :
getProj(/** @type {string} */ (projectionLike)) :
(/** @type {Projection} */ (projectionLike) || null);
}
@@ -271,7 +271,7 @@ export function addEquivalentTransforms(projections1, projections2, forwardTrans
* Clear all cached projections and transforms.
*/
export function clearAllProjections() {
projections.clear();
clearProj();
clearTransformFuncs();
}

View File

@@ -122,9 +122,10 @@ export function renderDeclutterItems(frameState, declutterTree) {
}
const items = frameState.declutterItems;
for (let z = items.length - 1; z >= 0; --z) {
const zIndexItems = items[z];
const item = items[z];
const zIndexItems = item.items;
for (let i = 0, ii = zIndexItems.length; i < ii; i += 3) {
declutterTree = zIndexItems[i].renderDeclutter(zIndexItems[i + 1], zIndexItems[i + 2], declutterTree);
declutterTree = zIndexItems[i].renderDeclutter(zIndexItems[i + 1], zIndexItems[i + 2], item.opacity, declutterTree);
}
}
items.length = 0;

View File

@@ -12,9 +12,8 @@ class RenderEvent extends Event {
* CSS pixels to rendered pixels.
* @param {import("../PluggableMap.js").FrameState=} opt_frameState Frame state.
* @param {?CanvasRenderingContext2D=} opt_context Context.
* @param {?import("../webgl/Helper.js").default=} opt_glContext WebGL Context.
*/
constructor(type, opt_inversePixelTransform, opt_frameState, opt_context, opt_glContext) {
constructor(type, opt_inversePixelTransform, opt_frameState, opt_context) {
super(type);
@@ -41,14 +40,6 @@ class RenderEvent extends Event {
*/
this.context = opt_context;
/**
* WebGL context. Only available when a WebGL renderer is used, null
* otherwise.
* @type {import("../webgl/Helper.js").default|null|undefined}
* @api
*/
this.glContext = opt_glContext;
}
}

View File

@@ -403,7 +403,7 @@ export function drawImage(context,
context.drawImage(image, originX, originY, w, h, x, y, w * scale, h * scale);
if (alpha) {
if (opacity != 1) {
context.globalAlpha = alpha;
}
if (transform) {

Some files were not shown because too many files have changed in this diff Show More