Share editing default styles

This commit is contained in:
Antoine Abt
2014-02-24 11:17:39 +01:00
parent 24ad507710
commit 5cc1a986c2
6 changed files with 108 additions and 106 deletions

View File

@@ -6,10 +6,6 @@ goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.GeoJSON');
goog.require('ol.source.MapQuest');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.style.Text');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'sat'})
@@ -22,35 +18,7 @@ var vector = new ol.layer.Vector({
})
});
var styleCache = {};
var select = new ol.interaction.Select({
style: function(feature, resolution) {
var text = feature.get('name');
if (!styleCache[text]) {
styleCache[text] = [new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255,0,0,0.3)'
}),
stroke: new ol.style.Stroke({
color: 'rgba(255,0,0,1)',
size: 2
}),
text: new ol.style.Text({
font: '12px Calibri,sans-serif',
text: text,
fill: new ol.style.Fill({
color: '#000'
}),
stroke: new ol.style.Stroke({
color: '#fff',
width: 3
})
})
})];
}
return styleCache[text];
}
});
var select = new ol.interaction.Select({});
var map = new ol.Map({
interactions: ol.interaction.defaults().extend([select]),