Lets ol.style.Icon to define default values
This commit is contained in:
@@ -526,6 +526,42 @@ describe('ol.format.KML', function() {
|
||||
expect(style.getStroke().getWidth()).to.be(1);
|
||||
});
|
||||
|
||||
it('can read a feature\'s IconStyle', function() {
|
||||
var text =
|
||||
'<kml xmlns="http://earth.google.com/kml/2.2">' +
|
||||
' <Placemark>' +
|
||||
' <Style>' +
|
||||
' <IconStyle>' +
|
||||
' <Icon>' +
|
||||
' <href>http://foo.png</href>' +
|
||||
' </Icon>' +
|
||||
' </IconStyle>' +
|
||||
' </Style>' +
|
||||
' </Placemark>' +
|
||||
'</kml>';
|
||||
var fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
expect(f).to.be.an(ol.Feature);
|
||||
var styleFunction = f.getStyleFunction();
|
||||
expect(styleFunction).not.to.be(undefined);
|
||||
var styleArray = styleFunction.call(f, 0);
|
||||
expect(styleArray).to.be.an(Array);
|
||||
expect(styleArray).to.have.length(1);
|
||||
var style = styleArray[0];
|
||||
expect(style).to.be.an(ol.style.Style);
|
||||
expect(style.getFill()).to.be(ol.format.KML.DEFAULT_FILL_STYLE_);
|
||||
expect(style.getStroke()).to.be(ol.format.KML.DEFAULT_STROKE_STYLE_);
|
||||
var imageStyle = style.getImage();
|
||||
expect(imageStyle).to.be.an(ol.style.Icon);
|
||||
expect(imageStyle.getSrc()).to.eql('http://foo.png');
|
||||
expect(imageStyle.getAnchor()).to.eql([0.5, 0.5]);
|
||||
expect(imageStyle.getRotation()).to.eql(0);
|
||||
expect(imageStyle.getSize()).to.be(null);
|
||||
expect(style.getText()).to.be(null);
|
||||
expect(style.getZIndex()).to.be(undefined);
|
||||
});
|
||||
|
||||
it('can read a feature\'s LineStyle', function() {
|
||||
var text =
|
||||
'<kml xmlns="http://earth.google.com/kml/2.2">' +
|
||||
@@ -1440,5 +1476,6 @@ goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Icon');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
|
||||
Reference in New Issue
Block a user