Compare commits

..

156 Commits

Author SHA1 Message Date
ahocevar
7ca396f727 Version and tag for v6.0.0-beta.2 2019-03-02 16:46:57 +01:00
Andreas Hocevar
f1aca67882 Merge pull request #9280 from openlayers/greenkeeper/ol-mapbox-style-4.0.0
Update ol-mapbox-style to the latest version 🚀
2019-03-01 09:56:49 +01:00
Tim Schaub
d7905896f7 Merge pull request #9266 from tschaub/vector-image-options
Full type definition for image vector layer options
2019-02-28 21:43:23 -07:00
greenkeeper[bot]
a7af9a0697 chore(package): update ol-mapbox-style to version 4.0.0 2019-02-28 16:31:06 +00:00
Andreas Hocevar
eea67868f7 Merge pull request #9279 from openlayers/greenkeeper/webpack-4.29.6
Update webpack to the latest version 🚀
2019-02-28 14:24:54 +01:00
Frédéric Junod
d99405feeb Merge pull request #9278 from fredj/bing_imagerySet
Update Bing's imagerySet used in examples
2019-02-28 12:59:17 +01:00
greenkeeper[bot]
14831a0d61 chore(package): update webpack to version 4.29.6 2019-02-28 10:53:28 +00:00
Marc Jansen
43bc53b20b Merge pull request #9270 from bvx89/patch-1
Update faq.md
2019-02-28 10:49:35 +01:00
Frederic Junod
c01dee0884 Update Bing's imagerySet used in examples 2019-02-28 10:43:59 +01:00
Andreas Hocevar
6fd83b9a8e Merge pull request #9277 from ahocevar/rotate-token
Rotate API token
2019-02-27 18:38:34 +01:00
ahocevar
05712acfef Rotate API token 2019-02-27 18:31:50 +01:00
Frédéric Junod
cd17f4b0d6 Merge pull request #9276 from fredj/graticule_cleanup
Use the constructor options instead of changing the private variables
2019-02-27 17:02:41 +01:00
Frederic Junod
7c7b43ee91 Use the constructor options instead of changing the private variables 2019-02-27 15:11:08 +01:00
Frédéric Junod
02f9411c6b Merge pull request #9275 from fredj/rm_setDeclutter
Remove setDeclutter function
2019-02-27 14:03:38 +01:00
Frederic Junod
1338a868e9 Remove setDeclutter function
Changing the declutter value after the layer creating doesn't work, remove the function to avoid confusion.
2019-02-27 11:41:08 +01:00
Lasse Brudeskar Vikås
6b1f9e681c Update faq.md 2019-02-27 11:30:55 +01:00
Andreas Hocevar
65d8b5f26b Merge pull request #9273 from chrismayer/9269-fix-gfi-examples
Fix WMS GetFeatureInfo examples
2019-02-27 10:15:16 +01:00
Christian Mayer
530e47d26c Remove IFrame usage in GetFeatureInfo img example
This replaces the loading of the GetFeatureInfo request via IFrame by a
fetch operation in the GetFeatureInfo image example.
2019-02-27 09:55:59 +01:00
Christian Mayer
85f2312370 Remove IFrame usage in GetFeatureInfo tile example
This replaces the loading of the GetFeatureInfo request via IFrame by a
fetch operation in the GetFeatureInfo tile example.
2019-02-27 09:55:59 +01:00
Lasse Brudeskar Vikås
301b45cb7c Update faq.md
Fixed typos in description, and tried to make the text more readable.
2019-02-26 16:13:06 +01:00
Frédéric Junod
3aa93014c0 Merge pull request #9246 from openlayers/mobile-full-screen
Add missing ol.css in mobile-full-screen example
2019-02-26 12:36:42 +01:00
Frederic Junod
734900f1d7 Add missing ol.css in mobile-full-screen example 2019-02-26 08:39:39 +01:00
Andreas Hocevar
fb2ea83838 Merge pull request #9268 from openlayers/greenkeeper/mocha-6.0.2
Update mocha to the latest version 🚀
2019-02-25 20:51:51 +01:00
greenkeeper[bot]
8534aaa304 chore(package): update mocha to version 6.0.2 2019-02-25 19:09:43 +00:00
Tim Schaub
36cf654f09 Full type definition for image vector layer options 2019-02-25 08:37:30 -07:00
Andreas Hocevar
4e8522e696 Merge pull request #9261 from openlayers/greenkeeper/coveralls-3.0.3
Update coveralls to the latest version 🚀
2019-02-25 15:43:05 +01:00
Frédéric Junod
88760de64b Merge pull request #9264 from tpluscode/patch-1
add question about resizing map element
2019-02-25 10:43:54 +01:00
Tomasz Pluskiewicz
b5f7705e1d Update faq.md 2019-02-25 10:02:52 +01:00
Tomasz Pluskiewicz
9efe10f747 add question about resizing map element 2019-02-25 09:42:54 +01:00
Frédéric Junod
73744de14e Merge pull request #9260 from fredj/rm_geom_param
Remove unused 'geometry' param from ol/render/canvas/Builder
2019-02-25 08:25:06 +01:00
greenkeeper[bot]
d6c18667f4 chore(package): update coveralls to version 3.0.3 2019-02-22 19:13:45 +00:00
Frederic Junod
cd28c8a301 Remove unused 'geometry' param from 'createFill' function 2019-02-22 16:52:32 +01:00
Frederic Junod
79c6cc5159 Remove unused 'geometry' param from '{begin,end}Geometry' functions 2019-02-22 16:45:25 +01:00
Frédéric Junod
345607be28 Merge pull request #9256 from openlayers/greenkeeper/mocha-6.0.1
Update mocha to the latest version 🚀
2019-02-22 15:14:35 +01:00
Andreas Hocevar
767c765524 Merge pull request #9254 from petrsloup/tilejson-tilesize
Add tileSize option to ol/source/TileJSON
2019-02-22 11:14:19 +01:00
Petr Sloup
67ee5a41b0 Add note about ignoring tileSize TileJSON property 2019-02-22 09:05:18 +01:00
greenkeeper[bot]
5c280e8114 chore(package): update mocha to version 6.0.1 2019-02-21 22:59:15 +00:00
Petr Sloup
bc25097899 Add tileSize option to ol/source/TileJSON
The TileJSON spec does not specify the tile size
and there is no TileJSON property specifying the value.

Many providers nowadays provide 512x512 with TileJSON.
2019-02-21 19:00:07 +01:00
Andreas Hocevar
6ce499532c Merge pull request #9250 from ahocevar/clear-refresh
Clearer behaviour of clear() and refresh() on sources
2019-02-21 17:12:26 +01:00
Andreas Hocevar
386f2dc67c Merge pull request #9247 from openlayers/greenkeeper/copy-webpack-plugin-5.0.0
Update copy-webpack-plugin to the latest version 🚀
2019-02-21 15:17:54 +01:00
Andreas Hocevar
90034e4d48 Merge pull request #9251 from ahocevar/cache-size
Fix cache size calculation
2019-02-21 01:57:40 +01:00
ahocevar
4166c80c6e Test cache size 2019-02-21 01:35:40 +01:00
ahocevar
d06d00ccbb Fix typo 2019-02-21 01:29:15 +01:00
Andreas Hocevar
959dba169d Merge pull request #9110 from crubier/master
Add TilePixelRatio to Zoomify
2019-02-21 00:29:42 +01:00
Vincent Lecrubier
900adaaffb Update Zoomify.js 2019-02-20 22:40:24 +00:00
ahocevar
94cd126189 Add setUrl function and don't reset loaded extents in setLoader 2019-02-20 21:55:29 +01:00
ahocevar
1416a3d162 Add upgrade notes 2019-02-20 20:40:33 +01:00
ahocevar
e4873a9952 Improve documentation for ol/Source#refresh 2019-02-20 20:40:09 +01:00
ahocevar
8d1022046e Clear loaded extents when a new loader is set 2019-02-20 20:39:26 +01:00
ahocevar
f40cbf2cac Do not reload on clear(), but on refresh() 2019-02-20 20:39:04 +01:00
ahocevar
a0ba8dd8c6 Add a clear() method for tile sources 2019-02-20 20:37:58 +01:00
ahocevar
8557bd96b5 Test refresh() for image sources 2019-02-20 20:36:40 +01:00
greenkeeper[bot]
3d4f77be51 chore(package): update copy-webpack-plugin to version 5.0.0 2019-02-20 13:19:25 +00:00
Andreas Hocevar
62d82411c8 Merge pull request #9244 from huyngkh/stylus-support
add stylus only and touch only mode to drawing a shape
2019-02-20 11:30:11 +01:00
Huy Nguyen
c3709ef51a remove arrow function, add JSDoc and restore original Draw 2019-02-20 17:23:50 +07:00
Andreas Hocevar
071e9a4735 Merge pull request #9242 from openlayers/greenkeeper/marked-0.6.1
Update marked to the latest version 🚀
2019-02-20 08:42:13 +01:00
Huy Nguyen
0c889da99c add stylus and touch mode to drawing a shape 2019-02-20 13:55:22 +07:00
greenkeeper[bot]
a41f51c437 chore(package): update marked to version 0.6.1 2019-02-19 21:23:11 +00:00
Frédéric Junod
4cb3e24048 Merge pull request #9240 from fredj/text_rotateWithView
Add setRotateWithView function to ol/style/Text
2019-02-19 15:29:00 +01:00
Frederic Junod
4cb9b1eeb3 Add setRotateWithView function to ol/style/Text 2019-02-19 14:20:58 +01:00
Frederic Junod
f0a97ee460 Fix comments indentation 2019-02-19 14:12:14 +01:00
Andreas Hocevar
7c1e16abc3 Merge pull request #9230 from ahocevar/hitdetect-declutter
Consider all tiles for hit detection when decluttering
2019-02-19 12:58:07 +01:00
Andreas Hocevar
84995c688c Merge pull request #9237 from umbe1987/export-to-pdf-example
Fix zoom after export to PDF is done
2019-02-19 11:46:26 +01:00
Umberto Minora
cefb5d4d32 fixed indents checked with npm run lint 2019-02-19 11:25:12 +01:00
Umberto Minora
8eadb3d04c Fixed indent spaces so that hopefully ci/circleci: build does not fail 2019-02-19 10:57:21 +01:00
Umberto Minora
a6023a710a Cleared mixed spaces and tabs 2019-02-19 10:48:11 +01:00
Umberto Minora
33ac3e34ee constrainResolution: false on view fit instead of setting the zoom 2019-02-19 10:38:23 +01:00
Andreas Hocevar
3c64018b37 Merge pull request #9239 from ahocevar/tests-puppeteer
Run tests in Puppeteer and non headless mode
2019-02-19 09:43:13 +01:00
Frédéric Junod
b01970cb86 Merge pull request #9236 from fredj/cleanup
Move params list to the constructor function
2019-02-19 09:26:46 +01:00
Andreas Hocevar
ffa24bfd22 Merge pull request #9238 from openlayers/greenkeeper/mocha-6.0.0
Update mocha to the latest version 🚀
2019-02-18 23:57:33 +01:00
ahocevar
be17bfe85a Avoid render test issues by not running Puppeteer in headless mode 2019-02-18 23:54:20 +01:00
ahocevar
974684ed2b Use Puppeteer for tests 2019-02-18 23:54:20 +01:00
greenkeeper[bot]
f90a41a7ca chore(package): update mocha to version 6.0.0 2019-02-18 21:57:28 +00:00
Firstname Lastname
df847ae35c Fix zoom after export to PDF is done 2019-02-18 22:12:38 +01:00
Frederic Junod
746455a9b9 Move params list to the constructor function 2019-02-18 17:33:07 +01:00
Frederic Junod
3557247b27 Fix comments indentation 2019-02-18 17:31:36 +01:00
Frédéric Junod
658a4a9194 Merge pull request #9233 from fredj/rm_deprecated
Remove deprecated {get,set}SnapToPixel functions
2019-02-18 15:35:42 +01:00
Andreas Hocevar
ec6371d7a0 Merge pull request #9232 from openlayers/greenkeeper/webpack-4.29.5
Update webpack to the latest version 🚀
2019-02-18 14:41:58 +01:00
Frederic Junod
6bab8793a2 Remove deprecated {get,set}SnapToPixel functions 2019-02-18 14:07:27 +01:00
Andreas Hocevar
45b2e8885a Merge pull request #9231 from ahocevar/vectortile-extent
Set vector tile extent earlier
2019-02-18 13:48:25 +01:00
greenkeeper[bot]
40b5891ea7 chore(package): update webpack to version 4.29.5 2019-02-18 11:32:20 +00:00
ahocevar
667cadc403 Remove extent default so we catch errors when extent is not set 2019-02-18 12:07:10 +01:00
ahocevar
08be6cf9bc Set extent berfore features 2019-02-18 11:54:59 +01:00
ahocevar
fd07de39ad Consider all tiles for hit detection when decluttering 2019-02-18 11:40:52 +01:00
Vincent Lecrubier
44942dffb5 Update Zoomify.js 2019-02-18 10:04:02 +00:00
Andreas Hocevar
f7b1fe07d0 Merge pull request #9225 from openlayers/greenkeeper/webpack-4.29.4
Update webpack to the latest version 🚀
2019-02-16 17:46:04 +01:00
greenkeeper[bot]
9a7e5747eb chore(package): update webpack to version 4.29.4 2019-02-15 16:07:50 +00:00
Frédéric Junod
e4264b94ed Merge pull request #9224 from fredj/less_vendor_prefix
Remove vendor prefix for the 'transform' CSS property and fullscreen api
2019-02-15 16:09:24 +01:00
Frederic Junod
e9ecea3bb7 Remove 'moz' prefix for the Full Screen API
Browser support: https://caniuse.com/#feat=fullscreen
2019-02-15 14:37:49 +01:00
Frederic Junod
391dfc5025 Remove vendor prefix for the 'transform' CSS property
Browser support: https://caniuse.com/#feat=transforms2d
2019-02-15 14:29:15 +01:00
Frédéric Junod
3da449d77e Merge pull request #9222 from fredj/devDependencies
Update all dev dependencies
2019-02-15 12:49:08 +01:00
greenkeeper[bot]
7a66dc5774 chore(package): update yargs to version 13.2.0 2019-02-15 10:36:02 +01:00
greenkeeper[bot]
74f7b1974d chore(package): update @types/topojson-specification to version 1.0.1 2019-02-15 10:35:44 +01:00
greenkeeper[bot]
6b94aaa424 chore(package): update @types/arcgis-rest-api to version 10.4.4 2019-02-15 10:33:42 +01:00
greenkeeper[bot]
c4ed80dd92 chore(package): update @types/geojson to version 7946.0.6 2019-02-15 10:32:38 +01:00
greenkeeper[bot]
7a73638fb2 chore(package): update ol-mapbox-style to version 3.7.1 2019-02-15 10:32:21 +01:00
greenkeeper[bot]
0ece4a7dae chore(package): update webpack-dev-middleware to version 3.5.2 2019-02-15 10:31:59 +01:00
greenkeeper[bot]
6fe8b5c49d chore(package): update puppeteer to version 1.12.2 2019-02-15 10:30:37 +01:00
greenkeeper[bot]
2ba4be2661 chore(package): update webpack-cli to version 3.2.3 2019-02-15 10:30:15 +01:00
Andreas Hocevar
a2a3bda5c9 Merge pull request #9221 from ahocevar/remove-unused-sortbyzindex
Remove unused sortByZIndex function
2019-02-15 09:45:26 +01:00
Frédéric Junod
f28b7c7bcf Merge pull request #9220 from fredj/rm_extra_canvas_resize
Don't resize/clear the vector renderer canvas
2019-02-15 09:34:57 +01:00
Frédéric Junod
27d025327f Merge pull request #9217 from fredj/f_9211
Don't use loadImage function to avoid infinite loading loop
2019-02-15 08:47:59 +01:00
ahocevar
020f513ed5 Remove unused sortByZIndex function 2019-02-14 17:40:38 +01:00
Frederic Junod
30fb0b1ed1 Don't resize/clear the vector renderer canvas
Already done in the `renderFrame` function
2019-02-14 13:49:31 +01:00
Frederic Junod
40605d7c53 Don't use loadImage function to avoid infinite loading loop 2019-02-14 13:47:52 +01:00
Frédéric Junod
666c14d190 Merge pull request #9212 from fredj/cleanup
Remove unnecessary type cast
2019-02-14 09:41:15 +01:00
Andreas Hocevar
0a005527e7 Merge pull request #9207 from openlayers/greenkeeper/yargs-13.1.0
Update yargs to the latest version 🚀
2019-02-14 07:46:17 +01:00
Frederic Junod
c0a860a31f Remove unnecessary type cast 2019-02-13 11:42:22 +01:00
greenkeeper[bot]
3e82da4beb chore(package): update yargs to version 13.1.0 2019-02-12 06:35:53 +00:00
Andreas Hocevar
b71d7773d3 Merge pull request #9201 from ahocevar/drawable-child-range
Only consider child range with drawable tiles
2019-02-11 11:05:20 +01:00
Andreas Hocevar
7d5b2d8c3b Merge pull request #9204 from ahocevar/intellisense-notes-addendum
Add missing 'include' section
2019-02-10 22:50:32 +01:00
ahocevar
dc298b8895 Add missing 'include' section 2019-02-10 22:44:22 +01:00
Andreas Hocevar
693c763710 Merge pull request #9203 from ahocevar/intellisense-notes
Only promise what we can deliver regarding IntelliSense
2019-02-10 22:42:42 +01:00
Andreas Hocevar
680f3cde3c Merge pull request #9200 from ahocevar/vectorimage-note
Add upgrade note about renderMode: 'image' for vector layers
2019-02-10 09:55:25 +01:00
ahocevar
3ef6635c09 Only promise what we can deliver regarding IntelliSense 2019-02-10 09:10:01 +01:00
ahocevar
8028ce3ac5 Add upgrade note about renderMode: 'image' for vector layers 2019-02-10 08:47:16 +01:00
ahocevar
3557a13147 Only consider child range with drawable tiles 2019-02-09 19:35:31 +01:00
Frédéric Junod
f6e625f21a Merge pull request #9197 from fredj/cleanup
Remove unused opt_this param
2019-02-08 08:43:31 +01:00
Andreas Hocevar
d1c71c3c61 Merge pull request #9196 from ahocevar/pointresolution-scaleline
getPointResolution returns resolution in projection units
2019-02-07 15:32:32 +01:00
Frederic Junod
6f8ffddace Remove opt_this param in manageTilePyramid function 2019-02-07 13:18:52 +01:00
Frederic Junod
438736068e Remove opt_this param in forEach function 2019-02-07 13:07:36 +01:00
Andreas Hocevar
bfe8ee5309 Merge pull request #9195 from openlayers/greenkeeper/handlebars-4.1.0
Update handlebars to the latest version 🚀
2019-02-07 12:50:05 +01:00
ahocevar
703dadfcde Fix ScaleLine control now that getPointResolution works correctly 2019-02-07 12:26:18 +01:00
ahocevar
fecb8de769 getPointResolution returns proj units 2019-02-07 12:25:37 +01:00
ahocevar
b3bc78daec Provide center in the correct projection 2019-02-07 12:23:45 +01:00
ahocevar
d24ae3c2ac Fix expectation for degree point resolution 2019-02-07 12:22:18 +01:00
Frederic Junod
2879c0b6ad Remove opt_this param in forDataAtCoordinate function 2019-02-07 11:51:28 +01:00
greenkeeper[bot]
5ef1b51c02 chore(package): update handlebars to version 4.1.0 2019-02-07 10:45:15 +00:00
Frederic Junod
41d231a4c7 Remove opt_this param in forEachTileCoordParentTileRange function
The function is only called by `ol/renderer/canvas/TileLayer` and `opt_this` was always `null`.
2019-02-07 11:43:52 +01:00
Frédéric Junod
f4fe1babd2 Merge pull request #9194 from openlayers/greenkeeper/webpack-4.29.3
chore(package): update webpack to version 4.29.3
2019-02-07 11:08:44 +01:00
greenkeeper[bot]
efc85ed0ed chore(package): update webpack to version 4.29.3
Closes #9192
2019-02-07 09:29:38 +00:00
Andreas Hocevar
be16c2357d Merge pull request #9190 from romanzoller/multi-polygon-area
Fix MultiPolygon area calculation
2019-02-05 20:43:37 +01:00
Andreas Hocevar
88c213078e Merge pull request #9179 from gberaudo/allow_image_declutter
Allow declutter with image render mode
2019-02-05 20:29:15 +01:00
Roman Zoller
ee57b197e5 Fix offset passed from linearRingssAreOriented to linearRingsAreOriented
The offset needs to be set to the end of the previous Polygon,
see `offset = orientLinearRings(...)` in function orientLinearRingsArray

Fixes #9189
2019-02-05 17:56:52 +01:00
Roman Zoller
2c859b1196 Rename misnamed functions in geom/flat/orient
- Rename linearRingIsOriented => linearRingsAreOriented
  The function checks all linear rings of a Polygon, so
  the plural "rings" is more appropriate
- Rename linearRingsAreOriented => linearRingssAreOriented
  The double s is appropriate because the check is done for
  all Polygons of a MultiPolygon

This commit restores the function names from OpenLayers v4,
they were changed (wrongly IMHO) in #7820.
2019-02-05 17:49:21 +01:00
Roman Zoller
c4be22b1b6 Add failing test for MultiPolygon#getArea 2019-02-05 17:48:42 +01:00
Guillaume Beraudo
b00b877ca1 Update upgrade notes 2019-02-05 17:25:00 +01:00
Guillaume Beraudo
168edac4a6 Allow declutter with image render mode
Using declutter in image render mode is legitimate: each tile is
decluttered, avoiding symbol/text overlaps.
2019-02-05 17:25:00 +01:00
Frédéric Junod
caa9153dd0 Merge pull request #9187 from fredj/cleanup
Remove unnecessary type cast
2019-02-05 16:36:16 +01:00
Frederic Junod
ba02320fcc Remove unused layerState param 2019-02-05 11:46:12 +01:00
Frederic Junod
427c73ddf9 Remove unnecessary type cast
`npx tsc` output is the same before and after the changes.
2019-02-05 11:46:12 +01:00
Frédéric Junod
2c3ffdfdf8 Merge pull request #9186 from fredj/cleanup
Simplify typing in EsriJSON format
2019-02-05 10:57:36 +01:00
Frederic Junod
97b21145c4 Simplify typing in EsriJSON format 2019-02-05 10:27:26 +01:00
Frédéric Junod
2428c0984e Merge pull request #9161 from fredj/template_type
Use type template for the source type of layers
2019-02-05 10:07:52 +01:00
Frédéric Junod
e0aad192af Merge pull request #9184 from fredj/devDependencies
Update all dev dependencies
2019-02-05 09:22:03 +01:00
Frédéric Junod
e34806ad70 Merge pull request #9185 from openlayers/greenkeeper/webpack-4.29.1
Update webpack to the latest version 🚀
2019-02-05 09:21:22 +01:00
greenkeeper[bot]
a0fde2b24d chore(package): update webpack to version 4.29.1 2019-02-04 18:43:37 +00:00
Frederic Junod
abfe6b4359 Update jsdoc-plugin-typescript to version 1.0.7 2019-02-04 16:27:25 +01:00
greenkeeper[bot]
acd8c34535 chore(package): update terser-webpack-plugin to version 1.2.2 2019-02-04 16:14:46 +01:00
greenkeeper[bot]
1a1c7dec87 chore(package): update puppeteer to version 1.12.1 2019-02-04 16:14:36 +01:00
greenkeeper[bot]
5e4ee77968 chore(package): update eslint to version 5.13.0 2019-02-04 16:14:28 +01:00
greenkeeper[bot]
9f54e9cb4d chore(package): update ol-mapbox-style to version 3.6.4 2019-02-04 16:14:17 +01:00
Frederic Junod
0b53a3229b Remove unneeded type cast 2019-02-04 09:58:49 +01:00
Frederic Junod
5318d52036 Use type template for the source type of layers 2019-02-04 09:58:48 +01:00
Vincent Lecrubier
4d54ad0daf Update Zoomify.js 2019-01-12 13:44:17 +01:00
Vincent Lecrubier
37b1cca027 Add TilePixelRatio to Zoomify 2019-01-12 13:23:18 +01:00
94 changed files with 1013 additions and 739 deletions

View File

@@ -41,14 +41,13 @@ See the following examples for more detail on bundling OpenLayers with your appl
* Using [Parcel](https://github.com/openlayers/ol-parcel)
* Using [Browserify](https://github.com/openlayers/ol-browserify)
## TypeScript and VS Code IntelliSense support
## IntelliSense support and type checking for VS Code
The `ol` package contains a `src/` folder with JSDoc annotated sources. TypeScript can get type definitions from these sources with a `tsconfig.json` like this:
The `ol` package contains a `src/` folder with JSDoc annotated sources. TypeScript can get type definitions from these sources with a `jsconfig.json` config file in the project root:
```js
{
"compilerOptions": {
// Enable JavaScript support
"allowJs": true,
"checkJs": true,
// Point to the JSDoc typed sources when using modules from the ol package
"baseUrl": "./",
"paths": {
@@ -57,11 +56,14 @@ The `ol` package contains a `src/` folder with JSDoc annotated sources. TypeScri
}
},
"include": [
// Include JavaScript files from the ol package
"**/*.js",
"node_modules/ol/**/*.js"
]
}
```
Project template with this configuration: https://gist.github.com/9a7253cb4712e8bf38d75d8ac898e36c.
Note that the above only works when authoring in plain JavaScript. For similar configurations with a `tsconfig.json` in TypeScript projects, your mileage may vary.
## Supported Browsers

View File

@@ -4,11 +4,13 @@
#### Backwards incompatible changes
##### Removal of the deprecated "inherits" function
##### Removal of deprecated methods
The `inherits` function that was used to inherit the prototype methods from one constructor into another has been removed.
The standard ECMAScript classes should be used instead.
The deprecated `getSnapToPixel` and `setSnapToPixel` functions from the `ImageStyle` class have been removed.
##### New internal tile coordinates
Previously, the internal tile coordinates used in the library had an unusual row order the origin of the tile coordinate system was at the top left as expected, but the rows increased upwards. This meant that all tile coordinates within a tile grid's extent had negative `y` values.
@@ -60,6 +62,10 @@ In addition (this should be exceedingly rare), if you previously created a `ol/t
If you were previously using `VectorTile` layers with `renderMode: 'vector'`, you have to remove this configuration option. That mode was removed. `'hybrid'` (default) and `'image'` are still available.
##### Removal of the "renderMode" option for vector layers
If you were previously using `Vector` layers with `renderMode: 'image'`, you have to remove this configuration option. Instead, use the new `ol/layer/VectorImage` layer with your `ol/source/Vector`.
##### New `prerender` and `postrender` layer events replace old `precompose`, `render` and `postcompose` events
If you were previously registering for `precompose` and `postcompose` events, you should now register for `prerender` and `postrender` events on layers. Instead of the previous `render` event, you should now listen for `postrender`. Layers are no longer composed to a single Canvas element. Instead, they are added to the map viewport as individual elements.
@@ -118,8 +124,19 @@ The removed classes and components are:
Following the removal of the experimental WebGL renderer, the AtlasManager has been removed as well. The atlas was only used by this renderer.
The non API `getChecksum` functions of the style is also removed.
##### Change of the behavior of the vector source's clear() and refresh() methods
The `ol/source/Vector#clear()` method no longer triggers a reload of the data from the server. If you were previously using `clear()` to refetch from the server, you now have to use `refresh()`.
The `ol/source/Vector#refresh()` method now removes all features from the source and triggers a reload of the data from the server. If you were previously using the `refresh()` method to re-render a vector layer, you should instead call `ol/layer/Vector#changed()`.
#### Other changes
##### Allow declutter in image render mode
It is now possible to configure vector tile layers with `declutter: true` and `renderMode: 'image'`. However, note that decluttering will be done per tile, resulting in labels and point symbols getting cut off at tile boundaries.
Until now, using both options forced the render mode to be `hybrid`.
##### Always load tiles while animating or interacting
`ol/PluggableMap` and subclasses no longer support the `loadTilesWhileAnimating` and `loadTilesWhileInteracting` options. These options were used to enable tile loading during animations and interactions. With the new DOM composition render strategy, it is no longer necessary to postpone tile loading until after animations or interactions.

View File

@@ -21,7 +21,7 @@ Table of contents:
* [Why aren't there any features in my source?](#why-aren-t-there-any-features-in-my-source-)
* [How do I force a re-render of the map?](#how-do-i-force-a-re-render-of-the-map-)
* [Why are my features not found?](#why-are-my-features-not-found-)
* [Why is zooming or clicking off, inaccurate?](#user-content-why-is-zooming-or-clicking-off-inaccurate)
## What projection is OpenLayers using?
@@ -371,3 +371,30 @@ const vectorLayer = new VectorLayer({
```
The recommended value is the size of the largest symbol, line width or label.
## Why is zooming or clicking in the map off/inaccurate?
OpenLayers does not update the map when the container element is resized. This can be caused by progressive updates
to CSS styles or manually resizing the map. When that happens, any interaction will become inaccurate: the map would zoom in and out, and end up not being centered on the pointer. This makes it hard to do certain interactions, e.g. selecting the desired feature.
There is currently no built-in way to react to element's size changes, as [Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) is only implemented in Chrome.
There is however an easy to use [polyfill](https://github.com/que-etc/resize-observer-polyfill):
```javascript
import Map from 'ol/Map';
import ResizeObserver from 'resize-observer-polyfill';
const mapElement = document.querySelector('#map')
const map = new Map({
target: mapElement
})
const sizeObserver = new ResizeObserver(() => {
map.updateSize()
})
sizeObserver.observe(mapElement)
// called when the map is destroyed
// sizeObserver.disconnect()
```

View File

@@ -12,9 +12,8 @@ cloak:
<div id="map" class="map"></div>
<select id="layer-select">
<option value="Aerial">Aerial</option>
<option value="AerialWithLabels" selected>Aerial with labels</option>
<option value="Road">Road (static)</option>
<option value="RoadOnDemand">Road (dynamic)</option>
<option value="collinsBart">Collins Bart</option>
<option value="ordnanceSurvey">Ordnance Survey</option>
<option value="AerialWithLabelsOnDemand" selected>Aerial with labels</option>
<option value="RoadOnDemand">Road</option>
<option value="CanvasDark">Road dark</option>
<option value="OrdnanceSurvey">Ordnance Survey</option>
</select>

View File

@@ -5,12 +5,11 @@ import BingMaps from '../src/ol/source/BingMaps.js';
const styles = [
'Road',
'RoadOnDemand',
'Aerial',
'AerialWithLabels',
'collinsBart',
'ordnanceSurvey'
'AerialWithLabelsOnDemand',
'CanvasDark',
'OrdnanceSurvey'
];
const layers = [];
let i, ii;

View File

@@ -26,9 +26,8 @@ const styleFunction = function(feature) {
scale = size / 10;
let style = styleCache[size];
if (!style) {
const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('canvas'));
const vectorContext = toContext(
/** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')),
const canvas = document.createElement('canvas');
const vectorContext = toContext(canvas.getContext('2d'),
{size: [size, size], pixelRatio: 1});
vectorContext.setStyle(new Style({
fill: new Fill({color: 'rgba(255, 153, 0, 0.4)'}),

View File

@@ -63,7 +63,10 @@ exportButton.addEventListener('click', function() {
pdf.save('map.pdf');
// Reset original map size
map.setSize(size);
map.getView().fit(extent, {size});
map.getView().fit(extent, {
size: size,
constrainResolution: false
});
exportButton.disabled = false;
document.body.style.cursor = 'auto';
});

View File

@@ -133,7 +133,7 @@ const map = new Map({
layers: [
new TileLayer({
source: new BingMaps({
imagerySet: 'AerialWithLabels',
imagerySet: 'AerialWithLabelsOnDemand',
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
})
}),

View File

@@ -1,6 +1,3 @@
.map:-moz-full-screen {
height: 100%;
}
.map:-webkit-full-screen {
height: 100%;
}

View File

@@ -1,6 +1,3 @@
.fullscreen:-moz-full-screen {
height: 100%;
}
.fullscreen:-webkit-full-screen {
height: 100%;
}

View File

@@ -1,6 +1,3 @@
.map:-moz-full-screen {
height: 100%;
}
.map:-webkit-full-screen {
height: 100%;
}

View File

@@ -33,8 +33,11 @@ map.on('singleclick', function(evt) {
evt.coordinate, viewResolution, 'EPSG:3857',
{'INFO_FORMAT': 'text/html'});
if (url) {
document.getElementById('info').innerHTML =
'<iframe seamless src="' + url + '"></iframe>';
fetch(url)
.then((response) => response.text())
.then((html) => {
document.getElementById('info').innerHTML = html;
});
}
});

View File

@@ -33,8 +33,11 @@ map.on('singleclick', function(evt) {
evt.coordinate, viewResolution, 'EPSG:3857',
{'INFO_FORMAT': 'text/html'});
if (url) {
document.getElementById('info').innerHTML =
'<iframe seamless src="' + url + '"></iframe>';
fetch(url)
.then((response) => response.text())
.then((html) => {
document.getElementById('info').innerHTML = html;
});
}
});

View File

@@ -7,7 +7,7 @@ import BingMaps from '../src/ol/source/BingMaps.js';
const key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
const roads = new TileLayer({
source: new BingMaps({key: key, imagerySet: 'Road'})
source: new BingMaps({key: key, imagerySet: 'RoadOnDemand'})
});
const imagery = new TileLayer({

View File

@@ -8,7 +8,7 @@ tags: "mapbox, vector, tiles, mobile"
resources:
- resources/mapbox-streets-v6-style.js
cloak:
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
value: Your Mapbox access token from http://mapbox.com/ here
---
<div id="map" class="map"></div>

View File

@@ -8,7 +8,7 @@ import {Fill, Icon, Stroke, Style, Text} from '../src/ol/style.js';
import TileGrid from '../src/ol/tilegrid/TileGrid.js';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
// Calculation of resolutions that match zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
const resolutions = [];

View File

@@ -8,7 +8,7 @@ tags: "simple, mapbox, vector, tiles"
resources:
- resources/mapbox-streets-v6-style.js
cloak:
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
value: Your Mapbox access token from http://mapbox.com/ here
---
<div id="map" class="map"></div>

View File

@@ -6,7 +6,7 @@ import VectorTileSource from '../src/ol/source/VectorTile.js';
import {Fill, Icon, Stroke, Style, Text} from '../src/ol/style.js';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
const map = new Map({
layers: [

View File

@@ -14,6 +14,7 @@ cloak:
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>Mobile full screen example</title>
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<style type="text/css">
html, body, .map {
margin: 0;

View File

@@ -15,7 +15,7 @@ const map = new Map({
new TileLayer({
source: new BingMaps({
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
imagerySet: 'Road'
imagerySet: 'RoadOnDemand'
})
})
],

View File

@@ -29,7 +29,7 @@ const map2 = new Map({
preload: 0, // default value
source: new BingMaps({
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
imagerySet: 'AerialWithLabels'
imagerySet: 'AerialWithLabelsOnDemand'
})
})
],

View File

@@ -7,7 +7,7 @@ docs: >
Tiles made with [TileMill](http://tilemill.com). Hosting on MapBox.com or with open-source [TileServer](https://github.com/klokantech/tileserver-php/).
tags: "utfgrid, tilejson"
cloak:
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
value: Your Mapbox access token from http://mapbox.com/ here
---
<div id="map" class="map"></div>

View File

@@ -5,7 +5,7 @@ import TileLayer from '../src/ol/layer/Tile.js';
import TileJSON from '../src/ol/source/TileJSON.js';
import UTFGrid from '../src/ol/source/UTFGrid.js';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
const mapLayer = new TileLayer({
source: new TileJSON({

View File

@@ -1,6 +1,6 @@
{
"name": "ol",
"version": "6.0.0-beta.1",
"version": "6.0.0-beta.2",
"description": "OpenLayers mapping library",
"keywords": [
"map",
@@ -42,29 +42,29 @@
},
"devDependencies": {
"@openlayers/eslint-plugin": "^4.0.0-beta.1",
"@types/arcgis-rest-api": "^10.4.3",
"@types/geojson": "^7946.0.5",
"@types/arcgis-rest-api": "^10.4.4",
"@types/geojson": "^7946.0.6",
"@types/pbf": "^3.0.1",
"@types/rbush": "^2.0.2",
"@types/topojson-specification": "^1.0.0",
"@types/topojson-specification": "^1.0.1",
"buble": "^0.19.6",
"buble-loader": "^0.5.1",
"chaikin-smooth": "^1.0.4",
"clean-css-cli": "4.2.1",
"copy-webpack-plugin": "^4.6.0",
"coveralls": "3.0.1",
"eslint": "^5.8.0",
"copy-webpack-plugin": "^5.0.0",
"coveralls": "3.0.3",
"eslint": "^5.13.0",
"eslint-config-openlayers": "^11.0.0",
"expect.js": "0.3.1",
"front-matter": "^3.0.1",
"fs-extra": "^7.0.1",
"glob": "^7.1.2",
"globby": "^8.0.1",
"handlebars": "4.0.11",
"handlebars": "4.1.0",
"istanbul": "0.4.5",
"jquery": "3.3.1",
"jsdoc": "3.5.5",
"jsdoc-plugin-typescript": "^1.0.6",
"jsdoc-plugin-typescript": "^1.0.7",
"karma": "^4.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "^1.1.2",
@@ -73,25 +73,25 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.0-rc.2",
"loglevelnext": "^3.0.0",
"marked": "0.6.0",
"mocha": "5.2.0",
"ol-mapbox-style": "^3.6.3",
"marked": "0.6.1",
"mocha": "6.0.2",
"ol-mapbox-style": "^4.0.0",
"pixelmatch": "^4.0.2",
"pngjs": "^3.3.3",
"proj4": "2.5.0",
"puppeteer": "^1.11.0",
"puppeteer": "^1.12.2",
"serve-static": "^1.13.2",
"shx": "^0.3.2",
"sinon": "^7.2.3",
"terser-webpack-plugin": "^1.2.1",
"terser-webpack-plugin": "^1.2.2",
"typescript": "^3.2.2",
"url-polyfill": "^1.1.3",
"walk": "^2.3.9",
"webpack": "4.29.0",
"webpack-cli": "^3.2.0",
"webpack-dev-middleware": "^3.5.1",
"webpack": "4.29.6",
"webpack-cli": "^3.2.3",
"webpack-dev-middleware": "^3.5.2",
"webpack-dev-server": "^3.1.14",
"yargs": "^12.0.2"
"yargs": "^13.2.0"
},
"eslintConfig": {
"extends": "openlayers",

View File

@@ -351,7 +351,7 @@ if (require.main === module) {
option('headless', {
describe: 'Launch Puppeteer in headless mode',
type: 'boolean',
default: process.env.CI ? false : true
default: false
}).
option('puppeteer-args', {
describe: 'Additional args for Puppeteer',

View File

@@ -4,13 +4,6 @@
import Tile from './Tile.js';
import TileState from './TileState.js';
/**
* @const
* @type {import("./extent.js").Extent}
*/
const DEFAULT_EXTENT = [0, 0, 4096, 4096];
class VectorTile extends Tile {
/**
@@ -89,7 +82,7 @@ class VectorTile extends Tile {
* @api
*/
getExtent() {
return this.extent_ || DEFAULT_EXTENT;
return this.extent_;
}
/**
@@ -147,8 +140,8 @@ class VectorTile extends Tile {
*/
onLoad(features, dataProjection, extent) {
this.setProjection(dataProjection);
this.setFeatures(features);
this.setExtent(extent);
this.setFeatures(features);
}
/**
@@ -166,7 +159,7 @@ class VectorTile extends Tile {
* calculated by multiplying the tile size with the tile pixel ratio. For
* sources using {@link module:ol/format/MVT~MVT} as feature format, the
* {@link module:ol/format/MVT~MVT#getLastExtent} method will return the correct
* extent. The default is `[0, 0, 4096, 4096]`.
* extent.
* @param {import("./extent.js").Extent} extent The extent.
* @api
*/

View File

@@ -7,7 +7,7 @@ import {replaceNode} from '../dom.js';
import {listen} from '../events.js';
import EventType from '../events/EventType.js';
const events = ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'];
const events = ['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'];
/**
* @typedef {Object} Options
@@ -209,7 +209,6 @@ function isFullScreenSupported() {
const body = document.body;
return !!(
body.webkitRequestFullscreen ||
(body.mozRequestFullScreen && document.mozFullScreenEnabled) ||
(body.msRequestFullscreen && document.msFullscreenEnabled) ||
(body.requestFullscreen && document.fullscreenEnabled)
);
@@ -220,8 +219,7 @@ function isFullScreenSupported() {
*/
function isFullScreen() {
return !!(
document.webkitIsFullScreen || document.mozFullScreen ||
document.msFullscreenElement || document.fullscreenElement
document.webkitIsFullScreen || document.msFullscreenElement || document.fullscreenElement
);
}
@@ -234,8 +232,6 @@ function requestFullScreen(element) {
element.requestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
}
@@ -246,9 +242,7 @@ function requestFullScreen(element) {
* @param {HTMLElement} element Element to request fullscreen
*/
function requestFullScreenWithKeys(element) {
if (element.mozRequestFullScreenWithKeys) {
element.mozRequestFullScreenWithKeys();
} else if (element.webkitRequestFullscreen) {
if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else {
requestFullScreen(element);
@@ -263,8 +257,6 @@ function exitFullScreen() {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}

View File

@@ -169,8 +169,6 @@ export function render(mapEvent) {
this.element.classList.remove(CLASS_HIDDEN);
}
}
this.label_.style.msTransform = transform;
this.label_.style.webkitTransform = transform;
this.label_.style.transform = transform;
}
this.rotation_ = rotation;

View File

@@ -201,20 +201,12 @@ class ScaleLine extends Control {
ProjUnits.METERS;
let pointResolution =
getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
if (projection.getUnits() != ProjUnits.DEGREES && projection.getMetersPerUnit()
&& pointResolutionUnits == ProjUnits.METERS) {
pointResolution *= projection.getMetersPerUnit();
}
let nominalCount = this.minWidth_ * pointResolution;
let suffix = '';
if (units == Units.DEGREES) {
const metersPerDegree = METERS_PER_UNIT[ProjUnits.DEGREES];
if (projection.getUnits() == ProjUnits.DEGREES) {
nominalCount *= metersPerDegree;
} else {
pointResolution /= metersPerDegree;
}
nominalCount *= metersPerDegree;
if (nominalCount < metersPerDegree / 60) {
suffix = '\u2033'; // seconds
pointResolution *= 3600;

View File

@@ -10,14 +10,14 @@
* @return {CanvasRenderingContext2D} The context.
*/
export function createCanvasContext2D(opt_width, opt_height) {
const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('canvas'));
const canvas = document.createElement('canvas');
if (opt_width) {
canvas.width = opt_width;
}
if (opt_height) {
canvas.height = opt_height;
}
return /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d'));
return canvas.getContext('2d');
}

View File

@@ -230,6 +230,33 @@ export const mouseOnly = function(mapBrowserEvent) {
return pointerEvent.pointerType == 'mouse';
};
/**
* Return `true` if the event originates from a touchable device.
*
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
* @return {boolean} True if the event originates from a touchable device.
* @api
*/
export const touchOnly = function(mapBrowserEvent) {
const pointerEvt = /** @type {import("../MapBrowserPointerEvent").default} */ (mapBrowserEvent).pointerEvent;
assert(pointerEvt !== undefined, 56); // mapBrowserEvent must originate from a pointer event
// see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
return pointerEvt.pointerType === 'touch';
};
/**
* Return `true` if the event originates from a digital pen.
*
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
* @return {boolean} True if the event originates from a digital pen.
* @api
*/
export const penOnly = function(mapBrowserEvent) {
const pointerEvt = /** @type {import("../MapBrowserPointerEvent").default} */ (mapBrowserEvent).pointerEvent;
assert(pointerEvt !== undefined, 56); // mapBrowserEvent must originate from a pointer event
// see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
return pointerEvt.pointerType === 'pen';
};
/**
* Return `true` if the event originates from a primary pointer in

View File

@@ -410,15 +410,15 @@ function readPolygonGeometry(object) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("../geom/Point.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {EsriJSONPoint} EsriJSON geometry.
*/
function writePointGeometry(geometry, opt_options) {
const coordinates = /** @type {import("../geom/Point.js").default} */ (geometry).getCoordinates();
const coordinates = geometry.getCoordinates();
/** @type {EsriJSONPoint} */
let esriJSON;
const layout = /** @type {import("../geom/Point.js").default} */ (geometry).getLayout();
const layout = geometry.getLayout();
if (layout === GeometryLayout.XYZ) {
esriJSON = {
x: coordinates[0],
@@ -466,12 +466,11 @@ function getHasZM(geometry) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("../geom/LineString.js").default} lineString Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
function writeLineStringGeometry(geometry, opt_options) {
const lineString = /** @type {import("../geom/LineString.js").default} */ (geometry);
function writeLineStringGeometry(lineString, opt_options) {
const hasZM = getHasZM(lineString);
return {
hasZ: hasZM.hasZ,
@@ -484,12 +483,11 @@ function writeLineStringGeometry(geometry, opt_options) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("../geom/Polygon.js").default} polygon Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {EsriJSONPolygon} EsriJSON geometry.
*/
function writePolygonGeometry(geometry, opt_options) {
const polygon = /** @type {import("../geom/Polygon.js").default} */ (geometry);
function writePolygonGeometry(polygon, opt_options) {
// Esri geometries use the left-hand rule
const hasZM = getHasZM(polygon);
return {
@@ -501,12 +499,11 @@ function writePolygonGeometry(geometry, opt_options) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("../geom/MultiLineString.js").default} multiLineString Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
function writeMultiLineStringGeometry(geometry, opt_options) {
const multiLineString = /** @type {import("../geom/MultiLineString.js").default} */ (geometry);
function writeMultiLineStringGeometry(multiLineString, opt_options) {
const hasZM = getHasZM(multiLineString);
return {
hasZ: hasZM.hasZ,
@@ -517,12 +514,11 @@ function writeMultiLineStringGeometry(geometry, opt_options) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("../geom/MultiPoint.js").default} multiPoint Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {EsriJSONMultipoint} EsriJSON geometry.
*/
function writeMultiPointGeometry(geometry, opt_options) {
const multiPoint = /** @type {import("../geom/MultiPoint.js").default} */ (geometry);
function writeMultiPointGeometry(multiPoint, opt_options) {
const hasZM = getHasZM(multiPoint);
return {
hasZ: hasZM.hasZ,
@@ -533,13 +529,13 @@ function writeMultiPointGeometry(geometry, opt_options) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {EsriJSONPolygon} EsriJSON geometry.
*/
function writeMultiPolygonGeometry(geometry, opt_options) {
const hasZM = getHasZM(/** @type {import("../geom/MultiPolygon.js").default} */(geometry));
const coordinates = /** @type {import("../geom/MultiPolygon.js").default} */ (geometry).getCoordinates(false);
const hasZM = getHasZM(geometry);
const coordinates = geometry.getCoordinates(false);
const output = [];
for (let i = 0; i < coordinates.length; i++) {
for (let x = coordinates[i].length - 1; x >= 0; x--) {

View File

@@ -718,8 +718,7 @@ class WKT extends TextFeature {
* @inheritDoc
*/
writeGeometryText(geometry, opt_options) {
return encode(/** @type {import("../geom/Geometry.js").default} */ (
transformGeometryWithOptions(geometry, true, opt_options)));
return encode(transformGeometryWithOptions(geometry, true, opt_options));
}
}

View File

@@ -16,7 +16,7 @@ import {deflateMultiCoordinatesArray} from './flat/deflate.js';
import {inflateMultiCoordinatesArray} from './flat/inflate.js';
import {getInteriorPointsOfMultiArray} from './flat/interiorpoint.js';
import {intersectsLinearRingMultiArray} from './flat/intersectsextent.js';
import {linearRingsAreOriented, orientLinearRingsArray} from './flat/orient.js';
import {linearRingssAreOriented, orientLinearRingsArray} from './flat/orient.js';
import {quantizeMultiArray} from './flat/simplify.js';
/**
@@ -251,7 +251,7 @@ class MultiPolygon extends SimpleGeometry {
getOrientedFlatCoordinates() {
if (this.orientedRevision_ != this.getRevision()) {
const flatCoordinates = this.flatCoordinates;
if (linearRingsAreOriented(
if (linearRingssAreOriented(
flatCoordinates, 0, this.endss_, this.stride)) {
this.orientedFlatCoordinates_ = flatCoordinates;
} else {

View File

@@ -16,7 +16,7 @@ import {deflateCoordinatesArray} from './flat/deflate.js';
import {inflateCoordinatesArray} from './flat/inflate.js';
import {getInteriorPointOfArray} from './flat/interiorpoint.js';
import {intersectsLinearRingArray} from './flat/intersectsextent.js';
import {linearRingIsOriented, orientLinearRings} from './flat/orient.js';
import {linearRingsAreOriented, orientLinearRings} from './flat/orient.js';
import {quantizeArray} from './flat/simplify.js';
import {modulo} from '../math.js';
@@ -266,7 +266,7 @@ class Polygon extends SimpleGeometry {
getOrientedFlatCoordinates() {
if (this.orientedRevision_ != this.getRevision()) {
const flatCoordinates = this.flatCoordinates;
if (linearRingIsOriented(
if (linearRingsAreOriented(
flatCoordinates, 0, this.ends_, this.stride)) {
this.orientedFlatCoordinates_ = flatCoordinates;
} else {

View File

@@ -41,7 +41,7 @@ export function linearRingIsClockwise(flatCoordinates, offset, end, stride) {
* (counter-clockwise exterior ring and clockwise interior rings).
* @return {boolean} Rings are correctly oriented.
*/
export function linearRingIsOriented(flatCoordinates, offset, ends, stride, opt_right) {
export function linearRingsAreOriented(flatCoordinates, offset, ends, stride, opt_right) {
const right = opt_right !== undefined ? opt_right : false;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
@@ -75,12 +75,16 @@ export function linearRingIsOriented(flatCoordinates, offset, ends, stride, opt_
* (counter-clockwise exterior ring and clockwise interior rings).
* @return {boolean} Rings are correctly oriented.
*/
export function linearRingsAreOriented(flatCoordinates, offset, endss, stride, opt_right) {
export function linearRingssAreOriented(flatCoordinates, offset, endss, stride, opt_right) {
for (let i = 0, ii = endss.length; i < ii; ++i) {
if (!linearRingIsOriented(
flatCoordinates, offset, endss[i], stride, opt_right)) {
const ends = endss[i];
if (!linearRingsAreOriented(
flatCoordinates, offset, ends, stride, opt_right)) {
return false;
}
if (ends.length) {
offset = ends[ends.length - 1];
}
}
return true;
}

View File

@@ -11,21 +11,19 @@
* @param {number} offset Offset.
* @param {number} end End.
* @param {number} stride Stride.
* @param {function(this: S, import("../../coordinate.js").Coordinate, import("../../coordinate.js").Coordinate): T} callback Function
* @param {function(import("../../coordinate.js").Coordinate, import("../../coordinate.js").Coordinate): T} callback Function
* called for each segment.
* @param {S=} opt_this The object to be used as the value of 'this'
* within callback.
* @return {T|boolean} Value.
* @template T,S
* @template T
*/
export function forEach(flatCoordinates, offset, end, stride, callback, opt_this) {
export function forEach(flatCoordinates, offset, end, stride, callback) {
const point1 = [flatCoordinates[offset], flatCoordinates[offset + 1]];
const point2 = [];
let ret;
for (; (offset + stride) < end; offset += stride) {
point2[0] = flatCoordinates[offset + stride];
point2[1] = flatCoordinates[offset + stride + 1];
ret = callback.call(opt_this, point1, point2);
ret = callback(point1, point2);
if (ret) {
return ret;
}

View File

@@ -891,7 +891,7 @@ class Draw extends PointerInteraction {
this.sketchFeature_ = null;
this.sketchPoint_ = null;
this.sketchLine_ = null;
/** @type {VectorSource} */ (this.overlay_.getSource()).clear(true);
this.overlay_.getSource().clear(true);
}
return sketchFeature;
}
@@ -930,7 +930,7 @@ class Draw extends PointerInteraction {
if (this.sketchPoint_) {
sketchFeatures.push(this.sketchPoint_);
}
const overlaySource = /** @type {VectorSource} */ (this.overlay_.getSource());
const overlaySource = this.overlay_.getSource();
overlaySource.clear(true);
overlaySource.addFeatures(sketchFeatures);
}

View File

@@ -242,7 +242,7 @@ class ExtentInteraction extends PointerInteraction {
extentFeature = new Feature(polygonFromExtent(extent));
}
this.extentFeature_ = extentFeature;
/** @type {VectorSource} */ (this.extentOverlay_.getSource()).addFeature(extentFeature);
this.extentOverlay_.getSource().addFeature(extentFeature);
} else {
if (!extent) {
extentFeature.setGeometry(undefined);
@@ -263,7 +263,7 @@ class ExtentInteraction extends PointerInteraction {
if (!vertexFeature) {
vertexFeature = new Feature(new Point(vertex));
this.vertexFeature_ = vertexFeature;
/** @type {VectorSource} */ (this.vertexOverlay_.getSource()).addFeature(vertexFeature);
this.vertexOverlay_.getSource().addFeature(vertexFeature);
} else {
const geometry = /** @type {Point} */ (vertexFeature.getGeometry());
geometry.setCoordinates(vertex);

View File

@@ -368,7 +368,7 @@ class Modify extends PointerInteraction {
// Remove the vertex feature if the collection of canditate features
// is empty.
if (this.vertexFeature_ && this.features_.getLength() === 0) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_);
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
unlisten(feature, EventType.CHANGE,
@@ -407,7 +407,7 @@ class Modify extends PointerInteraction {
*/
setActive(active) {
if (this.vertexFeature_ && !active) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_);
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
super.setActive(active);
@@ -658,7 +658,7 @@ class Modify extends PointerInteraction {
if (!vertexFeature) {
vertexFeature = new Feature(new Point(coordinates));
this.vertexFeature_ = vertexFeature;
/** @type {VectorSource} */ (this.overlay_.getSource()).addFeature(vertexFeature);
this.overlay_.getSource().addFeature(vertexFeature);
} else {
const geometry = /** @type {Point} */ (vertexFeature.getGeometry());
geometry.setCoordinates(coordinates);
@@ -944,7 +944,7 @@ class Modify extends PointerInteraction {
}
}
if (this.vertexFeature_) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_);
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
}
@@ -1139,7 +1139,7 @@ class Modify extends PointerInteraction {
}
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
if (this.vertexFeature_) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_);
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
dragSegments.length = 0;

View File

@@ -275,7 +275,7 @@ class Select extends Interaction {
* @api
*/
getFeatures() {
return /** @type {VectorSource} */ (this.featureOverlay_.getSource()).getFeaturesCollection();
return this.featureOverlay_.getSource().getFeaturesCollection();
}
/**

View File

@@ -34,6 +34,7 @@ import Layer from './Layer.js';
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*
* @extends {Layer<import("../source/Image.js").default>}
* @api
*/
class BaseImageLayer extends Layer {
@@ -48,12 +49,4 @@ class BaseImageLayer extends Layer {
}
/**
* Return the associated {@link module:ol/source/Image source} of the image layer.
* @function
* @return {import("../source/Image.js").default} Source.
* @api
*/
BaseImageLayer.prototype.getSource;
export default BaseImageLayer;

View File

@@ -39,6 +39,7 @@ import {assign} from '../obj.js';
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*
* @extends {Layer<import("../source/Tile.js").default>}
* @api
*/
class BaseTileLayer extends Layer {
@@ -102,13 +103,4 @@ class BaseTileLayer extends Layer {
}
/**
* Return the associated {@link module:ol/source/Tile tilesource} of the layer.
* @function
* @return {import("../source/Tile.js").default} Source.
* @api
*/
BaseTileLayer.prototype.getSource;
export default BaseTileLayer;

View File

@@ -61,6 +61,8 @@ const Property = {
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*
* @template {import("../source/Vector.js").default|import("../source/VectorTile.js").default} VectorSourceType
* @extends {Layer<VectorSourceType>}
* @api
*/
class BaseVectorLayer extends Layer {
@@ -131,13 +133,6 @@ class BaseVectorLayer extends Layer {
return this.declutter_;
}
/**
* @param {boolean} declutter Declutter.
*/
setDeclutter(declutter) {
this.declutter_ = declutter;
}
/**
* @return {number|undefined} Render buffer.
*/
@@ -219,13 +214,4 @@ class BaseVectorLayer extends Layer {
}
/**
* Return the associated {@link module:ol/source/Vector vectorsource} of the layer.
* @function
* @return {import("../source/Vector.js").default} Source.
* @api
*/
BaseVectorLayer.prototype.getSource;
export default BaseVectorLayer;

View File

@@ -150,7 +150,11 @@ class Graticule extends VectorLayer {
constructor(opt_options) {
const options = opt_options ? opt_options : {};
const baseOptions = assign({}, options);
const baseOptions = assign({
updateWhileAnimating: true,
updateWhileInteracting: true,
renderBuffer: 0
}, options);
delete baseOptions.maxLines;
delete baseOptions.strokeStyle;
@@ -422,11 +426,6 @@ class Graticule extends VectorLayer {
this.setRenderOrder(null);
this.renderBuffer_ = 0;
this.updateWhileAnimating_ = true;
this.updateWhileInteracting_ = true;
this.tmpExtent_ = null;
}
@@ -437,7 +436,7 @@ class Graticule extends VectorLayer {
* @param {import("../proj/Projection.js").default} projection Projection
*/
loaderFunction(extent, resolution, projection) {
const source = /** @type {import("../source/Vector.js").default} */ (this.getSource());
const source = this.getSource();
// only consider the intersection between our own extent & the requested one
const layerExtent = this.getExtent() || [-Infinity, -Infinity, Infinity, Infinity];

View File

@@ -62,6 +62,8 @@ import SourceState from '../source/State.js';
*
* @fires import("../render/Event.js").RenderEvent#prerender
* @fires import("../render/Event.js").RenderEvent#postrender
*
* @template {import("../source/Source.js").default} SourceType
*/
class Layer extends BaseLayer {
/**
@@ -106,7 +108,7 @@ class Layer extends BaseLayer {
getChangeEventType(LayerProperty.SOURCE),
this.handleSourcePropertyChange_, this);
const source = options.source ? options.source : null;
const source = options.source ? /** @type {SourceType} */ (options.source) : null;
this.setSource(source);
}
@@ -130,15 +132,12 @@ class Layer extends BaseLayer {
/**
* Get the layer source.
* @return {import("../source/Source.js").default} The layer source (or `null` if not yet set).
* @return {SourceType} The layer source (or `null` if not yet set).
* @observable
* @api
*/
getSource() {
const source = this.get(LayerProperty.SOURCE);
return (
/** @type {import("../source/Source.js").default} */ (source) || null
);
return /** @type {SourceType} */ (this.get(LayerProperty.SOURCE)) || null;
}
/**
@@ -227,7 +226,7 @@ class Layer extends BaseLayer {
/**
* Set the layer source.
* @param {import("../source/Source.js").default} source The layer source.
* @param {SourceType} source The layer source.
* @observable
* @api
*/

View File

@@ -17,6 +17,7 @@ import CanvasVectorLayerRenderer from '../renderer/canvas/VectorLayer.js';
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*
* @extends {BaseVectorLayer<import("../source/Vector.js").default>}
* @api
*/
class VectorLayer extends BaseVectorLayer {

View File

@@ -6,7 +6,41 @@ import {assign} from '../obj.js';
import CanvasVectorImageLayerRenderer from '../renderer/canvas/VectorImageLayer.js';
/**
* @typedef {import("./BaseVector.js").Options} Options
* @typedef {Object} Options
* @property {number} [opacity=1] Opacity (0, 1).
* @property {boolean} [visible=true] Visibility.
* @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
* rendered outside of this extent.
* @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
* will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
* for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
* method was used.
* @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
* visible.
* @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
* be visible.
* @property {import("../render.js").OrderFunction} [renderOrder] Render order. Function to be used when sorting
* features before rendering. By default features are drawn in the order that they are created. Use
* `null` to avoid the sort, but get an undefined draw order.
* @property {number} [renderBuffer=100] The buffer in pixels around the viewport extent used by the
* renderer when getting features from the vector source for the rendering or hit-detection.
* Recommended value: the size of the largest symbol, line width or label.
* @property {import("../source/Vector.js").default} [source] Source.
* @property {import("../PluggableMap.js").default} [map] Sets the layer as overlay on a map. The map will not manage
* this layer in its layers collection, and the layer will be rendered on top. This is useful for
* temporary layers. The standard way to add a layer to a map and have it managed by the map is to
* use {@link module:ol/Map#addLayer}.
* @property {boolean} [declutter=false] Declutter images and text. Decluttering is applied to all
* image and text styles, and the priority is defined by the z-index of the style. Lower z-index
* means higher priority.
* @property {import("../style/Style.js").StyleLike} [style] Layer style. See
* {@link module:ol/style} for default style which will be used if this is not defined.
* @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will
* be recreated during animations. This means that no vectors will be shown clipped, but the
* setting will have a performance impact for large amounts of vector data. When set to `false`,
* batches will be recreated when no animation is active.
* @property {boolean} [updateWhileInteracting=false] When set to `true`, feature batches will
* be recreated during interactions. See also `updateWhileAnimating`.
* @property {number} [imageRatio=1] Ratio by which the rendered extent should be larger than the
* viewport extent. A larger ratio avoids cut images during panning, but will cause a decrease in performance.
*/

View File

@@ -33,12 +33,13 @@ import {assign} from '../obj.js';
* point symbol or line width.
* @property {import("./VectorTileRenderType.js").default|string} [renderMode='hybrid'] Render mode for vector tiles:
* * `'image'`: Vector tiles are rendered as images. Great performance, but point symbols and texts
* are always rotated with the view and pixels are scaled during zoom animations.
* are always rotated with the view and pixels are scaled during zoom animations. When `declutter`
* is set to `true`, the decluttering is done per tile resulting in labels and point symbols getting
* cut off at tile boundaries.
* * `'hybrid'`: Polygon and line elements are rendered as images, so pixels are scaled during zoom
* animations. Point symbols and texts are accurately rendered as vectors and can stay upright on
* rotated views.
*
* When `declutter` is set to `true`, `'hybrid'` will be used instead of `'image'`.
* @property {import("../source/VectorTile.js").default} [source] Source.
* @property {import("../PluggableMap.js").default} [map] Sets the layer as overlay on a map. The map will not manage
* this layer in its layers collection, and the layer will be rendered on top. This is useful for
@@ -46,8 +47,7 @@ import {assign} from '../obj.js';
* use {@link module:ol/Map#addLayer}.
* @property {boolean} [declutter=false] Declutter images and text. Decluttering is applied to all
* image and text styles, and the priority is defined by the z-index of the style. Lower z-index
* means higher priority. When set to `true`, a `renderMode` of `'image'` will be overridden with
* `'hybrid'`.
* means higher priority.
* @property {import("../style/Style.js").StyleLike} [style] Layer style. See
* {@link module:ol/style} for default style which will be used if this is not defined.
* @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will be
@@ -70,6 +70,7 @@ import {assign} from '../obj.js';
* options means that `title` is observable, and has get/set accessors.
*
* @param {Options=} opt_options Options.
* @extends {BaseVectorLayer<import("../source/VectorTile.js").default>}
* @api
*/
class VectorTileLayer extends BaseVectorLayer {
@@ -85,16 +86,12 @@ class VectorTileLayer extends BaseVectorLayer {
super(/** @type {import("./Vector.js").Options} */ (baseOptions));
let renderMode = options.renderMode || VectorTileRenderType.HYBRID;
const renderMode = options.renderMode || VectorTileRenderType.HYBRID;
assert(renderMode == undefined ||
renderMode == VectorTileRenderType.IMAGE ||
renderMode == VectorTileRenderType.HYBRID,
28); // `renderMode` must be `'image'` or `'hybrid'`
if (options.declutter && renderMode == VectorTileRenderType.IMAGE) {
renderMode = VectorTileRenderType.HYBRID;
}
/**
* @private
* @type {VectorTileRenderType}
@@ -165,11 +162,4 @@ class VectorTileLayer extends BaseVectorLayer {
}
/**
* Return the associated {@link module:ol/source/VectorTile vectortilesource} of the layer.
* @function
* @return {import("../source/VectorTile.js").default} Source.
* @api
*/
VectorTileLayer.prototype.getSource;
export default VectorTileLayer;

View File

@@ -188,6 +188,12 @@ export function getPointResolution(projection, resolution, point, opt_units) {
const getter = projection.getPointResolutionFunc();
if (getter) {
pointResolution = getter(resolution, point);
if (opt_units && opt_units !== projection.getUnits()) {
const metersPerUnit = projection.getMetersPerUnit();
if (metersPerUnit) {
pointResolution = pointResolution * metersPerUnit / METERS_PER_UNIT[opt_units];
}
}
} else {
const units = projection.getUnits();
if (units == Units.DEGREES && !opt_units || opt_units == Units.DEGREES) {

View File

@@ -19,7 +19,7 @@ import {METERS_PER_UNIT} from './Units.js';
* @property {function(number, import("../coordinate.js").Coordinate):number} [getPointResolution]
* Function to determine resolution at a point. The function is called with a
* `{number}` view resolution and an `{import("../coordinate.js").Coordinate}` as arguments, and returns
* the `{number}` resolution at the passed coordinate. If this is `undefined`,
* the `{number}` resolution in projection units at the passed coordinate. If this is `undefined`,
* the default {@link module:ol/proj#getPointResolution} function will be used.
*/

View File

@@ -22,7 +22,7 @@ class RenderBox extends Disposable {
* @type {HTMLDivElement}
* @private
*/
this.element_ = /** @type {HTMLDivElement} */ (document.createElement('div'));
this.element_ = document.createElement('div');
this.element_.style.position = 'absolute';
this.element_.className = 'ol-box ' + className;

View File

@@ -22,81 +22,82 @@ const tmpTransform = createTransform();
* Lightweight, read-only, {@link module:ol/Feature~Feature} and {@link module:ol/geom/Geometry~Geometry} like
* structure, optimized for vector tile rendering and styling. Geometry access
* through the API is limited to getting the type and extent of the geometry.
*
* @param {GeometryType} type Geometry type.
* @param {Array<number>} flatCoordinates Flat coordinates. These always need
* to be right-handed for polygons.
* @param {Array<number>|Array<Array<number>>} ends Ends or Endss.
* @param {Object<string, *>} properties Properties.
* @param {number|string|undefined} id Feature id.
*/
class RenderFeature {
/**
* @param {GeometryType} type Geometry type.
* @param {Array<number>} flatCoordinates Flat coordinates. These always need
* to be right-handed for polygons.
* @param {Array<number>|Array<Array<number>>} ends Ends or Endss.
* @param {Object<string, *>} properties Properties.
* @param {number|string|undefined} id Feature id.
*/
constructor(type, flatCoordinates, ends, properties, id) {
/**
* @private
* @type {import("../extent.js").Extent|undefined}
*/
* @private
* @type {import("../extent.js").Extent|undefined}
*/
this.extent_;
/**
* @private
* @type {number|string|undefined}
*/
* @private
* @type {number|string|undefined}
*/
this.id_ = id;
/**
* @private
* @type {GeometryType}
*/
* @private
* @type {GeometryType}
*/
this.type_ = type;
/**
* @private
* @type {Array<number>}
*/
* @private
* @type {Array<number>}
*/
this.flatCoordinates_ = flatCoordinates;
/**
* @private
* @type {Array<number>}
*/
* @private
* @type {Array<number>}
*/
this.flatInteriorPoints_ = null;
/**
* @private
* @type {Array<number>}
*/
* @private
* @type {Array<number>}
*/
this.flatMidpoints_ = null;
/**
* @private
* @type {Array<number>|Array<Array<number>>}
*/
* @private
* @type {Array<number>|Array<Array<number>>}
*/
this.ends_ = ends;
/**
* @private
* @type {Object<string, *>}
*/
* @private
* @type {Object<string, *>}
*/
this.properties_ = properties;
}
/**
* Get a feature property by its key.
* @param {string} key Key
* @return {*} Value for the requested key.
* @api
*/
* Get a feature property by its key.
* @param {string} key Key
* @return {*} Value for the requested key.
* @api
*/
get(key) {
return this.properties_[key];
}
/**
* Get the extent of this feature's geometry.
* @return {import("../extent.js").Extent} Extent.
* @api
*/
* Get the extent of this feature's geometry.
* @return {import("../extent.js").Extent} Extent.
* @api
*/
getExtent() {
if (!this.extent_) {
this.extent_ = this.type_ === GeometryType.POINT ?
@@ -109,8 +110,8 @@ class RenderFeature {
}
/**
* @return {Array<number>} Flat interior points.
*/
* @return {Array<number>} Flat interior points.
*/
getFlatInteriorPoint() {
if (!this.flatInteriorPoints_) {
const flatCenter = getCenter(this.getExtent());
@@ -121,8 +122,8 @@ class RenderFeature {
}
/**
* @return {Array<number>} Flat interior points.
*/
* @return {Array<number>} Flat interior points.
*/
getFlatInteriorPoints() {
if (!this.flatInteriorPoints_) {
const flatCenters = linearRingssCenter(
@@ -134,8 +135,8 @@ class RenderFeature {
}
/**
* @return {Array<number>} Flat midpoint.
*/
* @return {Array<number>} Flat midpoint.
*/
getFlatMidpoint() {
if (!this.flatMidpoints_) {
this.flatMidpoints_ = interpolatePoint(
@@ -145,8 +146,8 @@ class RenderFeature {
}
/**
* @return {Array<number>} Flat midpoints.
*/
* @return {Array<number>} Flat midpoints.
*/
getFlatMidpoints() {
if (!this.flatMidpoints_) {
this.flatMidpoints_ = [];
@@ -165,28 +166,28 @@ class RenderFeature {
}
/**
* Get the feature identifier. This is a stable identifier for the feature and
* is set when reading data from a remote source.
* @return {number|string|undefined} Id.
* @api
*/
* Get the feature identifier. This is a stable identifier for the feature and
* is set when reading data from a remote source.
* @return {number|string|undefined} Id.
* @api
*/
getId() {
return this.id_;
}
/**
* @return {Array<number>} Flat coordinates.
*/
* @return {Array<number>} Flat coordinates.
*/
getOrientedFlatCoordinates() {
return this.flatCoordinates_;
}
/**
* For API compatibility with {@link module:ol/Feature~Feature}, this method is useful when
* determining the geometry type in style function (see {@link #getType}).
* @return {RenderFeature} Feature.
* @api
*/
* For API compatibility with {@link module:ol/Feature~Feature}, this method is useful when
* determining the geometry type in style function (see {@link #getType}).
* @return {RenderFeature} Feature.
* @api
*/
getGeometry() {
return this;
}
@@ -200,17 +201,17 @@ class RenderFeature {
}
/**
* Get the feature properties.
* @return {Object<string, *>} Feature properties.
* @api
*/
* Get the feature properties.
* @return {Object<string, *>} Feature properties.
* @api
*/
getProperties() {
return this.properties_;
}
/**
* @return {number} Stride.
*/
* @return {number} Stride.
*/
getStride() {
return 2;
}
@@ -223,21 +224,21 @@ class RenderFeature {
}
/**
* Get the type of this feature's geometry.
* @return {GeometryType} Geometry type.
* @api
*/
* Get the type of this feature's geometry.
* @return {GeometryType} Geometry type.
* @api
*/
getType() {
return this.type_;
}
/**
* Transform geometry coordinates from tile pixel space to projected.
* The SRS of the source and destination are expected to be the same.
*
* @param {import("../proj.js").ProjectionLike} source The current projection
* @param {import("../proj.js").ProjectionLike} destination The desired projection.
*/
* Transform geometry coordinates from tile pixel space to projected.
* The SRS of the source and destination are expected to be the same.
*
* @param {import("../proj.js").ProjectionLike} source The current projection
* @param {import("../proj.js").ProjectionLike} destination The desired projection.
*/
transform(source, destination) {
source = getProjection(source);
const pixelExtent = source.getExtent();

View File

@@ -206,7 +206,7 @@ class CanvasBuilder extends VectorContext {
* @inheritDoc.
*/
drawCustom(geometry, feature, renderer) {
this.beginGeometry(geometry, feature);
this.beginGeometry(feature);
const type = geometry.getType();
const stride = geometry.getStride();
const builderBegin = this.coordinates.length;
@@ -248,15 +248,14 @@ class CanvasBuilder extends VectorContext {
this.instructions.push([CanvasInstruction.CUSTOM,
builderBegin, builderEnd, geometry, renderer]);
}
this.endGeometry(geometry, feature);
this.endGeometry(feature);
}
/**
* @protected
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
* @param {import("../../Feature.js").FeatureLike} feature Feature.
*/
beginGeometry(geometry, feature) {
beginGeometry(feature) {
this.beginGeometryInstruction1_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
this.instructions.push(this.beginGeometryInstruction1_);
this.beginGeometryInstruction2_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
@@ -353,10 +352,9 @@ class CanvasBuilder extends VectorContext {
/**
* @param {import("../canvas.js").FillStrokeState} state State.
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
* @return {Array<*>} Fill instruction.
*/
createFill(state, geometry) {
createFill(state) {
const fillStyle = state.fillStyle;
/** @type {Array<*>} */
const fillInstruction = [CanvasInstruction.SET_FILL_STYLE, fillStyle];
@@ -389,14 +387,13 @@ class CanvasBuilder extends VectorContext {
/**
* @param {import("../canvas.js").FillStrokeState} state State.
* @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState, (import("../../geom/Geometry.js").default|import("../Feature.js").default)):Array<*>} createFill Create fill.
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
* @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState):Array<*>} createFill Create fill.
*/
updateFillStyle(state, createFill, geometry) {
updateFillStyle(state, createFill) {
const fillStyle = state.fillStyle;
if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) {
if (fillStyle !== undefined) {
this.instructions.push(createFill.call(this, state, geometry));
this.instructions.push(createFill.call(this, state));
}
state.currentFillStyle = fillStyle;
}
@@ -435,10 +432,9 @@ class CanvasBuilder extends VectorContext {
}
/**
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
* @param {import("../../Feature.js").FeatureLike} feature Feature.
*/
endGeometry(geometry, feature) {
endGeometry(feature) {
this.beginGeometryInstruction1_[2] = this.instructions.length;
this.beginGeometryInstruction1_ = null;
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;

View File

@@ -113,7 +113,7 @@ class CanvasImageBuilder extends CanvasBuilder {
if (!this.image_) {
return;
}
this.beginGeometry(pointGeometry, feature);
this.beginGeometry(feature);
const flatCoordinates = pointGeometry.getFlatCoordinates();
const stride = pointGeometry.getStride();
const myBegin = this.coordinates.length;
@@ -132,7 +132,7 @@ class CanvasImageBuilder extends CanvasBuilder {
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
this.scale_, this.width_
]);
this.endGeometry(pointGeometry, feature);
this.endGeometry(feature);
}
/**
@@ -142,7 +142,7 @@ class CanvasImageBuilder extends CanvasBuilder {
if (!this.image_) {
return;
}
this.beginGeometry(multiPointGeometry, feature);
this.beginGeometry(feature);
const flatCoordinates = multiPointGeometry.getFlatCoordinates();
const stride = multiPointGeometry.getStride();
const myBegin = this.coordinates.length;
@@ -162,7 +162,7 @@ class CanvasImageBuilder extends CanvasBuilder {
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
this.scale_, this.width_
]);
this.endGeometry(multiPointGeometry, feature);
this.endGeometry(feature);
}
/**

View File

@@ -44,7 +44,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
return;
}
this.updateStrokeStyle(state, this.applyStroke);
this.beginGeometry(lineStringGeometry, feature);
this.beginGeometry(feature);
this.hitDetectionInstructions.push([
CanvasInstruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -54,7 +54,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
const stride = lineStringGeometry.getStride();
this.drawFlatCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
this.hitDetectionInstructions.push(strokeInstruction);
this.endGeometry(lineStringGeometry, feature);
this.endGeometry(feature);
}
/**
@@ -68,7 +68,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
return;
}
this.updateStrokeStyle(state, this.applyStroke);
this.beginGeometry(multiLineStringGeometry, feature);
this.beginGeometry(feature);
this.hitDetectionInstructions.push([
CanvasInstruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -82,7 +82,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
offset = this.drawFlatCoordinates_(flatCoordinates, offset, ends[i], stride);
}
this.hitDetectionInstructions.push(strokeInstruction);
this.endGeometry(multiLineStringGeometry, feature);
this.endGeometry(feature);
}
/**

View File

@@ -72,8 +72,8 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (fillStyle === undefined && strokeStyle === undefined) {
return;
}
this.setFillStrokeStyles_(circleGeometry);
this.beginGeometry(circleGeometry, feature);
this.setFillStrokeStyles_();
this.beginGeometry(feature);
if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE,
@@ -103,7 +103,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
this.instructions.push(strokeInstruction);
this.hitDetectionInstructions.push(strokeInstruction);
}
this.endGeometry(circleGeometry, feature);
this.endGeometry(feature);
}
/**
@@ -116,8 +116,8 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (fillStyle === undefined && strokeStyle === undefined) {
return;
}
this.setFillStrokeStyles_(polygonGeometry);
this.beginGeometry(polygonGeometry, feature);
this.setFillStrokeStyles_();
this.beginGeometry(feature);
if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE,
@@ -135,7 +135,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
const flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
const stride = polygonGeometry.getStride();
this.drawFlatCoordinatess_(flatCoordinates, 0, ends, stride);
this.endGeometry(polygonGeometry, feature);
this.endGeometry(feature);
}
/**
@@ -148,8 +148,8 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (fillStyle === undefined && strokeStyle === undefined) {
return;
}
this.setFillStrokeStyles_(multiPolygonGeometry);
this.beginGeometry(multiPolygonGeometry, feature);
this.setFillStrokeStyles_();
this.beginGeometry(feature);
if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE,
@@ -170,7 +170,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
for (let i = 0, ii = endss.length; i < ii; ++i) {
offset = this.drawFlatCoordinatess_(flatCoordinates, offset, endss[i], stride);
}
this.endGeometry(multiPolygonGeometry, feature);
this.endGeometry(feature);
}
/**
@@ -195,13 +195,12 @@ class CanvasPolygonBuilder extends CanvasBuilder {
/**
* @private
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
*/
setFillStrokeStyles_(geometry) {
setFillStrokeStyles_() {
const state = this.state;
const fillStyle = state.fillStyle;
if (fillStyle !== undefined) {
this.updateFillStyle(state, this.createFill, geometry);
this.updateFillStyle(state, this.createFill);
}
if (state.strokeStyle !== undefined) {
this.updateStrokeStyle(state, this.applyStroke);

View File

@@ -184,7 +184,7 @@ class CanvasTextBuilder extends CanvasBuilder {
ends.push(endss[i][0]);
}
}
this.beginGeometry(geometry, feature);
this.beginGeometry(feature);
const textAlign = textState.textAlign;
let flatOffset = 0;
let flatEnd;
@@ -204,7 +204,7 @@ class CanvasTextBuilder extends CanvasBuilder {
this.drawChars_(begin, end, this.declutterGroup_);
begin = end;
}
this.endGeometry(geometry, feature);
this.endGeometry(feature);
} else {
@@ -258,8 +258,8 @@ class CanvasTextBuilder extends CanvasBuilder {
if (textState.backgroundFill || textState.backgroundStroke) {
this.setFillStrokeStyle(textState.backgroundFill, textState.backgroundStroke);
if (textState.backgroundFill) {
this.updateFillStyle(this.state, this.createFill, geometry);
this.hitDetectionInstructions.push(this.createFill(this.state, geometry));
this.updateFillStyle(this.state, this.createFill);
this.hitDetectionInstructions.push(this.createFill(this.state));
}
if (textState.backgroundStroke) {
this.updateStrokeStyle(this.state, this.applyStroke);
@@ -267,7 +267,7 @@ class CanvasTextBuilder extends CanvasBuilder {
}
}
this.beginGeometry(geometry, feature);
this.beginGeometry(feature);
// The image is unknown at this stage so we pass null; it will be computed at render time.
// For clarity, we pass NaN for offsetX, offsetY, width and height, which will be computed at
@@ -293,7 +293,7 @@ class CanvasTextBuilder extends CanvasBuilder {
this.textOffsetX_, this.textOffsetY_, geometryWidths
]);
this.endGeometry(geometry, feature);
this.endGeometry(feature);
}
}

View File

@@ -221,10 +221,8 @@ class LayerRenderer extends Observable {
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} currentZ Current Z.
* @param {number} preload Load low resolution tiles up to 'preload' levels.
* @param {function(this: T, import("../Tile.js").default)=} opt_tileCallback Tile callback.
* @param {T=} opt_this Object to use as `this` in `opt_tileCallback`.
* @param {function(import("../Tile.js").default)=} opt_tileCallback Tile callback.
* @protected
* @template T
*/
manageTilePyramid(
frameState,
@@ -235,8 +233,7 @@ class LayerRenderer extends Observable {
extent,
currentZ,
preload,
opt_tileCallback,
opt_this
opt_tileCallback
) {
const tileSourceKey = getUid(tileSource);
if (!(tileSourceKey in frameState.wantedTiles)) {
@@ -261,7 +258,7 @@ class LayerRenderer extends Observable {
}
}
if (opt_tileCallback !== undefined) {
opt_tileCallback.call(opt_this, tile);
opt_tileCallback(tile);
}
} else {
tileSource.useTile(z, x, y, projection);

View File

@@ -305,12 +305,4 @@ function getLayerStatesMap(layerStatesArray) {
}, {});
}
/**
* @param {import("../layer/Layer.js").State} state1 First layer state.
* @param {import("../layer/Layer.js").State} state2 Second layer state.
* @return {number} The zIndex difference.
*/
export function sortByZIndex(state1, state2) {
return state1.zIndex - state2.zIndex;
}
export default MapRenderer;

View File

@@ -43,8 +43,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
const viewState = frameState.viewState;
const viewResolution = viewState.resolution;
const imageLayer = /** @type {import("../../layer/Image.js").default} */ (this.getLayer());
const imageSource = /** @type {import("../../source/Image.js").default} */ (imageLayer.getSource());
const imageSource = this.getLayer().getSource();
const hints = frameState.viewHints;

View File

@@ -88,7 +88,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
*/
getTile(z, x, y, pixelRatio, projection) {
const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer());
const tileSource = /** @type {import("../../source/Tile.js").default} */ (tileLayer.getSource());
const tileSource = tileLayer.getSource();
let tile = tileSource.getTile(z, x, y, pixelRatio, projection);
if (tile.getState() == TileState.ERROR) {
if (!tileLayer.getUseInterimTilesOnError()) {
@@ -105,6 +105,16 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
return tile;
}
/**
* @inheritDoc
*/
loadedTileCallback(tiles, zoom, tile) {
if (this.isDrawableTile(tile)) {
return super.loadedTileCallback(tiles, zoom, tile);
}
return false;
}
/**
* @inheritDoc
*/
@@ -130,7 +140,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
const pixelRatio = frameState.pixelRatio;
const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer());
const tileSource = /** @type {import("../../source/Tile.js").default} */ (tileLayer.getSource());
const tileSource = tileLayer.getSource();
const sourceRevision = tileSource.getRevision();
const tileGrid = tileSource.getTileGridForProjection(projection);
const z = tileGrid.getZForResolution(viewResolution, this.zDirection);
@@ -199,7 +209,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
covered = findLoadedTiles(z + 1, childTileRange);
}
if (!covered) {
tileGrid.forEachTileCoordParentTileRange(tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent);
tileGrid.forEachTileCoordParentTileRange(tile.tileCoord, findLoadedTiles, tmpTileRange, tmpExtent);
}
}
@@ -281,7 +291,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
const w = nextX - x;
const h = nextY - y;
this.drawTileImage(tile, frameState, layerState, x, y, w, h, tileGutter, z === currentZ);
this.drawTileImage(tile, frameState, x, y, w, h, tileGutter, z === currentZ);
this.renderedTiles.push(tile);
this.updateUsedTiles(frameState.usedTiles, tileSource, tile);
}
@@ -318,7 +328,6 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
/**
* @param {import("../../Tile.js").default} tile Tile.
* @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
* @param {import("../../layer/Layer.js").State} layerState Layer state.
* @param {number} x Left of the tile.
* @param {number} y Top of the tile.
* @param {number} w Width of the tile.
@@ -326,7 +335,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
* @param {number} gutter Tile gutter.
* @param {boolean} transition Apply an alpha transition.
*/
drawTileImage(tile, frameState, layerState, x, y, w, h, gutter, transition) {
drawTileImage(tile, frameState, x, y, w, h, gutter, transition) {
const image = this.getTileImage(tile);
if (!image) {
return;
@@ -334,7 +343,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
const uid = getUid(this);
const alpha = transition ? tile.getAlpha(uid, frameState.time) : 1;
const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer());
const tileSource = /** @type {import("../../source/Tile.js").default} */ (tileLayer.getSource());
const tileSource = tileLayer.getSource();
if (alpha === 1 && !tileSource.getOpaque(frameState.viewState.projection)) {
this.context.clearRect(x, y, w, h);
}

View File

@@ -8,6 +8,9 @@ import {getHeight, getWidth, isEmpty, scaleFromCenter} from '../../extent.js';
import {assign} from '../../obj.js';
import CanvasImageLayerRenderer from './ImageLayer.js';
import CanvasVectorLayerRenderer from './VectorLayer.js';
import {listen} from '../../events.js';
import EventType from '../../events/EventType.js';
import ImageState from '../../ImageState.js';
/**
* @classdesc
@@ -82,17 +85,19 @@ class CanvasVectorImageLayerRenderer extends CanvasImageLayerRenderer {
if (vectorRenderer.prepareFrame(imageFrameState, layerState) &&
(vectorRenderer.replayGroupChanged ||
!equals(skippedFeatures, newSkippedFeatures))) {
context.canvas.width = imageFrameState.size[0] * pixelRatio;
context.canvas.height = imageFrameState.size[1] * pixelRatio;
vectorRenderer.renderFrame(imageFrameState, layerState);
skippedFeatures = newSkippedFeatures;
callback();
}
});
if (this.loadImage(image)) {
this.image_ = image;
this.skippedFeatures_ = skippedFeatures;
}
listen(image, EventType.CHANGE, function() {
if (image.getState() === ImageState.LOADED) {
this.image_ = image;
this.skippedFeatures_ = skippedFeatures;
}
}, this);
image.load();
}
if (this.image_) {

View File

@@ -129,7 +129,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
const projection = viewState.projection;
const rotation = viewState.rotation;
const projectionExtent = projection.getExtent();
const vectorSource = /** @type {import("../../source/Vector.js").default} */ (this.getLayer().getSource());
const vectorSource = this.getLayer().getSource();
// clipped rendering if layer extent is set
const clipExtent = layerState.extent;
@@ -196,7 +196,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
} else {
const resolution = frameState.viewState.resolution;
const rotation = frameState.viewState.rotation;
const layer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
const layer = this.getLayer();
/** @type {!Object<string, boolean>} */
const features = {};
const result = this.replayGroup_.forEachFeatureAtCoordinate(coordinate, resolution, rotation, hitTolerance, {},
@@ -239,7 +239,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
*/
prepareFrame(frameState, layerState) {
const vectorLayer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
const vectorSource = /** @type {import("../../source/Vector.js").default} */ (vectorLayer.getSource());
const vectorSource = vectorLayer.getSource();
const animating = frameState.viewHints[ViewHint.ANIMATING];
const interacting = frameState.viewHints[ViewHint.INTERACTING];

View File

@@ -205,16 +205,14 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
* @inheritDoc
*/
getTileImage(tile) {
const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer());
return tile.getImage(tileLayer);
return tile.getImage(this.getLayer());
}
/**
* @inheritDoc
*/
prepareFrame(frameState, layerState) {
const layer = /** @type {import("../../layer/VectorTile.js").default} */ (this.getLayer());
const layerRevision = layer.getRevision();
const layerRevision = this.getLayer().getRevision();
if (this.renderedLayerRevision_ != layerRevision) {
this.renderedTiles.length = 0;
}
@@ -229,9 +227,9 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
* @private
*/
updateExecutorGroup_(tile, pixelRatio, projection) {
const layer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
const layer = /** @type {import("../../layer/VectorTile.js").default} */ (this.getLayer());
const revision = layer.getRevision();
const renderOrder = /** @type {import("../../render.js").OrderFunction} */ (layer.getRenderOrder()) || null;
const renderOrder = layer.getRenderOrder() || null;
const builderState = tile.getReplayState(layer);
if (!builderState.dirty && builderState.renderedRevision == revision &&
@@ -239,7 +237,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
return;
}
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource());
const source = layer.getSource();
const sourceTileGrid = source.getTileGrid();
const tileGrid = source.getTileGridForProjection(projection);
const zoom = tile.tileCoord[0];
@@ -334,21 +332,24 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
const rotation = frameState.viewState.rotation;
hitTolerance = hitTolerance == undefined ? 0 : hitTolerance;
const layer = this.getLayer();
const source = /** @type {import("../../source/VectorTile").default} */ (layer.getSource());
const source = layer.getSource();
const tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
/** @type {!Object<string, boolean>} */
const features = {};
const renderedTiles = /** @type {Array<import("../../VectorRenderTile.js").default>} */ (this.renderedTiles);
let bufferedExtent, found;
let found;
let i, ii;
for (i = 0, ii = renderedTiles.length; i < ii; ++i) {
const tile = renderedTiles[i];
const tileExtent = tileGrid.getTileCoordExtent(tile.wrappedTileCoord);
bufferedExtent = buffer(tileExtent, hitTolerance * resolution, bufferedExtent);
if (!containsCoordinate(bufferedExtent, coordinate)) {
continue;
if (!this.declutterTree_) {
// When not decluttering, we only need to consider the tile that contains the given
// coordinate, because each feature will be rendered for each tile that contains it.
const tileExtent = tileGrid.getTileCoordExtent(tile.wrappedTileCoord);
if (!containsCoordinate(tileExtent, coordinate)) {
continue;
}
}
const executorGroups = tile.executorGroups[getUid(layer)];
for (let t = 0, tt = executorGroups.length; t < tt; ++t) {
@@ -359,7 +360,10 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
* @return {?} Callback result.
*/
function(feature) {
const key = getUid(feature);
let key = feature.getId();
if (key === undefined) {
key = getUid(feature);
}
if (!(key in features)) {
features[key] = true;
return callback.call(thisArg, feature, layer);
@@ -378,7 +382,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
*/
getReplayTransform_(tile, frameState) {
const layer = this.getLayer();
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource());
const source = layer.getSource();
const tileGrid = source.getTileGrid();
const tileCoord = tile.tileCoord;
const tileResolution = tileGrid.getResolution(tileCoord[0]);
@@ -435,7 +439,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
const context = this.overlayContext_;
const declutterReplays = layer.getDeclutter() ? {} : null;
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource());
const source = layer.getSource();
const replayTypes = VECTOR_REPLAYS[renderMode];
const pixelRatio = frameState.pixelRatio;
const rotation = frameState.viewState.rotation;
@@ -547,6 +551,10 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
const tile = this.renderTileImageQueue_[uid];
frameState.animate = true;
delete this.renderTileImageQueue_[uid];
const layer = /** @type {import("../../layer/VectorTile.js").default} */ (this.getLayer());
if (this.declutterTree_ && layer.getRenderMode() === VectorTileRenderType.IMAGE) {
this.declutterTree_.clear();
}
this.renderTileImage_(tile, frameState.pixelRatio, frameState.viewState.projection);
}
clear(this.renderTileImageQueue_);
@@ -608,7 +616,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
replayState.renderedTileZ = tile.sourceZ;
const tileCoord = tile.wrappedTileCoord;
const z = tileCoord[0];
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource());
const source = layer.getSource();
const tileGrid = source.getTileGridForProjection(projection);
const resolution = tileGrid.getResolution(z);
const context = tile.getContext(layer);

View File

@@ -264,7 +264,7 @@ class WebGLPointsLayerRenderer extends LayerRenderer {
*/
prepareFrame(frameState) {
const vectorLayer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
const vectorSource = /** @type {import("../../source/Vector.js").default} */ (vectorLayer.getSource());
const vectorSource = vectorLayer.getSource();
const stride = 12;

View File

@@ -145,7 +145,7 @@ class Source extends BaseObject {
}
/**
* Refreshes the source and finally dispatches a 'change' event.
* Refreshes the source. The source will be cleared, and data from the server will be reloaded.
* @api
*/
refresh() {

View File

@@ -75,7 +75,7 @@ class TileSource extends Source {
if (tileGrid) {
toSize(tileGrid.getTileSize(tileGrid.getMinZoom()), tileSize);
}
const canUseScreen = 'screen ' in self;
const canUseScreen = 'screen' in self;
const width = canUseScreen ? (screen.availWidth || screen.width) : 1920;
const height = canUseScreen ? (screen.availHeight || screen.height) : 1080;
cacheSize = 4 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);
@@ -300,12 +300,20 @@ class TileSource extends Source {
return withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
}
/**
* Remove all cached tiles from the source. The next render cycle will fetch new tiles.
* @api
*/
clear() {
this.tileCache.clear();
}
/**
* @inheritDoc
*/
refresh() {
this.tileCache.clear();
this.changed();
this.clear();
super.refresh();
}
/**

View File

@@ -55,6 +55,8 @@ import {createXYZ, extentFromProjection} from '../tilegrid.js';
* imageTile.getImage().src = src;
* };
* ```
* @property {number|import("../size.js").Size} [tileSize=[256, 256]] The tile size used by the tile service.
* Note: `tileSize` and other non-standard TileJSON properties are currently ignored.
* @property {string} [url] URL to the TileJSON file. If not provided, `tileJSON` must be configured.
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
* @property {number} [transition] Duration of the opacity transition for rendering.
@@ -90,6 +92,12 @@ class TileJSON extends TileImage {
*/
this.tileJSON_ = null;
/**
* @type {number|import("../size.js").Size}
* @private
*/
this.tileSize_ = options.tileSize;
if (options.url) {
if (options.jsonp) {
@@ -168,7 +176,8 @@ class TileJSON extends TileImage {
const tileGrid = createXYZ({
extent: extentFromProjection(sourceProjection),
maxZoom: maxZoom,
minZoom: minZoom
minZoom: minZoom,
tileSize: this.tileSize_
});
this.tileGrid = tileGrid;

View File

@@ -138,25 +138,23 @@ export class CustomTile extends Tile {
* Calls the callback (synchronously by default) with the available data
* for given coordinate (or `null` if not yet loaded).
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {function(this: T, *): void} callback Callback.
* @param {T=} opt_this The object to use as `this` in the callback.
* @param {function(*): void} callback Callback.
* @param {boolean=} opt_request If `true` the callback is always async.
* The tile data is requested if not yet loaded.
* @template T
*/
forDataAtCoordinate(coordinate, callback, opt_this, opt_request) {
forDataAtCoordinate(coordinate, callback, opt_request) {
if (this.state == TileState.IDLE && opt_request === true) {
listenOnce(this, EventType.CHANGE, function(e) {
callback.call(opt_this, this.getData(coordinate));
callback(this.getData(coordinate));
}, this);
this.loadInternal_();
} else {
if (opt_request === true) {
setTimeout(function() {
callback.call(opt_this, this.getData(coordinate));
callback(this.getData(coordinate));
}.bind(this), 0);
} else {
callback.call(opt_this, this.getData(coordinate));
callback(this.getData(coordinate));
}
}
}
@@ -391,7 +389,7 @@ class UTFGrid extends TileSource {
coordinate, resolution);
const tile = /** @type {!CustomTile} */(this.getTile(
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
tile.forDataAtCoordinate(coordinate, callback, null, opt_request);
tile.forDataAtCoordinate(coordinate, callback, opt_request);
} else {
if (opt_request === true) {
setTimeout(function() {

View File

@@ -498,7 +498,6 @@ class VectorSource extends Source {
if (this.featuresRtree_) {
this.featuresRtree_.clear();
}
this.loadedExtentsRtree_.clear();
this.nullGeometryFeatures_ = {};
const clearEvent = new VectorSourceEvent(VectorEventType.CLEAR);
@@ -894,6 +893,15 @@ class VectorSource extends Source {
}
}
/**
* @inheritDoc
*/
refresh() {
this.clear(true);
this.loadedExtentsRtree_.clear();
super.refresh();
}
/**
* Remove an extent from the list of loaded extents.
@@ -977,7 +985,7 @@ class VectorSource extends Source {
/**
* Set the new loader of the source. The next loadFeatures call will use the
* Set the new loader of the source. The next render cycle will use the
* new loader.
* @param {import("../featureloader.js").FeatureLoader} loader The loader to set.
* @api
@@ -986,6 +994,16 @@ class VectorSource extends Source {
this.loader_ = loader;
}
/**
* Points the source to a new url. The next render cycle will use the new url.
* @param {string|import("../featureloader.js").FeatureUrlFunction} url Url.
* @api
*/
setUrl(url) {
assert(this.format_, 7); // `format` must be set when `url` is set
this.setLoader(xhr(url, this.format_));
}
}

View File

@@ -42,12 +42,11 @@ import {equals} from '../array.js';
* var data = // ... fetch data
* var format = tile.getFormat();
* tile.setProjection(format.readProjection(data));
* tile.setExtent(format.getLastExtent()); // line only required for ol/format/MVT
* tile.setFeatures(format.readFeatures(data, {
* // featureProjection is not required for ol/format/MVT
* featureProjection: map.getView().getProjection()
* }));
* // the line below is only required for ol/format/MVT
* tile.setExtent(format.getLastExtent());
* }
* });
* ```

View File

@@ -87,6 +87,7 @@ export class CustomTile extends ImageTile {
* you must provide a `crossOrigin` value you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
* @property {number} [tilePixelRatio] The pixel ratio used by the tile service. For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px by 512px images (for retina/hidpi devices) then `tilePixelRatio` should be set to `2`
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {string} [url] URL template or base URL of the Zoomify service.
@@ -244,6 +245,7 @@ class Zoomify extends TileImage {
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
projection: options.projection,
tilePixelRatio: options.tilePixelRatio,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
tileClass: ZoomifyTileClass,
tileGrid: tileGrid,

View File

@@ -42,9 +42,7 @@ class IconImage extends EventTarget {
* @private
* @type {HTMLCanvasElement}
*/
this.canvas_ = color ?
/** @type {HTMLCanvasElement} */ (document.createElement('canvas')) :
null;
this.canvas_ = color ? document.createElement('canvas') : null;
/**
* @private

View File

@@ -103,16 +103,6 @@ class ImageStyle {
return this.scale_;
}
/**
* This method is deprecated and always returns false.
* @return {boolean} false.
* @deprecated
* @api
*/
getSnapToPixel() {
return false;
}
/**
* Get the anchor point in pixels. The anchor determines the center point for the
* symbolizer.
@@ -223,14 +213,6 @@ class ImageStyle {
this.scale_ = scale;
}
/**
* This method is deprecated and does nothing.
* @param {boolean} snapToPixel Snap to pixel?
* @deprecated
* @api
*/
setSnapToPixel(snapToPixel) {}
/**
* @abstract
* @param {function(this: T, import("../events/Event.js").default): void} listener Listener function.

View File

@@ -59,114 +59,114 @@ class Text {
const options = opt_options || {};
/**
* @private
* @type {string|undefined}
*/
* @private
* @type {string|undefined}
*/
this.font_ = options.font;
/**
* @private
* @type {number|undefined}
*/
* @private
* @type {number|undefined}
*/
this.rotation_ = options.rotation;
/**
* @private
* @type {boolean|undefined}
*/
* @private
* @type {boolean|undefined}
*/
this.rotateWithView_ = options.rotateWithView;
/**
* @private
* @type {number|undefined}
*/
* @private
* @type {number|undefined}
*/
this.scale_ = options.scale;
/**
* @private
* @type {string|undefined}
*/
* @private
* @type {string|undefined}
*/
this.text_ = options.text;
/**
* @private
* @type {string|undefined}
*/
* @private
* @type {string|undefined}
*/
this.textAlign_ = options.textAlign;
/**
* @private
* @type {string|undefined}
*/
* @private
* @type {string|undefined}
*/
this.textBaseline_ = options.textBaseline;
/**
* @private
* @type {import("./Fill.js").default}
*/
* @private
* @type {import("./Fill.js").default}
*/
this.fill_ = options.fill !== undefined ? options.fill :
new Fill({color: DEFAULT_FILL_COLOR});
/**
* @private
* @type {number}
*/
* @private
* @type {number}
*/
this.maxAngle_ = options.maxAngle !== undefined ? options.maxAngle : Math.PI / 4;
/**
* @private
* @type {import("./TextPlacement.js").default|string}
*/
* @private
* @type {import("./TextPlacement.js").default|string}
*/
this.placement_ = options.placement !== undefined ? options.placement : TextPlacement.POINT;
/**
* @private
* @type {boolean}
*/
* @private
* @type {boolean}
*/
this.overflow_ = !!options.overflow;
/**
* @private
* @type {import("./Stroke.js").default}
*/
* @private
* @type {import("./Stroke.js").default}
*/
this.stroke_ = options.stroke !== undefined ? options.stroke : null;
/**
* @private
* @type {number}
*/
* @private
* @type {number}
*/
this.offsetX_ = options.offsetX !== undefined ? options.offsetX : 0;
/**
* @private
* @type {number}
*/
* @private
* @type {number}
*/
this.offsetY_ = options.offsetY !== undefined ? options.offsetY : 0;
/**
* @private
* @type {import("./Fill.js").default}
*/
* @private
* @type {import("./Fill.js").default}
*/
this.backgroundFill_ = options.backgroundFill ? options.backgroundFill : null;
/**
* @private
* @type {import("./Stroke.js").default}
*/
* @private
* @type {import("./Stroke.js").default}
*/
this.backgroundStroke_ = options.backgroundStroke ? options.backgroundStroke : null;
/**
* @private
* @type {Array<number>}
*/
* @private
* @type {Array<number>}
*/
this.padding_ = options.padding === undefined ? null : options.padding;
}
/**
* Clones the style.
* @return {Text} The cloned style.
* @api
*/
* Clones the style.
* @return {Text} The cloned style.
* @api
*/
clone() {
return new Text({
font: this.getFont(),
@@ -189,314 +189,324 @@ class Text {
}
/**
* Get the `overflow` configuration.
* @return {boolean} Let text overflow the length of the path they follow.
* @api
*/
* Get the `overflow` configuration.
* @return {boolean} Let text overflow the length of the path they follow.
* @api
*/
getOverflow() {
return this.overflow_;
}
/**
* Get the font name.
* @return {string|undefined} Font.
* @api
*/
* Get the font name.
* @return {string|undefined} Font.
* @api
*/
getFont() {
return this.font_;
}
/**
* Get the maximum angle between adjacent characters.
* @return {number} Angle in radians.
* @api
*/
* Get the maximum angle between adjacent characters.
* @return {number} Angle in radians.
* @api
*/
getMaxAngle() {
return this.maxAngle_;
}
/**
* Get the label placement.
* @return {import("./TextPlacement.js").default|string} Text placement.
* @api
*/
* Get the label placement.
* @return {import("./TextPlacement.js").default|string} Text placement.
* @api
*/
getPlacement() {
return this.placement_;
}
/**
* Get the x-offset for the text.
* @return {number} Horizontal text offset.
* @api
*/
* Get the x-offset for the text.
* @return {number} Horizontal text offset.
* @api
*/
getOffsetX() {
return this.offsetX_;
}
/**
* Get the y-offset for the text.
* @return {number} Vertical text offset.
* @api
*/
* Get the y-offset for the text.
* @return {number} Vertical text offset.
* @api
*/
getOffsetY() {
return this.offsetY_;
}
/**
* Get the fill style for the text.
* @return {import("./Fill.js").default} Fill style.
* @api
*/
* Get the fill style for the text.
* @return {import("./Fill.js").default} Fill style.
* @api
*/
getFill() {
return this.fill_;
}
/**
* Determine whether the text rotates with the map.
* @return {boolean|undefined} Rotate with map.
* @api
*/
* Determine whether the text rotates with the map.
* @return {boolean|undefined} Rotate with map.
* @api
*/
getRotateWithView() {
return this.rotateWithView_;
}
/**
* Get the text rotation.
* @return {number|undefined} Rotation.
* @api
*/
* Get the text rotation.
* @return {number|undefined} Rotation.
* @api
*/
getRotation() {
return this.rotation_;
}
/**
* Get the text scale.
* @return {number|undefined} Scale.
* @api
*/
* Get the text scale.
* @return {number|undefined} Scale.
* @api
*/
getScale() {
return this.scale_;
}
/**
* Get the stroke style for the text.
* @return {import("./Stroke.js").default} Stroke style.
* @api
*/
* Get the stroke style for the text.
* @return {import("./Stroke.js").default} Stroke style.
* @api
*/
getStroke() {
return this.stroke_;
}
/**
* Get the text to be rendered.
* @return {string|undefined} Text.
* @api
*/
* Get the text to be rendered.
* @return {string|undefined} Text.
* @api
*/
getText() {
return this.text_;
}
/**
* Get the text alignment.
* @return {string|undefined} Text align.
* @api
*/
* Get the text alignment.
* @return {string|undefined} Text align.
* @api
*/
getTextAlign() {
return this.textAlign_;
}
/**
* Get the text baseline.
* @return {string|undefined} Text baseline.
* @api
*/
* Get the text baseline.
* @return {string|undefined} Text baseline.
* @api
*/
getTextBaseline() {
return this.textBaseline_;
}
/**
* Get the background fill style for the text.
* @return {import("./Fill.js").default} Fill style.
* @api
*/
* Get the background fill style for the text.
* @return {import("./Fill.js").default} Fill style.
* @api
*/
getBackgroundFill() {
return this.backgroundFill_;
}
/**
* Get the background stroke style for the text.
* @return {import("./Stroke.js").default} Stroke style.
* @api
*/
* Get the background stroke style for the text.
* @return {import("./Stroke.js").default} Stroke style.
* @api
*/
getBackgroundStroke() {
return this.backgroundStroke_;
}
/**
* Get the padding for the text.
* @return {Array<number>} Padding.
* @api
*/
* Get the padding for the text.
* @return {Array<number>} Padding.
* @api
*/
getPadding() {
return this.padding_;
}
/**
* Set the `overflow` property.
*
* @param {boolean} overflow Let text overflow the path that it follows.
* @api
*/
* Set the `overflow` property.
*
* @param {boolean} overflow Let text overflow the path that it follows.
* @api
*/
setOverflow(overflow) {
this.overflow_ = overflow;
}
/**
* Set the font.
*
* @param {string|undefined} font Font.
* @api
*/
* Set the font.
*
* @param {string|undefined} font Font.
* @api
*/
setFont(font) {
this.font_ = font;
}
/**
* Set the maximum angle between adjacent characters.
*
* @param {number} maxAngle Angle in radians.
* @api
*/
* Set the maximum angle between adjacent characters.
*
* @param {number} maxAngle Angle in radians.
* @api
*/
setMaxAngle(maxAngle) {
this.maxAngle_ = maxAngle;
}
/**
* Set the x offset.
*
* @param {number} offsetX Horizontal text offset.
* @api
*/
* Set the x offset.
*
* @param {number} offsetX Horizontal text offset.
* @api
*/
setOffsetX(offsetX) {
this.offsetX_ = offsetX;
}
/**
* Set the y offset.
*
* @param {number} offsetY Vertical text offset.
* @api
*/
* Set the y offset.
*
* @param {number} offsetY Vertical text offset.
* @api
*/
setOffsetY(offsetY) {
this.offsetY_ = offsetY;
}
/**
* Set the text placement.
*
* @param {import("./TextPlacement.js").default|string} placement Placement.
* @api
*/
* Set the text placement.
*
* @param {import("./TextPlacement.js").default|string} placement Placement.
* @api
*/
setPlacement(placement) {
this.placement_ = placement;
}
/**
* Set the fill.
*
* @param {import("./Fill.js").default} fill Fill style.
* @api
*/
* Set whether to rotate the text with the view.
*
* @param {boolean} rotateWithView Rotate with map.
* @api
*/
setRotateWithView(rotateWithView) {
this.rotateWithView_ = rotateWithView;
}
/**
* Set the fill.
*
* @param {import("./Fill.js").default} fill Fill style.
* @api
*/
setFill(fill) {
this.fill_ = fill;
}
/**
* Set the rotation.
*
* @param {number|undefined} rotation Rotation.
* @api
*/
* Set the rotation.
*
* @param {number|undefined} rotation Rotation.
* @api
*/
setRotation(rotation) {
this.rotation_ = rotation;
}
/**
* Set the scale.
*
* @param {number|undefined} scale Scale.
* @api
*/
* Set the scale.
*
* @param {number|undefined} scale Scale.
* @api
*/
setScale(scale) {
this.scale_ = scale;
}
/**
* Set the stroke.
*
* @param {import("./Stroke.js").default} stroke Stroke style.
* @api
*/
* Set the stroke.
*
* @param {import("./Stroke.js").default} stroke Stroke style.
* @api
*/
setStroke(stroke) {
this.stroke_ = stroke;
}
/**
* Set the text.
*
* @param {string|undefined} text Text.
* @api
*/
* Set the text.
*
* @param {string|undefined} text Text.
* @api
*/
setText(text) {
this.text_ = text;
}
/**
* Set the text alignment.
*
* @param {string|undefined} textAlign Text align.
* @api
*/
* Set the text alignment.
*
* @param {string|undefined} textAlign Text align.
* @api
*/
setTextAlign(textAlign) {
this.textAlign_ = textAlign;
}
/**
* Set the text baseline.
*
* @param {string|undefined} textBaseline Text baseline.
* @api
*/
* Set the text baseline.
*
* @param {string|undefined} textBaseline Text baseline.
* @api
*/
setTextBaseline(textBaseline) {
this.textBaseline_ = textBaseline;
}
/**
* Set the background fill.
*
* @param {import("./Fill.js").default} fill Fill style.
* @api
*/
* Set the background fill.
*
* @param {import("./Fill.js").default} fill Fill style.
* @api
*/
setBackgroundFill(fill) {
this.backgroundFill_ = fill;
}
/**
* Set the background stroke.
*
* @param {import("./Stroke.js").default} stroke Stroke style.
* @api
*/
* Set the background stroke.
*
* @param {import("./Stroke.js").default} stroke Stroke style.
* @api
*/
setBackgroundStroke(stroke) {
this.backgroundStroke_ = stroke;
}
/**
* Set the padding (`[top, right, bottom, left]`).
*
* @param {!Array<number>} padding Padding.
* @api
*/
* Set the padding (`[top, right, bottom, left]`).
*
* @param {!Array<number>} padding Padding.
* @api
*/
setPadding(padding) {
this.padding_ = padding;
}

View File

@@ -203,14 +203,12 @@ class TileGrid {
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {function(this: T, number, import("../TileRange.js").default): boolean} callback Callback.
* @param {T=} opt_this The object to use as `this` in `callback`.
* @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
* @param {import("../TileRange.js").default=} opt_tileRange Temporary import("../TileRange.js").default object.
* @param {import("../extent.js").Extent=} opt_extent Temporary import("../extent.js").Extent object.
* @return {boolean} Callback succeeded.
* @template T
*/
forEachTileCoordParentTileRange(tileCoord, callback, opt_this, opt_tileRange, opt_extent) {
forEachTileCoordParentTileRange(tileCoord, callback, opt_tileRange, opt_extent) {
let tileRange, x, y;
let tileCoordExtent = null;
let z = tileCoord[0] - 1;
@@ -228,7 +226,7 @@ class TileGrid {
} else {
tileRange = this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange);
}
if (callback.call(opt_this, z, tileRange)) {
if (callback(z, tileRange)) {
return true;
}
--z;

View File

@@ -323,7 +323,7 @@ let HAS = false;
//TODO Remove side effects
if (typeof window !== 'undefined' && 'WebGLRenderingContext' in window) {
try {
const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('canvas'));
const canvas = document.createElement('canvas');
const gl = getContext(canvas);
if (gl) {
HAS = true;

View File

@@ -74,6 +74,7 @@ module.exports = function(karma) {
}
});
process.env.CHROME_BIN = require('puppeteer').executablePath();
if (process.env.CIRCLECI) {
karma.set({
browsers: ['Chrome'],

View File

@@ -470,6 +470,7 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters text', function(done) {
createMap();
const layer = new VectorLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -488,7 +489,6 @@ describe('ol.rendering.layer.Vector', function() {
text: 'east'
}));
layer.setDeclutter(true);
layer.setStyle(function(feature) {
return new Style({
text: new Text({
@@ -510,6 +510,7 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters text and respects z-index', function(done) {
createMap();
const layer = new VectorLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -530,7 +531,6 @@ describe('ol.rendering.layer.Vector', function() {
zIndex: 1
}));
layer.setDeclutter(true);
layer.setStyle(function(feature) {
return new Style({
zIndex: feature.get('zIndex'),
@@ -550,6 +550,7 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters images', function(done) {
createMap();
const layer = new VectorLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -565,7 +566,6 @@ describe('ol.rendering.layer.Vector', function() {
geometry: new Point([center[0] + 540, center[1]])
}));
layer.setDeclutter(true);
layer.setStyle(function(feature) {
return new Style({
image: new CircleStyle({
@@ -589,6 +589,7 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters images and respects z-index', function(done) {
createMap();
const layer = new VectorLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -606,7 +607,6 @@ describe('ol.rendering.layer.Vector', function() {
zIndex: 1
}));
layer.setDeclutter(true);
layer.setStyle(function(feature) {
return new Style({
zIndex: feature.get('zIndex'),
@@ -628,6 +628,7 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters image & text groups', function(done) {
createMap();
const layer = new VectorLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -645,7 +646,6 @@ describe('ol.rendering.layer.Vector', function() {
text: 'east'
}));
layer.setDeclutter(true);
layer.setStyle(function(feature) {
return new Style({
image: new CircleStyle({
@@ -672,6 +672,7 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters text along lines and images', function(done) {
createMap();
const layer = new VectorLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -704,8 +705,6 @@ describe('ol.rendering.layer.Vector', function() {
source.addFeature(point);
source.addFeature(line);
layer.setDeclutter(true);
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-line.png',
IMAGE_TOLERANCE, done);
@@ -715,6 +714,7 @@ describe('ol.rendering.layer.Vector', function() {
it('declutters text along lines and images with z-index', function(done) {
createMap();
const layer = new VectorLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -749,8 +749,6 @@ describe('ol.rendering.layer.Vector', function() {
source.addFeature(point);
source.addFeature(line);
layer.setDeclutter(true);
map.once('postrender', function() {
const hitDetected = map.getFeaturesAtPixel([35, 46]);
expect(hitDetected).to.have.length(1);

View File

@@ -166,6 +166,7 @@ describe('ol.rendering.layer.VectorImage', function() {
it('declutters text', function(done) {
createMap();
const layer = new VectorImageLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -184,7 +185,6 @@ describe('ol.rendering.layer.VectorImage', function() {
text: 'east'
}));
layer.setDeclutter(true);
layer.setStyle(function(feature) {
return new Style({
text: new Text({
@@ -206,6 +206,7 @@ describe('ol.rendering.layer.VectorImage', function() {
it('declutters images', function(done) {
createMap();
const layer = new VectorImageLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -221,7 +222,6 @@ describe('ol.rendering.layer.VectorImage', function() {
geometry: new Point([center[0] + 540, center[1]])
}));
layer.setDeclutter(true);
layer.setStyle(function(feature) {
return new Style({
image: new CircleStyle({
@@ -245,6 +245,7 @@ describe('ol.rendering.layer.VectorImage', function() {
it('declutters text along lines and images', function(done) {
createMap();
const layer = new VectorImageLayer({
declutter: true,
source: source
});
map.addLayer(layer);
@@ -277,8 +278,6 @@ describe('ol.rendering.layer.VectorImage', function() {
source.addFeature(point);
source.addFeature(line);
layer.setDeclutter(true);
map.once('postrender', function() {
expectResemble(map, 'rendering/ol/layer/expected/vector-canvas-declutter-line.png',
IMAGE_TOLERANCE, done);

View File

@@ -1,8 +1,10 @@
import Map from '../../../../src/ol/Map.js';
import View from '../../../../src/ol/View.js';
import ScaleLine, {render} from '../../../../src/ol/control/ScaleLine.js';
import {fromLonLat} from '../../../../src/ol/proj.js';
import {fromLonLat, clearAllProjections, addCommon} from '../../../../src/ol/proj.js';
import Projection from '../../../../src/ol/proj/Projection.js';
import proj4 from 'proj4';
import {register} from '../../../../src/ol/proj/proj4.js';
describe('ol.control.ScaleLine', function() {
let map;
@@ -244,6 +246,25 @@ describe('ol.control.ScaleLine', function() {
});
describe('projections affect the scaleline', function() {
beforeEach(function() {
proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' +
'SPHEROID["GRS1980",6378137.000,298.25722210]],PRIMEM["Greenwich",0],' +
'UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],' +
'PARAMETER["false_easting",328083.333],' +
'PARAMETER["false_northing",820208.333],' +
'PARAMETER["scale_factor",0.999966666667],' +
'PARAMETER["central_meridian",-85.66666666666670],' +
'PARAMETER["latitude_of_origin",37.50000000000000],' +
'UNIT["Foot_US",0.30480060960122]]');
register(proj4);
});
afterEach(function() {
clearAllProjections();
addCommon();
});
it('is rendered differently for different projections', function() {
const ctrl = new ScaleLine();
ctrl.setMap(map);
@@ -253,15 +274,47 @@ describe('ol.control.ScaleLine', function() {
projection: 'EPSG:3857'
}));
map.renderSync();
const innerHtml3857 = ctrl.element.innerHTML;
expect(ctrl.element.innerText).to.be('2000 km');
map.setView(new View({
center: [7, 52],
zoom: 2,
projection: 'EPSG:4326'
}));
map.renderSync();
const innerHtml4326 = ctrl.element.innerHTML;
expect(innerHtml4326).to.not.be(innerHtml3857);
expect(ctrl.element.innerText).to.be('5000 km');
map.setView(new View({
center: fromLonLat([-85.685, 39.891], 'Indiana-East'),
zoom: 7,
projection: 'Indiana-East'
}));
map.renderSync();
expect(ctrl.element.innerText).to.be('100 km');
});
it('shows the same scale for different projections at higher resolutions', function() {
const ctrl = new ScaleLine();
ctrl.setMap(map);
map.setView(new View({
center: fromLonLat([-85.685, 39.891]),
zoom: 7,
projection: 'EPSG:3857'
}));
map.renderSync();
expect(ctrl.element.innerText).to.be('100 km');
map.setView(new View({
center: [-85.685, 39.891],
zoom: 7,
projection: 'EPSG:4326'
}));
map.renderSync();
expect(ctrl.element.innerText).to.be('100 km');
map.setView(new View({
center: fromLonLat([-85.685, 39.891], 'Indiana-East'),
zoom: 7,
projection: 'Indiana-East'
}));
map.renderSync();
expect(ctrl.element.innerText).to.be('100 km');
});
it('Projection\'s metersPerUnit affect scale for non-degree units', function() {
@@ -344,7 +397,7 @@ describe('ol.control.ScaleLine', function() {
const ctrl = new ScaleLine();
ctrl.setMap(map);
map.setView(new View({
center: fromLonLat([7, 0]),
center: [7, 0],
zoom: 2,
projection: 'EPSG:4326'
}));
@@ -362,7 +415,7 @@ describe('ol.control.ScaleLine', function() {
});
ctrl.setMap(map);
map.setView(new View({
center: fromLonLat([7, 0]),
center: [7, 0],
zoom: 2,
projection: 'EPSG:4326'
}));

View File

@@ -1,5 +1,5 @@
import {linearRingIsClockwise, linearRingIsOriented,
linearRingsAreOriented, orientLinearRings, orientLinearRingsArray} from '../../../../../src/ol/geom/flat/orient.js';
import {linearRingIsClockwise, linearRingsAreOriented,
linearRingssAreOriented, orientLinearRings, orientLinearRingsArray} from '../../../../../src/ol/geom/flat/orient.js';
describe('ol.geom.flat.orient', function() {
@@ -22,8 +22,8 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.linearRingIsOriented', function() {
const oriented = linearRingIsOriented;
describe('ol.geom.flat.orient.linearRingsAreOriented', function() {
const oriented = linearRingsAreOriented;
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
@@ -49,8 +49,8 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.linearRingsAreOriented', function() {
const oriented = linearRingsAreOriented;
describe('ol.geom.flat.orient.linearRingssAreOriented', function() {
const oriented = linearRingssAreOriented;
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,

View File

@@ -188,6 +188,17 @@ describe('ol.geom.MultiPolygon', function() {
});
describe('#getArea', function() {
it('works with a clockwise and a counterclockwise Polygon', function() {
const multiPolygon = new MultiPolygon([
[[[1, 3], [1, 2], [0, 2], [1, 3]]], // clockwise polygon with area 0.5
[[[2, 1], [2, 0.5], [3, 1], [2, 1]]] // counterclockwise polygon with area 0.25
]);
expect(multiPolygon.getArea()).to.be(0.75);
});
});
describe('#getInteriorPoints', function() {
it('returns XYM multipoint with intersection width as M', function() {

View File

@@ -1,11 +1,9 @@
import {getUid} from '../../../../src/ol/util.js';
import {stableSort} from '../../../../src/ol/array.js';
import Collection from '../../../../src/ol/Collection.js';
import {getIntersection} from '../../../../src/ol/extent.js';
import LayerGroup from '../../../../src/ol/layer/Group.js';
import Layer from '../../../../src/ol/layer/Layer.js';
import {assign} from '../../../../src/ol/obj.js';
import {sortByZIndex} from '../../../../src/ol/renderer/Map.js';
import Source from '../../../../src/ol/source/Source.js';
@@ -331,6 +329,36 @@ describe('ol.layer.Group', function() {
describe('#getLayerStatesArray', function() {
let layer1, layer2, layer3;
beforeEach(function() {
layer1 = new Layer({
source: new Source({
projection: 'EPSG:4326'
})
});
layer2 = new Layer({
source: new Source({
projection: 'EPSG:4326'
}),
opacity: 0.5,
visible: false,
maxResolution: 500,
minResolution: 0.25
});
layer3 = new Layer({
source: new Source({
projection: 'EPSG:4326'
}),
extent: [-5, -2, 5, 2]
});
});
afterEach(function() {
layer1.dispose();
layer2.dispose();
layer3.dispose();
});
it('returns an empty array if no layer', function() {
const layerGroup = new LayerGroup();
@@ -341,27 +369,6 @@ describe('ol.layer.Group', function() {
layerGroup.dispose();
});
const layer1 = new Layer({
source: new Source({
projection: 'EPSG:4326'
})
});
const layer2 = new Layer({
source: new Source({
projection: 'EPSG:4326'
}),
opacity: 0.5,
visible: false,
maxResolution: 500,
minResolution: 0.25
});
const layer3 = new Layer({
source: new Source({
projection: 'EPSG:4326'
}),
extent: [-5, -2, 5, 2]
});
it('does not transform layerStates by default', function() {
const layerGroup = new LayerGroup({
layers: [layer1, layer2]
@@ -444,55 +451,6 @@ describe('ol.layer.Group', function() {
layerGroup.dispose();
});
it('let order of layers without Z-index unchanged', function() {
const layerGroup = new LayerGroup({
layers: [layer1, layer2]
});
const layerStatesArray = layerGroup.getLayerStatesArray();
const initialArray = layerStatesArray.slice();
stableSort(layerStatesArray, sortByZIndex);
expect(layerStatesArray[0]).to.eql(initialArray[0]);
expect(layerStatesArray[1]).to.eql(initialArray[1]);
layerGroup.dispose();
});
it('orders layer with higher Z-index on top', function() {
const layer10 = new Layer({
source: new Source({
projection: 'EPSG:4326'
})
});
layer10.setZIndex(10);
const layerM1 = new Layer({
source: new Source({
projection: 'EPSG:4326'
})
});
layerM1.setZIndex(-1);
const layerGroup = new LayerGroup({
layers: [layer1, layer10, layer2, layerM1]
});
const layerStatesArray = layerGroup.getLayerStatesArray();
const initialArray = layerStatesArray.slice();
stableSort(layerStatesArray, sortByZIndex);
expect(layerStatesArray[0]).to.eql(initialArray[3]);
expect(layerStatesArray[1]).to.eql(initialArray[0]);
expect(layerStatesArray[2]).to.eql(initialArray[2]);
expect(layerStatesArray[3]).to.eql(initialArray[1]);
layer10.dispose();
layerM1.dispose();
layerGroup.dispose();
});
layer1.dispose();
layer2.dispose();
layer3.dispose();
});
});

View File

@@ -9,11 +9,12 @@ import {
toLonLat,
getTransform,
getPointResolution,
getTransformFromProjections
getTransformFromProjections,
METERS_PER_UNIT
} from '../../../src/ol/proj.js';
import {register} from '../../../src/ol/proj/proj4.js';
import {HALF_SIZE} from '../../../src/ol/proj/epsg3857.js';
import {METERS_PER_UNIT} from '../../../src/ol/proj/epsg4326.js';
import {METERS_PER_UNIT as metersPerDegree} from '../../../src/ol/proj/epsg4326.js';
import Projection from '../../../src/ol/proj/Projection.js';
@@ -268,7 +269,7 @@ describe('ol.proj', function() {
expect(pointResolution).to.roughlyEqual(0.615661, 1e-5);
});
it('returns the correct point resolution for EPSG:3857 with custom units', function() {
let pointResolution = getPointResolution('EPSG:3857', 1, [0, 0], 'degrees');
let pointResolution = getPointResolution('EPSG:3857', METERS_PER_UNIT['degrees'], [0, 0], 'degrees');
expect(pointResolution).to.be(1);
pointResolution = getPointResolution('EPSG:4326', 1, fromLonLat([0, 52]), 'degrees');
expect(pointResolution).to.be(1);
@@ -600,7 +601,7 @@ describe('ol.proj', function() {
it('returns value in meters', function() {
const epsg4326 = getProjection('EPSG:4326');
expect(epsg4326.getMetersPerUnit()).to.eql(METERS_PER_UNIT);
expect(epsg4326.getMetersPerUnit()).to.eql(metersPerDegree);
});
it('works for proj4js projections without units', function() {

View File

@@ -203,6 +203,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
let tile;
tileCallback = function(t) {
t.setProjection(proj);
t.setExtent([0, 0, 4096, 4096]);
tile = t;
};
map.renderSync();

View File

@@ -18,7 +18,7 @@ describe('ol.source.BingMaps', function() {
beforeEach(function(done) {
source = new BingMaps({
imagerySet: 'AerialWithLabels',
imagerySet: 'AerialWithLabelsOnDemand',
key: ''
});
@@ -39,7 +39,7 @@ describe('ol.source.BingMaps', function() {
});
it('getImagerySet works correctly', function() {
expect(source.getImagerySet()).to.equal('AerialWithLabels');
expect(source.getImagerySet()).to.equal('AerialWithLabelsOnDemand');
});
it('getApiKey works correctly', function() {

View File

@@ -1,6 +1,10 @@
import ImageWMS from '../../../../src/ol/source/ImageWMS.js';
import Image from '../../../../src/ol/layer/Image.js';
import {get as getProjection} from '../../../../src/ol/proj.js';
import {getWidth, getHeight} from '../../../../src/ol/extent.js';
import View from '../../../../src/ol/View.js';
import Map from '../../../../src/ol/Map.js';
import ImageState from '../../../../src/ol/ImageState.js';
describe('ol.source.ImageWMS', function() {
@@ -326,4 +330,51 @@ describe('ol.source.ImageWMS', function() {
});
});
describe('#refresh()', function() {
let map, source;
let callCount = 0;
beforeEach(function(done) {
source = new ImageWMS(options);
source.setImageLoadFunction(function(image) {
++callCount;
image.state = ImageState.LOADED;
source.loading = false;
});
const target = document.createElement('div');
target.style.width = target.style.height = '100px';
document.body.appendChild(target);
map = new Map({
target: target,
layers: [
new Image({
source: source
})
],
view: new View({
center: [0, 0],
zoom: 0
})
});
map.once('rendercomplete', function() {
callCount = 0;
done();
});
});
afterEach(function() {
document.body.removeChild(map.getTargetElement());
map.setTarget(null);
});
it('reloads from server', function(done) {
map.once('rendercomplete', function() {
expect(callCount).to.be(1);
done();
});
source.refresh();
});
});
});

View File

@@ -59,6 +59,10 @@ describe('ol.source.Tile', function() {
expect(source).to.be.a(Source);
expect(source).to.be.a(TileSource);
});
it('sets a screen dependent cache size', function() {
const source = new TileSource({});
expect(source.tileCache.highWaterMark).to.be(4 * Math.ceil(screen.availWidth / 256) * Math.ceil(screen.availHeight / 256));
});
it('sets a custom cache size', function() {
const projection = getProjection('EPSG:4326');
const source = new TileSource({

View File

@@ -9,6 +9,7 @@ import VectorLayer from '../../../../src/ol/layer/Vector.js';
import {bbox as bboxStrategy} from '../../../../src/ol/loadingstrategy.js';
import {get as getProjection, transformExtent, fromLonLat} from '../../../../src/ol/proj.js';
import VectorSource from '../../../../src/ol/source/Vector.js';
import GeoJSON from '../../../../src/ol/format/GeoJSON.js';
describe('ol.source.Vector', function() {
@@ -147,6 +148,79 @@ describe('ol.source.Vector', function() {
});
describe('clear and refresh', function() {
let map, source, spy;
beforeEach(function(done) {
source = new VectorSource({
format: new GeoJSON(),
url: 'spec/ol/source/vectorsource/single-feature.json'
});
const target = document.createElement('div');
target.style.width = target.style.height = '100px';
document.body.appendChild(target);
map = new Map({
target: target,
layers: [
new VectorLayer({
source: source
})
],
view: new View({
center: [0, 0],
zoom: 0
})
});
map.once('rendercomplete', function() {
spy = sinon.spy(source, 'loader_');
done();
});
});
afterEach(function() {
if (spy) {
source.loader_.restore();
}
document.body.removeChild(map.getTargetElement());
map.setTarget(null);
});
it('#refresh() reloads from server', function(done) {
expect(source.getFeatures()).to.have.length(1);
map.once('rendercomplete', function() {
expect(source.getFeatures()).to.have.length(1);
expect(spy.callCount).to.be(1);
done();
});
source.refresh();
});
it('#clear() removes all features from the source', function(done) {
expect(source.getFeatures()).to.have.length(1);
map.once('rendercomplete', function() {
expect(source.getFeatures()).to.have.length(0);
expect(spy.callCount).to.be(0);
done();
});
source.clear();
});
it('After #setUrl(), refresh() loads from the new url', function(done) {
source.loader_.restore();
spy = undefined;
expect(source.getFeatures()).to.have.length(1);
const oldCoordinates = source.getFeatures()[0].getGeometry().getCoordinates();
map.on('rendercomplete', function() {
expect(source.getFeatures()).to.have.length(1);
const newCoordinates = source.getFeatures()[0].getGeometry().getCoordinates();
expect(newCoordinates).to.not.eql(oldCoordinates);
done();
});
source.setUrl('spec/ol/data/point.json');
source.refresh();
});
});
describe('when populated with 10 random points and a null', function() {
let features;
@@ -167,8 +241,6 @@ describe('ol.source.Vector', function() {
describe('#clear', function() {
it('removes all features using fast path', function() {
const changeSpy = sinon.spy();
listen(vectorSource, 'change', changeSpy);
const removeFeatureSpy = sinon.spy();
listen(vectorSource, 'removefeature', removeFeatureSpy);
const clearSourceSpy = sinon.spy();
@@ -176,8 +248,6 @@ describe('ol.source.Vector', function() {
vectorSource.clear(true);
expect(vectorSource.getFeatures()).to.eql([]);
expect(vectorSource.isEmpty()).to.be(true);
expect(changeSpy).to.be.called();
expect(changeSpy.callCount).to.be(1);
expect(removeFeatureSpy).not.to.be.called();
expect(removeFeatureSpy.callCount).to.be(0);
expect(clearSourceSpy).to.be.called();
@@ -185,8 +255,6 @@ describe('ol.source.Vector', function() {
});
it('removes all features using slow path', function() {
const changeSpy = sinon.spy();
listen(vectorSource, 'change', changeSpy);
const removeFeatureSpy = sinon.spy();
listen(vectorSource, 'removefeature', removeFeatureSpy);
const clearSourceSpy = sinon.spy();
@@ -194,8 +262,6 @@ describe('ol.source.Vector', function() {
vectorSource.clear();
expect(vectorSource.getFeatures()).to.eql([]);
expect(vectorSource.isEmpty()).to.be(true);
expect(changeSpy).to.be.called();
expect(changeSpy.callCount).to.be(1);
expect(removeFeatureSpy).to.be.called();
expect(removeFeatureSpy.callCount).to.be(features.length);
expect(clearSourceSpy).to.be.called();
@@ -521,7 +587,7 @@ describe('ol.source.Vector', function() {
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
getProjection('EPSG:3857'));
source.setLoader(loader2);
source.clear();
source.refresh();
source.loadFeatures([-10000, -10000, 10000, 10000], 1,
getProjection('EPSG:3857'));
expect(count1).to.eql(1);

View File

@@ -1,8 +1,11 @@
import TileSource from '../../../../src/ol/source/Tile.js';
import TileLayer from '../../../../src/ol/layer/Tile.js';
import TileImage from '../../../../src/ol/source/TileImage.js';
import UrlTile from '../../../../src/ol/source/UrlTile.js';
import XYZ from '../../../../src/ol/source/XYZ.js';
import {createXYZ} from '../../../../src/ol/tilegrid.js';
import View from '../../../../src/ol/View.js';
import Map from '../../../../src/ol/Map.js';
describe('ol.source.XYZ', function() {
@@ -183,4 +186,62 @@ describe('ol.source.XYZ', function() {
});
describe('clear and refresh', function() {
let map, source;
let callCount = 0;
beforeEach(function(done) {
source = new XYZ({
url: 'spec/ol/data/osm-{z}-{x}-{y}.png',
tileLoadFunction: function(image, src) {
++callCount;
image.getImage().src = src;
}
});
const target = document.createElement('div');
target.style.width = target.style.height = '100px';
document.body.appendChild(target);
map = new Map({
target: target,
layers: [
new TileLayer({
source: source
})
],
view: new View({
center: [0, 0],
zoom: 0
})
});
map.once('rendercomplete', function() {
callCount = 0;
done();
});
});
afterEach(function() {
document.body.removeChild(map.getTargetElement());
map.setTarget(null);
});
it('#refresh() reloads from server', function(done) {
map.once('rendercomplete', function() {
expect(callCount).to.be(1);
done();
});
source.refresh();
});
it('#clear() clears the tile cache', function(done) {
map.once('rendercomplete', function() {
done(new Error('should not re-render'));
});
source.clear();
setTimeout(function() {
done();
}, 1000);
});
});
});

View File

@@ -97,4 +97,13 @@ describe('ol.style.Text', function() {
});
describe('#setRotateWithView', function() {
it('sets the rotateWithView property', function() {
const textStyle = new Text();
expect(textStyle.getRotateWithView()).to.eql(undefined);
textStyle.setRotateWithView(true);
expect(textStyle.getRotateWithView()).to.eql(true);
});
});
});

10
types/dom.d.ts vendored
View File

@@ -4,30 +4,20 @@
*/
interface Document {
readonly mozFullScreen: boolean;
readonly webkitIsFullScreen: boolean;
readonly fullscreenElement: Element;
readonly mozFullScreenElement: Element;
readonly msFullscreenElement: Element;
readonly webkitFullscreenElement: Element;
readonly mozFullScreenEnabled: boolean;
readonly msFullscreenEnabled: boolean;
readonly webkitFullscreenEnabled: boolean;
mozCancelFullScreen(): void;
msExitFullscreen(): void;
webkitExitFullscreen(): void;
}
interface Element {
mozRequestFullScreen(): Promise<void>;
mozRequestFullScreenWithKeys(): Promise<void>;
msRequestFullscreen(): Promise<void>;
webkitRequestFullscreen(allowKeyboardInput?: number): Promise<void>;
}
interface CSSStyleDeclaration {
msTransform: string | null;
}