Skip to content

Instantly share code, notes, and snippets.

@mikeskaug
Last active August 22, 2016 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeskaug/c4cc9a97755c0945051e9d0fee5e3680 to your computer and use it in GitHub Desktop.
Save mikeskaug/c4cc9a97755c0945051e9d0fee5e3680 to your computer and use it in GitHub Desktop.
OpenLayers vector layer extent
<!DOCTYPE html>
<html>
<head>
<title>Limited Layer Extent</title>
<link rel="stylesheet" href="http://openlayers.org/en/v3.17.1/css/ol.css" type="text/css">
<script src="http://openlayers.org/en/v3.17.1/build/ol.js"></script>
</head>
<body>
<div id="map"></div>
</div>
<script>
var base = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.TopoJSON(),
url: 'https://gist.githubusercontent.com/quizzicol/7068241/raw/4f6ced3a2412a48141843bee07f6ae2034eea21b/world110.json'
}),
extent: ol.proj.transformExtent([0, -45, 90, 45], 'EPSG:4326', 'EPSG:3857')
});
var map = new ol.Map({
layers: [base],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 1
})
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment