Compare commits

...

349 Commits

Author SHA1 Message Date
ahocevar
a8b5dfa981 6.0.0-beta.15 2019-08-20 11:18:27 +02:00
Andreas Hocevar
42f1a7ed30 Merge pull request #9873 from ahocevar/another-vectortile-load-fix
Only check extent when a url tile coordinate is available
2019-08-20 11:08:04 +02:00
Andreas Hocevar
f3d6456876 Merge pull request #9876 from openlayers/greenkeeper/yargs-14.0.0
Update yargs to the latest version 🚀
2019-08-20 08:36:49 +02:00
greenkeeper[bot]
2ca13de4de chore(package): update lockfile package-lock.json 2019-08-19 23:21:53 +00:00
greenkeeper[bot]
87ae93ca2d chore(package): update yargs to version 14.0.0 2019-08-19 23:21:44 +00:00
ahocevar
5da32dbc5b More tests 2019-08-19 11:39:39 +02:00
ahocevar
6be2818f14 Handle empty url tile coord (no wrapx) 2019-08-19 11:01:03 +02:00
Andreas Hocevar
b602a6b33a Merge pull request #9871 from ahocevar/tile-load-key-change
Properly handle tile source key change
2019-08-19 08:08:31 +02:00
Andreas Hocevar
20a81ceb2f Merge pull request #9870 from ahocevar/declutter-multi-geometries
Declutter multi geometries per geometry instead of per feature
2019-08-19 08:06:39 +02:00
Andreas Hocevar
3d6cf24c26 Merge pull request #9872 from ahocevar/wrapx-extent
Check extent for wrapped tile coordinate
2019-08-18 18:10:24 +02:00
ahocevar
6a741d0504 Check extent for wrapped tile coordinate 2019-08-18 16:21:46 +02:00
ahocevar
aa55cce3ba Add rendering test for decluttered multipolygons 2019-08-18 15:43:41 +02:00
ahocevar
a5fbbef970 Always go through source tile change logic 2019-08-18 11:44:20 +02:00
ahocevar
25c8d93eba Fix test 2019-08-18 11:44:20 +02:00
Tim Schaub
eb294c78d1 Failing test 2019-08-18 08:58:59 +02:00
ahocevar
bd3f35eef0 Declutter multi geometries per geometry instead of per feature 2019-08-17 23:55:20 +02:00
Tim Schaub
f839b34594 Merge pull request #9869 from MoonE/master
Only get squared tolerance once per render
2019-08-17 07:23:22 -06:00
Tim Schaub
99462d3b53 Only get squared tolerance once per render 2019-08-17 07:10:10 -06:00
Maximilian Krög
200392785d Squared tolerance does not change for each style. 2019-08-17 11:15:06 +02:00
Tim Schaub
c0e5c4b7fe 6.0.0-beta.14 2019-08-16 07:03:28 -06:00
ahocevar
189ad24528 Adjust expected image for CircleCI 2019-08-16 13:22:18 +02:00
ahocevar
4aa11ecc94 Remove lint 2019-08-16 13:05:46 +02:00
Andreas Hocevar
e61c5c07bc Merge pull request #9389 from KaiVolland/tile-rendering
Replaces listener test in tile.tests.js and removes artifacts
2019-08-16 13:02:48 +02:00
Tim Schaub
0212ce6554 Merge pull request #9855 from tschaub/vector-tile-loading
Make sure vector tile load handler is called
2019-08-16 04:05:11 -06:00
Tim Schaub
b76a0379dd Merge pull request #9864 from tschaub/opacity
Properly update frameState.animate and deal with non-numeric layer opacity
2019-08-15 15:09:14 -06:00
Tim Schaub
e94c7b6c39 Only set frameState.animate true if in transition and alpha < 1 2019-08-15 12:55:27 -06:00
Tim Schaub
2c69ad2bb4 Throw on non-numeric opacity values 2019-08-15 12:55:13 -06:00
Tim Schaub
e8e7c46463 Merge pull request #9858 from tschaub/audit-fix
Run npm audit fix
2019-08-13 16:42:43 -06:00
Tim Schaub
abda7f4f1d Separate lookups for source tiles by tile coord and tile key 2019-08-13 16:40:01 -06:00
Tim Schaub
e8500c395c Run npm audit fix 2019-08-13 16:28:18 -06:00
Tim Schaub
6f5a066bab Merge pull request #9856 from openlayers/greenkeeper/webpack-4.39.2
Update webpack to the latest version 🚀
2019-08-13 16:26:50 -06:00
Tim Schaub
08816ec9f9 Merge pull request #9857 from openlayers/greenkeeper/karma-chrome-launcher-3.1.0
Update karma-chrome-launcher to the latest version 🚀
2019-08-13 16:26:16 -06:00
greenkeeper[bot]
fac659fa0a chore(package): update lockfile package-lock.json 2019-08-13 19:40:27 +00:00
greenkeeper[bot]
b0069c3c5d chore(package): update karma-chrome-launcher to version 3.1.0 2019-08-13 19:40:15 +00:00
greenkeeper[bot]
e7be28d2b5 chore(package): update lockfile package-lock.json 2019-08-13 18:10:17 +00:00
greenkeeper[bot]
15aa5ebc1f chore(package): update webpack to version 4.39.2 2019-08-13 18:10:00 +00:00
Tim Schaub
a9ad24cce2 6.0.0-beta.13 2019-08-12 21:22:15 -06:00
Andreas Hocevar
486eb205cb Merge pull request #9844 from ahocevar/empty-vectorrendertile
Set initial tile state to EMPTY when outside source extent
2019-08-11 21:50:50 +02:00
ahocevar
28e64f646f Set initial tile state to EMPTY when outside source extent 2019-08-11 00:13:18 +02:00
Andreas Hocevar
78cf32ae70 Merge pull request #9839 from mike-000/patch-1
Enable correct display of side-by-side example when not using the examples template
2019-08-09 00:40:38 +02:00
mike-000
a340da8f6e Update side-by-side.css 2019-08-08 22:48:08 +01:00
mike-000
336056f4f0 Update side-by-side.html 2019-08-08 22:40:37 +01:00
Andreas Hocevar
e31e4b7867 Merge pull request #9838 from ahocevar/wms-servertype
Make WMSServerType appear in API docs
2019-08-08 21:36:52 +02:00
ahocevar
683c0ef5dc Make WMSServerType appear in API docs 2019-08-08 21:29:29 +02:00
Andreas Hocevar
23179e9ac5 Merge pull request #9754 from mike-000/patch-1
Export PDF example extent corrections
2019-08-08 21:07:49 +02:00
mike-000
7cdfc33d15 Export PDF example extent corrections
Fixes #9460 and #9665

Replace calculateExtent and fit with getResolution and setResolution as the former do not produce the desired result when the view is rotated.

Export the viewport instead of the map div (which doesn't resize) and specify the width and height in the export options

This is a minimal fix for the two issues.  Further enhancement including a fallback to export layer canvases where the browser doesn't support html-to-image could be done separately if necessary.
2019-08-08 19:41:51 +02:00
Andreas Hocevar
776dab81b8 Merge pull request #9834 from ahocevar/nextzen
Use nextzen for osm-vector-tiles example
2019-08-08 18:38:56 +02:00
ahocevar
182f1448a9 Use nextzen for osm-vector-tiles example 2019-08-08 12:57:55 +02:00
Andreas Hocevar
9b6fcf8d7b Merge pull request #9833 from ahocevar/remove-package-lock
Remove accidentally added package-lock.json
2019-08-08 12:52:33 +02:00
ahocevar
bd1c8db7a3 Remove accidentally added package-lock.json 2019-08-08 12:35:24 +02:00
Tim Schaub
0fb638fcb6 Merge pull request #9817 from openlayers/greenkeeper/webpack-4.39.1
Update webpack to the latest version 🚀
2019-08-07 06:38:10 -06:00
Tim Schaub
effb95b322 Merge pull request #9827 from openlayers/greenkeeper/coveralls-3.0.6
Update coveralls to the latest version 🚀
2019-08-07 06:37:12 -06:00
Tim Schaub
e5ac326f1c Merge pull request #9826 from tschaub/publish-options
Accept additional args when publishing
2019-08-07 06:33:14 -06:00
greenkeeper[bot]
2d0d06842d chore(package): update lockfile package-lock.json 2019-08-07 07:41:55 +00:00
greenkeeper[bot]
7355906c3a chore(package): update coveralls to version 3.0.6 2019-08-07 07:41:48 +00:00
Andreas Hocevar
ec10cda088 Merge pull request #9812 from ahocevar/zdirection
Make zDirection configurable on tile source
2019-08-07 08:56:23 +02:00
Tim Schaub
d59eed5d3b Accept additional args when publishing 2019-08-07 00:01:57 -04:00
Tim Schaub
dec44a7202 6.0.0-beta.12 2019-08-06 23:49:25 -04:00
Tim Schaub
082e160212 Merge pull request #9824 from tschaub/zooms
Support zoom limits for layers
2019-08-06 21:32:26 -04:00
Tim Schaub
65ad4932f4 Support zoom limits for layers 2019-08-06 21:19:09 -04:00
greenkeeper[bot]
d4980754ad chore(package): update webpack to version 4.39.1 2019-08-02 12:51:21 +00:00
Andreas Hocevar
c767091faf Merge pull request #9816 from openlayers/greenkeeper/webpack-4.39.0
Update webpack to the latest version 🚀
2019-08-02 13:28:07 +02:00
greenkeeper[bot]
d8aec039a9 chore(package): update webpack to version 4.39.0 2019-08-01 16:07:39 +00:00
ahocevar
e07ff9c04e Make zDirection configurable on tile source 2019-07-30 16:50:01 +02:00
Marc Jansen
230205c3fd Merge pull request #9804 from mike-000/9799
Replacement for the Shared Views example
2019-07-26 21:50:31 +02:00
mike-000
c66347c365 Update side-by-side.js 2019-07-26 16:31:20 +01:00
Frédéric Junod
bf2a13138d Merge pull request #9803 from openlayers/mp_cleanup
Remove unused variable in MousePosition control
2019-07-26 15:52:09 +02:00
Andreas Hocevar
8f85b1ba23 Merge pull request #9802 from ahocevar/empty-image
Introduce EMPTY image state to deal with images outside the view extent
2019-07-26 15:35:30 +02:00
mike-000
576fc6a82e Update side-by-side.js 2019-07-26 14:23:49 +01:00
mike-000
1e1a6d0939 Update side-by-side.js 2019-07-26 14:17:42 +01:00
mike-000
8034b72231 Update side-by-side.html 2019-07-26 14:02:37 +01:00
Frederic Junod
2d2f4eb1a2 Remove unused variable in MousePosition control
`this.lastMouseMovePixel_` value is never read.
2019-07-26 14:54:14 +02:00
mike-000
ac9b435a74 Create side-by-side.js 2019-07-26 13:36:51 +01:00
mike-000
9946554575 Create side-by-side.css 2019-07-26 13:34:28 +01:00
mike-000
e6458222c1 Create side-by-side.html 2019-07-26 13:32:28 +01:00
ahocevar
62d8760420 Introduce EMPTY image state to deal with images outside the view extent 2019-07-26 13:47:35 +02:00
Frédéric Junod
1cc92b4751 Merge pull request #9801 from openlayers/greenkeeper/webpack-4.38.0
Update webpack to the latest version 🚀
2019-07-26 11:45:25 +02:00
greenkeeper[bot]
8bf0284443 chore(package): update webpack to version 4.38.0 2019-07-26 07:50:01 +00:00
Andreas Hocevar
17551d2f08 Merge pull request #9795 from openlayers/greenkeeper/webpack-4.37.0
Update webpack to the latest version 🚀
2019-07-24 01:37:38 +02:00
greenkeeper[bot]
3f47a7e7be chore(package): update webpack to version 4.37.0 2019-07-23 21:39:52 +02:00
Andreas Hocevar
0cc1166a2d Merge pull request #9797 from ahocevar/vectortile-false-positives
Avoid false positives for line and polygon hit detection
2019-07-23 21:32:22 +02:00
Marc Jansen
6d09acc0d3 Merge pull request #9794 from marcjansen/fix-lint
Fix linting error (import extension missing)
2019-07-23 20:10:22 +02:00
ahocevar
ba9cdd3aa2 Fix rendering tests 2019-07-23 19:28:28 +02:00
ahocevar
387f797f23 Avoid false positives for line and polygon hit detection 2019-07-23 19:24:27 +02:00
Marc Jansen
f6fba61b47 Fix linting error (import extension missing) 2019-07-23 11:52:31 +02:00
Marc Jansen
15cbd69457 Merge pull request #9792 from marcjansen/better-getgetlegendgraphicurl
Improve documentation of getGetLegendGraphicUrl
2019-07-23 11:38:32 +02:00
Andreas Hocevar
3dca01490f Merge pull request #9793 from openlayers/greenkeeper/puppeteer-1.19.0
Update puppeteer to the latest version 🚀
2019-07-23 10:18:25 +02:00
Marc Jansen
b9c2ef389c Merge pull request #9375 from KaiVolland/reproj-rendering
Replaces reproj image.tests.js and tile.tests.js
2019-07-23 08:20:28 +02:00
greenkeeper[bot]
6000b296e2 chore(package): update puppeteer to version 1.19.0 2019-07-23 05:09:59 +00:00
Marc Jansen
2869ed245c Improve documentation of getGetLegendGraphicUrl
This also adresses one review comment by @jahow on #9762.
2019-07-22 17:02:30 +02:00
Marc Jansen
993bf0d2cb Merge pull request #9762 from KlausBenndorf/get-legend-request
Get legend request
2019-07-22 13:54:01 +02:00
Andreas Hocevar
2dda7127ed Merge pull request #9789 from ahocevar/decode-if-src-only
Use Image.prototype.decode only when src is already set
2019-07-22 09:18:56 +02:00
ahocevar
3cef9f2e00 Use Image.prototype.decode only when src is already set 2019-07-19 17:09:24 +02:00
Andreas Hocevar
6948bb7ebb Merge pull request #9778 from ahocevar/faster-getsourcetiles
Return existing source tiles if at target resolution
2019-07-19 16:55:25 +02:00
Frédéric Junod
7a0619447c Merge pull request #9787 from openlayers/greenkeeper/mocha-6.2.0
Update mocha to the latest version 🚀
2019-07-19 11:40:41 +02:00
greenkeeper[bot]
30925b4250 chore(package): update mocha to version 6.2.0 2019-07-18 22:39:09 +00:00
Andreas Hocevar
f232622ad4 Merge pull request #9786 from openlayers/greenkeeper/webpack-4.36.1
chore(package): update webpack to version 4.36.1
2019-07-18 11:18:59 +02:00
greenkeeper[bot]
3a20993d1f chore(package): update webpack to version 4.36.1
Closes #9781
2019-07-17 14:16:32 +00:00
ahocevar
612dd6fe28 Return existing source tiles if at target resolution 2019-07-16 22:09:24 +02:00
Tim Schaub
dc3ab508d4 Merge pull request #9622 from kekel87/master
Avoid mutating input in EsriJSON format
2019-07-15 14:35:58 -07:00
Andreas Hocevar
ff063caa4e Merge pull request #9755 from ahocevar/font-loading
Font loading improvements
2019-07-15 12:21:28 +02:00
Olivier Guyot
a629b7e5f2 Merge pull request #9767 from jahow/webgl-hit-retina
Fix hit detection for webgl layers on retina devices
2019-07-15 09:06:59 +02:00
Andreas Hocevar
99c920d393 Merge pull request #9774 from ahocevar/observable-properties-docs
Fix observable properties documentation
2019-07-15 00:46:53 +02:00
Tim Schaub
26950a2fca Merge pull request #9775 from openlayers/greenkeeper/jsdoc-3.6.3
Update jsdoc to the latest version 🚀
2019-07-14 11:11:46 -07:00
greenkeeper[bot]
5aabff5821 chore(package): update jsdoc to version 3.6.3 2019-07-14 17:36:55 +00:00
Michael Parry
a8e31dddee FIx #9510: EsriJSON readGeometry should not mutate input 2019-07-14 18:56:49 +02:00
ahocevar
b6bd35c15c Fix observable properties documentation 2019-07-14 10:15:00 +02:00
Frédéric Junod
5222a0ffd6 Merge pull request #9772 from openlayers/greenkeeper/karma-chrome-launcher-3.0.0
Update karma-chrome-launcher to the latest version 🚀
2019-07-13 08:42:57 +02:00
Frédéric Junod
f43898bac1 Merge pull request #9769 from openlayers/greenkeeper/coveralls-3.0.5
Update coveralls to the latest version 🚀
2019-07-13 08:42:24 +02:00
Frédéric Junod
dd683855f2 Merge pull request #9759 from openlayers/greenkeeper/marked-0.7.0
Update marked to the latest version 🚀
2019-07-13 08:41:54 +02:00
greenkeeper[bot]
6812e13490 chore(package): update karma-chrome-launcher to version 3.0.0 2019-07-12 23:38:02 +00:00
greenkeeper[bot]
e8794e78a1 chore(package): update coveralls to version 3.0.5 2019-07-12 02:40:13 +00:00
Olivier Guyot
2f3e8d04f1 Webgl points / fix hit detection for retina devices 2019-07-11 00:05:55 +02:00
jahow
a0ff08b734 Webgl points / improve tests
Now testing with two features and adding a call to `prepareFrame`
without which the final render transform was off.
Also added a test with a pixelratio > 1.
2019-07-11 00:05:55 +02:00
Andreas Hocevar
32325bc4ab Merge pull request #9763 from openlayers/greenkeeper/webpack-4.35.3
Update webpack to the latest version 🚀
2019-07-08 17:34:23 +02:00
greenkeeper[bot]
0ddc7da2f8 chore(package): update webpack to version 4.35.3 2019-07-08 14:33:48 +00:00
simonseyock
c0000e745e make resolution in getGetLegendGraphicUrl optional 2019-07-08 15:14:13 +02:00
Kai Volland
f493f01bd0 Introduces getGetLegendGraphic method
Adds the `getGetLegendGraphic` method to `ImageWMS` and `TileWMS` source.
Also adds an example and corresponding tests.
2019-07-08 15:14:13 +02:00
greenkeeper[bot]
22e1bb0e2f chore(package): update marked to version 0.7.0 2019-07-06 04:14:39 +00:00
Frédéric Junod
7e3ed92ba6 Merge pull request #9757 from fredj/canvas_types
Use CanvasLineJoin and CanvasLienCap types instead of string
2019-07-05 17:55:17 +02:00
Frederic Junod
ad51c7c08f Use CanvasLineCap type instead of string 2019-07-05 11:11:35 +02:00
Frederic Junod
7a8a0c18ae Use CanvasLineJoin type instead of string 2019-07-05 11:07:10 +02:00
Frédéric Junod
5cff84522a Merge pull request #9745 from fredj/misc_webgl
Simplify heatmap's shaders
2019-07-05 08:27:08 +02:00
Frédéric Junod
562f14fc83 Merge pull request #9748 from fredj/rm_hit_transform
Remove hit detection transforms from ol/renderer/webgl/PointsLayer
2019-07-05 08:21:04 +02:00
Andreas Hocevar
79fc4bafe6 Merge pull request #9752 from mike-000/mike-000-9750
Custom Animation example and the multiWorld view constraint
2019-07-04 23:04:05 +02:00
ahocevar
4b48997a0b Check font style and weight in addition to family 2019-07-04 16:12:35 +02:00
ahocevar
ab2d97d49b Don't give up too early when waiting for fonts 2019-07-04 16:11:39 +02:00
ahocevar
5616c535b0 Clean up properly when clearing label cache 2019-07-04 16:10:28 +02:00
ahocevar
b4306da7bb Fix font comparison, less context.font operations 2019-07-04 16:06:13 +02:00
Frédéric Junod
32d1d9214c Merge pull request #9751 from logan-bounet/set-minarea-in-dragzoom
Add minArea typedef and ctor prop in DragZoom
2019-07-04 09:34:41 +02:00
mike-000
12d21689c6 Stop the default multiWorld constraint being applied on Custom Animation example
For zoom: 1 to be reached the default extent constraint must be removed by adding multiWorld: true
2019-07-03 17:36:07 +01:00
Logan BOUNET
87d80be915 Add minArea typedef and ctor prop in DragZoom 2019-07-03 10:29:13 -04:00
Frederic Junod
89295b0359 Remove hit detection transforms from ol/renderer/webgl/PointsLayer 2019-07-03 10:38:13 +02:00
Andreas Hocevar
621a573dd8 Merge pull request #9747 from ahocevar/format-setprojection-tilepixels-only
Set world projection only for tile-pixels units
2019-07-03 08:25:25 +02:00
Frederic Junod
73032db345 Remove unused 'v_screenCoord' from fragment shader 2019-07-03 08:16:37 +02:00
Tim Schaub
1f86818250 Merge pull request #9744 from openlayers/greenkeeper/webpack-4.35.2
chore(package): update webpack to version 4.35.2
2019-07-02 16:03:22 -06:00
ahocevar
534afae345 Set world projection only for tile-pixels units 2019-07-02 23:03:22 +02:00
Tim Schaub
ac3072d888 Merge pull request #9743 from lutzhelm/iiif-v3beta
Finalize IIIF Image API version 3
2019-07-02 08:28:14 -06:00
Lutz Helm
018a7e2753 Remove superfluous comma 2019-07-02 13:50:29 +02:00
Lutz Helm
3cc18b6ea1 Test full region zoom levels with IIIF Image API v3 tile source 2019-07-02 13:39:23 +02:00
Lutz Helm
0507132a21 Correct and test IIIF version 3 image info parser 2019-07-02 13:21:09 +02:00
Lutz Helm
7147dce4d0 Remove unused code in IIIFInfo parser 2019-07-02 09:52:08 +02:00
Lutz Helm
cc976dd4ad Adjust IIIF info parsing to 3.0-beta spec
- respect `preferredFormats`
- correct compliance level profile formats and features
2019-07-01 17:51:52 +02:00
greenkeeper[bot]
dfd7b1f24f chore(package): update webpack to version 4.35.2
Closes #9740
2019-07-01 13:04:21 +00:00
Frederic Junod
bb35a03704 Don't rotate the points of the heatmap layer 2019-07-01 11:29:27 +02:00
Frederic Junod
ed340d7e2c Remove unused 'resolution' uniform from fragment shader 2019-07-01 10:00:55 +02:00
Frederic Junod
24e4f41452 Use size property from the frameState instead of creating new array 2019-07-01 09:44:37 +02:00
Andreas Hocevar
f44a199bae Merge pull request #9738 from openlayers/greenkeeper/marked-0.6.3
Update marked to the latest version 🚀
2019-06-30 12:36:05 +02:00
greenkeeper[bot]
37af683630 chore(package): update marked to version 0.6.3 2019-06-30 02:13:29 +00:00
Andreas Hocevar
bb756bdc2c Merge pull request #9737 from openlayers/greenkeeper/globby-10.0.0
Update globby to the latest version 🚀
2019-06-29 23:01:20 +02:00
greenkeeper[bot]
f3ea4e0301 chore(package): update globby to version 10.0.0 2019-06-29 18:02:47 +00:00
Andreas Hocevar
4a3e4c7c23 Merge pull request #9733 from ahocevar/apidoc-fixes
Get rid of JSDoc warnings and fix fires arguments
2019-06-29 14:40:08 +02:00
ahocevar
cb77f9e3dd Get rid of JSDoc warnings and fix fires arguments 2019-06-29 10:25:35 +02:00
Andreas Hocevar
8ff29f8431 Merge pull request #9732 from ahocevar/vectortile-empty-key
Fix EMPTY state and source key handling
2019-06-29 10:18:53 +02:00
ahocevar
c4937bc716 Fix EMPTY state and source key handling 2019-06-28 23:25:36 +02:00
Frédéric Junod
abb696d0fa Merge pull request #9724 from fredj/fix_import_in_tutorial
Fix wrong import in tutorial
2019-06-28 16:13:17 +02:00
Frédéric Junod
75a0a0ed49 Merge pull request #9722 from fredj/rm_unused
Remove unused param in getState function
2019-06-28 16:13:02 +02:00
Olivier Guyot
d9a4f37f75 Merge pull request #9655 from jahow/webgl-interaction
Add hit detection on the WebGL points renderer
2019-06-28 11:22:03 +02:00
Frederic Junod
933a6297bb Remove unused hasFeatureAtCoordinate from ol/renderer/Layer 2019-06-28 11:10:33 +02:00
jahow
3bca9b5297 Webgl / use feature index for hit detection in points layer
For each feature its opacity value index is encoded on 4 bytes
in the color values, and the uid is stored in the opacity
value, allowing for a much higher range of uids to be read.
2019-06-28 09:12:20 +02:00
Olivier Guyot
28b99767f8 Webgl points / read only one pixel for feature hit detection
Also implements `hasFeatureAtCoordinate`.

`hitTolerance` is not supported for now.
2019-06-28 09:12:20 +02:00
Olivier Guyot
e852294938 Webgl / improve reading of render targets data
Now two methods are available: `readAll` and `readPixel`,
and the data from the render target is not re-read every time unless
`clearCachedData` is called.
2019-06-28 09:12:20 +02:00
Olivier Guyot
917950a32b Improve icon-sprite-webgl example to include hit detection 2019-06-28 09:12:20 +02:00
Olivier Guyot
5ffca0633c Webgl Points / Add support for feature hit detection
For now only `forEachFeatureAtCoordinate` is implemented.

Each time the viewport is rendered, another similar render pass is
done using the specific hit detection instructions. Feature uid's are
encoded in the r,g,b,a channels and can then be decoded on the fly.

Note: the `readPixels` operation is taking a lot of time,
around 10-20ms each frame.
2019-06-28 09:12:20 +02:00
Olivier Guyot
38920867fb Webgl Helper / Add a method to prepare drawing to render targets 2019-06-28 09:12:20 +02:00
Olivier Guyot
6224d749c4 WebGL / Introduced the WebGLRenderTarget class
This utility class simplifies rendering to a texture & reading the
results of the render.

It also allows clearing its content before a new render.
2019-06-28 09:12:20 +02:00
Olivier Guyot
1257ade199 Webgl renderer / rename function to avoid confusion
`getBlankTexture` was too close to `WebGLHelper#createTexture`
2019-06-28 09:12:20 +02:00
Olivier Guyot
f25a16d90c Webgl helper / rework create texture utils
Now only one util is available: `createTexture`, which
is tested and allows binding an image and reusing an existing texture.
2019-06-28 09:12:20 +02:00
Olivier Guyot
b6425187de Remove unused WebGLShader class 2019-06-28 09:06:16 +02:00
Olivier Guyot
2b5e5459ab Webgl points / add hit detection buffers generation
Hit detection is done by rendering features with their id encoded in the
color attribute. A parallel set of render instructions and a second
vertex buffer is used specifically for that.
2019-06-28 09:06:16 +02:00
Olivier Guyot
8145b358c0 Webgl renderer / add id encode/decode utils 2019-06-28 09:06:16 +02:00
Olivier Guyot
034e0be76f Vector Source / index all features by uid
Previously features were indexed by uid only when they
did not have a defined id.
A new method was added: `getFeatureByUid`. This is not part of
the public API.
This will facilitate the lookup of features for hit detection.
2019-06-28 09:06:16 +02:00
Andreas Hocevar
6b60b25e8b Merge pull request #9728 from ahocevar/remove-package-lock
Remove accidently added package-lock.json
2019-06-28 09:04:39 +02:00
ahocevar
9bceccb5d1 Remove accidently added package-lock.json 2019-06-27 22:05:20 +02:00
Frederic Junod
0497225d5d Fix wrong import in tutorial 2019-06-27 17:01:46 +02:00
Frederic Junod
49a65568d8 Remove unused param in getState function 2019-06-27 15:07:59 +02:00
Tim Schaub
a4b76b2a00 Merge pull request #9719 from petrsloup/special-maptiler-key
Use special MapTiler API key dedicated for OpenLayers examples
2019-06-25 17:41:32 -06:00
Petr Sloup
61fdf965ba Use special MapTiler API key dedicated for OpenLayers examples 2019-06-25 16:34:58 +02:00
Frédéric Junod
9e928b996c Merge pull request #9714 from fredj/f9662
Update the circle style after setRadius calls
2019-06-25 16:15:48 +02:00
Frédéric Junod
3d60dfdeeb Merge pull request #9718 from fredj/cleanup
Remove unused variable in ol/renderer/webgl/PointsLayer
2019-06-25 15:37:23 +02:00
Frederic Junod
54c670de77 Remove unused variable in ol/renderer/webgl/PointsLayer 2019-06-25 15:24:00 +02:00
Frederic Junod
9aa11d2e11 Update the circle style after setRadius calls 2019-06-25 10:42:52 +02:00
Frederic Junod
0d6368d4ec Remove underscore from protected function, fix indentation, remove typecast 2019-06-25 10:40:11 +02:00
Frédéric Junod
caac90e8d7 Merge pull request #9711 from fredj/viewParams_space
Remove extra space for the 'viewParams' attribute
2019-06-25 08:29:22 +02:00
Tim Schaub
7464cedff7 6.0.0-beta.11 2019-06-24 17:06:04 -06:00
Tim Schaub
51c49e36bc Merge pull request #9712 from tschaub/mvt-id
Allow an arbitrary tag to be used as feature id
2019-06-24 16:42:06 -06:00
Andreas Hocevar
b29099a278 Merge pull request #9709 from ahocevar/circleci-puppeteer
Try to make rendering tests run again in puppeteer
2019-06-24 21:59:32 +02:00
Tim Schaub
08c494dd11 Allow an arbitrary tag to be used as feature id 2019-06-24 12:01:12 -06:00
Frederic Junod
c428421586 Remove extra space for the 'viewParams' attribute 2019-06-24 16:28:04 +02:00
ahocevar
c0a2549285 Try to make rendering tests run again in puppeteer 2019-06-24 10:20:47 +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
engsterhold
f77b0941b8 fixed styling 2019-05-17 13:52:10 +02:00
ahocevar
b0fae46aa6 Do not use css z-index 2019-05-16 22:29:32 +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
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
Kai Volland
c9939d2bff Replaces reproj image.tests.js and tile.tests.js
Transforms the old rendering tests for
ReprojImage and ReprojTile to the new
rendering test approach.
2019-04-03 11:01:32 +02:00
Kai Volland
94edf32540 Removes artifacts of old rendering test approach
Data and comparison images of the old rendering test approach
are removed as every test is transformed to the new approach.
2019-04-01 15:56:03 +02:00
Kai Volland
91d2f98774 Replaces listener test in tile.tests.js
Transforms the old render listener test to
the new rendering test approach.
2019-04-01 15:53:19 +02:00
280 changed files with 16009 additions and 2203 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,9 +4,19 @@
#### Backwards incompatible changes #### 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` #### Removal of `GEOLOCATION` constant from `ol/has`
If you were previously using this constant, you can check if `'geolocation'` is define in `navigator` instead. If you were previously using this constant, you can check if `'geolocation'` is defined in `navigator` instead.
```js ```js
if ('geolocation' in navigator) { if ('geolocation' in navigator) {

View File

@@ -31,6 +31,24 @@ function hasApiMembers(doclet) {
} }
function includeAugments(doclet) { function includeAugments(doclet) {
// Make sure that `observables` and `fires` are taken from an already processed `class` doclet.
// This is necessary because JSDoc generates multiple doclets with the same longname.
const cls = classes[doclet.longname];
if (cls.observables && !doclet.observables) {
doclet.observables = cls.observables;
}
if (doclet.fires && cls.fires) {
for (let i = 0, ii = cls.fires.length; i < ii; ++i) {
const fires = cls.fires[i];
if (doclet.fires.indexOf(fires) == -1) {
doclet.fires.push(fires);
}
}
}
if (cls.fires && !doclet.fires) {
doclet.fires = cls.fires;
}
const augments = doclet.augments; const augments = doclet.augments;
if (augments) { if (augments) {
let cls; let cls;
@@ -59,7 +77,9 @@ function includeAugments(doclet) {
}); });
} }
cls._hideConstructor = true; cls._hideConstructor = true;
delete cls.undocumented; if (!cls.undocumented) {
cls._documented = true;
}
} }
} }
} }
@@ -146,10 +166,13 @@ exports.handlers = {
// constructor from the docs. // constructor from the docs.
doclet._hideConstructor = true; doclet._hideConstructor = true;
includeAugments(doclet); includeAugments(doclet);
} else if (doclet.undocumented !== false && !doclet._hideConstructor && !(doclet.kind == 'typedef' && doclet.longname in types)) { } else if (!doclet._hideConstructor && !(doclet.kind == 'typedef' && doclet.longname in types)) {
// Remove all other undocumented symbols // Remove all other undocumented symbols
doclet.undocumented = true; doclet.undocumented = true;
} }
if (doclet._documented) {
delete doclet.undocumented;
}
} }
} }

View File

@@ -214,55 +214,39 @@ function buildNav(members) {
} }
return 0; 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) { _.each(merged, function(v) {
// exclude interfaces from sidebar // exclude interfaces from sidebar
if (v.interface !== true) { if (v.interface !== true) {
if (v.kind == 'module') { if (v.kind == 'module') {
nav.push({ nav.push(createEntry('module', v));
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
})
});
} }
} }
}); });

View File

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

View File

@@ -18,7 +18,7 @@
<sup class="variation"><?js= doc.variation ?></sup> <sup class="variation"><?js= doc.variation ?></sup>
<?js } ?></h2> <?js } ?></h2>
<br> <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 ancestors = doc.ancestors.map(a => a.replace(/>\./g, '>').replace(/\.</g, '<')).join('/');
var parts = []; var parts = [];
if (ancestors) { if (ancestors) {
@@ -26,7 +26,20 @@
} }
var importPath = parts.join('/'); 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 } ?>
<?js if (doc.classdesc) { ?> <?js if (doc.classdesc) { ?>
<div class="class-description"><?js= doc.classdesc ?></div> <div class="class-description"><?js= doc.classdesc ?></div>
@@ -143,6 +156,7 @@
<h3 class="subsection-title">Methods</h3> <h3 class="subsection-title">Methods</h3>
<dl><?js methods.forEach(function(m) { ?> <dl><?js methods.forEach(function(m) { ?>
<?js m.parent = doc ?>
<?js= self.partial('method.tmpl', m) ?> <?js= self.partial('method.tmpl', m) ?>
<?js }); ?></dl> <?js }); ?></dl>
<?js } ?> <?js } ?>

View File

@@ -27,6 +27,10 @@ var self = this;
</dt> </dt>
<dd class="<?js= (data.stability && data.stability !== 'stable') ? 'unstable' : '' ?>"> <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) { ?> <?js if (data.description) { ?>
<div class="description"> <div class="description">
<?js= data.description ?> <?js= data.description ?>

View File

@@ -10,11 +10,12 @@ function toShortName(name) {
</div> </div>
<ul class="list"> <ul class="list">
<?js <?js
this.nav.forEach(function (item) { let navbuilder;
this.nav.forEach(navbuilder = function (item) {
?> ?>
<li class="item" data-name="<?js= item.longname ?>"> <li class="item" data-name="<?js= item.longname ?>">
<span class="title"> <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' && <?js if (item.type === 'namespace' &&
(item.members.length + item.typedefs.length + item.methods.length + (item.members.length + item.typedefs.length + item.methods.length +
item.events.length > 0)) { ?> item.events.length > 0)) { ?>
@@ -22,6 +23,18 @@ function toShortName(name) {
</span> </span>
<ul class="members itemMembers"> <ul class="members itemMembers">
<?js <?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) { if (item.members.length) {
?> ?>
<span class="subtitle">Members</span> <span class="subtitle">Members</span>

View File

@@ -228,3 +228,15 @@ Missing or invalid `size`.
### 61 ### 61
Cannot determine IIIF Image API version from provided image information JSON. 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.
### 64
Layer opacity must be a number.

View File

@@ -75,7 +75,7 @@ The above snippets can be combined into a single script that renders a map with
import Map from 'ol/Map'; import Map from 'ol/Map';
import View from 'ol/View'; import View from 'ol/View';
import OSM from 'ol/source/OSM'; import OSM from 'ol/source/OSM';
import TileLayer from 'ol/source/Tile'; import TileLayer from 'ol/layer/Tile';
new Map({ new Map({
layers: [ 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 {OSM, Vector as VectorSource} from '../src/ol/source.js';
import {Circle as CircleStyle, Fill, Stroke, Style} from '../src/ol/style.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({ const source = new VectorSource({
url: 'data/geojson/switzerland.geojson', url: 'data/geojson/switzerland.geojson',
format: new GeoJSON() format: new GeoJSON()
@@ -51,21 +52,21 @@ const zoomtoswitzerland =
document.getElementById('zoomtoswitzerland'); document.getElementById('zoomtoswitzerland');
zoomtoswitzerland.addEventListener('click', function() { zoomtoswitzerland.addEventListener('click', function() {
const feature = source.getFeatures()[0]; 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]}); view.fit(polygon, {padding: [170, 50, 30, 150]});
}, false); }, false);
const zoomtolausanne = document.getElementById('zoomtolausanne'); const zoomtolausanne = document.getElementById('zoomtolausanne');
zoomtolausanne.addEventListener('click', function() { zoomtolausanne.addEventListener('click', function() {
const feature = source.getFeatures()[1]; 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}); view.fit(point, {padding: [170, 50, 30, 150], minResolution: 50});
}, false); }, false);
const centerlausanne = document.getElementById('centerlausanne'); const centerlausanne = document.getElementById('centerlausanne');
centerlausanne.addEventListener('click', function() { centerlausanne.addEventListener('click', function() {
const feature = source.getFeatures()[1]; 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(); const size = map.getSize();
view.centerOn(point.getCoordinates(), size, [570, 500]); view.centerOn(point.getCoordinates(), size, [570, 500]);
}, false); }, false);

View File

@@ -129,7 +129,7 @@ const map = new Map({
layers: [ layers: [
new TileLayer({ new TileLayer({
source: new TileJSON({ 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({ new VectorLayer({

2
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 View from '../src/ol/View.js';
import {getWidth, getCenter} from '../src/ol/extent.js'; import {getWidth, getCenter} from '../src/ol/extent.js';
import {Layer, Tile as TileLayer} from '../src/ol/layer.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 {fromLonLat, toLonLat} from '../src/ol/proj.js';
import Stamen from '../src/ol/source/Stamen.js'; import Stamen from '../src/ol/source/Stamen.js';

View File

@@ -65,18 +65,18 @@ exportButton.addEventListener('click', function() {
const width = Math.round(dim[0] * resolution / 25.4); const width = Math.round(dim[0] * resolution / 25.4);
const height = Math.round(dim[1] * resolution / 25.4); const height = Math.round(dim[1] * resolution / 25.4);
const size = map.getSize(); const size = map.getSize();
const extent = map.getView().calculateExtent(size); const viewResolution = map.getView().getResolution();
map.once('rendercomplete', function() { map.once('rendercomplete', function() {
toJpeg(map.getTargetElement(), exportOptions).then(function(dataUrl) { exportOptions.width = width;
exportOptions.height = height;
toJpeg(map.getViewport(), exportOptions).then(function(dataUrl) {
const pdf = new jsPDF('landscape', undefined, format); const pdf = new jsPDF('landscape', undefined, format);
pdf.addImage(dataUrl, 'JPEG', 0, 0, dim[0], dim[1]); pdf.addImage(dataUrl, 'JPEG', 0, 0, dim[0], dim[1]);
pdf.save('map.pdf'); pdf.save('map.pdf');
// Reset original map size // Reset original map size
map.setSize(size); map.setSize(size);
map.getView().fit(extent, { map.getView().setResolution(viewResolution);
size: size
});
exportButton.disabled = false; exportButton.disabled = false;
document.body.style.cursor = 'auto'; document.body.style.cursor = 'auto';
}); });
@@ -85,6 +85,7 @@ exportButton.addEventListener('click', function() {
// Set print size // Set print size
const printSize = [width, height]; const printSize = [width, height];
map.setSize(printSize); map.setSize(printSize);
map.getView().fit(extent, {size: printSize}); const scaling = Math.min(width / size[0], height / size[1]);
map.getView().setResolution(viewResolution / scaling);
}, false); }, false);

View File

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

View File

@@ -21,7 +21,8 @@ const map = new Map({
target: 'map', target: 'map',
view: new View({ view: new View({
center: [0, 0], center: [0, 0],
zoom: 1 zoom: 1,
multiWorld: true
}) })
}); });

View File

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

View File

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

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

View File

@@ -56,7 +56,7 @@ const vectorLayer = new VectorLayer({
const rasterLayer = new TileLayer({ const rasterLayer = new TileLayer({
source: new TileJSON({ 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: '' crossOrigin: ''
}) })
}); });

View File

@@ -13,5 +13,9 @@ docs: >
The dataset contains around 80k points and can be found here: https://www.kaggle.com/NUFORC/ufo-sightings The dataset contains around 80k points and can be found here: https://www.kaggle.com/NUFORC/ufo-sightings
tags: "webgl, icon, sprite, point, ufo" 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> <div id="map" class="map"></div>
<div>Current sighting: <span id="info"></span></div>

View File

@@ -1,14 +1,16 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js'; import TileLayer from '../src/ol/layer/Tile.js';
import TileJSON from '../src/ol/source/TileJSON'; import TileJSON from '../src/ol/source/TileJSON.js';
import Feature from '../src/ol/Feature'; import Feature from '../src/ol/Feature.js';
import Point from '../src/ol/geom/Point'; import Point from '../src/ol/geom/Point.js';
import VectorLayer from '../src/ol/layer/Vector'; import VectorLayer from '../src/ol/layer/Vector.js';
import {Vector} from '../src/ol/source'; import {Vector} from '../src/ol/source.js';
import {fromLonLat} from '../src/ol/proj'; import {fromLonLat} from '../src/ol/proj.js';
import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer'; import WebGLPointsLayerRenderer from '../src/ol/renderer/webgl/PointsLayer.js';
import {lerp} from '../src/ol/math'; import {lerp} from '../src/ol/math.js';
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
const vectorSource = new Vector({ const vectorSource = new Vector({
features: [], features: [],
@@ -101,11 +103,11 @@ function loadData() {
loadData(); loadData();
new Map({ const map = new Map({
layers: [ layers: [
new TileLayer({ new TileLayer({
source: new TileJSON({ 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' crossOrigin: 'anonymous'
}) })
}), }),
@@ -119,3 +121,18 @@ new Map({
zoom: 2 zoom: 2
}) })
}); });
const info = document.getElementById('info');
map.on('pointermove', function(evt) {
if (map.getView().getInteracting()) {
return;
}
const pixel = evt.pixel;
info.innerText = '';
map.forEachFeatureAtPixel(pixel, function(feature) {
const datetime = feature.get('datetime');
const duration = feature.get('duration');
const shape = feature.get('shape');
info.innerText = 'On ' + datetime + ', lasted ' + duration + ' seconds and had a "' + shape + '" shape.';
});
});

View File

@@ -37,7 +37,7 @@ const vectorLayer = new VectorLayer({
const rasterLayer = new TileLayer({ const rasterLayer = new TileLayer({
source: new TileJSON({ 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: '' crossOrigin: ''
}) })
}); });

View File

@@ -0,0 +1,13 @@
---
layout: example.html
title: Layer Zoom Limits
shortdesc: Using minZoom and maxZoom to control layer visibility.
docs: >
Layers support `minZoom` and `maxZoom` options for controlling visibility based on the view's zoom level.
If min or max zoom are set, the layer will only be visible at zoom levels greater than the `minZoom` and
less than or equal to the `maxZoom`. After construction, the layer's `setMinZoom` and `setMaxZoom` can
be used to set limits. This example shows an OSM layer at zoom levels 14 and lower and a USGS layer at
zoom levels higher than 14.
tags: "minZoom, maxZoom, layer"
---
<div id="map" class="map"></div>

View File

@@ -0,0 +1,33 @@
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 XYZ from '../src/ol/source/XYZ.js';
import {transformExtent, fromLonLat} from '../src/ol/proj.js';
const mapExtent = [-112.261791, 35.983744, -112.113981, 36.132062];
const map = new Map({
target: 'map',
layers: [
new TileLayer({
maxZoom: 14, // visible at zoom levels 14 and below
source: new OSM()
}),
new TileLayer({
minZoom: 14, // visible at zoom levels above 14
source: new XYZ({
attributions: 'Tiles © USGS, rendered with ' +
'<a href="http://www.maptiler.com/">MapTiler</a>',
url: 'https://tileserver.maptiler.com/grandcanyon/{z}/{x}/{y}.png'
})
})
],
view: new View({
center: fromLonLat([-112.18688965, 36.057944835]),
zoom: 15,
maxZoom: 18,
extent: transformExtent(mapExtent, 'EPSG:4326', 'EPSG:3857'),
constrainOnlyCenter: true
})
});

View File

@@ -3,13 +3,13 @@ layout: example.html
title: Mapbox-gl Layer title: Mapbox-gl Layer
shortdesc: Example of a Mapbox-gl-js layer integration. shortdesc: Example of a Mapbox-gl-js layer integration.
docs: > 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. 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" tags: "simple, mapbox, vector, tiles, maptiler"
resources: resources:
- https://unpkg.com/mapbox-gl@0.54.0/dist/mapbox-gl.js - https://unpkg.com/mapbox-gl@0.54.0/dist/mapbox-gl.js
- https://unpkg.com/mapbox-gl@0.54.0/dist/mapbox-gl.css - https://unpkg.com/mapbox-gl@0.54.0/dist/mapbox-gl.css
cloak: cloak:
- key: ER67WIiPdCQvhgsUjoWK - key: get_your_own_D6rA4zTHduk6KOKTXzGB
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> <div id="map" class="map"></div>

View File

@@ -1,17 +1,17 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import Layer from '../src/ol/layer/Layer'; import Layer from '../src/ol/layer/Layer.js';
import {toLonLat, fromLonLat} from '../src/ol/proj'; import {toLonLat, fromLonLat} from '../src/ol/proj.js';
import {Stroke, Style} from '../src/ol/style.js'; import {Stroke, Style} from '../src/ol/style.js';
import VectorLayer from '../src/ol/layer/Vector.js'; import VectorLayer from '../src/ol/layer/Vector.js';
import VectorSource from '../src/ol/source/Vector.js'; import VectorSource from '../src/ol/source/Vector.js';
import GeoJSON from '../src/ol/format/GeoJSON.js'; import GeoJSON from '../src/ol/format/GeoJSON.js';
const center = [-98.8, 37.9]; const center = [-98.8, 37.9];
const key = 'ER67WIiPdCQvhgsUjoWK'; const key = 'get_your_own_D6rA4zTHduk6KOKTXzGB';
const mbMap = new mapboxgl.Map({ const mbMap = new mapboxgl.Map({
style: 'https://maps.tilehosting.com/styles/bright/style.json?key=' + key, style: 'https://api.maptiler.com/maps/bright/style.json?key=' + key,
attributionControl: false, attributionControl: false,
boxZoom: false, boxZoom: false,
center: center, center: center,

View File

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

View File

@@ -1,3 +1,3 @@
import apply from 'ol-mapbox-style'; 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=get_your_own_D6rA4zTHduk6KOKTXzGB');

View File

@@ -6,7 +6,7 @@ docs: >
A simple vector tiles map with Mapzen vector tiles. This example uses the TopoJSON format's `layerName` option to determine the layer ("water", "roads", "buildings") for styling. **Note**: [`ol/format/MVT`] is an even more efficient format for vector tiles. A simple vector tiles map with Mapzen vector tiles. This example uses the TopoJSON format's `layerName` option to determine the layer ("water", "roads", "buildings") for styling. **Note**: [`ol/format/MVT`] is an even more efficient format for vector tiles.
tags: "vector, tiles, osm, mapzen" tags: "vector, tiles, osm, mapzen"
cloak: cloak:
- key: vector-tiles-5eJz6JX - key: uZNs91nMR-muUTP99MyBSg
value: Your Mapzen API key from https://mapzen.com/developers value: Your Nextzen API key from https://developers.nextzen.org/
--- ---
<div id="map" class="map"></div> <div id="map" class="map"></div>

View File

@@ -6,7 +6,7 @@ import {fromLonLat} from '../src/ol/proj.js';
import VectorTileSource from '../src/ol/source/VectorTile.js'; import VectorTileSource from '../src/ol/source/VectorTile.js';
import {Fill, Stroke, Style} from '../src/ol/style.js'; import {Fill, Stroke, Style} from '../src/ol/style.js';
const key = 'vector-tiles-5eJz6JX'; const key = 'uZNs91nMR-muUTP99MyBSg';
const roadStyleCache = {}; const roadStyleCache = {};
const roadColor = { const roadColor = {
@@ -67,7 +67,7 @@ const map = new Map({
layers: ['water', 'roads', 'buildings'] layers: ['water', 'roads', 'buildings']
}), }),
maxZoom: 19, maxZoom: 19,
url: 'https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.topojson?api_key=' + key url: 'https://tile.nextzen.org/tilezen/vector/v1/all/{z}/{x}/{y}.topojson?api_key=' + key
}), }),
style: function(feature, resolution) { style: function(feature, resolution) {
switch (feature.get('layer')) { switch (feature.get('layer')) {

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. 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> </p>
tags: "overlay, popup" 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="map" class="map"></div>
<div id="popup" class="ol-popup"> <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 {toLonLat} from '../src/ol/proj.js';
import TileJSON from '../src/ol/source/TileJSON.js'; import TileJSON from '../src/ol/source/TileJSON.js';
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
/** /**
* Elements that make up the popup. * Elements that make up the popup.
@@ -45,7 +46,7 @@ const map = new Map({
layers: [ layers: [
new TileLayer({ new TileLayer({
source: new TileJSON({ 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' crossOrigin: 'anonymous'
}) })
}) })

10
examples/side-by-side.css Normal file
View File

@@ -0,0 +1,10 @@
@media (min-width: 800px) {
.wrapper {
display: flex;
}
.half {
padding: 0 10px;
width: 50%;
float: left;
}
}

View File

@@ -0,0 +1,21 @@
---
layout: example.html
title: Shared Views
shortdesc: Two maps share view properties
docs: >
Two maps (one Road, one Aerial) share the same center, resolution and rotation.
tags: "side-by-side, bing, bing-maps"
cloak:
- key: As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5
value: Your Bing Maps Key from http://www.bingmapsportal.com/ here
---
<div class="wrapper">
<div class="half">
<h4>Road</h4>
<div id="roadMap" class="map"></div>
</div>
<div class="half">
<h4>Aerial</h4>
<div id="aerialMap" class="map"></div>
</div>
</div>

37
examples/side-by-side.js Normal file
View File

@@ -0,0 +1,37 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import BingMaps from '../src/ol/source/BingMaps.js';
const roadLayer = new TileLayer({
source: new BingMaps({
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
imagerySet: 'RoadOnDemand',
maxZoom: 19
})
});
const aerialLayer = new TileLayer({
source: new BingMaps({
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
imagerySet: 'Aerial',
maxZoom: 19
})
});
const view = new View({
center: [-6655.5402445057125, 6709968.258934638],
zoom: 13
});
const map1 = new Map({
target: 'roadMap',
layers: [roadLayer],
view: view
});
const map2 = new Map({
target: 'aerialMap',
layers: [aerialLayer],
view: view
});

View File

@@ -8,7 +8,7 @@ const map = new Map({
layers: [ layers: [
new TileLayer({ new TileLayer({
source: new TileJSON({ 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' crossOrigin: 'anonymous'
}) })
}) })

View File

@@ -4,7 +4,7 @@ title: UTFGrid
shortdesc: This example shows how to read data from a UTFGrid source. shortdesc: This example shows how to read data from a UTFGrid source.
docs: > docs: >
<p>Point to a country to see its name and flag.</p> <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" tags: "utfgrid, tilejson"
cloak: cloak:
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q - key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q

View File

@@ -5,7 +5,7 @@ shortdesc: Label decluttering with a custom renderer.
resources: resources:
- https://cdn.polyfill.io/v2/polyfill.min.js?features=Set" - https://cdn.polyfill.io/v2/polyfill.min.js?features=Set"
docs: > docs: >
Decluttering is used to avoid overlapping labels with `overflow: true` set on the text style. For MultiPolygon geometries, only the widest polygon is selected in a custom `geometry` function. Decluttering is used to avoid overlapping labels. The `overflow: true` setting on the text style makes it so labels that do not fit within the bounds of a polygon are also included.
tags: "vector, decluttering, labels" tags: "vector, decluttering, labels"
--- ---
<div id="map" class="map"></div> <div id="map" class="map"></div>

View File

@@ -1,6 +1,5 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import {getWidth} from '../src/ol/extent.js';
import GeoJSON from '../src/ol/format/GeoJSON.js'; import GeoJSON from '../src/ol/format/GeoJSON.js';
import VectorLayer from '../src/ol/layer/Vector.js'; import VectorLayer from '../src/ol/layer/Vector.js';
import VectorSource from '../src/ol/source/Vector.js'; import VectorSource from '../src/ol/source/Vector.js';
@@ -15,23 +14,6 @@ const map = new Map({
}); });
const labelStyle = new Style({ const labelStyle = new Style({
geometry: function(feature) {
let geometry = feature.getGeometry();
if (geometry.getType() == 'MultiPolygon') {
// Only render label for the widest polygon of a multipolygon
const polygons = geometry.getPolygons();
let widest = 0;
for (let i = 0, ii = polygons.length; i < ii; ++i) {
const polygon = polygons[i];
const width = getWidth(polygon.getExtent());
if (width > widest) {
widest = width;
geometry = polygon;
}
}
}
return geometry;
},
text: new Text({ text: new Text({
font: '12px Calibri,sans-serif', font: '12px Calibri,sans-serif',
overflow: true, overflow: true,

View File

@@ -2,14 +2,7 @@ const build = require('../../tasks/serialize-workers').build;
function loader() { function loader() {
const callback = this.async(); const callback = this.async();
const minify = this.mode === 'production';
let minify = false;
// TODO: remove when https://github.com/webpack/webpack/issues/6496 is addressed
const compilation = this._compilation;
if (compilation) {
minify = compilation.compiler.options.mode === 'production';
}
build(this.resource, {minify}) build(this.resource, {minify})
.then(chunk => { .then(chunk => {

View File

@@ -0,0 +1,15 @@
---
layout: example.html
title: WMS GetLegendGraphic
shortdesc: Example of a WMS GetLegendGraphic.
docs: >
WMS supports the [getLegendGraphic request](https://docs.geoserver.org/latest/en/user/services/wms/get_legend_graphic/index.html).
This example demonstrates the use of the `getGetLegendGraphicUrl` method.
As a legend can be responsive to the scale it is updated on every change of the resolution.
tags: "GetLegendGraphic, getGetLegendGraphicURL, WMS"
---
<div id="map" class="map"></div>
Legend:
<div><img id="legend" src=""/></div>

View File

@@ -0,0 +1,47 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import {Image as ImageLayer, Tile as TileLayer} from '../src/ol/layer.js';
import ImageWMS from '../src/ol/source/ImageWMS.js';
import OSM from '../src/ol/source/OSM.js';
const wmsSource = new ImageWMS({
url: 'https://ahocevar.com/geoserver/wms',
params: {'LAYERS': 'topp:states'},
ratio: 1,
serverType: 'geoserver'
});
const updateLegend = function(resolution) {
const graphicUrl = wmsSource.getGetLegendGraphicUrl(resolution);
const img = document.getElementById('legend');
img.src = graphicUrl;
};
const layers = [
new TileLayer({
source: new OSM()
}),
new ImageLayer({
extent: [-13884991, 2870341, -7455066, 6338219],
source: wmsSource
})
];
const map = new Map({
layers: layers,
target: 'map',
view: new View({
center: [-10997148, 4569099],
zoom: 4
})
});
// Initial legend
const resolution = map.getView().getResolution();
updateLegend(resolution);
// Update the legend when the resolution changes
map.getView().on('change:resolution', function(event) {
const resolution = event.target.getResolution();
updateLegend(resolution);
});

View File

@@ -4,7 +4,7 @@ import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js'; import TileLayer from '../src/ol/layer/Tile.js';
import OSM from '../src/ol/source/OSM.js'; import OSM from '../src/ol/source/OSM.js';
import {create as createVersionWorker} from '../src/ol/worker/version'; import {create as createVersionWorker} from '../src/ol/worker/version.js';
const map = new Map({ const map = new Map({

11295
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "ol", "name": "ol",
"version": "6.0.0-beta.8", "version": "6.0.0-beta.15",
"description": "OpenLayers mapping library", "description": "OpenLayers mapping library",
"keywords": [ "keywords": [
"map", "map",
@@ -54,23 +54,23 @@
"chaikin-smooth": "^1.0.4", "chaikin-smooth": "^1.0.4",
"clean-css-cli": "4.3.0", "clean-css-cli": "4.3.0",
"copy-webpack-plugin": "^5.0.3", "copy-webpack-plugin": "^5.0.3",
"coveralls": "3.0.3", "coveralls": "3.0.6",
"eslint": "^5.16.0", "eslint": "^6.0.0",
"eslint-config-openlayers": "^11.0.0", "eslint-config-openlayers": "^12.0.0",
"expect.js": "0.3.1", "expect.js": "0.3.1",
"front-matter": "^3.0.2", "front-matter": "^3.0.2",
"fs-extra": "^8.0.0", "fs-extra": "^8.0.0",
"glob": "^7.1.4", "glob": "^7.1.4",
"globby": "^9.2.0", "globby": "^10.0.0",
"handlebars": "4.1.2", "handlebars": "4.1.2",
"html-to-image": "^0.1.0", "html-to-image": "^0.1.0",
"istanbul": "0.4.5", "istanbul": "0.4.5",
"istanbul-instrumenter-loader": "^3.0.1", "istanbul-instrumenter-loader": "^3.0.1",
"jquery": "3.4.1", "jquery": "3.4.1",
"jsdoc": "3.6.2", "jsdoc": "3.6.3",
"jsdoc-plugin-typescript": "^2.0.1", "jsdoc-plugin-typescript": "^2.0.1",
"karma": "^4.1.0", "karma": "^4.1.0",
"karma-chrome-launcher": "2.2.0", "karma-chrome-launcher": "3.1.0",
"karma-coverage": "^1.1.2", "karma-coverage": "^1.1.2",
"karma-coverage-istanbul-reporter": "^2.0.5", "karma-coverage-istanbul-reporter": "^2.0.5",
"karma-firefox-launcher": "^1.1.0", "karma-firefox-launcher": "^1.1.0",
@@ -78,18 +78,18 @@
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.0-rc.2", "karma-webpack": "^4.0.0-rc.2",
"loglevelnext": "^3.0.1", "loglevelnext": "^3.0.1",
"marked": "0.6.2", "marked": "0.7.0",
"mocha": "6.1.4", "mocha": "6.2.0",
"ol-mapbox-style": "^5.0.0-beta.2", "ol-mapbox-style": "^5.0.0-beta.3",
"pixelmatch": "^4.0.2", "pixelmatch": "^5.0.0",
"pngjs": "^3.4.0", "pngjs": "^3.4.0",
"proj4": "2.5.0", "proj4": "2.5.0",
"puppeteer": "~1.16.0", "puppeteer": "~1.19.0",
"rollup": "^1.12.0", "rollup": "^1.12.0",
"rollup-plugin-babel": "^4.3.2", "rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^10.0.0", "rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.0", "rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-terser": "^4.0.4", "rollup-plugin-terser": "^5.0.0",
"serve-static": "^1.14.0", "serve-static": "^1.14.0",
"shx": "^0.3.2", "shx": "^0.3.2",
"sinon": "^7.3.2", "sinon": "^7.3.2",
@@ -97,11 +97,11 @@
"typescript": "^3.4.5", "typescript": "^3.4.5",
"url-polyfill": "^1.1.5", "url-polyfill": "^1.1.5",
"walk": "^2.3.9", "walk": "^2.3.9",
"webpack": "4.31.0", "webpack": "4.39.2",
"webpack-cli": "^3.3.2", "webpack-cli": "^3.3.2",
"webpack-dev-middleware": "^3.6.2", "webpack-dev-middleware": "^3.6.2",
"webpack-dev-server": "^3.3.1", "webpack-dev-server": "^3.3.1",
"yargs": "^13.2.2" "yargs": "^14.0.0"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "openlayers", "extends": "openlayers",

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,57 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.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 VectorSource from '../../../src/ol/source/Vector.js';
import Circle from '../../../src/ol/style/Circle.js';
import Style from '../../../src/ol/style/Style.js';
import Stroke from '../../../src/ol/style/Stroke.js';
const vectorSource = new VectorSource();
vectorSource.addFeatures([
new Feature({
geometry: new Point([-50, 50]),
radius: 10
}),
new Feature({
geometry: new Point([50, -50]),
radius: 20
}),
new Feature({
geometry: new Point([50, 50]),
radius: 30
})
]);
const style = new Style({
image: new Circle({
radius: 1,
stroke: new Stroke({
color: '#00f',
width: 3
})
})
});
new Map({
pixelRatio: 1,
layers: [
new VectorLayer({
source: vectorSource,
style: function(feature) {
style.getImage().setRadius(feature.get('radius'));
return style;
}
})
],
target: 'map',
view: new View({
center: [0, 0],
resolution: 1
})
});
render();

View File

@@ -1,10 +1,10 @@
import Map from '../../../src/ol/Map.js'; import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js'; import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.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 {Heatmap as HeatmapLayer} from '../../../src/ol/layer'; import {Heatmap as HeatmapLayer} from '../../../src/ol/layer.js';
import VectorSource from '../../../src/ol/source/Vector'; import VectorSource from '../../../src/ol/source/Vector.js';
import KML from '../../../src/ol/format/KML'; import KML from '../../../src/ol/format/KML.js';
const vector = new HeatmapLayer({ const vector = new HeatmapLayer({
source: new VectorSource({ 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, get as getProjection,
transform, transform,
transformExtent transformExtent
} from '../../../src/ol/proj'; } from '../../../src/ol/proj.js';
import ImageLayer from '../../../src/ol/layer/Image.js'; import ImageLayer from '../../../src/ol/layer/Image.js';
const center = transform([-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'); 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 Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js'; import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.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 {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 center = fromLonLat([7, 50]);
const extent = transformExtent([2, 47, 10, 53], 'EPSG:4326', 'EPSG:3857'); 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 Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js'; import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.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'; import {createXYZ} from '../../../src/ol/tilegrid.js';
const center = [-10997148, 4569099]; const center = [-10997148, 4569099];

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View File

@@ -0,0 +1,46 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {transform, fromLonLat} from '../../../src/ol/proj.js';
import XYZ from '../../../src/ol/source/XYZ.js';
import CircleStyle from '../../../src/ol/style/Circle.js';
import Fill from '../../../src/ol/style/Fill.js';
import Stroke from '../../../src/ol/style/Stroke.js';
import Point from '../../../src/ol/geom/Point.js';
import {getVectorContext} from '../../../src/ol/render.js';
const center = fromLonLat([8.6, 50.1]);
const layer = new TileLayer({
source: new XYZ({
url: '/data/tiles/satellite/{z}/{x}/{y}.jpg',
transition: 0
})
});
const onRender = function(event) {
const context = event.context;
context.restore();
const vectorContext = getVectorContext(event);
vectorContext.setImageStyle(new CircleStyle({
radius: 12,
fill: new Fill({color: 'yellow'}),
stroke: new Stroke({color: 'red', width: 1})
}));
vectorContext.drawPoint(new Point(
transform([13, 37], 'EPSG:4326', 'EPSG:3857')));
};
layer.on('postrender', onRender);
const map = new Map({
layers: [
],
target: 'map',
view: new View({
center: center,
zoom: 3
})
});
map.addLayer(layer);
render();

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -0,0 +1,55 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import GeoJSON from '../../../src/ol/format/GeoJSON.js';
import VectorLayer from '../../../src/ol/layer/Vector.js';
import VectorSource from '../../../src/ol/source/Vector.js';
import {Fill, Stroke, Style, Text} from '../../../src/ol/style.js';
const map = new Map({
target: 'map',
view: new View({
center: [-17465028, 2331736],
zoom: 5
})
});
const labelStyle = new Style({
text: new Text({
font: '16px Ubuntu',
overflow: true,
fill: new Fill({
color: '#000'
}),
stroke: new Stroke({
color: '#fff',
width: 3
})
})
});
const countryStyle = new Style({
fill: new Fill({
color: 'rgba(255, 255, 255, 0.6)'
}),
stroke: new Stroke({
color: '#319FD3',
width: 1
})
});
const style = [countryStyle, labelStyle];
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: '/data/countries.json',
format: new GeoJSON()
}),
style: function(feature) {
labelStyle.getText().setText(feature.get('name'));
return style;
},
declutter: true
});
map.addLayer(vectorLayer);
render({tolerance: 0.007});

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,31 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import Static from '../../../src/ol/source/ImageStatic.js';
import {
get as getProjection,
transformExtent
} from '../../../src/ol/proj.js';
import ImageLayer from '../../../src/ol/layer/Image.js';
const source = new Static({
url: '/data/tiles/osm/5/5/12.png',
imageExtent: transformExtent([-123, 37, -122, 38], 'EPSG:4326', 'EPSG:3857'),
projection: getProjection('EPSG:3857')
});
new Map({
pixelRatio: 1,
target: 'map',
layers: [new ImageLayer({
source: source
})],
view: new View({
center: [-122.416667, 37.783333],
zoom: 8,
projection: 'EPSG:4326'
})
});
render({
tolerance: 0.001
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,36 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import XYZ from '../../../src/ol/source/XYZ.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {toLonLat, get} from '../../../src/ol/proj.js';
import {createXYZ, createForProjection} from '../../../src/ol/tilegrid.js';
const tileGrid = createXYZ();
const extent = tileGrid.getTileCoordExtent([5, 5, 12]);
const center = [(extent[0] + extent[2]) / 2, extent[1]];
const source = new XYZ({
transition: 0,
minZoom: 5,
maxZoom: 5,
url: '/data/tiles/osm/{z}/{x}/{y}.png'
});
source.setTileGridForProjection(get('EPSG:4326'), createForProjection(get('EPSG:4326'), 7, [64, 64]));
new Map({
pixelRatio: 1,
target: 'map',
layers: [
new TileLayer({
source: source
})
],
view: new View({
projection: 'EPSG:4326',
center: toLonLat(center),
zoom: 5
})
});
render();

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,41 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import XYZ from '../../../src/ol/source/XYZ.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {get, transform} from '../../../src/ol/proj.js';
import {register} from '../../../src/ol/proj/proj4.js';
import proj4 from 'proj4';
proj4.defs('EPSG:5070',
'+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' +
'+y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
register(proj4);
const proj5070 = get('EPSG:5070');
proj5070.setExtent([-6e6, 0, 4e6, 6e6]);
const center4326 = [-118.125, 31.95];
const center = transform(center4326, 'EPSG:4326', 'EPSG:5070');
const source = new XYZ({
transition: 0,
minZoom: 5,
maxZoom: 5,
url: '/data/tiles/osm/{z}/{x}/{y}.png'
});
new Map({
pixelRatio: 1,
target: 'map',
layers: [
new TileLayer({
source: source
})
],
view: new View({
projection: 'EPSG:5070',
center: center,
zoom: 4
})
});
render();

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,40 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import XYZ from '../../../src/ol/source/XYZ.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {get, transform} from '../../../src/ol/proj.js';
import {register} from '../../../src/ol/proj/proj4.js';
import proj4 from 'proj4';
proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
register(proj4);
const proj54009 = get('ESRI:54009');
proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]);
const center4326 = [-118.125, 31.95];
const center = transform(center4326, 'EPSG:4326', 'ESRI:54009');
const source = new XYZ({
transition: 0,
minZoom: 5,
maxZoom: 5,
url: '/data/tiles/osm/{z}/{x}/{y}.png'
});
new Map({
pixelRatio: 1,
target: 'map',
layers: [
new TileLayer({
source: source
})
],
view: new View({
projection: 'ESRI:54009',
center: center,
zoom: 6
})
});
render();

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,40 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import XYZ from '../../../src/ol/source/XYZ.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {get, transform} from '../../../src/ol/proj.js';
import {register} from '../../../src/ol/proj/proj4.js';
import proj4 from 'proj4';
proj4.defs('merc_180', '+proj=merc +lon_0=180 +units=m +no_defs');
register(proj4);
const merc = get('merc_180');
merc.setExtent([-20026376.39, -20048966.10, 20026376.39, 20048966.10]);
const center4326 = [180, 0];
const center = transform(center4326, 'EPSG:4326', 'merc_180');
const source = new XYZ({
projection: 'EPSG:4326',
minZoom: 0,
maxZoom: 0,
url: '/data/tiles/4326/{z}/{x}/{y}.png'
});
new Map({
pixelRatio: 1,
target: 'map',
layers: [
new TileLayer({
source: source
})
],
view: new View({
projection: 'merc_180',
center: center,
zoom: 0
})
});
render();

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@@ -0,0 +1,38 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import XYZ from '../../../src/ol/source/XYZ.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {toLonLat} from '../../../src/ol/proj.js';
import {createXYZ} from '../../../src/ol/tilegrid.js';
const tileGrid = createXYZ({tileSize: [512, 256]});
const extent = tileGrid.getTileCoordExtent([5, 3, 12]);
const center = [
(extent[0] + extent[2]) / 2,
(extent[1] + extent[3]) / 2
];
const source = new XYZ({
projection: 'EPSG:3857',
minZoom: 5,
maxZoom: 5,
url: '/data/tiles/512x256/{z}/{x}/{y}.png',
tileSize: [512, 256]
});
new Map({
pixelRatio: 1,
target: 'map',
layers: [
new TileLayer({
source: source
})
],
view: new View({
projection: 'EPSG:4326',
center: toLonLat(center),
zoom: 5
})
});
render();

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -0,0 +1,40 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import XYZ from '../../../src/ol/source/XYZ.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {get, transform} from '../../../src/ol/proj.js';
import {register} from '../../../src/ol/proj/proj4.js';
import proj4 from 'proj4';
proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 ' +
'+k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
register(proj4);
const proj3413 = get('EPSG:3413');
proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]);
const center4326 = [0, 90];
const center = transform(center4326, 'EPSG:4326', 'EPSG:3413');
const source = new XYZ({
maxZoom: 0,
projection: 'EPSG:4326',
url: '/data/tiles/4326/{z}/{x}/{y}.png'
});
new Map({
pixelRatio: 1,
target: 'map',
layers: [
new TileLayer({
source: source
})
],
view: new View({
projection: 'EPSG:3413',
center: center,
zoom: 0
})
});
render();

View File

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

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -357,7 +357,7 @@ if (require.main === module) {
option('puppeteer-args', { option('puppeteer-args', {
describe: 'Additional args for Puppeteer', describe: 'Additional args for Puppeteer',
type: 'array', type: 'array',
default: process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : [] default: process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'] : []
}). }).
parse(); parse();

View File

@@ -22,5 +22,16 @@ module.exports = {
context: __dirname, context: __dirname,
target: 'web', target: 'web',
entry: entry, 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 * @api
* @template {import("./geom/Geometry.js").default} Geometry
*/ */
class Feature extends BaseObject { 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 * You may pass a Geometry object directly, or an object literal containing
* properties. If you pass an object literal, you may include a Geometry * properties. If you pass an object literal, you may include a Geometry
* associated with a `geometry` key. * associated with a `geometry` key.
@@ -106,7 +107,7 @@ class Feature extends BaseObject {
if (opt_geometryOrProperties) { if (opt_geometryOrProperties) {
if (typeof /** @type {?} */ (opt_geometryOrProperties).getSimplifiedGeometry === 'function') { 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); this.setGeometry(geometry);
} else { } else {
/** @type {Object<string, *>} */ /** @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 * 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 * geometries. The "default" geometry (the one that is rendered by default) is
* set when calling {@link module:ol/Feature~Feature#setGeometry}. * 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 * @api
* @observable * @observable
*/ */
getGeometry() { getGeometry() {
return ( 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 * Set the default geometry for the feature. This will update the property
* with the name returned by {@link module:ol/Feature~Feature#getGeometryName}. * 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 * @api
* @observable * @observable
*/ */

View File

@@ -6,6 +6,7 @@ import ImageState from './ImageState.js';
import {listenOnce, unlistenByKey} from './events.js'; import {listenOnce, unlistenByKey} from './events.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
import {getHeight} from './extent.js'; import {getHeight} from './extent.js';
import {IMAGE_DECODE} from './has.js';
/** /**
@@ -157,7 +158,8 @@ class ImageWrapper extends ImageBase {
*/ */
export function listenImage(image, loadHandler, errorHandler) { export function listenImage(image, loadHandler, errorHandler) {
const img = /** @type {HTMLImageElement} */ (image); const img = /** @type {HTMLImageElement} */ (image);
if (img.decode) {
if (img.src && IMAGE_DECODE) {
const promise = img.decode(); const promise = img.decode();
let listening = true; let listening = true;
const unlisten = function() { const unlisten = function() {
@@ -169,7 +171,13 @@ export function listenImage(image, loadHandler, errorHandler) {
} }
}).catch(function(error) { }).catch(function(error) {
if (listening) { if (listening) {
errorHandler(); // 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; return unlisten;

View File

@@ -9,5 +9,6 @@ export default {
IDLE: 0, IDLE: 0,
LOADING: 1, LOADING: 1,
LOADED: 2, LOADED: 2,
ERROR: 3 ERROR: 3,
EMPTY: 4
}; };

View File

@@ -260,12 +260,6 @@ class MapBrowserEventHandler extends EventTarget {
this.dragging_); this.dragging_);
this.dispatchEvent(newEvent); 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 EventType from './events/EventType.js';
import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js'; import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
import {TRUE} from './functions.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 LayerGroup from './layer/Group.js';
import {hasArea} from './size.js'; import {hasArea} from './size.js';
import {DROP} from './structs/PriorityQueue.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 {boolean} animate
* @property {import("./transform.js").Transform} coordinateToPixelTransform * @property {import("./transform.js").Transform} coordinateToPixelTransform
* @property {null|import("./extent.js").Extent} extent * @property {null|import("./extent.js").Extent} extent
* @property {Array<*>} declutterItems * @property {Array<DeclutterItems>} declutterItems
* @property {import("./coordinate.js").Coordinate} focus * @property {import("./coordinate.js").Coordinate} focus
* @property {number} index * @property {number} index
* @property {Array<import("./layer/Layer.js").State>} layerStatesArray * @property {Array<import("./layer/Layer.js").State>} layerStatesArray
* @property {number} layerIndex
* @property {import("./transform.js").Transform} pixelToCoordinateTransform * @property {import("./transform.js").Transform} pixelToCoordinateTransform
* @property {Array<PostRenderFunction>} postRenderFunctions * @property {Array<PostRenderFunction>} postRenderFunctions
* @property {import("./size.js").Size} size * @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 * @typedef {function(PluggableMap, ?FrameState): any} PostRenderFunction
*/ */
@@ -222,7 +230,7 @@ class PluggableMap extends BaseObject {
* @type {!HTMLElement} * @type {!HTMLElement}
*/ */
this.viewport_ = document.createElement('div'); 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.position = 'relative';
this.viewport_.style.overflow = 'hidden'; this.viewport_.style.overflow = 'hidden';
this.viewport_.style.width = '100%'; this.viewport_.style.width = '100%';
@@ -293,6 +301,11 @@ class PluggableMap extends BaseObject {
*/ */
this.interactions = optionsInternal.interactions || new Collection(); this.interactions = optionsInternal.interactions || new Collection();
/**
* @type {import("./events/Target.js").default}
*/
this.labelCache_ = null;
/** /**
* @type {import("./events.js").EventsKey} * @type {import("./events.js").EventsKey}
*/ */
@@ -315,7 +328,7 @@ class PluggableMap extends BaseObject {
* @type {import("./renderer/Map.js").default} * @type {import("./renderer/Map.js").default}
* @private * @private
*/ */
this.renderer_ = this.createRenderer(); this.renderer_ = null;
/** /**
* @type {function(Event): void|undefined} * @type {function(Event): void|undefined}
@@ -503,24 +516,6 @@ class PluggableMap extends BaseObject {
overlay.setMap(this); overlay.setMap(this);
} }
/**
* Attach a label cache for listening to font changes.
* @param {import("./events/Target.js").default} labelCache Label cache.
*/
attachLabelCache(labelCache) {
this.detachLabelCache();
this.labelCacheListenerKey_ = listen(labelCache, EventType.CLEAR, this.redrawText.bind(this));
}
/**
* Detach the label cache, i.e. no longer listen to font changes.
*/
detachLabelCache() {
if (this.labelCacheListenerKey_) {
unlistenByKey(this.labelCacheListenerKey_);
}
}
/** /**
* *
* @inheritDoc * @inheritDoc
@@ -534,11 +529,6 @@ class PluggableMap extends BaseObject {
removeEventListener(EventType.RESIZE, this.handleResize_, false); removeEventListener(EventType.RESIZE, this.handleResize_, false);
this.handleResize_ = undefined; this.handleResize_ = undefined;
} }
if (this.animationDelayKey_) {
cancelAnimationFrame(this.animationDelayKey_);
this.animationDelayKey_ = undefined;
}
this.detachLabelCache();
this.setTarget(null); this.setTarget(null);
super.disposeInternal(); super.disposeInternal();
} }
@@ -977,7 +967,7 @@ class PluggableMap extends BaseObject {
if (frameState) { if (frameState) {
const hints = frameState.viewHints; const hints = frameState.viewHints;
if (hints[ViewHint.ANIMATING] || hints[ViewHint.INTERACTING]) { 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; maxTotalLoading = lowOnFrameBudget ? 0 : 8;
maxNewLoads = lowOnFrameBudget ? 0 : 2; maxNewLoads = lowOnFrameBudget ? 0 : 2;
} }
@@ -1033,6 +1023,14 @@ class PluggableMap extends BaseObject {
} }
if (!targetElement) { if (!targetElement) {
if (this.renderer_) {
this.renderer_.dispose();
this.renderer_ = null;
}
if (this.animationDelayKey_) {
cancelAnimationFrame(this.animationDelayKey_);
this.animationDelayKey_ = undefined;
}
removeNode(this.viewport_); removeNode(this.viewport_);
if (this.handleResize_ !== undefined) { if (this.handleResize_ !== undefined) {
removeEventListener(EventType.RESIZE, this.handleResize_, false); removeEventListener(EventType.RESIZE, this.handleResize_, false);
@@ -1040,6 +1038,9 @@ class PluggableMap extends BaseObject {
} }
} else { } else {
targetElement.appendChild(this.viewport_); targetElement.appendChild(this.viewport_);
if (!this.renderer_) {
this.renderer_ = this.createRenderer();
}
const keyboardEventTarget = !this.keyboardEventTarget_ ? const keyboardEventTarget = !this.keyboardEventTarget_ ?
targetElement : this.keyboardEventTarget_; targetElement : this.keyboardEventTarget_;
@@ -1050,7 +1051,7 @@ class PluggableMap extends BaseObject {
if (!this.handleResize_) { if (!this.handleResize_) {
this.handleResize_ = this.updateSize.bind(this); this.handleResize_ = this.updateSize.bind(this);
addEventListener(EventType.RESIZE, this.handleResize_, false); window.addEventListener(EventType.RESIZE, this.handleResize_, false);
} }
} }
@@ -1158,7 +1159,7 @@ class PluggableMap extends BaseObject {
* @api * @api
*/ */
render() { render() {
if (this.animationDelayKey_ === undefined) { if (this.renderer_ && this.animationDelayKey_ === undefined) {
this.animationDelayKey_ = requestAnimationFrame(this.animationDelay_); this.animationDelayKey_ = requestAnimationFrame(this.animationDelay_);
} }
} }
@@ -1223,14 +1224,15 @@ class PluggableMap extends BaseObject {
let frameState = null; let frameState = null;
if (size !== undefined && hasArea(size) && view && view.isDef()) { if (size !== undefined && hasArea(size) && view && view.isDef()) {
const viewHints = view.getHints(this.frameState_ ? this.frameState_.viewHints : undefined); const viewHints = view.getHints(this.frameState_ ? this.frameState_.viewHints : undefined);
viewState = view.getState(this.pixelRatio_); viewState = view.getState();
frameState = /** @type {FrameState} */ ({ frameState = {
animate: false, animate: false,
coordinateToPixelTransform: this.coordinateToPixelTransform_, coordinateToPixelTransform: this.coordinateToPixelTransform_,
declutterItems: previousFrameState ? previousFrameState.declutterItems : [], declutterItems: previousFrameState ? previousFrameState.declutterItems : [],
extent: extent, extent: extent,
focus: this.focus_ ? this.focus_ : viewState.center, focus: this.focus_ ? this.focus_ : viewState.center,
index: this.frameIndex_++, index: this.frameIndex_++,
layerIndex: 0,
layerStatesArray: this.getLayerGroup().getLayerStatesArray(), layerStatesArray: this.getLayerGroup().getLayerStatesArray(),
pixelRatio: this.pixelRatio_, pixelRatio: this.pixelRatio_,
pixelToCoordinateTransform: this.pixelToCoordinateTransform_, pixelToCoordinateTransform: this.pixelToCoordinateTransform_,
@@ -1243,7 +1245,7 @@ class PluggableMap extends BaseObject {
viewState: viewState, viewState: viewState,
viewHints: viewHints, viewHints: viewHints,
wantedTiles: {} wantedTiles: {}
}); };
} }
if (frameState) { if (frameState) {

View File

@@ -21,9 +21,9 @@ import {clamp, modulo} from './math.js';
import {assign} from './obj.js'; import {assign} from './obj.js';
import {createProjection, METERS_PER_UNIT} from './proj.js'; import {createProjection, METERS_PER_UNIT} from './proj.js';
import Units from './proj/Units.js'; import Units from './proj/Units.js';
import {equals} from './coordinate'; import {equals} from './coordinate.js';
import {easeOut} from './easing'; import {easeOut} from './easing.js';
import {createMinMaxResolution} from './resolutionconstraint'; import {createMinMaxResolution} from './resolutionconstraint.js';
/** /**
@@ -927,10 +927,9 @@ class View extends BaseObject {
} }
/** /**
* @param {number} pixelRatio Pixel ratio for center rounding.
* @return {State} View state. * @return {State} View state.
*/ */
getState(pixelRatio) { getState() {
const center = /** @type {import("./coordinate.js").Coordinate} */ (this.getCenter()); const center = /** @type {import("./coordinate.js").Coordinate} */ (this.getCenter());
const projection = this.getProjection(); const projection = this.getProjection();
const resolution = /** @type {number} */ (this.getResolution()); const resolution = /** @type {number} */ (this.getResolution());
@@ -1148,7 +1147,6 @@ class View extends BaseObject {
* constraint will apply. * constraint will apply.
* @param {number} ratio The ratio to apply on the view resolution. * @param {number} ratio The ratio to apply on the view resolution.
* @param {import("./coordinate.js").Coordinate=} opt_anchor The origin of the transformation. * @param {import("./coordinate.js").Coordinate=} opt_anchor The origin of the transformation.
* @observable
* @api * @api
*/ */
adjustResolution(ratio, opt_anchor) { adjustResolution(ratio, opt_anchor) {
@@ -1180,7 +1178,6 @@ class View extends BaseObject {
* constraint will apply. * constraint will apply.
* @param {number} delta Relative value to add to the zoom rotation, in radians. * @param {number} delta Relative value to add to the zoom rotation, in radians.
* @param {import("./coordinate.js").Coordinate=} opt_anchor The rotation center. * @param {import("./coordinate.js").Coordinate=} opt_anchor The rotation center.
* @observable
* @api * @api
*/ */
adjustRotation(delta, opt_anchor) { adjustRotation(delta, opt_anchor) {

View File

@@ -7,7 +7,7 @@ import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_COLLAPSED} from '../css.js';
import {removeChildren, replaceNode} from '../dom.js'; import {removeChildren, replaceNode} from '../dom.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {visibleAtResolution} from '../layer/Layer.js'; import {inView} from '../layer/Layer.js';
/** /**
@@ -170,10 +170,9 @@ class Attribution extends Control {
const visibleAttributions = []; const visibleAttributions = [];
const layerStatesArray = frameState.layerStatesArray; const layerStatesArray = frameState.layerStatesArray;
const resolution = frameState.viewState.resolution;
for (let i = 0, ii = layerStatesArray.length; i < ii; ++i) { for (let i = 0, ii = layerStatesArray.length; i < ii; ++i) {
const layerState = layerStatesArray[i]; const layerState = layerStatesArray[i];
if (!visibleAtResolution(layerState, resolution)) { if (!inView(layerState, frameState.viewState)) {
continue; continue;
} }

View File

@@ -108,12 +108,6 @@ class MousePosition extends Control {
*/ */
this.transform_ = null; this.transform_ = null;
/**
* @private
* @type {import("../pixel.js").Pixel}
*/
this.lastMouseMovePixel_ = null;
} }
/** /**
@@ -156,8 +150,7 @@ class MousePosition extends Control {
*/ */
handleMouseMove(event) { handleMouseMove(event) {
const map = this.getMap(); const map = this.getMap();
this.lastMouseMovePixel_ = map.getEventPixel(event); this.updateHTML_(map.getEventPixel(event));
this.updateHTML_(this.lastMouseMovePixel_);
} }
/** /**
@@ -166,7 +159,6 @@ class MousePosition extends Control {
*/ */
handleMouseOut(event) { handleMouseOut(event) {
this.updateHTML_(null); this.updateHTML_(null);
this.lastMouseMovePixel_ = null;
} }
/** /**

View File

@@ -51,8 +51,8 @@ class ControlledMap extends PluggableMap {
* @property {boolean} [collapsible=true] Whether the control can be collapsed or not. * @property {boolean} [collapsible=true] Whether the control can be collapsed or not.
* @property {string|HTMLElement} [label='»'] Text label to use for the collapsed * @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. * 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 * @property {Array<import("../layer/Layer.js").default>|import("../Collection.js").default<import("../layer/Layer.js").default>} [layers]
* Layers for the overview map (mandatory). * Layers for the overview map.
* @property {function(import("../MapEvent.js").default)} [render] Function called when the control * @property {function(import("../MapEvent.js").default)} [render] Function called when the control
* should be re-rendered. This is called in a `requestAnimationFrame` callback. * should be re-rendered. This is called in a `requestAnimationFrame` callback.
* @property {HTMLElement|string} [target] Specify a target if you want the control * @property {HTMLElement|string} [target] Specify a target if you want the control
@@ -159,13 +159,9 @@ class OverviewMap extends Control {
const ovmap = this.ovmap_; const ovmap = this.ovmap_;
if (options.layers) { if (options.layers) {
/** @type {Array<import("../layer/Layer.js").default>} */ (options.layers).forEach( options.layers.forEach(function(layer) {
/** ovmap.addLayer(layer);
* @param {import("../layer/Layer.js").default} layer Layer. });
*/
(function(layer) {
ovmap.addLayer(layer);
}).bind(this));
} }
const box = document.createElement('div'); const box = document.createElement('div');

View File

@@ -2,6 +2,13 @@
* @module ol/css * @module ol/css
*/ */
/**
* @typedef {Object} FontParameters
* @property {Array<string>} families
* @property {string} style
* @property {string} weight
*/
/** /**
* The CSS class for hidden feature. * The CSS class for hidden feature.
@@ -62,10 +69,13 @@ export const CLASS_COLLAPSED = 'ol-collapsed';
* Get the list of font families from a font spec. Note that this doesn't work * Get the list of font families from a font spec. Note that this doesn't work
* for font families that have commas in them. * for font families that have commas in them.
* @param {string} The CSS font property. * @param {string} The CSS font property.
* @return {Object<string>} The font families (or null if the input spec is invalid). * @return {FontParameters} The font families (or null if the input spec is invalid).
*/ */
export const getFontFamilies = (function() { export const getFontParameters = (function() {
let style; let style;
/**
* @type {Object<string, FontParameters>}
*/
const cache = {}; const cache = {};
return function(font) { return function(font) {
if (!style) { if (!style) {
@@ -74,11 +84,18 @@ export const getFontFamilies = (function() {
if (!(font in cache)) { if (!(font in cache)) {
style.font = font; style.font = font;
const family = style.fontFamily; const family = style.fontFamily;
const fontWeight = style.fontWeight;
const fontStyle = style.fontStyle;
style.font = ''; style.font = '';
if (!family) { if (!family) {
return null; return null;
} }
cache[font] = family.split(/,\s?/); const families = family.split(/,\s?/);
cache[font] = {
families: families,
weight: fontWeight,
style: fontStyle
};
} }
return cache[font]; return cache[font];
}; };

View File

@@ -256,10 +256,10 @@ function readGeometry(object, opt_options) {
const rings = convertRings(esriJSONPolygon.rings, layout); const rings = convertRings(esriJSONPolygon.rings, layout);
if (rings.length === 1) { if (rings.length === 1) {
type = GeometryType.POLYGON; type = GeometryType.POLYGON;
object['rings'] = rings[0]; object = Object.assign({}, object, {['rings']: rings[0]});
} else { } else {
type = GeometryType.MULTI_POLYGON; type = GeometryType.MULTI_POLYGON;
object['rings'] = rings; object = Object.assign({}, object, {['rings']: rings});
} }
} }
const geometryReader = GEOMETRY_READERS[type]; const geometryReader = GEOMETRY_READERS[type];

View File

@@ -4,6 +4,7 @@
import {assign} from '../obj.js'; import {assign} from '../obj.js';
import {abstract} from '../util.js'; import {abstract} from '../util.js';
import {get as getProjection, equivalent as equivalentProjection, transformExtent} from '../proj.js'; import {get as getProjection, equivalent as equivalentProjection, transformExtent} from '../proj.js';
import Units from '../proj/Units.js';
/** /**
@@ -13,8 +14,10 @@ import {get as getProjection, equivalent as equivalentProjection, transformExten
* the `dataProjection` of the format is assigned (where set). If the projection * 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, * can not be derived from the data and if no `dataProjection` is set for a format,
* the features will not be reprojected. * the features will not be reprojected.
* @property {import("../extent.js").Extent} [extent] Tile extent of the tile being read. This is only used and * @property {import("../extent.js").Extent} [extent] Tile extent in map units of the tile being read.
* required for {@link module:ol/format/MVT}. * 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 * @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 * created by the format reader. If not provided, features will be returned in the
* `dataProjection`. * `dataProjection`.
@@ -86,9 +89,15 @@ class FeatureFormat {
getReadOptions(source, opt_options) { getReadOptions(source, opt_options) {
let options; let options;
if (opt_options) { if (opt_options) {
let dataProjection = opt_options.dataProjection ?
getProjection(opt_options.dataProjection) : this.readProjection(source);
if (opt_options.extent &&
dataProjection && dataProjection.getUnits() === Units.TILE_PIXELS) {
dataProjection = getProjection(dataProjection);
dataProjection.setWorldExtent(opt_options.extent);
}
options = { options = {
dataProjection: opt_options.dataProjection ? dataProjection: dataProjection,
opt_options.dataProjection : this.readProjection(source),
featureProjection: opt_options.featureProjection featureProjection: opt_options.featureProjection
}; };
} }

View File

@@ -94,6 +94,8 @@ import {assert} from '../asserts.js';
* image service additional to the ones indicated by the compliance level. * image service additional to the ones indicated by the compliance level.
* @property {Array<string>} [extraFeatures] Additional supported features whose support * @property {Array<string>} [extraFeatures] Additional supported features whose support
* is not indicated by the compliance level. * is not indicated by the compliance level.
* @property {Array<string>} [preferredFormats] Image formats that should preferrably
* be used.
*/ */
/** /**
@@ -156,15 +158,15 @@ IIIF_PROFILE_VALUES[Versions.VERSION3] = {
qualities: ['default'] qualities: ['default']
}, },
'level1': { 'level1': {
supports: ['regionByPx', 'regionSquare', 'sizeByW', 'sizeByH'], supports: ['regionByPx', 'regionSquare', 'sizeByW', 'sizeByH', 'sizeByWh'],
formats: ['jpg'], formats: ['jpg'],
qualities: ['default'] qualities: ['default']
}, },
'level2': { 'level2': {
supports: ['regionByPx', 'regionSquare', 'regionByPct', supports: ['regionByPx', 'regionSquare', 'regionByPct',
'sizeByW', 'sizeByH', 'sizeByPct', 'sizeByConfinedWh', 'sizeByWh'], 'sizeByW', 'sizeByH', 'sizeByPct', 'sizeByConfinedWh', 'sizeByWh'],
formats: ['jpg'], formats: ['jpg', 'png'],
qualities: ['default', 'bitonal'] qualities: ['default']
} }
}; };
IIIF_PROFILE_VALUES['none'] = { IIIF_PROFILE_VALUES['none'] = {
@@ -231,7 +233,16 @@ function generateVersion2Options(iiifInfo) {
} }
function generateVersion3Options(iiifInfo) { function generateVersion3Options(iiifInfo) {
const levelProfile = iiifInfo.getComplianceLevelSupportedFeatures(); const levelProfile = iiifInfo.getComplianceLevelSupportedFeatures(),
formats = iiifInfo.imageInfo.extraFormats === undefined ? levelProfile.formats :
[...levelProfile.formats, ...iiifInfo.imageInfo.extraFormats],
preferredFormat = iiifInfo.imageInfo.preferredFormats !== undefined && Array.isArray(iiifInfo.imageInfo.preferredFormats) &&
iiifInfo.imageInfo.preferredFormats.length > 0 ?
iiifInfo.imageInfo.preferredFormats.filter(function(format) {
return ['jpg', 'png', 'gif'].includes(format);
}).reduce(function(acc, format) {
return acc === undefined && formats.includes(format) ? format : acc;
}, undefined) : undefined;
return { return {
url: iiifInfo.imageInfo['id'], url: iiifInfo.imageInfo['id'],
sizes: iiifInfo.imageInfo.sizes === undefined ? undefined : iiifInfo.imageInfo.sizes.map(function(size) { sizes: iiifInfo.imageInfo.sizes === undefined ? undefined : iiifInfo.imageInfo.sizes.map(function(size) {
@@ -251,13 +262,10 @@ function generateVersion3Options(iiifInfo) {
})[0], })[0],
supports: iiifInfo.imageInfo.extraFeatures === undefined ? levelProfile.supports : supports: iiifInfo.imageInfo.extraFeatures === undefined ? levelProfile.supports :
[...levelProfile.supports, ...iiifInfo.imageInfo.extraFeatures], [...levelProfile.supports, ...iiifInfo.imageInfo.extraFeatures],
formats: iiifInfo.imageInfo.extraFormats === undefined ? levelProfile.formats : formats: formats,
[...levelProfile.formats, ...iiifInfo.imageInfo.extraFormats],
qualities: iiifInfo.imageInfo.extraQualities === undefined ? levelProfile.qualities : qualities: iiifInfo.imageInfo.extraQualities === undefined ? levelProfile.qualities :
[...levelProfile.supports, ...iiifInfo.imageInfo.extraQualities], [...levelProfile.qualities, ...iiifInfo.imageInfo.extraQualities],
maxWidth: undefined, preferredFormat: preferredFormat
maxHeight: undefined,
maxArea: undefined
}; };
} }
@@ -414,7 +422,8 @@ class IIIFInfo {
version: version, version: version,
size: [this.imageInfo.width, this.imageInfo.height], size: [this.imageInfo.width, this.imageInfo.height],
sizes: imageOptions.sizes, sizes: imageOptions.sizes,
format: imageOptions.formats.includes(options.format) ? options.format : 'jpg', format: options.format !== undefined && imageOptions.formats.includes(options.format) ? options.format :
imageOptions.preferredFormat !== undefined ? imageOptions.preferredFormat : 'jpg',
supports: imageOptions.supports, supports: imageOptions.supports,
quality: options.quality && imageOptions.qualities.includes(options.quality) ? quality: options.quality && imageOptions.qualities.includes(options.quality) ?
options.quality : imageOptions.qualities.includes('native') ? 'native' : 'default', options.quality : imageOptions.qualities.includes('native') ? 'native' : 'default',

View File

@@ -31,6 +31,7 @@ import {get} from '../proj.js';
* @property {string} [geometryName='geometry'] Geometry name to use when creating features. * @property {string} [geometryName='geometry'] Geometry name to use when creating features.
* @property {string} [layerName='layer'] Name of the feature attribute that holds the layer name. * @property {string} [layerName='layer'] Name of the feature attribute that holds the layer name.
* @property {Array<string>} [layers] Layers to read features from. If not provided, features will be read from all * @property {Array<string>} [layers] Layers to read features from. If not provided, features will be read from all
* @property {string} [idProperty] Optional property that will be assigned as the feature id and removed from the properties.
* layers. * layers.
*/ */
@@ -84,6 +85,12 @@ class MVT extends FeatureFormat {
*/ */
this.layers_ = options.layers ? options.layers : null; this.layers_ = options.layers ? options.layers : null;
/**
* @private
* @type {string}
*/
this.idProperty_ = options.idProperty;
} }
/** /**
@@ -164,8 +171,16 @@ class MVT extends FeatureFormat {
} }
let feature; let feature;
const id = rawFeature.id;
const values = rawFeature.properties; const values = rawFeature.properties;
let id;
if (!this.idProperty_) {
id = rawFeature.id;
} else {
id = values[this.idProperty_];
delete values[this.idProperty_];
}
values[this.layerName_] = rawFeature.layer.name; values[this.layerName_] = rawFeature.layer.name;
const flatCoordinates = []; const flatCoordinates = [];

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