Skip to content

Instantly share code, notes, and snippets.

@plepe
Created May 31, 2015 05:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save plepe/de0db5e5461b99ca0351 to your computer and use it in GitHub Desktop.
ol3 tilegrid
<!DOCTYPE HTML>
<html>
<head>
<script src="lib/ol3/ol.js"></script>
<link rel="stylesheet" href="lib/ol3/ol.css" type="text/css">
<script>
window.onload = function() {
var map = new ol.Map({
target: "map",
view: new ol.View({
center: ol.proj.transform([ 16.34, 48.15 ], 'EPSG:4326', 'EPSG:3857'),
zoom: 12
})
});
var back = new ol.layer.Tile({
source: new ol.source.OSM()
});
if(ol.tilegrid.createXYZ)
var tile_grid = ol.tilegrid.createXYZ();
else
var tile_grid = new ol.tilegrid.XYZ({});
var vec_source = new ol.source.TileVector({
url: 'something/{z}/{x}/{y}.json',
tileGrid: tile_grid
});
var vec_layer = new ol.layer.Vector({
source: vec_source,
visible: true
});
map.addLayer(back);
map.addLayer(vec_layer);
}
</script>
</head>
<body>
<div id='map' style='width: 400px; height: 300px;'>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment