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:
+14
-11
@@ -56,18 +56,21 @@ 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 (type === ol.geom.GeometryType.POINT ||
|
if (!goog.isNull(geometry)) {
|
||||||
type === ol.geom.GeometryType.MULTIPOINT) {
|
var type = geometry.getType();
|
||||||
symbolizerLiterals.push(ol.style.ShapeDefaults);
|
if (type === ol.geom.GeometryType.POINT ||
|
||||||
} else if (type === ol.geom.GeometryType.LINESTRING ||
|
type === ol.geom.GeometryType.MULTIPOINT) {
|
||||||
type === ol.geom.GeometryType.MULTILINESTRING) {
|
symbolizerLiterals.push(ol.style.ShapeDefaults);
|
||||||
symbolizerLiterals.push(ol.style.LineDefaults);
|
} else if (type === ol.geom.GeometryType.LINESTRING ||
|
||||||
} else if (type === ol.geom.GeometryType.LINEARRING ||
|
type === ol.geom.GeometryType.MULTILINESTRING) {
|
||||||
type === ol.geom.GeometryType.POLYGON ||
|
symbolizerLiterals.push(ol.style.LineDefaults);
|
||||||
type === ol.geom.GeometryType.MULTIPOLYGON) {
|
} else if (type === ol.geom.GeometryType.LINEARRING ||
|
||||||
symbolizerLiterals.push(ol.style.PolygonDefaults);
|
type === ol.geom.GeometryType.POLYGON ||
|
||||||
|
type === ol.geom.GeometryType.MULTIPOLYGON) {
|
||||||
|
symbolizerLiterals.push(ol.style.PolygonDefaults);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return symbolizerLiterals;
|
return symbolizerLiterals;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user