Add synthetic data example
This commit is contained in:
50
examples/synthetic-data.html
Normal file
50
examples/synthetic-data.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!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>Synthetic data example</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">Synthetic data example</h4>
|
||||
<p id="shortdesc">Synthetic data example.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="synthetic-data.js" target="_blank">synthetic-data.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">vector</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="loader.js?id=synthetic-data" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
69
examples/synthetic-data.js
Normal file
69
examples/synthetic-data.js
Normal file
@@ -0,0 +1,69 @@
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.Overlay');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.format.GeoJSON');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.symbol');
|
||||
|
||||
|
||||
// build up some GeoJSON features
|
||||
var count = 20000;
|
||||
var features = new Array(count);
|
||||
var e = 18000000;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
features[i] = {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
i: i,
|
||||
size: i % 2 ? 10 : 20
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [
|
||||
2 * e * Math.random() - e, 2 * e * Math.random() - e
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var vectorSource = new ol.source.Vector();
|
||||
new ol.format.GeoJSON().readObject({
|
||||
type: 'FeatureCollection',
|
||||
features: features
|
||||
}, vectorSource.addFeature, vectorSource);
|
||||
|
||||
var styleFunction = goog.functions.constant({
|
||||
image: ol.symbol.renderCircle(
|
||||
5,
|
||||
{
|
||||
color: '#666666'
|
||||
},
|
||||
{
|
||||
color: '#bada55',
|
||||
width: 1
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
source: vectorSource,
|
||||
styleFunction: styleFunction
|
||||
});
|
||||
|
||||
var popup = new ol.Overlay({
|
||||
element: document.getElementById('popup')
|
||||
});
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [vector],
|
||||
renderer: ol.RendererHint.CANVAS,
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
}),
|
||||
overlays: [popup]
|
||||
});
|
||||
Reference in New Issue
Block a user