Add stars to example

This commit is contained in:
tsauerwein
2014-11-13 12:04:51 +01:00
parent f07e59d63f
commit 327763cc82

View File

@@ -7,10 +7,14 @@ goog.require('ol.source.Vector');
goog.require('ol.style.AtlasManager'); goog.require('ol.style.AtlasManager');
goog.require('ol.style.Circle'); goog.require('ol.style.Circle');
goog.require('ol.style.Fill'); goog.require('ol.style.Fill');
goog.require('ol.style.RegularShape');
goog.require('ol.style.Stroke'); goog.require('ol.style.Stroke');
goog.require('ol.style.Style'); goog.require('ol.style.Style');
var atlasManager = new ol.style.AtlasManager({ var atlasManager = new ol.style.AtlasManager({
// we increase the default size so that all symbols fit into
// a single atlas image
size: 512,
maxSize: ol.has.WEBGL_MAX_TEXTURE_SIZE}); maxSize: ol.has.WEBGL_MAX_TEXTURE_SIZE});
var symbolInfo = [{ var symbolInfo = [{
@@ -36,12 +40,13 @@ var symbolInfo = [{
}]; }];
var radiuses = [3, 6, 9, 15, 19, 25]; var radiuses = [3, 6, 9, 15, 19, 25];
var symbolCount = symbolInfo.length * radiuses.length; var symbolCount = symbolInfo.length * radiuses.length * 2;
var symbols = []; var symbols = [];
var i, j; var i, j;
for (i = 0; i < symbolInfo.length; ++i) { for (i = 0; i < symbolInfo.length; ++i) {
var info = symbolInfo[i]; var info = symbolInfo[i];
for (j = 0; j < radiuses.length; ++j) { for (j = 0; j < radiuses.length; ++j) {
// circle symbol
symbols.push(new ol.style.Circle({ symbols.push(new ol.style.Circle({
opacity: info.opacity, opacity: info.opacity,
scale: info.scale, scale: info.scale,
@@ -57,6 +62,24 @@ for (i = 0; i < symbolInfo.length; ++i) {
// the symbol will be added to an atlas // the symbol will be added to an atlas
atlasManager: atlasManager atlasManager: atlasManager
})); }));
// star symbol
symbols.push(new ol.style.RegularShape({
points: 8,
opacity: info.opacity,
scale: info.scale,
radius: radiuses[j],
radius2: radiuses[j] * 0.7,
angle: 1.4,
fill: new ol.style.Fill({
color: info.fillColor
}),
stroke: new ol.style.Stroke({
color: info.strokeColor,
width: 1
}),
atlasManager: atlasManager
}));
} }
} }
@@ -95,6 +118,6 @@ var map = new ol.Map({
target: document.getElementById('map'), target: document.getElementById('map'),
view: new ol.View({ view: new ol.View({
center: [0, 0], center: [0, 0],
zoom: 3 zoom: 4
}) })
}); });