diff --git a/src/ol/feature.js b/src/ol/feature.js index 3dd74b8143..0ad334338f 100644 --- a/src/ol/feature.js +++ b/src/ol/feature.js @@ -7,10 +7,6 @@ goog.require('goog.events.EventType'); goog.require('goog.functions'); goog.require('ol.Object'); goog.require('ol.geom.Geometry'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); goog.require('ol.style.Style'); @@ -325,67 +321,3 @@ ol.feature.createFeatureStyleFunction = function(obj) { } return styleFunction; }; - - -/** - * Default styles for editing features. - * @return {Object.>} Styles - */ -ol.feature.createDefaultEditingStyles = function() { - /** @type {Object.>} */ - var styles = {}; - var white = [255, 255, 255, 1]; - var blue = [0, 153, 255, 1]; - var width = 3; - styles[ol.geom.GeometryType.POLYGON] = [ - new ol.style.Style({ - fill: new ol.style.Fill({ - color: [255, 255, 255, 0.5] - }) - }) - ]; - styles[ol.geom.GeometryType.MULTI_POLYGON] = - styles[ol.geom.GeometryType.POLYGON]; - - styles[ol.geom.GeometryType.LINE_STRING] = [ - new ol.style.Style({ - stroke: new ol.style.Stroke({ - color: white, - width: width + 2 - }) - }), - new ol.style.Style({ - stroke: new ol.style.Stroke({ - color: blue, - width: width - }) - }) - ]; - styles[ol.geom.GeometryType.MULTI_LINE_STRING] = - styles[ol.geom.GeometryType.LINE_STRING]; - - styles[ol.geom.GeometryType.POINT] = [ - new ol.style.Style({ - image: new ol.style.Circle({ - radius: width * 2, - fill: new ol.style.Fill({ - color: blue - }), - stroke: new ol.style.Stroke({ - color: white, - width: width / 2 - }) - }), - zIndex: Infinity - }) - ]; - styles[ol.geom.GeometryType.MULTI_POINT] = - styles[ol.geom.GeometryType.POINT]; - - styles[ol.geom.GeometryType.GEOMETRY_COLLECTION] = - styles[ol.geom.GeometryType.POLYGON].concat( - styles[ol.geom.GeometryType.POINT] - ); - - return styles; -}; diff --git a/src/ol/interaction/drawinteraction.js b/src/ol/interaction/drawinteraction.js index 7c3d98f4bd..dbfba3aac6 100644 --- a/src/ol/interaction/drawinteraction.js +++ b/src/ol/interaction/drawinteraction.js @@ -11,7 +11,6 @@ goog.require('ol.Map'); goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.events.condition'); -goog.require('ol.feature'); goog.require('ol.geom.GeometryType'); goog.require('ol.geom.LineString'); goog.require('ol.geom.MultiLineString'); @@ -21,6 +20,7 @@ goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); goog.require('ol.interaction.Pointer'); goog.require('ol.source.Vector'); +goog.require('ol.style.Style'); /** @@ -208,7 +208,7 @@ goog.inherits(ol.interaction.Draw, ol.interaction.Pointer); * @return {ol.style.StyleFunction} Styles. */ ol.interaction.Draw.getDefaultStyleFunction = function() { - var styles = ol.feature.createDefaultEditingStyles(); + var styles = ol.style.createDefaultEditingStyles(); return function(feature, resolution) { return styles[feature.getGeometry().getType()]; }; diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index 2513de9833..a56a212c3d 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -13,7 +13,6 @@ goog.require('ol.ViewHint'); goog.require('ol.coordinate'); goog.require('ol.events.condition'); goog.require('ol.extent'); -goog.require('ol.feature'); goog.require('ol.geom.GeometryType'); goog.require('ol.geom.LineString'); goog.require('ol.geom.MultiLineString'); @@ -23,6 +22,7 @@ goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); goog.require('ol.interaction.Pointer'); goog.require('ol.structs.RBush'); +goog.require('ol.style.Style'); /** @@ -772,7 +772,7 @@ ol.interaction.Modify.prototype.updateSegmentIndices_ = function( * @return {ol.style.StyleFunction} Styles. */ ol.interaction.Modify.getDefaultStyleFunction = function() { - var style = ol.feature.createDefaultEditingStyles(); + var style = ol.style.createDefaultEditingStyles(); return function(feature, resolution) { return style[ol.geom.GeometryType.POINT]; }; diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 5d40859f9b..545e37f2bf 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -8,9 +8,9 @@ goog.require('ol.CollectionEventType'); goog.require('ol.Feature'); goog.require('ol.FeatureOverlay'); goog.require('ol.events.condition'); -goog.require('ol.feature'); goog.require('ol.geom.GeometryType'); goog.require('ol.interaction.Interaction'); +goog.require('ol.style.Style'); @@ -207,7 +207,7 @@ ol.interaction.Select.prototype.setMap = function(map) { * @return {ol.style.StyleFunction} Styles. */ ol.interaction.Select.getDefaultStyleFunction = function() { - var styles = ol.feature.createDefaultEditingStyles(); + var styles = ol.style.createDefaultEditingStyles(); goog.array.extend(styles[ol.geom.GeometryType.POLYGON], styles[ol.geom.GeometryType.LINE_STRING]); goog.array.extend(styles[ol.geom.GeometryType.GEOMETRY_COLLECTION], diff --git a/src/ol/style/style.js b/src/ol/style/style.js index b2aa63dabb..b182db47bb 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -2,6 +2,7 @@ goog.provide('ol.style.Style'); goog.require('goog.asserts'); goog.require('goog.functions'); +goog.require('ol.geom.GeometryType'); goog.require('ol.style.Circle'); goog.require('ol.style.Fill'); goog.require('ol.style.Image'); @@ -178,3 +179,67 @@ ol.style.defaultStyleFunction = function(feature, resolution) { return styles; }; + + +/** + * Default styles for editing features. + * @return {Object.>} Styles + */ +ol.style.createDefaultEditingStyles = function() { + /** @type {Object.>} */ + var styles = {}; + var white = [255, 255, 255, 1]; + var blue = [0, 153, 255, 1]; + var width = 3; + styles[ol.geom.GeometryType.POLYGON] = [ + new ol.style.Style({ + fill: new ol.style.Fill({ + color: [255, 255, 255, 0.5] + }) + }) + ]; + styles[ol.geom.GeometryType.MULTI_POLYGON] = + styles[ol.geom.GeometryType.POLYGON]; + + styles[ol.geom.GeometryType.LINE_STRING] = [ + new ol.style.Style({ + stroke: new ol.style.Stroke({ + color: white, + width: width + 2 + }) + }), + new ol.style.Style({ + stroke: new ol.style.Stroke({ + color: blue, + width: width + }) + }) + ]; + styles[ol.geom.GeometryType.MULTI_LINE_STRING] = + styles[ol.geom.GeometryType.LINE_STRING]; + + styles[ol.geom.GeometryType.POINT] = [ + new ol.style.Style({ + image: new ol.style.Circle({ + radius: width * 2, + fill: new ol.style.Fill({ + color: blue + }), + stroke: new ol.style.Stroke({ + color: white, + width: width / 2 + }) + }), + zIndex: Infinity + }) + ]; + styles[ol.geom.GeometryType.MULTI_POINT] = + styles[ol.geom.GeometryType.POINT]; + + styles[ol.geom.GeometryType.GEOMETRY_COLLECTION] = + styles[ol.geom.GeometryType.POLYGON].concat( + styles[ol.geom.GeometryType.POINT] + ); + + return styles; +};