Move createDefaultEditingStyles() to ol.style
This commit is contained in:
@@ -7,10 +7,6 @@ goog.require('goog.events.EventType');
|
|||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.geom.Geometry');
|
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');
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
@@ -325,67 +321,3 @@ ol.feature.createFeatureStyleFunction = function(obj) {
|
|||||||
}
|
}
|
||||||
return styleFunction;
|
return styleFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default styles for editing features.
|
|
||||||
* @return {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} Styles
|
|
||||||
*/
|
|
||||||
ol.feature.createDefaultEditingStyles = function() {
|
|
||||||
/** @type {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} */
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ goog.require('ol.Map');
|
|||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol.MapBrowserEvent');
|
||||||
goog.require('ol.MapBrowserEvent.EventType');
|
goog.require('ol.MapBrowserEvent.EventType');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.feature');
|
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
goog.require('ol.geom.MultiLineString');
|
goog.require('ol.geom.MultiLineString');
|
||||||
@@ -21,6 +20,7 @@ goog.require('ol.geom.Point');
|
|||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.interaction.Pointer');
|
goog.require('ol.interaction.Pointer');
|
||||||
goog.require('ol.source.Vector');
|
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.
|
* @return {ol.style.StyleFunction} Styles.
|
||||||
*/
|
*/
|
||||||
ol.interaction.Draw.getDefaultStyleFunction = function() {
|
ol.interaction.Draw.getDefaultStyleFunction = function() {
|
||||||
var styles = ol.feature.createDefaultEditingStyles();
|
var styles = ol.style.createDefaultEditingStyles();
|
||||||
return function(feature, resolution) {
|
return function(feature, resolution) {
|
||||||
return styles[feature.getGeometry().getType()];
|
return styles[feature.getGeometry().getType()];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ goog.require('ol.ViewHint');
|
|||||||
goog.require('ol.coordinate');
|
goog.require('ol.coordinate');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.feature');
|
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
goog.require('ol.geom.MultiLineString');
|
goog.require('ol.geom.MultiLineString');
|
||||||
@@ -23,6 +22,7 @@ goog.require('ol.geom.Point');
|
|||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.interaction.Pointer');
|
goog.require('ol.interaction.Pointer');
|
||||||
goog.require('ol.structs.RBush');
|
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.
|
* @return {ol.style.StyleFunction} Styles.
|
||||||
*/
|
*/
|
||||||
ol.interaction.Modify.getDefaultStyleFunction = function() {
|
ol.interaction.Modify.getDefaultStyleFunction = function() {
|
||||||
var style = ol.feature.createDefaultEditingStyles();
|
var style = ol.style.createDefaultEditingStyles();
|
||||||
return function(feature, resolution) {
|
return function(feature, resolution) {
|
||||||
return style[ol.geom.GeometryType.POINT];
|
return style[ol.geom.GeometryType.POINT];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ goog.require('ol.CollectionEventType');
|
|||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.FeatureOverlay');
|
goog.require('ol.FeatureOverlay');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.feature');
|
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.interaction.Interaction');
|
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.
|
* @return {ol.style.StyleFunction} Styles.
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.getDefaultStyleFunction = function() {
|
ol.interaction.Select.getDefaultStyleFunction = function() {
|
||||||
var styles = ol.feature.createDefaultEditingStyles();
|
var styles = ol.style.createDefaultEditingStyles();
|
||||||
goog.array.extend(styles[ol.geom.GeometryType.POLYGON],
|
goog.array.extend(styles[ol.geom.GeometryType.POLYGON],
|
||||||
styles[ol.geom.GeometryType.LINE_STRING]);
|
styles[ol.geom.GeometryType.LINE_STRING]);
|
||||||
goog.array.extend(styles[ol.geom.GeometryType.GEOMETRY_COLLECTION],
|
goog.array.extend(styles[ol.geom.GeometryType.GEOMETRY_COLLECTION],
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ goog.provide('ol.style.Style');
|
|||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.style.Circle');
|
goog.require('ol.style.Circle');
|
||||||
goog.require('ol.style.Fill');
|
goog.require('ol.style.Fill');
|
||||||
goog.require('ol.style.Image');
|
goog.require('ol.style.Image');
|
||||||
@@ -178,3 +179,67 @@ ol.style.defaultStyleFunction = function(feature, resolution) {
|
|||||||
|
|
||||||
return styles;
|
return styles;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default styles for editing features.
|
||||||
|
* @return {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} Styles
|
||||||
|
*/
|
||||||
|
ol.style.createDefaultEditingStyles = function() {
|
||||||
|
/** @type {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} */
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user