Files
DefinitelyTyped/leaflet-draw/leaflet-draw-tests.ts
Ryan Blace 8f4c8d6c5b [types/leaflet-draw] Fixes and updated to work with Leaflet 1.x and Leaflet Draw 0.4.6 (#13262)
* Updating to work with Leaflet 1.x and Leaflet Draw 4.x

* Removing the I in the interfaces to be consistent with Leaflet

* Just updating a missing semicolon
2016-12-25 05:25:09 +09:00

47 lines
1.2 KiB
TypeScript

/// <reference types="leaflet" />
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
map = L.map('map', {layers: [osm], center: L.latLng(-37.7772, 175.2756), zoom: 15 });
var drawnItems = L.featureGroup();
map.addLayer(drawnItems);
var drawControl = new L.Control.Draw({
position: 'topleft' ,
draw: {
polygon: {
allowIntersection: false,
drawError: {
color: '#b00b00',
timeout: 1000
},
shapeOptions: {
color: '#bada55'
},
showArea: true
},
polyline: {
metric: false
},
circle: {
shapeOptions: {
color: '#662d91'
}
}
},
edit: {
featureGroup: drawnItems
}
});
map.addControl(drawControl);
map.on('draw:created', function (e: any) {
var drawEvent = (e as L.DrawEvents.Created);
var type = drawEvent.layerType,
layer = drawEvent.layer;
drawnItems.addLayer(layer);
});