Add a radius input to the heatmap-earthquakes example

This commit is contained in:
Frederic Junod
2015-02-12 14:20:49 +01:00
parent dfda3e37a4
commit f117550694
2 changed files with 16 additions and 3 deletions

View File

@@ -29,7 +29,7 @@
<div class="row-fluid">
<div class="span12">
<div class="span8">
<h4 id="title">Earthquakes heatmap</h4>
<p id="shortdesc">Demonstrates the use of a heatmap layer.</p>
<div id="docs">
@@ -40,8 +40,15 @@
</div>
<div id="tags">heatmap, kml, vector, style</div>
</div>
</div>
<div class="span4">
<form>
<label>radius size</label>
<input id="radius" type="range" min="1" max="50" step="1" value="5"/>
</form>
</div>
</div>
</div>
<script src="../resources/jquery.min.js" type="text/javascript"></script>

View File

@@ -5,6 +5,7 @@ goog.require('ol.layer.Tile');
goog.require('ol.source.KML');
goog.require('ol.source.Stamen');
var radius = $('#radius');
var vector = new ol.layer.Heatmap({
source: new ol.source.KML({
@@ -12,7 +13,7 @@ var vector = new ol.layer.Heatmap({
projection: 'EPSG:3857',
url: 'data/kml/2012_Earthquakes_Mag5.kml'
}),
radius: 5
radius: parseInt(radius.val(), 10)
});
vector.getSource().on('addfeature', function(event) {
@@ -38,3 +39,8 @@ var map = new ol.Map({
zoom: 2
})
});
radius.on('input', function() {
vector.setRadius(parseInt(radius.val(), 10));
});