Basic support for text symbolizers
This adds basic label rendering for points and polygons to the canvas renderer, and a text symbolizer to the style package.
This commit is contained in:
@@ -4,13 +4,17 @@ goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.filter.Filter');
|
||||
goog.require('ol.filter.Geometry');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.parser.GeoJSON');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.Line');
|
||||
goog.require('ol.style.Rule');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.style.Text');
|
||||
|
||||
|
||||
var style = new ol.style.Style({rules: [
|
||||
@@ -42,6 +46,21 @@ var style = new ol.style.Style({rules: [
|
||||
opacity: 1
|
||||
})
|
||||
]
|
||||
}),
|
||||
new ol.style.Rule({
|
||||
filter: new ol.filter.Geometry(ol.geom.GeometryType.POINT),
|
||||
symbolizers: [
|
||||
new ol.style.Shape({
|
||||
size: 40,
|
||||
fillColor: '#013'
|
||||
}),
|
||||
new ol.style.Text({
|
||||
color: '#bada55',
|
||||
name: new ol.Expression('label'),
|
||||
fontFamily: 'Calibri,sans-serif',
|
||||
fontSize: 14
|
||||
})
|
||||
]
|
||||
})
|
||||
]});
|
||||
|
||||
@@ -114,6 +133,42 @@ vector.parseFeatures({
|
||||
'type': 'LineString',
|
||||
'coordinates': [[10000000, -10000000], [-10000000, -10000000]]
|
||||
}
|
||||
}, {
|
||||
'type': 'Feature',
|
||||
'properties': {
|
||||
'label': 'South'
|
||||
},
|
||||
'geometry': {
|
||||
'type': 'Point',
|
||||
'coordinates': [0, -6000000]
|
||||
}
|
||||
}, {
|
||||
'type': 'Feature',
|
||||
'properties': {
|
||||
'label': 'West'
|
||||
},
|
||||
'geometry': {
|
||||
'type': 'Point',
|
||||
'coordinates': [-6000000, 0]
|
||||
}
|
||||
}, {
|
||||
'type': 'Feature',
|
||||
'properties': {
|
||||
'label': 'North'
|
||||
},
|
||||
'geometry': {
|
||||
'type': 'Point',
|
||||
'coordinates': [0, 6000000]
|
||||
}
|
||||
}, {
|
||||
'type': 'Feature',
|
||||
'properties': {
|
||||
'label': 'East'
|
||||
},
|
||||
'geometry': {
|
||||
'type': 'Point',
|
||||
'coordinates': [6000000, 0]
|
||||
}
|
||||
}]
|
||||
}, new ol.parser.GeoJSON(), ol.proj.get('EPSG:3857'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user