Lazily create KML style defaults
This commit is contained in:
+10
-14
@@ -65,7 +65,8 @@ ol.format.KML = function(opt_options) {
|
|||||||
* @type {Array.<ol.style.Style>}
|
* @type {Array.<ol.style.Style>}
|
||||||
*/
|
*/
|
||||||
this.defaultStyle_ = options.defaultStyle ?
|
this.defaultStyle_ = options.defaultStyle ?
|
||||||
options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_;
|
options.defaultStyle :
|
||||||
|
(ol.format.KML.DEFAULT_STYLE_ARRAY_ || ol.format.KML.createStyleDefaults_());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -139,6 +140,11 @@ ol.format.KML.SCHEMA_LOCATION_ = 'http://www.opengis.net/kml/2.2 ' +
|
|||||||
'https://developers.google.com/kml/schema/kml22gx.xsd';
|
'https://developers.google.com/kml/schema/kml22gx.xsd';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Array.<ol.style.Style>} Default style.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.format.KML.createStyleDefaults_ = function() {
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Color}
|
* @type {ol.Color}
|
||||||
@@ -146,7 +152,6 @@ ol.format.KML.SCHEMA_LOCATION_ = 'http://www.opengis.net/kml/2.2 ' +
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.DEFAULT_COLOR_ = [255, 255, 255, 1];
|
ol.format.KML.DEFAULT_COLOR_ = [255, 255, 255, 1];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.Fill}
|
* @type {ol.style.Fill}
|
||||||
@@ -156,7 +161,6 @@ ol.format.KML.DEFAULT_FILL_STYLE_ = new ol.style.Fill({
|
|||||||
color: ol.format.KML.DEFAULT_COLOR_
|
color: ol.format.KML.DEFAULT_COLOR_
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Size}
|
* @type {ol.Size}
|
||||||
@@ -164,7 +168,6 @@ ol.format.KML.DEFAULT_FILL_STYLE_ = new ol.style.Fill({
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_ = [20, 2]; // FIXME maybe [8, 32] ?
|
ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_ = [20, 2]; // FIXME maybe [8, 32] ?
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.IconAnchorUnits}
|
* @type {ol.style.IconAnchorUnits}
|
||||||
@@ -173,7 +176,6 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_ = [20, 2]; // FIXME maybe [8, 32] ?
|
|||||||
ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ =
|
ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ =
|
||||||
ol.style.IconAnchorUnits.PIXELS;
|
ol.style.IconAnchorUnits.PIXELS;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.IconAnchorUnits}
|
* @type {ol.style.IconAnchorUnits}
|
||||||
@@ -182,7 +184,6 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ =
|
|||||||
ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ =
|
ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ =
|
||||||
ol.style.IconAnchorUnits.PIXELS;
|
ol.style.IconAnchorUnits.PIXELS;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Size}
|
* @type {ol.Size}
|
||||||
@@ -190,7 +191,6 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ =
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_ = [64, 64];
|
ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_ = [64, 64];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -199,7 +199,6 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_ = [64, 64];
|
|||||||
ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_ =
|
ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_ =
|
||||||
'https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png';
|
'https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
@@ -207,7 +206,6 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_ =
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_ = 0.5;
|
ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_ = 0.5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.Image}
|
* @type {ol.style.Image}
|
||||||
@@ -225,7 +223,6 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_ = new ol.style.Icon({
|
|||||||
src: ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_
|
src: ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.Stroke}
|
* @type {ol.style.Stroke}
|
||||||
@@ -236,7 +233,6 @@ ol.format.KML.DEFAULT_STROKE_STYLE_ = new ol.style.Stroke({
|
|||||||
width: 1
|
width: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.Stroke}
|
* @type {ol.style.Stroke}
|
||||||
@@ -247,7 +243,6 @@ ol.format.KML.DEFAULT_TEXT_STROKE_STYLE_ = new ol.style.Stroke({
|
|||||||
width: 2
|
width: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.Text}
|
* @type {ol.style.Text}
|
||||||
@@ -260,7 +255,6 @@ ol.format.KML.DEFAULT_TEXT_STYLE_ = new ol.style.Text({
|
|||||||
scale: 0.8
|
scale: 0.8
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.style.Style}
|
* @type {ol.style.Style}
|
||||||
@@ -274,7 +268,6 @@ ol.format.KML.DEFAULT_STYLE_ = new ol.style.Style({
|
|||||||
zIndex: 0
|
zIndex: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Array.<ol.style.Style>}
|
* @type {Array.<ol.style.Style>}
|
||||||
@@ -282,6 +275,9 @@ ol.format.KML.DEFAULT_STYLE_ = new ol.style.Style({
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.DEFAULT_STYLE_ARRAY_ = [ol.format.KML.DEFAULT_STYLE_];
|
ol.format.KML.DEFAULT_STYLE_ARRAY_ = [ol.format.KML.DEFAULT_STYLE_];
|
||||||
|
|
||||||
|
return ol.format.KML.DEFAULT_STYLE_ARRAY_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
|
|||||||
Reference in New Issue
Block a user