Add regular shape example
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||||
|
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||||
|
<title>Regular shape symbols</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="navbar-inner">
|
||||||
|
<div class="container">
|
||||||
|
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span12">
|
||||||
|
<div id="map" class="map"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row-fluid">
|
||||||
|
|
||||||
|
<div class="span12">
|
||||||
|
<h4 id="title">Regular shape symbols</h4>
|
||||||
|
<p id="shortdesc">Drawing stars with regular shape symbols.</p>
|
||||||
|
<div id="docs">
|
||||||
|
<p>See the <a href="symbol-stars.js" target="_blank">symbol-stars.js source</a> to see how this is done.</p>
|
||||||
|
</div>
|
||||||
|
<div id="tags">symbol, regular, star, vector, point</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../resources/jquery.min.js" type="text/javascript"></script>
|
||||||
|
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
|
||||||
|
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||||
|
<script src="loader.js?id=symbol-stars" type="text/javascript"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
goog.require('ol.Feature');
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.geom.Point');
|
||||||
|
goog.require('ol.layer.Vector');
|
||||||
|
goog.require('ol.source.Vector');
|
||||||
|
goog.require('ol.style.Fill');
|
||||||
|
goog.require('ol.style.RegularShape');
|
||||||
|
goog.require('ol.style.Stroke');
|
||||||
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
var symbolInfo = [{
|
||||||
|
opacity: 1.0,
|
||||||
|
scale: 1.0,
|
||||||
|
fillColor: 'rgba(255, 153, 0, 0.4)',
|
||||||
|
strokeColor: 'rgba(255, 204, 0, 0.2)'
|
||||||
|
}, {
|
||||||
|
opacity: 0.75,
|
||||||
|
scale: 1.25,
|
||||||
|
fillColor: 'rgba(70, 80, 224, 0.4)',
|
||||||
|
strokeColor: 'rgba(12, 21, 138, 0.2)'
|
||||||
|
}, {
|
||||||
|
opacity: 0.5,
|
||||||
|
scale: 1.5,
|
||||||
|
fillColor: 'rgba(66, 150, 79, 0.4)',
|
||||||
|
strokeColor: 'rgba(20, 99, 32, 0.2)'
|
||||||
|
}, {
|
||||||
|
opacity: 1.0,
|
||||||
|
scale: 1.0,
|
||||||
|
fillColor: 'rgba(176, 61, 35, 0.4)',
|
||||||
|
strokeColor: 'rgba(145, 43, 20, 0.2)'
|
||||||
|
}];
|
||||||
|
|
||||||
|
var radiuses = [3, 6, 9, 15, 19, 25];
|
||||||
|
var symbolCount = symbolInfo.length * radiuses.length;
|
||||||
|
var symbols = [];
|
||||||
|
var i, j;
|
||||||
|
for (i = 0; i < symbolInfo.length; ++i) {
|
||||||
|
var info = symbolInfo[i];
|
||||||
|
for (j = 0; j < radiuses.length; ++j) {
|
||||||
|
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
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var featureCount = 5000;
|
||||||
|
var features = new Array(featureCount);
|
||||||
|
var feature, geometry;
|
||||||
|
var e = 25000000;
|
||||||
|
for (i = 0; i < featureCount; ++i) {
|
||||||
|
geometry = new ol.geom.Point(
|
||||||
|
[2 * e * Math.random() - e, 2 * e * Math.random() - e]);
|
||||||
|
feature = new ol.Feature(geometry);
|
||||||
|
feature.setStyle(
|
||||||
|
new ol.style.Style({
|
||||||
|
image: symbols[i % (symbolCount - 1)]
|
||||||
|
})
|
||||||
|
);
|
||||||
|
features[i] = feature;
|
||||||
|
}
|
||||||
|
|
||||||
|
var vectorSource = new ol.source.Vector({
|
||||||
|
features: features
|
||||||
|
});
|
||||||
|
var vector = new ol.layer.Vector({
|
||||||
|
source: vectorSource
|
||||||
|
});
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [vector],
|
||||||
|
target: document.getElementById('map'),
|
||||||
|
view: new ol.View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 3
|
||||||
|
})
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user