Transformed
This commit is contained in:
+68
-67
@@ -1,11 +1,11 @@
|
||||
goog.provide('ol.style.Style');
|
||||
|
||||
goog.require('ol.asserts');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.Circle');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Stroke');
|
||||
|
||||
/**
|
||||
* @module ol/style/Style
|
||||
*/
|
||||
import _ol_asserts_ from '../asserts.js';
|
||||
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
|
||||
import _ol_style_Circle_ from '../style/Circle.js';
|
||||
import _ol_style_Fill_ from '../style/Fill.js';
|
||||
import _ol_style_Stroke_ from '../style/Stroke.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -18,7 +18,7 @@ goog.require('ol.style.Stroke');
|
||||
* @param {olx.style.StyleOptions=} opt_options Style options.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style = function(opt_options) {
|
||||
var _ol_style_Style_ = function(opt_options) {
|
||||
|
||||
var options = opt_options || {};
|
||||
|
||||
@@ -32,7 +32,7 @@ ol.style.Style = function(opt_options) {
|
||||
* @private
|
||||
* @type {!ol.StyleGeometryFunction}
|
||||
*/
|
||||
this.geometryFunction_ = ol.style.Style.defaultGeometryFunction;
|
||||
this.geometryFunction_ = _ol_style_Style_.defaultGeometryFunction;
|
||||
|
||||
if (options.geometry !== undefined) {
|
||||
this.setGeometry(options.geometry);
|
||||
@@ -82,12 +82,12 @@ ol.style.Style = function(opt_options) {
|
||||
* @return {ol.style.Style} The cloned style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.clone = function() {
|
||||
_ol_style_Style_.prototype.clone = function() {
|
||||
var geometry = this.getGeometry();
|
||||
if (geometry && geometry.clone) {
|
||||
geometry = geometry.clone();
|
||||
}
|
||||
return new ol.style.Style({
|
||||
return new _ol_style_Style_({
|
||||
geometry: geometry,
|
||||
fill: this.getFill() ? this.getFill().clone() : undefined,
|
||||
image: this.getImage() ? this.getImage().clone() : undefined,
|
||||
@@ -104,7 +104,7 @@ ol.style.Style.prototype.clone = function() {
|
||||
* @return {ol.StyleRenderFunction|null} Custom renderer function.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getRenderer = function() {
|
||||
_ol_style_Style_.prototype.getRenderer = function() {
|
||||
return this.renderer_;
|
||||
};
|
||||
|
||||
@@ -115,7 +115,7 @@ ol.style.Style.prototype.getRenderer = function() {
|
||||
* @param {ol.StyleRenderFunction|null} renderer Custom renderer function.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setRenderer = function(renderer) {
|
||||
_ol_style_Style_.prototype.setRenderer = function(renderer) {
|
||||
this.renderer_ = renderer;
|
||||
};
|
||||
|
||||
@@ -127,7 +127,7 @@ ol.style.Style.prototype.setRenderer = function(renderer) {
|
||||
* be rendered with this style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getGeometry = function() {
|
||||
_ol_style_Style_.prototype.getGeometry = function() {
|
||||
return this.geometry_;
|
||||
};
|
||||
|
||||
@@ -138,7 +138,7 @@ ol.style.Style.prototype.getGeometry = function() {
|
||||
* and returns the geometry to render instead of the feature's geometry.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getGeometryFunction = function() {
|
||||
_ol_style_Style_.prototype.getGeometryFunction = function() {
|
||||
return this.geometryFunction_;
|
||||
};
|
||||
|
||||
@@ -148,7 +148,7 @@ ol.style.Style.prototype.getGeometryFunction = function() {
|
||||
* @return {ol.style.Fill} Fill style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getFill = function() {
|
||||
_ol_style_Style_.prototype.getFill = function() {
|
||||
return this.fill_;
|
||||
};
|
||||
|
||||
@@ -158,7 +158,7 @@ ol.style.Style.prototype.getFill = function() {
|
||||
* @param {ol.style.Fill} fill Fill style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setFill = function(fill) {
|
||||
_ol_style_Style_.prototype.setFill = function(fill) {
|
||||
this.fill_ = fill;
|
||||
};
|
||||
|
||||
@@ -168,7 +168,7 @@ ol.style.Style.prototype.setFill = function(fill) {
|
||||
* @return {ol.style.Image} Image style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getImage = function() {
|
||||
_ol_style_Style_.prototype.getImage = function() {
|
||||
return this.image_;
|
||||
};
|
||||
|
||||
@@ -178,7 +178,7 @@ ol.style.Style.prototype.getImage = function() {
|
||||
* @param {ol.style.Image} image Image style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setImage = function(image) {
|
||||
_ol_style_Style_.prototype.setImage = function(image) {
|
||||
this.image_ = image;
|
||||
};
|
||||
|
||||
@@ -188,7 +188,7 @@ ol.style.Style.prototype.setImage = function(image) {
|
||||
* @return {ol.style.Stroke} Stroke style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getStroke = function() {
|
||||
_ol_style_Style_.prototype.getStroke = function() {
|
||||
return this.stroke_;
|
||||
};
|
||||
|
||||
@@ -198,7 +198,7 @@ ol.style.Style.prototype.getStroke = function() {
|
||||
* @param {ol.style.Stroke} stroke Stroke style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setStroke = function(stroke) {
|
||||
_ol_style_Style_.prototype.setStroke = function(stroke) {
|
||||
this.stroke_ = stroke;
|
||||
};
|
||||
|
||||
@@ -208,7 +208,7 @@ ol.style.Style.prototype.setStroke = function(stroke) {
|
||||
* @return {ol.style.Text} Text style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getText = function() {
|
||||
_ol_style_Style_.prototype.getText = function() {
|
||||
return this.text_;
|
||||
};
|
||||
|
||||
@@ -218,7 +218,7 @@ ol.style.Style.prototype.getText = function() {
|
||||
* @param {ol.style.Text} text Text style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setText = function(text) {
|
||||
_ol_style_Style_.prototype.setText = function(text) {
|
||||
this.text_ = text;
|
||||
};
|
||||
|
||||
@@ -228,7 +228,7 @@ ol.style.Style.prototype.setText = function(text) {
|
||||
* @return {number|undefined} ZIndex.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getZIndex = function() {
|
||||
_ol_style_Style_.prototype.getZIndex = function() {
|
||||
return this.zIndex_;
|
||||
};
|
||||
|
||||
@@ -241,7 +241,7 @@ ol.style.Style.prototype.getZIndex = function() {
|
||||
* for this style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setGeometry = function(geometry) {
|
||||
_ol_style_Style_.prototype.setGeometry = function(geometry) {
|
||||
if (typeof geometry === 'function') {
|
||||
this.geometryFunction_ = geometry;
|
||||
} else if (typeof geometry === 'string') {
|
||||
@@ -249,7 +249,7 @@ ol.style.Style.prototype.setGeometry = function(geometry) {
|
||||
return /** @type {ol.geom.Geometry} */ (feature.get(geometry));
|
||||
};
|
||||
} else if (!geometry) {
|
||||
this.geometryFunction_ = ol.style.Style.defaultGeometryFunction;
|
||||
this.geometryFunction_ = _ol_style_Style_.defaultGeometryFunction;
|
||||
} else if (geometry !== undefined) {
|
||||
this.geometryFunction_ = function() {
|
||||
return /** @type {ol.geom.Geometry} */ (geometry);
|
||||
@@ -265,7 +265,7 @@ ol.style.Style.prototype.setGeometry = function(geometry) {
|
||||
* @param {number|undefined} zIndex ZIndex.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setZIndex = function(zIndex) {
|
||||
_ol_style_Style_.prototype.setZIndex = function(zIndex) {
|
||||
this.zIndex_ = zIndex;
|
||||
};
|
||||
|
||||
@@ -278,7 +278,7 @@ ol.style.Style.prototype.setZIndex = function(zIndex) {
|
||||
* A style function, a single style, or an array of styles.
|
||||
* @return {ol.StyleFunction} A style function.
|
||||
*/
|
||||
ol.style.Style.createFunction = function(obj) {
|
||||
_ol_style_Style_.createFunction = function(obj) {
|
||||
var styleFunction;
|
||||
|
||||
if (typeof obj === 'function') {
|
||||
@@ -291,7 +291,7 @@ ol.style.Style.createFunction = function(obj) {
|
||||
if (Array.isArray(obj)) {
|
||||
styles = obj;
|
||||
} else {
|
||||
ol.asserts.assert(obj instanceof ol.style.Style,
|
||||
_ol_asserts_.assert(obj instanceof _ol_style_Style_,
|
||||
41); // Expected an `ol.style.Style` or an array of `ol.style.Style`
|
||||
styles = [obj];
|
||||
}
|
||||
@@ -307,7 +307,7 @@ ol.style.Style.createFunction = function(obj) {
|
||||
* @type {Array.<ol.style.Style>}
|
||||
* @private
|
||||
*/
|
||||
ol.style.Style.default_ = null;
|
||||
_ol_style_Style_.default_ = null;
|
||||
|
||||
|
||||
/**
|
||||
@@ -315,23 +315,23 @@ ol.style.Style.default_ = null;
|
||||
* @param {number} resolution Resolution.
|
||||
* @return {Array.<ol.style.Style>} Style.
|
||||
*/
|
||||
ol.style.Style.defaultFunction = function(feature, resolution) {
|
||||
_ol_style_Style_.defaultFunction = function(feature, resolution) {
|
||||
// We don't use an immediately-invoked function
|
||||
// and a closure so we don't get an error at script evaluation time in
|
||||
// browsers that do not support Canvas. (ol.style.Circle does
|
||||
// canvas.getContext('2d') at construction time, which will cause an.error
|
||||
// in such browsers.)
|
||||
if (!ol.style.Style.default_) {
|
||||
var fill = new ol.style.Fill({
|
||||
if (!_ol_style_Style_.default_) {
|
||||
var fill = new _ol_style_Fill_({
|
||||
color: 'rgba(255,255,255,0.4)'
|
||||
});
|
||||
var stroke = new ol.style.Stroke({
|
||||
var stroke = new _ol_style_Stroke_({
|
||||
color: '#3399CC',
|
||||
width: 1.25
|
||||
});
|
||||
ol.style.Style.default_ = [
|
||||
new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
_ol_style_Style_.default_ = [
|
||||
new _ol_style_Style_({
|
||||
image: new _ol_style_Circle_({
|
||||
fill: fill,
|
||||
stroke: stroke,
|
||||
radius: 5
|
||||
@@ -341,7 +341,7 @@ ol.style.Style.defaultFunction = function(feature, resolution) {
|
||||
})
|
||||
];
|
||||
}
|
||||
return ol.style.Style.default_;
|
||||
return _ol_style_Style_.default_;
|
||||
};
|
||||
|
||||
|
||||
@@ -349,53 +349,53 @@ ol.style.Style.defaultFunction = function(feature, resolution) {
|
||||
* Default styles for editing features.
|
||||
* @return {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} Styles
|
||||
*/
|
||||
ol.style.Style.createDefaultEditing = function() {
|
||||
_ol_style_Style_.createDefaultEditing = 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({
|
||||
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_.MULTI_POLYGON] =
|
||||
styles[_ol_geom_GeometryType_.POLYGON];
|
||||
|
||||
styles[ol.geom.GeometryType.LINE_STRING] = [
|
||||
new ol.style.Style({
|
||||
stroke: new ol.style.Stroke({
|
||||
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({
|
||||
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_.MULTI_LINE_STRING] =
|
||||
styles[_ol_geom_GeometryType_.LINE_STRING];
|
||||
|
||||
styles[ol.geom.GeometryType.CIRCLE] =
|
||||
styles[ol.geom.GeometryType.POLYGON].concat(
|
||||
styles[ol.geom.GeometryType.LINE_STRING]
|
||||
styles[_ol_geom_GeometryType_.CIRCLE] =
|
||||
styles[_ol_geom_GeometryType_.POLYGON].concat(
|
||||
styles[_ol_geom_GeometryType_.LINE_STRING]
|
||||
);
|
||||
|
||||
|
||||
styles[ol.geom.GeometryType.POINT] = [
|
||||
new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
styles[_ol_geom_GeometryType_.POINT] = [
|
||||
new _ol_style_Style_({
|
||||
image: new _ol_style_Circle_({
|
||||
radius: width * 2,
|
||||
fill: new ol.style.Fill({
|
||||
fill: new _ol_style_Fill_({
|
||||
color: blue
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
stroke: new _ol_style_Stroke_({
|
||||
color: white,
|
||||
width: width / 2
|
||||
})
|
||||
@@ -403,13 +403,13 @@ ol.style.Style.createDefaultEditing = function() {
|
||||
zIndex: Infinity
|
||||
})
|
||||
];
|
||||
styles[ol.geom.GeometryType.MULTI_POINT] =
|
||||
styles[ol.geom.GeometryType.POINT];
|
||||
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.LINE_STRING],
|
||||
styles[ol.geom.GeometryType.POINT]
|
||||
styles[_ol_geom_GeometryType_.GEOMETRY_COLLECTION] =
|
||||
styles[_ol_geom_GeometryType_.POLYGON].concat(
|
||||
styles[_ol_geom_GeometryType_.LINE_STRING],
|
||||
styles[_ol_geom_GeometryType_.POINT]
|
||||
);
|
||||
|
||||
return styles;
|
||||
@@ -422,6 +422,7 @@ ol.style.Style.createDefaultEditing = function() {
|
||||
* for.
|
||||
* @return {ol.geom.Geometry|ol.render.Feature|undefined} Geometry to render.
|
||||
*/
|
||||
ol.style.Style.defaultGeometryFunction = function(feature) {
|
||||
_ol_style_Style_.defaultGeometryFunction = function(feature) {
|
||||
return feature.getGeometry();
|
||||
};
|
||||
export default _ol_style_Style_;
|
||||
|
||||
Reference in New Issue
Block a user