Default value for zIndex
This commit is contained in:
@@ -49,7 +49,7 @@ describe('ol.style.Fill', function() {
|
||||
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||
expect(literal.fillOpacity).to.be(42 / 100);
|
||||
expect(literal.fillColor).to.be('#ff0000');
|
||||
expect(literal.zIndex).to.be(undefined);
|
||||
expect(literal.zIndex).to.be(0);
|
||||
});
|
||||
|
||||
it('applies default opacity', function() {
|
||||
@@ -104,6 +104,33 @@ describe('ol.style.Fill', function() {
|
||||
expect(literal.zIndex).to.be(2);
|
||||
});
|
||||
|
||||
it('applies default zIndex', function() {
|
||||
var symbolizer = new ol.style.Fill({
|
||||
opacity: 0.8
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(ol.geom.GeometryType.POLYGON);
|
||||
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||
expect(literal.zIndex).to.be(0);
|
||||
});
|
||||
|
||||
it('casts zIndex to number', function() {
|
||||
var symbolizer = new ol.style.Fill({
|
||||
zIndex: ol.expr.parse('zIndex'),
|
||||
color: '#ff00ff'
|
||||
});
|
||||
|
||||
var feature = new ol.Feature({
|
||||
zIndex: '11',
|
||||
geometry: new ol.geom.Polygon(
|
||||
[[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]])
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||
expect(literal.zIndex).to.be(11);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getColor()', function() {
|
||||
@@ -135,6 +162,21 @@ describe('ol.style.Fill', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#getZIndex()', function() {
|
||||
|
||||
it('returns the zIndex', function() {
|
||||
var symbolizer = new ol.style.Fill({
|
||||
color: '#ffffff',
|
||||
zIndex: 11
|
||||
});
|
||||
|
||||
var zIndex = symbolizer.getZIndex();
|
||||
expect(zIndex).to.be.a(ol.expr.Literal);
|
||||
expect(zIndex.getValue()).to.be(11);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setColor()', function() {
|
||||
|
||||
it('sets the fill color', function() {
|
||||
|
||||
@@ -10,49 +10,56 @@ describe('ol.style.IconLiteral', function() {
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
url: 'http://example.com/1.png',
|
||||
zIndex: 0
|
||||
});
|
||||
var equalLiteral = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
url: 'http://example.com/1.png',
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral1 = new ol.style.IconLiteral({
|
||||
var differentHeight = new ol.style.IconLiteral({
|
||||
height: 11,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
url: 'http://example.com/1.png',
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral2 = new ol.style.IconLiteral({
|
||||
var differentWidth = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 2,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
url: 'http://example.com/1.png',
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral3 = new ol.style.IconLiteral({
|
||||
var differentOpacity = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 0.5,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
url: 'http://example.com/1.png',
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral4 = new ol.style.IconLiteral({
|
||||
var differentRotation = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.2,
|
||||
url: 'http://example.com/1.png'
|
||||
url: 'http://example.com/1.png',
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral5 = new ol.style.IconLiteral({
|
||||
var differentUrl = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/2.png'
|
||||
url: 'http://example.com/2.png',
|
||||
zIndex: 0
|
||||
});
|
||||
var differentZIndex = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
@@ -63,11 +70,11 @@ describe('ol.style.IconLiteral', function() {
|
||||
zIndex: 20
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral1)).to.be(false);
|
||||
expect(literal.equals(differentLiteral2)).to.be(false);
|
||||
expect(literal.equals(differentLiteral3)).to.be(false);
|
||||
expect(literal.equals(differentLiteral4)).to.be(false);
|
||||
expect(literal.equals(differentLiteral5)).to.be(false);
|
||||
expect(literal.equals(differentHeight)).to.be(false);
|
||||
expect(literal.equals(differentWidth)).to.be(false);
|
||||
expect(literal.equals(differentOpacity)).to.be(false);
|
||||
expect(literal.equals(differentRotation)).to.be(false);
|
||||
expect(literal.equals(differentUrl)).to.be(false);
|
||||
expect(literal.equals(differentZIndex)).to.be(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('ol.style.Icon', function() {
|
||||
expect(literal.xOffset).to.be(20);
|
||||
expect(literal.yOffset).to.be(30);
|
||||
expect(literal.url).to.be('http://example.com/1.png');
|
||||
expect(literal.zIndex).to.be(undefined);
|
||||
expect(literal.zIndex).to.be(0);
|
||||
});
|
||||
|
||||
it('can be called without a feature', function() {
|
||||
@@ -250,6 +250,35 @@ describe('ol.style.Icon', function() {
|
||||
expect(literal.zIndex).to.be(4);
|
||||
});
|
||||
|
||||
it('applies default zIndex if none', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
height: 10,
|
||||
width: 20,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(ol.geom.GeometryType.POINT);
|
||||
expect(literal).to.be.a(ol.style.IconLiteral);
|
||||
expect(literal.zIndex).to.be(0);
|
||||
});
|
||||
|
||||
it('casts zIndex to number', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
zIndex: ol.expr.parse('zIndex'),
|
||||
width: 10,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
|
||||
var feature = new ol.Feature({
|
||||
zIndex: '42',
|
||||
geometry: new ol.geom.Point([1, 2])
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.IconLiteral);
|
||||
expect(literal.zIndex).to.be(42);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getHeight()', function() {
|
||||
|
||||
@@ -8,27 +8,32 @@ describe('ol.style.LineLiteral', function() {
|
||||
var literal = new ol.style.LineLiteral({
|
||||
width: 3,
|
||||
color: '#BADA55',
|
||||
opacity: 1
|
||||
opacity: 1,
|
||||
zIndex: 0
|
||||
});
|
||||
var equalLiteral = new ol.style.LineLiteral({
|
||||
color: '#BADA55',
|
||||
width: 3,
|
||||
opacity: 1
|
||||
opacity: 1,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentColor = new ol.style.LineLiteral({
|
||||
width: 3,
|
||||
color: '#ff0000',
|
||||
opacity: 1
|
||||
opacity: 1,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentWidth = new ol.style.LineLiteral({
|
||||
width: 3.5,
|
||||
color: '#BADA55',
|
||||
opacity: 1
|
||||
opacity: 1,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentOpacity = new ol.style.LineLiteral({
|
||||
width: 3,
|
||||
color: '#BADA55',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentZIndex = new ol.style.LineLiteral({
|
||||
width: 3,
|
||||
|
||||
@@ -10,49 +10,56 @@ describe('ol.style.PolygonLiteral', function() {
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
fillOpacity: 0.3,
|
||||
zIndex: 0
|
||||
});
|
||||
var equalLiteral = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
fillOpacity: 0.3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentStrokeWidth = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 5,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
fillOpacity: 0.3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentStrokeColor = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#ffff00',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
fillOpacity: 0.3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentStrokeOpacity = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.41,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
fillOpacity: 0.3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentFillColor = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#00ffff',
|
||||
fillOpacity: 0.3
|
||||
fillOpacity: 0.3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentFillOpacity = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.31
|
||||
fillOpacity: 0.31,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentZIndex = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
|
||||
@@ -12,7 +12,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
});
|
||||
var equalLiteral = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
@@ -21,7 +22,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentSize = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
@@ -30,7 +32,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentFillColor = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
@@ -39,7 +42,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentFillOpacity = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
@@ -48,7 +52,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.8,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentStrokeColor = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
@@ -57,7 +62,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#ffffff',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentStrokeOpacity = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
@@ -66,7 +72,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.7,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentStrokeWidth = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
@@ -75,7 +82,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 4
|
||||
strokeWidth: 4,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentZIndex = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('ol.style.Shape', function() {
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.size).to.be(42);
|
||||
expect(literal.fillOpacity).to.be(0.4);
|
||||
expect(literal.zIndex).to.be(undefined);
|
||||
expect(literal.zIndex).to.be(0);
|
||||
});
|
||||
|
||||
it('can be called without a feature', function() {
|
||||
@@ -185,6 +185,24 @@ describe('ol.style.Shape', function() {
|
||||
expect(literal.zIndex).to.be(-2);
|
||||
});
|
||||
|
||||
it('casts zIndex to number', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
fill: new ol.style.Fill({
|
||||
color: '#BADA55'
|
||||
}),
|
||||
zIndex: ol.expr.parse('zIndex')
|
||||
});
|
||||
|
||||
var feature = new ol.Feature({
|
||||
zIndex: '42',
|
||||
geometry: new ol.geom.Point([1, 2])
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.zIndex).to.be(42);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getFill()', function() {
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('ol.style.Stroke', function() {
|
||||
expect(literal).to.be.a(ol.style.LineLiteral);
|
||||
expect(literal.opacity).to.be(42 / 100);
|
||||
expect(literal.width).to.be(1.5);
|
||||
expect(literal.zIndex).to.be(undefined);
|
||||
expect(literal.zIndex).to.be(0);
|
||||
});
|
||||
|
||||
it('applies the default values', function() {
|
||||
@@ -60,6 +60,7 @@ describe('ol.style.Stroke', function() {
|
||||
expect(literal.color).to.be('#696969');
|
||||
expect(literal.opacity).to.be(0.75);
|
||||
expect(literal.width).to.be(1.5);
|
||||
expect(literal.zIndex).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -194,12 +194,14 @@ describe('ol.style.Style', function() {
|
||||
var literals = [
|
||||
new ol.style.PolygonLiteral({
|
||||
fillColor: '#ff0000',
|
||||
fillOpacity: 0.5
|
||||
fillOpacity: 0.5,
|
||||
zIndex: 0
|
||||
}),
|
||||
new ol.style.PolygonLiteral({
|
||||
strokeColor: '#00ff00',
|
||||
strokeOpacity: 0.6,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
})
|
||||
];
|
||||
|
||||
@@ -221,12 +223,14 @@ describe('ol.style.Style', function() {
|
||||
fillOpacity: 0.5,
|
||||
strokeColor: '#00ff00',
|
||||
strokeOpacity: 0.6,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
}),
|
||||
new ol.style.PolygonLiteral({
|
||||
strokeColor: '#0000ff',
|
||||
strokeOpacity: 0.7,
|
||||
strokeWidth: 1
|
||||
strokeWidth: 1,
|
||||
zIndex: 0
|
||||
})
|
||||
];
|
||||
|
||||
@@ -253,18 +257,21 @@ describe('ol.style.Style', function() {
|
||||
new ol.style.PolygonLiteral({
|
||||
strokeColor: '#00ff00',
|
||||
strokeOpacity: 0.6,
|
||||
strokeWidth: 3
|
||||
strokeWidth: 3,
|
||||
zIndex: 0
|
||||
}),
|
||||
new ol.style.PolygonLiteral({
|
||||
fillColor: '#ff0000',
|
||||
fillOpacity: 0.5
|
||||
fillOpacity: 0.5,
|
||||
zIndex: 0
|
||||
}),
|
||||
new ol.style.TextLiteral({
|
||||
color: '#ffffff',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
})
|
||||
];
|
||||
|
||||
|
||||
@@ -10,49 +10,56 @@ describe('ol.style.TextLiteral', function() {
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
});
|
||||
var equalLiteral = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral1 = new ol.style.TextLiteral({
|
||||
var differentColor = new ol.style.TextLiteral({
|
||||
color: '#0000ff',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral2 = new ol.style.TextLiteral({
|
||||
var differentFontFamily = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Dingbats',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral3 = new ol.style.TextLiteral({
|
||||
var differentFontSize = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 12,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentLiteral4 = new ol.style.TextLiteral({
|
||||
var differentOpacity = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.6
|
||||
opacity: 0.6,
|
||||
zIndex: 0
|
||||
});
|
||||
var equalLiteral2 = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Text is not compared for equality',
|
||||
opacity: 0.5
|
||||
opacity: 0.5,
|
||||
zIndex: 0
|
||||
});
|
||||
var differentZIndex = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
@@ -63,10 +70,10 @@ describe('ol.style.TextLiteral', function() {
|
||||
zIndex: 3
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral1)).to.be(false);
|
||||
expect(literal.equals(differentLiteral2)).to.be(false);
|
||||
expect(literal.equals(differentLiteral3)).to.be(false);
|
||||
expect(literal.equals(differentLiteral4)).to.be(false);
|
||||
expect(literal.equals(differentColor)).to.be(false);
|
||||
expect(literal.equals(differentFontFamily)).to.be(false);
|
||||
expect(literal.equals(differentFontSize)).to.be(false);
|
||||
expect(literal.equals(differentOpacity)).to.be(false);
|
||||
expect(literal.equals(equalLiteral2)).to.be(true);
|
||||
expect(literal.equals(differentZIndex)).to.be(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user