Testing GridLayer with 1.0 beta.2
-
-
Save knownasilya/1ba7ca488ecf4880e45a to your computer and use it in GitHub Desktop.
Testing Leaflet.js GridLayer
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>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