brouter-web/bower_components/leaflet-plugins/examples/marker-canvas.html
2014-01-27 18:46:51 +01:00

39 lines
1 KiB
HTML

<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
<script src="../layer/Icon.Canvas.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script type='text/javascript'>
var map = new L.Map('map', {center: new L.LatLng(67.66904, 33.68595), zoom: 10});
map.addLayer(new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'));
var circle = new L.Icon.Canvas({iconSize: new L.Point(30, 30)});
circle.draw = function(ctx, w, h) {
ctx.translate(w/2, h/2);
ctx.beginPath();
ctx.fillStyle = "#F00";
ctx.arc(0, 0, w/2-1, 0, Math.PI*2, true);
ctx.fill();
ctx.lineWidth = 2;
ctx.strokeStyle = '#FFF';
ctx.moveTo(-w/5, -h/5);
ctx.lineTo(w/5, h/5);
ctx.moveTo(-w/5, h/5);
ctx.lineTo(w/5, -h/5);
ctx.stroke();
ctx.closePath();
}
map.addLayer(new L.Marker(map.getCenter(), {icon: circle, draggable: true, opacity: 0.7}));
</script>
</body>
</html>