Sha256: 163a94978e23ba38c85d26d65b6356e883f040304077301073b44c48b0768a64

Contents?: true

Size: 838 Bytes

Versions: 3

Compression:

Stored size: 838 Bytes

Contents

---
layout: tutorial_frame
title: CanvasCircles
---
<script type='text/javascript'>

	var map = L.map('map', {
		center: [0, 0],
		zoom: 0
	});

	L.GridLayer.CanvasCircles = L.GridLayer.extend({
		createTile: function (coords) {
			var tile = document.createElement('canvas');
			
			var tileSize = this.getTileSize();
			tile.setAttribute('width', tileSize.x);
			tile.setAttribute('height', tileSize.y);
			
			var ctx = tile.getContext('2d');
			
			// Draw whatever is needed in the canvas context
			// For example, circles which get bigger as we zoom in
			ctx.arc(tileSize.x/2, tileSize.x/2, 4 + coords.z*4, 0, 2*Math.PI, false);
			ctx.fill();
			
			return tile;
		}
	});
	
	L.gridLayer.canvasCircles = function(opts) {
		return new L.GridLayer.CanvasCircles(opts);
	};

	map.addLayer( L.gridLayer.canvasCircles() );
	
</script>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
columbus3-0.5.1 bower_components/leaflet/docs/examples/extending/canvascircles.md
columbus3-0.6.0 bower_components/leaflet/docs/examples/extending/canvascircles.md
columbus3-0.5.0 bower_components/leaflet/docs/examples/extending/canvascircles.md