Files
openlayers/notes/2.12.md
2011-12-10 17:04:26 -07:00

3.9 KiB

Behavior Changes from Past Releases

Function return values

Previously a few functions in the library displayed error messages and returned undefined, null or false if the parameters passed in were bad. In 2.12 these functions now just throw an error/exception. People relying on return values to know if a function call is successful may need to change their code. Here are the modified functions:

  • OpenLayers.Bounds.add throws a TypeError exception if x or y is null
  • OpenLayers.LonLat.add throws a TypeError exception if lon or lat is null
  • OpenLayers.Pixel.add throws a TypeError exception if x or y is null
  • OpenLayers.Filter.Comparison.value2regex throws an Error exception if wildcard equals to "."
  • OpenLayers.Layer.PointTrack.addNodes throws a TypeError exception if endPoint isn't actually a point
  • OpenLayers.Layer.Vector.getFeatureFromEvent throws an Error exception if the layer has no renderer

Changes in formats WMTSCapabilities and SOSCapabilities

The structure of the object returned by Format.WMTSCapabilities:read and Format.SOSCapabilities:read has slightly changed.

For WMTSCapabilities the GET href used to be made available at operationsMetadata.GetCapabilities.dcp.http.get, the latter is now an array of objects with two properties: url and constrains. People using operationsMetadata.GetCapabilities.dcp.http.get in their applications should certainly use operationsMetadata.GetCapabilities.dcp.http.get[0].url.

Likewise for SOSCapabilities.

Looking at the tests is a good way to understand what the requires changes are. See SOSCapabilities/v1_0_0.html and WMTSCapabilities/v1_0_0.html.

Rico deprecation

We are deprecating the Rico classes/objects in OpenLayers. This has the following implications:

Popup.AnchoredBubble is deprecated. Its constructor now displays a deprecation message on the console. If you want popups with rounded corners either use Popup.FramedClould, or use Popup.Anchored and round corners using the border-radius CSS property.

The roundedCorner option of Control.LayerSwitcher is deprecated, and it now defaults to false. Setting it to true results in deprecation messages being output on the console. If you still want to set roundedCorner to true (you should not!) you need to make sure that the Rico/Corner.js and Rico/Color.js scripts are loaded in the page. This can be ensured by adding Rico/Corner.js in the build profile. The controls.html example demonstrates how to use border-radius to round corners of a layer switcher:

olControlLayerSwitcher .layersDiv {
    border-radius: 10px 0 0 10px;
}

See more detail in the Rico deprecation pull request.

In future releases we intend to move the Rico and AnchoredBubble code into deprecated.js. You really should consider stop using Rico-based functionalities in your applications.

Changes in Geometry

The base OpenLayers.Geometry class no longer depends on OpenLayers.Format.WKT or OpenLayers.Feature.Vector. If you want to make use of the OpenLayers.Geometry.fromWKT method, you must explicitly include the OpenLayers/Format/WKT.js file in your build.

Without the WKT format included (by default), the the OpenLayers.Geometry::toString method now returns "[object Object]." Previously, it returned the Well-Known Text representation of the geometry. To maintain the previous behavior, include the OpenLayers/Format/WKT.js file in your build.