Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Forked from d3noob/index.html
Last active November 12, 2015 17:44
Show Gist options
  • Save knownasilya/1ba7ca488ecf4880e45a to your computer and use it in GitHub Desktop.
Save knownasilya/1ba7ca488ecf4880e45a to your computer and use it in GitHub Desktop.
Testing Leaflet.js GridLayer

Testing GridLayer with 1.0 beta.2

<!DOCTYPE html>
<html>
<head>
<title>GridLayer Test</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet/v1.0.0-beta.2/leaflet.css"
/>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="http://cdn.leafletjs.com/leaflet/v1.0.0-beta.2/leaflet.js">
</script>
<script>
var tiles = new L.GridLayer();
tiles.createTile = function(coords) {
var tile = document.createElement('canvas'),
ctx = tile.getContext('2d');
tile.width = tile.height = 256;
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 255, 255);
ctx.fillStyle = 'black';
ctx.fillText('x: ' + coords.x + ', y: ' + coords.y + ', zoom: ' + coords.z, 20, 20);
ctx.strokeStyle = 'red';
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(255, 0);
ctx.lineTo(255, 255);
ctx.lineTo(0, 255);
ctx.closePath();
ctx.stroke();
return tile;
}
var map = new L.Map('map', {center: new L.LatLng(50.5, 30.51), zoom: 15, layers: [tiles]});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment