Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Return an empty array for features without geometry

This ensures that the static applyDefaultStyle() method works
exactly the same way as the instance's apply() method.
  • Loading branch information...
commit db52ff926e3578e13505ca094d221c32c394edb9 1 parent 9d1f737
@ahocevar ahocevar authored
Showing with 14 additions and 11 deletions.
  1. +14 −11 src/ol/style/style.js
View
25 src/ol/style/style.js
@@ -56,18 +56,21 @@ ol.style.Style.prototype.apply = function(feature) {
* the feature.
*/
ol.style.Style.applyDefaultStyle = function(feature) {
- var type = feature.getGeometry().getType(),
+ var geometry = feature.getGeometry(),
symbolizerLiterals = [];
- if (type === ol.geom.GeometryType.POINT ||
- type === ol.geom.GeometryType.MULTIPOINT) {
- symbolizerLiterals.push(ol.style.ShapeDefaults);
- } else if (type === ol.geom.GeometryType.LINESTRING ||
- type === ol.geom.GeometryType.MULTILINESTRING) {
- symbolizerLiterals.push(ol.style.LineDefaults);
- } else if (type === ol.geom.GeometryType.LINEARRING ||
- type === ol.geom.GeometryType.POLYGON ||
- type === ol.geom.GeometryType.MULTIPOLYGON) {
- symbolizerLiterals.push(ol.style.PolygonDefaults);
+ if (!goog.isNull(geometry)) {
+ var type = geometry.getType();
+ if (type === ol.geom.GeometryType.POINT ||
+ type === ol.geom.GeometryType.MULTIPOINT) {
+ symbolizerLiterals.push(ol.style.ShapeDefaults);
+ } else if (type === ol.geom.GeometryType.LINESTRING ||
+ type === ol.geom.GeometryType.MULTILINESTRING) {
+ symbolizerLiterals.push(ol.style.LineDefaults);
+ } else if (type === ol.geom.GeometryType.LINEARRING ||
+ type === ol.geom.GeometryType.POLYGON ||
+ type === ol.geom.GeometryType.MULTIPOLYGON) {
+ symbolizerLiterals.push(ol.style.PolygonDefaults);
+ }
}
return symbolizerLiterals;
};
Please sign in to comment.
Something went wrong with that request. Please try again.