Monday, 4 January 2016

OpenLayers 3 restrict map to an area


I want to restrict the OpenLayers 3 heatmap-earthquakes examle to show only Europe.


I have:


var raster = new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'toner-background'

})
});

var map = new ol.Map({

layers: [raster, vectorLayer],
target: 'map',
view: new ol.View({
projection: 'EPSG:3857',
center: [0, 0],

maxZoom: 9,
minZoom: 0,
zoom: 4
})
});

Let`s say that the points:


var point1 = new ol.geom.Point(ol.proj.transform([-20.000000, 28.000000], 'EPSG:4326', 'EPSG:3857'));
var point2 = new ol.geom.Point(ol.proj.transform([50.000000, 73.000000], 'EPSG:4326', 'EPSG:3857'));


are the bounds of Europe, how can I restrict the map view only between the two point?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...