1 | ## Upgrade notes
|
2 |
|
3 | ### Next Release
|
4 |
|
5 | #### Behavior change for polygon labels
|
6 |
|
7 | Polygon labels are now only rendered when the label does not exceed the polygon at the label position. To get the old behavior, configure your `ol.style.Text` with `exceedLength: true`.
|
8 |
|
9 | #### Minor change for custom `tileLoadFunction` with `ol.source.VectorTile`
|
10 |
|
11 | It is no longer necessary to set the projection on the tile. Instead, the `readFeatures` method must be called with the tile's extent as `extent` option and the view's projection as `featureProjection`.
|
12 |
|
13 | Before:
|
14 | ```js
|
15 | tile.setLoader(function() {
|
16 | var data = // ... fetch data
|
17 | var format = tile.getFormat();
|
18 | tile.setFeatures(format.readFeatures(data));
|
19 | tile.setProjection(format.readProjection(data));
|
20 | // uncomment the line below for ol.format.MVT only
|
21 | //tile.setExtent(format.getLastExtent());
|
22 | });
|
23 | ```
|
24 |
|
25 | After:
|
26 | ```js
|
27 | tile.setLoader(function() {
|
28 | var data = // ... fetch data
|
29 | var format = tile.getFormat();
|
30 | tile.setFeatures(format.readFeatures(data, {
|
31 | featureProjection: map.getView().getProjection(),
|
32 | // uncomment the line below for ol.format.MVT only
|
33 | //extent: tile.getExtent()
|
34 | }));
|
35 | );
|
36 | ```
|
37 |
|
38 | #### Deprecation of `ol.DeviceOrientation`
|
39 |
|
40 | `ol.DeviceOrientation` is deprecated and will be removed in the next major version.
|
41 | The device-orientation example has been updated to use the (gyronorm.js)[https://github.com/dorukeker/gyronorm.js] library.
|
42 |
|
43 |
|
44 | ### v4.3.0
|
45 |
|
46 | #### `ol.source.VectorTile` no longer requires a `tileGrid` option
|
47 |
|
48 | By default, the `ol.source.VectorTile` constructor creates an XYZ tile grid (in Web Mercator) for 512 pixel tiles and assumes a max zoom level of 22. If you were creating a vector tile source with an explicit `tileGrid` option, you can now remove this.
|
49 |
|
50 | Before:
|
51 | ```js
|
52 | var source = new ol.source.VectorTile({
|
53 | tileGrid: ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22}),
|
54 | url: url
|
55 | });
|
56 | ```
|
57 |
|
58 | After:
|
59 | ```js
|
60 | var source = new ol.source.VectorTile({
|
61 | url: url
|
62 | });
|
63 | ```
|
64 |
|
65 | If you need to change the max zoom level, you can pass the source a `maxZoom` option. If you need to change the tile size, you can pass the source a `tileSize` option. If you need a completely custom tile grid, you can still pass the source a `tileGrid` option.
|
66 |
|
67 | #### `ol.interaction.Modify` deletes with `alt` key only
|
68 |
|
69 | To delete features with the modify interaction, press the `alt` key while clicking on an existing vertex. If you want to configure the modify interaction with a different delete condition, use the `deleteCondition` option. For example, to allow deletion on a single click with no modifier keys, configure the interaction like this:
|
70 | ```js
|
71 | var interaction = new ol.interaction.Modify({
|
72 | source: source,
|
73 | deleteCondition: function(event) {
|
74 | return ol.events.condition.noModifierKeys(event) && ol.events.condition.singleClick(event);
|
75 | }
|
76 | });
|
77 | ```
|
78 |
|
79 | The motivation for this change is to make the modify, draw, and snap interactions all work well together. Previously, the use of these interactions with the default configuration would make it so you couldn't reliably add new vertices (click with no modifier) and delete existing vertices (click with no modifier).
|
80 |
|
81 | #### `ol.source.VectorTile` no longer has a `tilePixelRatio` option
|
82 |
|
83 | The `tilePixelRatio` option was only used for tiles in projections with `tile-pixels` as units. For tiles read with `ol.format.MVT` and the default tile loader, or tiles with the default pixel size of 4096 pixels, no changes are necessary. For the very rare cases that do not fall under these categories, a custom `tileLoadFunction` now needs to be configured on the `ol.source.VectorTile`. In addition to calling `tile.setFeatures()` and `tile.setProjection()`, it also needs to contain code like the following:
|
84 | ```js
|
85 | var extent = tile.getFormat() instanceof ol.format.MVT ?
|
86 | tile.getLastExtent() :
|
87 | [0, 0, tilePixelRatio * tileSize, tilePixelRatio * tileSize];
|
88 | tile.setExtent(extent);
|
89 | ```
|
90 |
|
91 | #### `ol.animate` now takes the shortest arc for rotation animation
|
92 |
|
93 | Usually rotation animations should animate along the shortest arc. There are rare occasions where a spinning animation effect is desired. So if you previously had something like
|
94 | ```js
|
95 | map.getView().animate({
|
96 | rotation: 2 * Math.PI,
|
97 | duration: 2000
|
98 | });
|
99 | ```
|
100 | we recommend to split the animation into two parts and use different easing functions. The code below results in the same effect as the snippet above did with previous versions:
|
101 | ```js
|
102 | map.getView().animate({
|
103 | rotation: Math.PI,
|
104 | easing: ol.easing.easeIn
|
105 | }, {
|
106 | rotation: 2 * Math.PI,
|
107 | easing: ol.easing.easeOut
|
108 | });
|
109 | ```
|
110 |
|
111 | ### v4.2.0
|
112 |
|
113 | #### Return values of two `ol.style.RegularShape` getters have changed
|
114 |
|
115 | To provide a more consistent behaviour the following getters now return the same value that was given to constructor:
|
116 |
|
117 | `ol.style.RegularShape#getPoints` does not return the double amount of points anymore if a radius2 is set.
|
118 |
|
119 | `ol.style.RegularShape#getRadius2` will return `undefined` if no radius2 is set.
|
120 |
|
121 | ### v4.1.0
|
122 |
|
123 | #### Adding duplicate layers to a map throws
|
124 |
|
125 | Previously, you could do this:
|
126 | ```js
|
127 | map.addLayer(layer);
|
128 | map.addLayer(layer);
|
129 | ```
|
130 |
|
131 | However, after adding a duplicate layer, things failed if you tried to remove that layer.
|
132 |
|
133 | Now, `map.addLayer()` throws if you try adding a layer that has already been added to the map.
|
134 |
|
135 | #### Simpler `constrainResolution` configuration
|
136 |
|
137 | The `constrainResolution` configuration for `ol.interaction.PinchZoom` and `ol.interaction.MouseWheelZoom`
|
138 | can now be set directly with an option in `ol.interaction.defaults`:
|
139 | ```js
|
140 | ol.interaction.defaults({
|
141 | constrainResolution: true
|
142 | });
|
143 | ```
|
144 |
|
145 | ### v4.0.0
|
146 |
|
147 | #### Simpler `ol.source.Zoomify` `url` configuration
|
148 |
|
149 | Instead specifying a base url, the `url` for the `ol.source.Zoomify` source can now be a template. The `{TileGroup}`, `{x}`, `{y}`, `{z}` and placeholders must be included in the `url` in this case. the `url` can now also include subdomain placeholders:
|
150 | ```js
|
151 | new ol.source.Zoomify({
|
152 | url: 'https://{a-f}.example.com/cgi-bin/iipsrv.fcgi?zoomify=/a/b/{TileGroup}/{z}-{x}-{y}.jpg'
|
153 | });
|
154 | ```
|
155 |
|
156 | #### Removal of deprecated methods
|
157 |
|
158 | The deprecated `ol.animation` functions and `map.beforeRender()` method have been removed. Use `view.animate()` instead.
|
159 |
|
160 | The `unByKey()` method has been removed from `ol.Observable` instances. Use the `ol.Observable.unByKey()` static function instead.
|
161 | ```js
|
162 | var key = map.on('moveend', function() { ...});
|
163 | map.unByKey(key);
|
164 | ```
|
165 | New code:
|
166 | ```js
|
167 | var key = map.on('moveend', function() { ...});
|
168 | ol.Observable.unByKey(key);
|
169 | ```
|
170 |
|
171 | #### Simplified `ol.View#fit()` API
|
172 |
|
173 | In most cases, it is no longer necessary to provide an `ol.Size` (previously the 2nd argument) to `ol.View#fit()`. By default, the size of the first map that uses the view will be used. If you want to specify a different size, it goes in the options now (previously the 3rd argument, now the 2nd).
|
174 |
|
175 | Most common use case - old API:
|
176 | ```js
|
177 | map.getView().fit(extent, map.getSize());
|
178 | ```
|
179 | Most common use case - new API:
|
180 | ```js
|
181 | map.getView().fit(extent);
|
182 | ```
|
183 | Advanced use - old API:
|
184 | ```js
|
185 | map.getView().fit(extent, [200, 100], {padding: 10});
|
186 | ```
|
187 | Advanced use - new API:
|
188 | ```js
|
189 | map.getView().fit(extent, {size: [200, 100], padding 10});
|
190 | ```
|
191 |
|
192 | #### Removed build flags (`@define`)
|
193 |
|
194 | The `ol.DEBUG`, `ol.ENABLE_TILE`, `ol.ENABLE_IMAGE`, `ol.ENABLE_VECTOR`, and `ol.ENABLE_VECTOR_TILE` build flags are no longer necessary and have been removed. If you were using these in a `define` array for a custom build, you can remove them.
|
195 |
|
196 | If you leave `ol.ENABLE_WEBGL` set to `true` in your build, you should set `ol.DEBUG_WEBGL` to `false` to avoid including debuggable shader sources.
|
197 |
|
198 |
|
199 | ### v3.20.0
|
200 |
|
201 | #### Use `view.animate()` instead of `map.beforeRender()` and `ol.animation` functions
|
202 |
|
203 | The `map.beforeRender()` and `ol.animation` functions have been deprecated in favor of a new `view.animate()` function. Use of the deprecated functions will result in a warning during development. These functions are subject to removal in an upcoming release.
|
204 |
|
205 | For details on the `view.animate()` method, see the API docs and the view animation example. Upgrading should be relatively straightforward. For example, if you wanted to have an animated pan, zoom, and rotation previously, you might have done this:
|
206 |
|
207 | ```js
|
208 | var zoom = ol.animation.zoom({
|
209 | resolution: view.getResolution()
|
210 | });
|
211 | var pan = ol.animation.pan({
|
212 | source: view.getCenter()
|
213 | });
|
214 | var rotate = ol.animation.rotate({
|
215 | rotation: view.getRotation()
|
216 | });
|
217 |
|
218 | map.beforeRender(zoom, pan, rotate);
|
219 |
|
220 | map.setZoom(1);
|
221 | map.setCenter([0, 0]);
|
222 | map.setRotation(Math.PI);
|
223 | ```
|
224 |
|
225 | Now, the same can be accomplished with this:
|
226 | ```js
|
227 | view.animate({
|
228 | zoom: 1,
|
229 | center: [0, 0],
|
230 | rotation: Math.PI
|
231 | });
|
232 | ```
|
233 |
|
234 | #### `ol.Map#forEachFeatureAtPixel` and `ol.Map#hasFeatureAtPixel` parameters have changed
|
235 |
|
236 | If you are using the layer filter of one of these methods, please note that you now have to pass in the layer filter via an `ol.AtPixelOptions` object. If you are not using the layer filter the usage has not changed.
|
237 |
|
238 | Old syntax:
|
239 | ```js
|
240 | map.forEachFeatureAtPixel(pixel, callback, callbackThis, layerFilterFn, layerFilterThis);
|
241 |
|
242 | map.hasFeatureAtPixel(pixel, layerFilterFn, layerFilterThis);
|
243 | ```
|
244 |
|
245 | New syntax:
|
246 | ```js
|
247 | map.forEachFeatureAtPixel(pixel, callback.bind(callbackThis), {
|
248 | layerFilter: layerFilterFn.bind(layerFilterThis)
|
249 | });
|
250 |
|
251 | map.hasFeatureAtPixel(pixel, {
|
252 | layerFilter: layerFilterFn.bind(layerFilterThis)
|
253 | });
|
254 | ```
|
255 |
|
256 | This change is due to the introduction of the `hitTolerance` parameter which can be passed in via this `ol.AtPixelOptions` object, too.
|
257 |
|
258 | #### Use `ol.proj.getPointResolution()` instead of `projection.getPointResolution()`
|
259 |
|
260 | The experimental `getPointResolution` method has been removed from `ol.Projection` instances. Since the implementation of this method required an inverse transform (function for transforming projected coordinates to geographic coordinates) and `ol.Projection` instances are not constructed with forward or inverse transforms, it does not make sense that a projection instance can always calculate the point resolution.
|
261 |
|
262 | As a substitute for the `projection.getPointResolution()` function, a `ol.proj.getPointResolution()` function has been added. To upgrade, you will need to change things like this:
|
263 | ```js
|
264 | projection.getPointResolution(resolution, point);
|
265 | ```
|
266 |
|
267 | into this:
|
268 | ```js
|
269 | ol.proj.getPointResolution(projection, resolution, point);
|
270 | ```
|
271 |
|
272 | Note that if you were previously creating a projection with a `getPointResolution` function in the constructor (or calling `projection.setGetPointResolution()` after construction), this function will be used by `ol.proj.getPointResolution()`.
|
273 |
|
274 | #### `ol.interaction.PinchZoom` no longer zooms to a whole-number zoom level after the gesture ends
|
275 |
|
276 | The old behavior of `ol.interaction.PinchZoom` was to zoom to the next integer zoom level after the user ends the gesture.
|
277 |
|
278 | Now the pinch zoom keeps the user selected zoom level even if it is a fractional zoom.
|
279 |
|
280 | To get the old behavior set the new `constrainResolution` parameter to `true` like this:
|
281 | ```js
|
282 | new ol.interaction.PinchZoom({constrainResolution: true})
|
283 | ```
|
284 |
|
285 | See the new `pinch-zoom` example for a complete implementation.
|
286 |
|
287 | ### v3.19.1
|
288 |
|
289 | #### `ol.style.Fill` with `CanvasGradient` or `CanvasPattern`
|
290 |
|
291 | The origin for gradients and patterns has changed from `[0, 0]` to the top-left
|
292 | corner of the extent of the geometry being filled.
|
293 |
|
294 | ### v3.19.0
|
295 |
|
296 | #### `ol.style.Fill` with `CanvasGradient` or `CanvasPattern`
|
297 |
|
298 | Previously, gradients and patterns were aligned with the canvas, so they did not
|
299 | move and rotate with the map. This was changed to a more expected behavior by anchoring the fill to the map origin (usually at map coordinate `[0, 0]`).
|
300 |
|
301 | #### `goog.DEBUG` define was renamed to `ol.DEBUG`
|
302 |
|
303 | As last step in the removal of the dependency on Google Closure Library, the `goog.DEBUG` compiler define was renamed to `ol.DEBUG`. Please change accordingly in your custom build configuration json files.
|
304 |
|
305 | #### `ol.format.ogc.filter` namespace was renamed to `ol.format.filter`
|
306 |
|
307 | `ol.format.ogc.filter` was simplified to `ol.format.filter`; to upgrade your code, simply remove the `ogc` string from the name.
|
308 | For example: `ol.format.ogc.filter.and` to `ol.format.filter.and`.
|
309 |
|
310 | #### Changes only relevant to those who compile their applications together with the Closure Compiler
|
311 |
|
312 | A number of internal types have been renamed. This will not affect those who use the API provided by the library, but if you are compiling your application together with OpenLayers and using type names, you'll need to do the following:
|
313 |
|
314 | * rename `ol.CollectionProperty` to `ol.Collection.Property`
|
315 | * rename `ol.DeviceOrientationProperty` to `ol.DeviceOrientation.Property`
|
316 | * rename `ol.DragBoxEvent` to `ol.interaction.DragBox.Event`
|
317 | * rename `ol.DragBoxEventType` to `ol.interaction.DragBox.EventType`
|
318 | * rename `ol.GeolocationProperty` to `ol.Geolocation.Property`
|
319 | * rename `ol.OverlayPositioning` to `ol.Overlay.Positioning`
|
320 | * rename `ol.OverlayProperty` to `ol.Overlay.Property`
|
321 | * rename `ol.control.MousePositionProperty` to `ol.control.MousePosition.Property`
|
322 | * rename `ol.format.IGCZ` to `ol.format.IGC.Z`
|
323 | * rename `ol.interaction.InteractionProperty` to `ol.interaction.Interaction.Property`
|
324 | * rename `ol.interaction.DrawMode` to `ol.interaction.Draw.Mode`
|
325 | * rename `ol.interaction.DrawEvent` to `ol.interaction.Draw.Event`
|
326 | * rename `ol.interaction.DrawEventType` to `ol.interaction.Draw.EventType`
|
327 | * rename `ol.interaction.ExtentEvent` to `ol.interaction.Extent.Event`
|
328 | * rename `ol.interaction.ExtentEventType` to `ol.interaction.Extent.EventType`
|
329 | * rename `ol.interaction.DragAndDropEvent` to `ol.interaction.DragAndDrop.Event`
|
330 | * rename `ol.interaction.DragAndDropEventType` to `ol.interaction.DragAndDrop.EventType`
|
331 | * rename `ol.interaction.ModifyEvent` to `ol.interaction.Modify.Event`
|
332 | * rename `ol.interaction.SelectEvent` to `ol.interaction.Select.Event`
|
333 | * rename `ol.interaction.SelectEventType` to `ol.interaction.Select.EventType`
|
334 | * rename `ol.interaction.TranslateEvent` to `ol.interaction.Translate.Event`
|
335 | * rename `ol.interaction.TranslateEventType` to `ol.interaction.Translate.EventType`
|
336 | * rename `ol.layer.GroupProperty` to `ol.layer.Group.Property`
|
337 | * rename `ol.layer.HeatmapLayerProperty` to `ol.layer.Heatmap.Property`
|
338 | * rename `ol.layer.TileProperty` to `ol.layer.Tile.Property`
|
339 | * rename `ol.layer.VectorTileRenderType` to `ol.layer.VectorTile.RenderType`
|
340 | * rename `ol.MapEventType` to `ol.MapEvent.Type`
|
341 | * rename `ol.MapProperty` to `ol.Map.Property`
|
342 | * rename `ol.ModifyEventType` to `ol.interaction.Modify.EventType`
|
343 | * rename `ol.RendererType` to `ol.renderer.Type`
|
344 | * rename `ol.render.EventType` to `ol.render.Event.Type`
|
345 | * rename `ol.source.ImageEvent` to `ol.source.Image.Event`
|
346 | * rename `ol.source.ImageEventType` to `ol.source.Image.EventType`
|
347 | * rename `ol.source.RasterEvent` to `ol.source.Raster.Event`
|
348 | * rename `ol.source.RasterEventType` to `ol.source.Raster.EventType`
|
349 | * rename `ol.source.TileEvent` to `ol.source.Tile.Event`
|
350 | * rename `ol.source.TileEventType` to `ol.source.Tile.EventType`
|
351 | * rename `ol.source.VectorEvent` to `ol.source.Vector.Event`
|
352 | * rename `ol.source.VectorEventType` to `ol.source.Vector.EventType`
|
353 | * rename `ol.source.wms.ServerType` to `ol.source.WMSServerType`
|
354 | * rename `ol.source.WMTSRequestEncoding` to `ol.source.WMTS.RequestEncoding`
|
355 | * rename `ol.style.IconAnchorUnits` to `ol.style.Icon.AnchorUnits`
|
356 | * rename `ol.style.IconOrigin` to `ol.style.Icon.Origin`
|
357 |
|
358 | ### v3.18.0
|
359 |
|
360 | #### Removal of the DOM renderer
|
361 |
|
362 | The DOM renderer has been removed. Instead, the Canvas renderer should be used. If you were previously constructing a map with `'dom'` as the `renderer` option, you will see an error message in the console in debug mode and the Canvas renderer will be used instead. To remove the warning, remove the `renderer` option from your map constructor.
|
363 |
|
364 | #### Changes in the way assertions are handled
|
365 |
|
366 | Previously, minified builds of the library did not have any assertions. This caused applications to fail silently or with cryptic stack traces. Starting with this release, developers get notified of many runtime errors through the new `ol.AssertionError`. This error has a `code` property. The meaning of the code can be found on https://openlayers.org/en/latest/doc/errors/. There are additional console assertion checks in debug mode when the `goog.DEBUG` compiler flag is `true`. As this is `true` by default, it is recommended that those creating custom builds set this to `false` so these assertions are stripped.'
|
367 |
|
368 | #### Removal of `ol.ENABLE_NAMED_COLORS`
|
369 |
|
370 | This option was previously needed to use named colors with the WebGL renderer but is no longer needed.
|
371 |
|
372 | #### KML format now uses URL()
|
373 |
|
374 | The URL constructor is supported by all modern browsers, but not by older ones, such as IE. To use the KML format in such older browsers, a URL polyfill will have to be loaded before use.
|
375 |
|
376 | #### Changes only relevant to those who compile their applications together with the Closure Compiler
|
377 |
|
378 | A number of internal types have been renamed. This will not affect those who use the API provided by the library, but if you are compiling your application together with OpenLayers and using type names, you'll need to do the following:
|
379 |
|
380 | * rename `ol.CollectionEventType` to `ol.Collection.EventType`
|
381 | * rename `ol.CollectionEvent` to `ol.Collection.Event`
|
382 | * rename `ol.ViewHint` to `ol.View.Hint`
|
383 | * rename `ol.ViewProperty` to `ol.View.Property`
|
384 | * rename `ol.render.webgl.imagereplay.shader.Default.Locations` to `ol.render.webgl.imagereplay.defaultshader.Locations`
|
385 | * rename `ol.render.webgl.imagereplay.shader.DefaultFragment` to `ol.render.webgl.imagereplay.defaultshader.Fragment`
|
386 | * rename `ol.render.webgl.imagereplay.shader.DefaultVertex` to `ol.render.webgl.imagereplay.defaultshader.Vertex`
|
387 | * rename `ol.renderer.webgl.map.shader.Default.Locations` to `ol.renderer.webgl.defaultmapshader.Locations`
|
388 | * rename `ol.renderer.webgl.map.shader.Default.Locations` to `ol.renderer.webgl.defaultmapshader.Locations`
|
389 | * rename `ol.renderer.webgl.map.shader.DefaultFragment` to `ol.renderer.webgl.defaultmapshader.Fragment`
|
390 | * rename `ol.renderer.webgl.map.shader.DefaultVertex` to `ol.renderer.webgl.defaultmapshader.Vertex`
|
391 | * rename `ol.renderer.webgl.tilelayer.shader.Fragment` to `ol.renderer.webgl.tilelayershader.Fragment`
|
392 | * rename `ol.renderer.webgl.tilelayer.shader.Locations` to `ol.renderer.webgl.tilelayershader.Locations`
|
393 | * rename `ol.renderer.webgl.tilelayer.shader.Vertex` to `ol.renderer.webgl.tilelayershader.Vertex`
|
394 | * rename `ol.webgl.WebGLContextEventType` to `ol.webgl.ContextEventType`
|
395 | * rename `ol.webgl.shader.Fragment` to `ol.webgl.Fragment`
|
396 | * rename `ol.webgl.shader.Vertex` to `ol.webgl.Vertex`
|
397 |
|
398 | ### v3.17.0
|
399 |
|
400 | #### `ol.source.MapQuest` removal
|
401 |
|
402 | Because of changes at MapQuest (see: https://lists.openstreetmap.org/pipermail/talk/2016-June/076106.html) we had to remove the MapQuest source for now (see https://github.com/openlayers/openlayers/issues/5484 for details).
|
403 |
|
404 | #### `ol.interaction.ModifyEvent` changes
|
405 |
|
406 | The event object previously had a `mapBrowserPointerEvent` property, which has been renamed to `mapBrowserEvent`.
|
407 |
|
408 | #### Removal of ol.raster namespace
|
409 |
|
410 | Users compiling their code with the library and using types in the `ol.raster` namespace should note that this has now been removed. `ol.raster.Pixel` has been deleted, and the other types have been renamed as follows, and your code may need changing if you use these:
|
411 | * `ol.raster.Operation` to `ol.RasterOperation`
|
412 | * `ol.raster.OperationType` to `ol.RasterOperationType`
|
413 |
|
414 | #### All typedefs now in ol namespace
|
415 |
|
416 | Users compiling their code with the library should note that the following typedefs have been renamed; your code may need changing if you use these:
|
417 | * ol.events.ConditionType to ol.EventsConditionType
|
418 | * ol.events.EventTargetLike to ol.EventTargetLike
|
419 | * ol.events.Key to ol.EventsKey
|
420 | * ol.events.ListenerFunctionType to ol.EventsListenerFunctionType
|
421 | * ol.interaction.DragBoxEndConditionType to ol.DragBoxEndConditionType
|
422 | * ol.interaction.DrawGeometryFunctionType to ol.DrawGeometryFunctionType
|
423 | * ol.interaction.SegmentDataType to ol.ModifySegmentDataType
|
424 | * ol.interaction.SelectFilterFunction to ol.SelectFilterFunction
|
425 | * ol.interaction.SnapResultType to ol.SnapResultType
|
426 | * ol.interaction.SnapSegmentDataType to ol.SnapSegmentDataType
|
427 | * ol.proj.ProjectionLike to ol.ProjectionLike
|
428 | * ol.style.AtlasBlock to ol.AtlasBlock
|
429 | * ol.style.AtlasInfo to ol.AtlasInfo
|
430 | * ol.style.AtlasManagerInfo to ol.AtlasManagerInfo
|
431 | * ol.style.CircleRenderOptions to ol.CircleRenderOptions
|
432 | * ol.style.ImageOptions to ol.StyleImageOptions
|
433 | * ol.style.GeometryFunction to ol.StyleGeometryFunction
|
434 | * ol.style.RegularShapeRenderOptions to ol.RegularShapeRenderOptions
|
435 | * ol.style.StyleFunction to ol.StyleFunction
|
436 |
|
437 | ### v3.16.0
|
438 |
|
439 | #### Rendering change for tile sources
|
440 |
|
441 | Previously, if you called `source.setUrl()` on a tile source, all currently rendered tiles would be cleared before new tiles were loaded and rendered. This clearing of the map is undesirable if you are trying to smoothly update the tiles used by a source. This behavior has now changed, and calling `source.setUrl()` (or `source.setUrls()`) will *not* clear currently rendered tiles before loading and rendering new tiles. Instead, previously rendered tiles remain rendered until new tiles have loaded and can replace them. If you want to achieve the old behavior (render a blank map before loading new tiles), you can call `source.refresh()` or you can replace the old source with a new one (using `layer.setSource()`).
|
442 |
|
443 | #### Move of typedefs out of code and into separate file
|
444 |
|
445 | This change should not affect the great majority of application developers, but it's possible there are edge cases when compiling application code together with the library which cause compiler errors or warnings. In this case, please raise a GitHub issue. `goog.require`s for typedefs should not be necessary.
|
446 | Users compiling their code with the library should note that the following API `@typedef`s have been renamed; your code may need changing if you use these:
|
447 | * `ol.format.WFS.FeatureCollectionMetadata` to `ol.WFSFeatureCollectionMetadata`
|
448 | * `ol.format.WFS.TransactionResponse` to `ol.WFSTransactionResponse`
|
449 |
|
450 | #### Removal of `opaque` option for `ol.source.VectorTile`
|
451 |
|
452 | This option is no longer needed, so it was removed from the API.
|
453 |
|
454 | #### XHR loading for `ol.source.TileUTFGrid`
|
455 |
|
456 | The `ol.source.TileUTFGrid` now uses XMLHttpRequest to load UTFGrid tiles by default. This works out of the box with the v4 Mapbox API. To work with the v3 API, you must use the new `jsonp` option on the source. See the examples below for detail.
|
457 |
|
458 | ```js
|
459 | // To work with the v4 API
|
460 | var v4source = new ol.source.TileUTFGrid({
|
461 | url: 'https://api.tiles.mapbox.com/v4/example.json?access_token=' + YOUR_KEY_HERE
|
462 | });
|
463 |
|
464 | // To work with the v3 API
|
465 | var v3source = new ol.source.TileUTFGrid({
|
466 | jsonp: true, // <--- this is required for v3
|
467 | url: 'http://api.tiles.mapbox.com/v3/example.json'
|
468 | });
|
469 | ```
|
470 |
|
471 | ### v3.15.0
|
472 |
|
473 | #### Internet Explorer 9 support
|
474 |
|
475 | As of this release, OpenLayers requires a `classList` polyfill for IE 9 support. See https://cdn.polyfill.io/v2/docs/features#Element_prototype_classList.
|
476 |
|
477 | #### Immediate rendering API
|
478 |
|
479 | Listeners for `precompose`, `render`, and `postcompose` receive an event with a `vectorContext` property with methods for immediate vector rendering. The previous geometry drawing methods have been replaced with a single `vectorContext.drawGeometry(geometry)` method. If you were using any of the following experimental methods on the vector context, replace them with `drawGeometry`:
|
480 |
|
481 | * Removed experimental geometry drawing methods: `drawPointGeometry`, `drawLineStringGeometry`, `drawPolygonGeometry`, `drawMultiPointGeometry`, `drawMultiLineStringGeometry`, `drawMultiPolygonGeometry`, and `drawCircleGeometry` (all have been replaced with `drawGeometry`).
|
482 |
|
483 | In addition, the previous methods for setting style parts have been replaced with a single `vectorContext.setStyle(style)` method. If you were using any of the following experimental methods on the vector context, replace them with `setStyle`:
|
484 |
|
485 | * Removed experimental style setting methods: `setFillStrokeStyle`, `setImageStyle`, `setTextStyle` (all have been replaced with `setStyle`).
|
486 |
|
487 | Below is an example of how the vector context might have been used in the past:
|
488 |
|
489 | ```js
|
490 | // OLD WAY, NO LONGER SUPPORTED
|
491 | map.on('postcompose', function(event) {
|
492 | event.vectorContext.setFillStrokeStyle(style.getFill(), style.getStroke());
|
493 | event.vectorContext.drawPointGeometry(geometry);
|
494 | });
|
495 | ```
|
496 |
|
497 | Here is an example of how you could accomplish the same with the new methods:
|
498 | ```js
|
499 | // NEW WAY, USE THIS INSTEAD OF THE CODE ABOVE
|
500 | map.on('postcompose', function(event) {
|
501 | event.vectorContext.setStyle(style);
|
502 | event.vectorContext.drawGeometry(geometry);
|
503 | });
|
504 | ```
|
505 |
|
506 | A final change to the immediate rendering API is that `vectorContext.drawFeature()` calls are now "immediate" as well. The drawing now occurs synchronously. This means that any `zIndex` in a style passed to `drawFeature()` will be ignored. To achieve `zIndex` ordering, order your calls to `drawFeature()` instead.
|
507 |
|
508 | #### Removal of `ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK`
|
509 |
|
510 | The `ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK` define has been removed. The size of the cache can now be defined on every tile based `ol.source`:
|
511 | ```js
|
512 | new ol.layer.Tile({
|
513 | source: new ol.source.OSM({
|
514 | cacheSize: 128
|
515 | })
|
516 | })
|
517 | ```
|
518 | The default cache size is `2048`.
|
519 |
|
520 | ### v3.14.0
|
521 |
|
522 | #### Internet Explorer 9 support
|
523 |
|
524 | As of this release, OpenLayers requires a `requestAnimationFrame`/`cancelAnimationFrame` polyfill for IE 9 support. See https://cdn.polyfill.io/v2/docs/features/#requestAnimationFrame.
|
525 |
|
526 | #### Layer pre-/postcompose event changes
|
527 |
|
528 | It is the responsibility of the application to undo any canvas transform changes at the end of a layer 'precompose' or 'postcompose' handler. Previously, it was ok to set a null transform. The API now guarantees a device pixel coordinate system on the canvas with its origin in the top left corner of the map. However, applications should not rely on the underlying canvas being the same size as the visible viewport.
|
529 |
|
530 | Old code:
|
531 | ```js
|
532 | layer.on('precompose', function(e) {
|
533 | // rely on canvas dimensions to move coordinate origin to center
|
534 | e.context.translate(e.context.canvas.width / 2, e.context.canvas.height / 2);
|
535 | e.context.scale(3, 3);
|
536 | // draw an x in the center of the viewport
|
537 | e.context.moveTo(-20, -20);
|
538 | e.context.lineTo(20, 20);
|
539 | e.context.moveTo(-20, 20);
|
540 | e.context.lineTo(20, -20);
|
541 | // rely on the canvas having a null transform
|
542 | e.context.setTransform(1, 0, 0, 1, 0, 0);
|
543 | });
|
544 | ```
|
545 | New code:
|
546 | ```js
|
547 | layer.on('precompose', function(e) {
|
548 | // use map size and pixel ratio to move coordinate origin to center
|
549 | var size = map.getSize();
|
550 | var pixelRatio = e.frameState.pixelRatio;
|
551 | e.context.translate(size[0] / 2 * pixelRatio, size[1] / 2 * pixelRatio);
|
552 | e.context.scale(3, 3);
|
553 | // draw an x in the center of the viewport
|
554 | e.context.moveTo(-20, -20);
|
555 | e.context.lineTo(20, 20);
|
556 | e.context.moveTo(-20, 20);
|
557 | e.context.lineTo(20, -20);
|
558 | // undo all transforms
|
559 | e.context.scale(1 / 3, 1 / 3);
|
560 | e.context.translate(-size[0] / 2 * pixelRatio, -size[1] / 2 * pixelRatio);
|
561 | });
|
562 | ```
|
563 |
|
564 | ### v3.13.0
|
565 |
|
566 | #### `proj4js` integration
|
567 |
|
568 | Before this release, OpenLayers depended on the global proj4 namespace. When using a module loader like Browserify, you might not want to depend on the global `proj4` namespace. You can use the `ol.proj.setProj4` function to set the proj4 function object. For example in a browserify ES6 environment:
|
569 |
|
570 | ```js
|
571 | import ol from 'openlayers';
|
572 | import proj4 from 'proj4';
|
573 | ol.proj.setProj4(proj4);
|
574 | ```
|
575 |
|
576 | #### `ol.source.TileJSON` changes
|
577 |
|
578 | The `ol.source.TileJSON` now uses `XMLHttpRequest` to load the TileJSON instead of JSONP with callback.
|
579 | When using server without proper CORS support, `jsonp: true` option can be passed to the constructor to get the same behavior as before:
|
580 | ```js
|
581 | new ol.source.TileJSON({
|
582 | url: 'http://serverwithoutcors.com/tilejson.json',
|
583 | jsonp: true
|
584 | })
|
585 | ```
|
586 | Also for Mapbox v3, make sure you use urls ending with `.json` (which are able to handle both `XMLHttpRequest` and JSONP) instead of `.jsonp`.
|
587 |
|
588 | ### v3.12.0
|
589 |
|
590 | #### `ol.Map#forEachFeatureAtPixel` changes
|
591 |
|
592 | The optional `layerFilter` function is now also called for unmanaged layers. To get the same behaviour as before, wrap your layer filter code in an if block like this:
|
593 | ```js
|
594 | function layerFilter(layer) {
|
595 | if (map.getLayers().getArray().indexOf(layer) !== -1) {
|
596 | // existing layer filter code
|
597 | }
|
598 | }
|
599 | ```
|
600 |
|
601 | ### v3.11.0
|
602 |
|
603 | #### `ol.format.KML` changes
|
604 |
|
605 | KML icons are scaled 50% so that the rendering better matches Google Earth rendering.
|
606 |
|
607 | If a KML placemark has a name and is a point, an `ol.style.Text` is created with the name displayed to the right of the icon (if there is an icon).
|
608 | This can be controlled with the showPointNames option which defaults to true.
|
609 |
|
610 | To disable rendering of the point names for placemarks, use the option:
|
611 | new ol.format.KML({ showPointNames: false });
|
612 |
|
613 |
|
614 | #### `ol.interaction.DragBox` and `ol.interaction.DragZoom` changes
|
615 |
|
616 | Styling is no longer done with `ol.Style`, but with pure CSS. The `style` constructor option is no longer required, and no longer available. Instead, there is a `className` option for the CSS selector. The default for `ol.interaction.DragBox` is `ol-dragbox`, and `ol.interaction.DragZoom` uses `ol-dragzoom`. If you previously had
|
617 | ```js
|
618 | new ol.interaction.DragZoom({
|
619 | style: new ol.style.Style({
|
620 | stroke: new ol.style.Stroke({
|
621 | color: 'red',
|
622 | width: 3
|
623 | }),
|
624 | fill: new ol.style.Fill({
|
625 | color: [255, 255, 255, 0.4]
|
626 | })
|
627 | })
|
628 | });
|
629 | ```
|
630 | you'll now just need
|
631 | ```js
|
632 | new ol.interaction.DragZoom();
|
633 | ```
|
634 | but with additional css:
|
635 | ```css
|
636 | .ol-dragzoom {
|
637 | border-color: red;
|
638 | border-width: 3px;
|
639 | background-color: rgba(255,255,255,0.4);
|
640 | }
|
641 | ```
|
642 |
|
643 | #### Removal of `ol.source.TileVector`
|
644 |
|
645 | With the introduction of true vector tile support, `ol.source.TileVector` becomes obsolete. Change your code to use `ol.layer.VectorTile` and `ol.source.VectorTile` instead of `ol.layer.Vector` and `ol.source.TileVector`.
|
646 |
|
647 | #### `ol.Map#forEachFeatureAtPixel` changes for unmanaged layers
|
648 |
|
649 | `ol.Map#forEachFeatureAtPixel` will still be called for unmanaged layers, but the 2nd argument to the callback function will be `null` instead of a reference to the unmanaged layer. This brings back the behavior of the abandoned `ol.FeatureOverlay` that was replaced by unmanaged layers.
|
650 |
|
651 | If you are affected by this change, please change your unmanaged layer to a regular layer by using e.g. `ol.Map#addLayer` instead of `ol.layer.Layer#setMap`.
|
652 |
|
653 | ### v3.10.0
|
654 |
|
655 | #### `ol.layer.Layer` changes
|
656 |
|
657 | The experimental `setHue`, `setContrast`, `setBrightness`, `setSaturation`, and the corresponding getter methods have been removed. These properties only worked with the WebGL renderer. If are interested in applying color transforms, look for the `postcompose` event in the API docs. In addition, the `ol.source.Raster` source provides a way to create new raster data based on arbitrary transforms run on any number of input sources.
|
658 |
|
659 | ### v3.9.0
|
660 |
|
661 | #### `ol.style.Circle` changes
|
662 |
|
663 | The experimental `getAnchor`, `getOrigin`, and `getSize` methods have been removed. The anchor and origin of a circle symbolizer are not modifiable, so these properties should not need to be accessed. The radius and stroke width can be used to calculate the rendered size of a circle symbolizer if needed:
|
664 |
|
665 | ```js
|
666 | // calculate rendered size of a circle symbolizer
|
667 | var width = 2 * circle.getRadius();
|
668 | if (circle.getStroke()) {
|
669 | width += circle.getStroke().getWidth() + 1;
|
670 | }
|
671 | ```
|
672 |
|
673 | ### v3.8.0
|
674 |
|
675 | There should be nothing special required when upgrading from v3.7.0 to v3.8.0.
|
676 |
|
677 | ### v3.7.0
|
678 |
|
679 | #### Removal of `ol.FeatureOverlay`
|
680 |
|
681 | Instead of an `ol.FeatureOverlay`, we now use an `ol.layer.Vector` with an
|
682 | `ol.source.Vector`. If you previously had:
|
683 | ```js
|
684 | var featureOverlay = new ol.FeatureOverlay({
|
685 | map: map,
|
686 | style: overlayStyle
|
687 | });
|
688 | featureOverlay.addFeature(feature);
|
689 | featureOverlay.removeFeature(feature);
|
690 | var collection = featureOverlay.getFeatures();
|
691 | ```
|
692 | you will have to change this to:
|
693 | ```js
|
694 | var collection = new ol.Collection();
|
695 | var featureOverlay = new ol.layer.Vector({
|
696 | map: map,
|
697 | source: new ol.source.Vector({
|
698 | features: collection,
|
699 | useSpatialIndex: false // optional, might improve performance
|
700 | }),
|
701 | style: overlayStyle,
|
702 | updateWhileAnimating: true, // optional, for instant visual feedback
|
703 | updateWhileInteracting: true // optional, for instant visual feedback
|
704 | });
|
705 | featureOverlay.getSource().addFeature(feature);
|
706 | featureOverlay.getSource().removeFeature(feature);
|
707 | ```
|
708 |
|
709 | With the removal of `ol.FeatureOverlay`, `zIndex` symbolizer properties of overlays are no longer stacked per map, but per layer/overlay. If you previously had multiple feature overlays where you controlled the rendering order of features by using `zIndex` symbolizer properties, you can now achieve the same rendering order only if all overlay features are on the same layer.
|
710 |
|
711 | Note that `ol.FeatureOverlay#getFeatures()` returned an `{ol.Collection.<ol.Feature>}`, whereas `ol.source.Vector#getFeatures()` returns an `{Array.<ol.Feature>}`.
|
712 |
|
713 | #### `ol.TileCoord` changes
|
714 |
|
715 | Until now, the API exposed two different types of `ol.TileCoord` tile coordinates: internal ones that increase left to right and upward, and transformed ones that may increase downward, as defined by a transform function on the tile grid. With this change, the API now only exposes tile coordinates that increase left to right and upward.
|
716 |
|
717 | Previously, tile grids created by OpenLayers either had their origin at the top-left or at the bottom-left corner of the extent. To make it easier for application developers to transform tile coordinates to the common XYZ tiling scheme, all tile grids that OpenLayers creates internally have their origin now at the top-left corner of the extent.
|
718 |
|
719 | This change affects applications that configure a custom `tileUrlFunction` for an `ol.source.Tile`. Previously, the `tileUrlFunction` was called with rather unpredictable tile coordinates, depending on whether a tile coordinate transform took place before calling the `tileUrlFunction`. Now it is always called with OpenLayers tile coordinates. To transform these into the common XYZ tiling scheme, a custom `tileUrlFunction` has to change the `y` value (tile row) of the `ol.TileCoord`:
|
720 | ```js
|
721 | function tileUrlFunction = function(tileCoord, pixelRatio, projection) {
|
722 | var urlTemplate = '{z}/{x}/{y}';
|
723 | return urlTemplate
|
724 | .replace('{z}', tileCoord[0].toString())
|
725 | .replace('{x}', tileCoord[1].toString())
|
726 | .replace('{y}', (-tileCoord[2] - 1).toString());
|
727 | }
|
728 | ```
|
729 |
|
730 | The `ol.tilegrid.TileGrid#createTileCoordTransform()` function which could be used to get the tile grid's tile coordinate transform function has been removed. This function was confusing and should no longer be needed now that application developers get tile coordinates in a known layout.
|
731 |
|
732 | The code snippets below show how your application code needs to be changed:
|
733 |
|
734 | Old application code (with `ol.tilegrid.TileGrid#createTileCoordTransform()`):
|
735 | ```js
|
736 | var transform = source.getTileGrid().createTileCoordTransform();
|
737 | var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
|
738 | tileCoord = transform(tileCoord, projection);
|
739 | return 'http://mytiles.com/' +
|
740 | tileCoord[0] + '/' + tileCoord[1] + '/' + tileCoord[2] + '.png';
|
741 | };
|
742 | ```
|
743 | Old application code (with custom `y` transform):
|
744 | ```js
|
745 | var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
|
746 | var z = tileCoord[0];
|
747 | var yFromBottom = tileCoord[2];
|
748 | var resolution = tileGrid.getResolution(z);
|
749 | var tileHeight = ol.size.toSize(tileSize)[1];
|
750 | var matrixHeight =
|
751 | Math.floor(ol.extent.getHeight(extent) / tileHeight / resolution);
|
752 | return 'http://mytiles.com/' +
|
753 | tileCoord[0] + '/' + tileCoord[1] + '/' +
|
754 | (matrixHeight - yFromBottom - 1) + '.png';
|
755 |
|
756 | };
|
757 | ```
|
758 | New application code (simple -y - 1 transform):
|
759 | ```js
|
760 | var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
|
761 | return 'http://mytiles.com/' +
|
762 | tileCoord[0] + '/' + tileCoord[1] + '/' + (-tileCoord[2] - 1) + '.png';
|
763 | };
|
764 | ```
|
765 |
|
766 | #### Removal of `ol.tilegrid.Zoomify`
|
767 |
|
768 | The replacement of `ol.tilegrid.Zoomify` is a plain `ol.tilegrid.TileGrid`, configured with `extent`, `origin` and `resolutions`. If the `size` passed to the `ol.source.Zoomify` source is `[width, height]`, then the extent for the tile grid will be `[0, -height, width, 0]`, and the origin will be `[0, 0]`.
|
769 |
|
770 | #### Replace `ol.View.fitExtent()` and `ol.View.fitGeometry()` with `ol.View.fit()`
|
771 | * This combines two previously distinct functions into one more flexible call which takes either a geometry or an extent.
|
772 | * Rename all calls to `fitExtent` and `fitGeometry` to `fit`.
|
773 |
|
774 | #### Change to `ol.interaction.Modify`
|
775 |
|
776 | When single clicking a line or boundary within the `pixelTolerance`, a vertex is now created.
|
777 |
|
778 | ### v3.6.0
|
779 |
|
780 | #### `ol.interaction.Draw` changes
|
781 |
|
782 | * The `minPointsPerRing` config option has been renamed to `minPoints`. It is now also available for linestring drawing, not only for polygons.
|
783 | * The `ol.DrawEvent` and `ol.DrawEventType` types were renamed to `ol.interaction.DrawEvent` and `ol.interaction.DrawEventType`. This has an impact on your code only if your code is compiled together with OpenLayers.
|
784 |
|
785 | #### `ol.tilegrid` changes
|
786 |
|
787 | * The `ol.tilegrid.XYZ` constructor has been replaced by a static `ol.tilegrid.createXYZ()` function. The `ol.tilegrid.createXYZ()` function takes the same arguments as the previous `ol.tilegrid.XYZ` constructor, but returns an `ol.tilegrid.TileGrid` instance.
|
788 | * The internal tile coordinate scheme for XYZ sources has been changed. Previously, the `y` of tile coordinates was transformed to the coordinates used by sources by calculating `-y-1`. Now, it is transformed by calculating `height-y-1`, where height is the number of rows of the tile grid at the zoom level of the tile coordinate.
|
789 | * The `widths` constructor option of `ol.tilegrid.TileGrid` and subclasses is no longer available, and it is no longer necessary to get proper wrapping at the 180° meridian. However, for `ol.tilegrid.WMTS`, there is a new option `sizes`, where each entry is an `ol.Size` with the `width` ('TileMatrixWidth' in WMTS capabilities) as first and the `height` ('TileMatrixHeight') as second entry of the array. For other tile grids, users can
|
790 | now specify an `extent` instead of `widths`. These settings are used to restrict the range of tiles that sources will request.
|
791 | * For `ol.source.TileWMS`, the default value of `warpX` used to be `undefined`, meaning that WMS requests with out-of-extent tile BBOXes would be sent. Now `wrapX` can only be `true` or `false`, and the new default is `true`. No application code changes should be required, but the resulting WMS requests for out-of-extent tiles will no longer use out-of-extent BBOXes, but ones that are shifted to real-world coordinates.
|
792 |
|
793 | ### v3.5.0
|
794 |
|
795 | #### `ol.Object` and `bindTo`
|
796 |
|
797 | * The following experimental methods have been removed from `ol.Object`: `bindTo`, `unbind`, and `unbindAll`. If you want to get notification about `ol.Object` property changes, you can listen for the `'propertychange'` event (e.g. `object.on('propertychange', listener)`). Two-way binding can be set up at the application level using property change listeners. See [#3472](https://github.com/openlayers/openlayers/pull/3472) for details on the change.
|
798 |
|
799 | * The experimental `ol.dom.Input` component has been removed. If you need to synchronize the state of a dom Input element with an `ol.Object`, this can be accomplished using listeners for change events. For example, you might bind the state of a checkbox type input with a layer's visibility like this:
|
800 |
|
801 | ```js
|
802 | var layer = new ol.layer.Tile();
|
803 | var checkbox = document.querySelector('#checkbox');
|
804 |
|
805 | checkbox.addEventListener('change', function() {
|
806 | var checked = this.checked;
|
807 | if (checked !== layer.getVisible()) {
|
808 | layer.setVisible(checked);
|
809 | }
|
810 | });
|
811 |
|
812 | layer.on('change:visible', function() {
|
813 | var visible = this.getVisible();
|
814 | if (visible !== checkbox.checked) {
|
815 | checkbox.checked = visible;
|
816 | }
|
817 | });
|
818 | ```
|
819 |
|
820 | #### New Vector API
|
821 |
|
822 | * The following experimental vector classes have been removed: `ol.source.GeoJSON`, `ol.source.GML`, `ol.source.GPX`, `ol.source.IGC`, `ol.source.KML`, `ol.source.OSMXML`, and `ol.source.TopoJSON`. You now will use `ol.source.Vector` instead.
|
823 |
|
824 | For example, if you used `ol.source.GeoJSON` as follows:
|
825 |
|
826 | ```js
|
827 | var source = new ol.source.GeoJSON({
|
828 | url: 'features.json',
|
829 | projection: 'EPSG:3857'
|
830 | });
|
831 | ```
|
832 |
|
833 | you will need to change your code to:
|
834 |
|
835 | ```js
|
836 | var source = new ol.source.Vector({
|
837 | url: 'features.json',
|
838 | format: new ol.format.GeoJSON()
|
839 | });
|
840 | ```
|
841 |
|
842 | See https://openlayers.org/en/master/examples/vector-layer.html for a real example.
|
843 |
|
844 | Note that you no longer need to set a `projection` on the source!
|
845 |
|
846 | Previously the vector data was loaded at source construction time, and, if the data projection and the source projection were not the same, the vector data was transformed to the source projection before being inserted (as features) into the source.
|
847 |
|
848 | The vector data is now loaded at render time, when the view projection is known. And the vector data is transformed to the view projection if the data projection and the source projection are not the same.
|
849 |
|
850 | If you still want to "eagerly" load the source you will use something like this:
|
851 |
|
852 | ```js
|
853 | var source = new ol.source.Vector();
|
854 | $.ajax('features.json').then(function(response) {
|
855 | var geojsonFormat = new ol.format.GeoJSON();
|
856 | var features = geojsonFormat.readFeatures(response,
|
857 | {featureProjection: 'EPSG:3857'});
|
858 | source.addFeatures(features);
|
859 | });
|
860 | ```
|
861 |
|
862 | The above code uses jQuery to send an Ajax request, but you can obviously use any Ajax library.
|
863 |
|
864 | See https://openlayers.org/en/master/examples/igc.html for a real example.
|
865 |
|
866 | * Note about KML
|
867 |
|
868 | If you used `ol.source.KML`'s `extractStyles` or `defaultStyle` options, you will now have to set these options on `ol.format.KML` instead. For example, if you used:
|
869 |
|
870 | ```js
|
871 | var source = new ol.source.KML({
|
872 | url: 'features.kml',
|
873 | extractStyles: false,
|
874 | projection: 'EPSG:3857'
|
875 | });
|
876 | ```
|
877 |
|
878 | you will now use:
|
879 |
|
880 | ```js
|
881 | var source = new ol.source.Vector({
|
882 | url: 'features.kml',
|
883 | format: new ol.format.KML({
|
884 | extractStyles: false
|
885 | })
|
886 | });
|
887 | ```
|
888 |
|
889 | * The `ol.source.ServerVector` class has been removed. If you used it, for example as follows:
|
890 |
|
891 | ```js
|
892 | var source = new ol.source.ServerVector({
|
893 | format: new ol.format.GeoJSON(),
|
894 | loader: function(extent, resolution, projection) {
|
895 | var url = …;
|
896 | $.ajax(url).then(function(response) {
|
897 | source.addFeatures(source.readFeatures(response));
|
898 | });
|
899 | },
|
900 | strategy: ol.loadingstrategy.bbox,
|
901 | projection: 'EPSG:3857'
|
902 | });
|
903 | ```
|
904 |
|
905 | you will need to change your code to:
|
906 |
|
907 | ```js
|
908 | var source = new ol.source.Vector({
|
909 | loader: function(extent, resolution, projection) {
|
910 | var url = …;
|
911 | $.ajax(url).then(function(response) {
|
912 | var format = new ol.format.GeoJSON();
|
913 | var features = format.readFeatures(response,
|
914 | {featureProjection: projection});
|
915 | source.addFeatures(features);
|
916 | });
|
917 | },
|
918 | strategy: ol.loadingstrategy.bbox
|
919 | });
|
920 | ```
|
921 |
|
922 | See https://openlayers.org/en/master/examples/vector-osm.html for a real example.
|
923 |
|
924 | * The experimental `ol.loadingstrategy.createTile` function has been renamed to `ol.loadingstrategy.tile`. The signature of the function hasn't changed. See https://openlayers.org/en/master/examples/vector-osm.html for an example.
|
925 |
|
926 | #### Change to `ol.style.Icon`
|
927 |
|
928 | * When manually loading an image for `ol.style.Icon`, the image size should now be set
|
929 | with the `imgSize` option and not with `size`. `size` is supposed to be used for the
|
930 | size of a sub-rectangle in an image sprite.
|
931 |
|
932 | #### Support for non-square tiles
|
933 |
|
934 | The return value of `ol.tilegrid.TileGrid#getTileSize()` will now be an `ol.Size` array instead of a number if non-square tiles (i.e. an `ol.Size` array instead of a number as `tilsSize`) are used. To always get an `ol.Size`, the new `ol.size.toSize()` was added.
|
935 |
|
936 | #### Change to `ol.interaction.Draw`
|
937 |
|
938 | When finishing a draw, the `drawend` event is now dispatched before the feature is inserted to either the source or the collection. This change allows application code to finish setting up the feature.
|
939 |
|
940 | #### Misc.
|
941 |
|
942 | If you compile your application together with the library and use the `ol.feature.FeatureStyleFunction` type annotation (this should be extremely rare), the type is now named `ol.FeatureStyleFunction`.
|
943 |
|
944 | ### v3.4.0
|
945 |
|
946 | There should be nothing special required when upgrading from v3.3.0 to v3.4.0.
|
947 |
|
948 | ### v3.3.0
|
949 |
|
950 | * The `ol.events.condition.mouseMove` function was replaced by `ol.events.condition.pointerMove` (see [#3281](https://github.com/openlayers/openlayers/pull/3281)). For example, if you use `ol.events.condition.mouseMove` as the condition in a `Select` interaction then you now need to use `ol.events.condition.pointerMove`:
|
951 |
|
952 | ```js
|
953 | var selectInteraction = new ol.interaction.Select({
|
954 | condition: ol.events.condition.pointerMove
|
955 | // …
|
956 | });
|
957 | ```
|
958 |
|
\ | No newline at end of file |