Last active
August 22, 2016 16:02
-
-
Save mikeskaug/c4cc9a97755c0945051e9d0fee5e3680 to your computer and use it in GitHub Desktop.
OpenLayers vector layer extent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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