[OpenLayers-Users] simple heatmap does not appear
Domenico Di Leo
domenico.dileo at critiware.com
Sun Oct 26 02:29:20 PDT 2014
Hello,
I'm new to OpenLayers, anyway I'm trying to ad an heatmap.
I tried two different ways to get the heatmap, the first one
<html><body>
<div id="demoMap"></div>
<script src=" <http://www.openlayers.org/api/OpenLayers.js>
http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
map = new OpenLayers.Map("demoMap");
map.addLayer(new OpenLayers.Layer.OSM());
map.zoomToMaxExtent();
var layer = new OpenLayers.Layer.OSM();
heatmap = new OpenLayers.Layer.Heatmap("Heatmap Layer", map, layer,
null,
{visible: true, radius: 15},
{isBaseLayer: false, opacity: 0.3, projection: new
OpenLayers.Projection("EPSG:4326")});
var lon, lat, c;
for(var i=0; i<100; i++) {
lon = i;
lat = i;
c = Math.floor(Math.random()*50);
heatmap.addDataPoint(new OpenLayers.LonLat(lon, lat), c);
}
</script>
</body></html>
the second one
<html><body>
<div id="demoMap"></div>
<script src=" <http://www.openlayers.org/api/OpenLayers.js>
http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
var testData={
max: 46,
data: [{lat: 33.5363, lon:-117.044, count: 1}, {lat: 35.8278, lon:-78.6421,
count: 1}]
};
layer = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
" <http://labs.metacarta.com/wms/vmap0>
http://labs.metacarta.com/wms/vmap0", {layers: 'basic'}
);
map = new OpenLayers.Map("demoMap");
map.addLayer(new OpenLayers.Layer.OSM());
map.zoomToMaxExtent();
heatmap = new OpenLayers.Layer.Heatmap( "Heatmap Layer", map, layer,
{visible: true, radius:10}, {isBaseLayer: false, opacity: 0.3}
);
heatmap.setDataSet(testData);
map.addLayer(heatmap);
</script>
</body></html>
I can only visualize the map without the heatmap layer.
Thank you in advance for any suggestion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20141026/700199a8/attachment.html>
More information about the Users
mailing list