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.
This commit is contained in:
ahocevar
2013-03-03 15:22:33 +01:00
parent 9d1f737bce
commit db52ff926e
+4 -1
View File
@@ -56,8 +56,10 @@ ol.style.Style.prototype.apply = function(feature) {
* the feature. * the feature.
*/ */
ol.style.Style.applyDefaultStyle = function(feature) { ol.style.Style.applyDefaultStyle = function(feature) {
var type = feature.getGeometry().getType(), var geometry = feature.getGeometry(),
symbolizerLiterals = []; symbolizerLiterals = [];
if (!goog.isNull(geometry)) {
var type = geometry.getType();
if (type === ol.geom.GeometryType.POINT || if (type === ol.geom.GeometryType.POINT ||
type === ol.geom.GeometryType.MULTIPOINT) { type === ol.geom.GeometryType.MULTIPOINT) {
symbolizerLiterals.push(ol.style.ShapeDefaults); symbolizerLiterals.push(ol.style.ShapeDefaults);
@@ -69,5 +71,6 @@ ol.style.Style.applyDefaultStyle = function(feature) {
type === ol.geom.GeometryType.MULTIPOLYGON) { type === ol.geom.GeometryType.MULTIPOLYGON) {
symbolizerLiterals.push(ol.style.PolygonDefaults); symbolizerLiterals.push(ol.style.PolygonDefaults);
} }
}
return symbolizerLiterals; return symbolizerLiterals;
}; };