[WIP] Add type definitions for Leaflet 1.0 (#11165)

* Rename leaflet.d.ts to leaflet-0.7.d.ts

* Defined several important interfaces and the skeleton of some others

* Started adding tests

* Added more interfaces, factory methods and tests

* Implemented other interfaces and nested namespaces

* Added more types
This commit is contained in:
Alejandro Sánchez
2016-09-19 16:07:25 +09:00
committed by Masahiro Wakame
parent 4b82641492
commit 1adaa22d7a
17 changed files with 5911 additions and 4717 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Yang Guan <https://github.com/lookuptable>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/*
* Configuration object of a heatmap
+1 -1
View File
@@ -1,4 +1,4 @@
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/// <reference path="leaflet-curve.d.ts" />
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Onikiienko <https://github.com/onikiienko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
/**
+2 -2
View File
@@ -1,4 +1,4 @@
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/// <reference path="leaflet-draw.d.ts" />
@@ -44,4 +44,4 @@ map.on('draw:created', function (e: L.DrawEvents.Created) {
layer = e.layer;
drawnItems.addLayer(layer);
});
});
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Matt Guest <https://github.com/matt-guest>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
export interface MapOptions {
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Dominic Alie <https://github.com/dalie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
/**
@@ -1,4 +1,4 @@
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/// <reference path="leaflet-geocoder-mapzen.d.ts" />
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
+1 -1
View File
@@ -4,7 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
namespace Control {
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
export interface IconOptions {
+4 -4
View File
@@ -3,7 +3,7 @@
// Definitions by: Robert Imig <https://github.com/rimig>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
export interface MarkerClusterGroupOptions {
@@ -51,7 +51,7 @@ declare namespace L {
/*
* The maximum radius that a cluster will cover from the central marker (in pixels). Default 80.
* Decreasing will make more, smaller clusters. You can also use a function that accepts
* Decreasing will make more, smaller clusters. You can also use a function that accepts
* the current map zoom and returns the maximum cluster radius in pixels
*/
maxClusterRadius?: number | ((zoom: number) => number);
@@ -134,9 +134,9 @@ declare namespace L {
getAllChildMarkers(): Marker[];
/*
* Zooms to show the given marker (spiderfying if required),
* Zooms to show the given marker (spiderfying if required),
* calls the callback when the marker is visible on the map.
*/
*/
zoomToShowLayer(layer: any, callback: () => void): void;
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Egor Komarov <https://github.com/Odrin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare module L {
module AwesomeMarkers {
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: William Comartin <https://github.com/wcomartin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
+427
View File
@@ -0,0 +1,427 @@
/// <reference path="leaflet-0.7.d.ts" />
// initialize the map on the "map" div with a given center and zoom
var div = document.getElementById('map');
var map : L.Map = L.map(div, {
center: L.latLng([51.505, -0.09]),
zoom: 13,
minZoom: 3,
maxZoom: 8,
maxBounds: L.latLngBounds([L.latLng(-60, -60), L.latLng(60, 60)]),
dragging: true,
touchZoom: true,
scrollWheelZoom: true,
boxZoom: true,
tap: true,
tapTolerance: 30,
trackResize: true,
worldCopyJump: false,
closePopupOnClick: true,
bounceAtZoomLimits: true,
keyboard: true,
keyboardPanOffset: 80,
keyboardZoomOffset: 1,
inertia: true,
inertiaDeceleration: 3000,
inertiaMaxSpeed: 1500,
inertiaThreshold: 32,
zoomControl: true,
attributionControl: true,
fadeAnimation: true,
zoomAnimation: true,
zoomAnimationThreshold: 4,
markerZoomAnimation: true
});
map.dragging.enable();
map.touchZoom.enable();
map.scrollWheelZoom.enable();
map.doubleClickZoom.enable();
map.boxZoom.enable();
map.tap.enable();
map.setView(new L.LatLng(42, 51));
map.setView(L.latLng(42, 51));
map.setView(L.latLng(42, 51), 12);
map.setView(L.latLng(42, 51), 12, {
reset: true,
pan: {
animate: true,
duration: 0.25,
easeLinearity: 0.25,
noMoveStart: false
},
zoom: {
animate: true
}
});
map.setZoom(50);
map.setZoom(50, {});
map.zoomIn();
map.zoomOut();
map.zoomIn(2);
map.zoomOut(2);
map.zoomIn(2, { animate: true });
map.zoomOut(2, { animate: true });
map.setZoomAround(L.latLng(42, 51), 8, { animate: false });
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)), {
paddingTopLeft: L.point(20, 20),
paddingBottomRight: L.point(20, 20),
padding: L.point(0, 0),
maxZoom: null
});
map.fitWorld();
map.fitWorld({
animate: false
});
map.panTo(L.latLng(42, 42));
map.panTo(L.latLng(42, 42), {
animate: true
});
map.invalidateSize(true);
map.invalidateSize({ reset: true });
map.setMaxBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.locate();
map.locate({
watch: false,
setView: false,
maxZoom: 18,
timeout: 10000,
maximumAge: 0,
enableHighAccuracy: false
});
map.stopLocate();
map.remove();
var center : L.LatLng = map.getCenter();
var zoom : number = map.getZoom();
var minZoom: number = map.getMinZoom();
var maxZoom: number = map.getMaxZoom();
var bounds: L.LatLngBounds = map.getBounds();
var boundsZoom: number = map.getBoundsZoom(bounds, true);
var size: L.Point = map.getSize();
var pixelBounds: L.Bounds = map.getPixelBounds();
var pixelOrigin: L.Point = map.getPixelOrigin();
var layer = L.tileLayer("http://{s}.example.net/{x}/{y}/{z}.png");
map.addLayer(layer);
map.addLayer(layer, false);
map.eachLayer(l => {});
map.removeLayer(layer);
map.hasLayer(layer);
map.openPopup("canard", L.latLng(42, 51));
var popup = L.popup({
autoPan: true
});
map.openPopup(popup);
map.closePopup(popup);
map.closePopup();
map.addControl(L.control.attribution({position: 'bottomright'}));
map.removeControl(L.control.attribution({ position: 'bottomright' }));
L.control.layers({'Base': layer}).addTo(map);
map.on('baseLayerChange', function(e: L.LeafletLayersControlEvent) {
alert(e.name);
});
map.latLngToLayerPoint(map.layerPointToLatLng(L.point(0, 0)));
map.latLngToContainerPoint(map.containerPointToLatLng(L.point(0, 0)));
map.containerPointToLayerPoint(L.point(0, 0));
map.layerPointToContainerPoint(L.point(0, 0));
map.project(map.unproject(L.point(10, 20)));
map.project(map.unproject(L.point(10, 20), 12), 12);
var mouseEvent: L.LeafletMouseEvent;
map.mouseEventToContainerPoint(mouseEvent);
map.mouseEventToLayerPoint(mouseEvent);
map.mouseEventToLatLng(mouseEvent);
map.getContainer().classList.add('roger');
map.getPanes().mapPane.classList.add('roger');
map.getPanes().markerPane.classList.add('roger');
map.getPanes().objectsPane.classList.add('roger');
map.getPanes().overlayPane.classList.add('roger');
map.getPanes().popupPane.classList.add('roger');
map.getPanes().shadowPane.classList.add('roger');
map.getPanes().tilePane.classList.add('roger');
map.whenReady((m: L.Map) => {
m.zoomOut();
});
map.on('click', () => {
map.zoomOut();
});
map.off('dblclick', L.Util.falseFn);
map.once('contextmenu', (e: L.LeafletMouseEvent) => {
map.openPopup('contextmenu', e.latlng);
});
var marker = L.marker(L.latLng(42, 51), {
icon: L.icon({
iconUrl: 'roger.png',
iconRetinaUrl: 'roger-retina.png',
iconSize: L.point(40, 40),
iconAnchor: L.point(20, 0),
shadowUrl: 'roger-shadow.png',
shadowRetinaUrl: 'roger-shadow-retina.png',
shadowSize: L.point(44, 44),
shadowAnchor: L.point(22, 0),
popupAnchor: L.point(0, 0),
className: 'roger-icon'
}),
clickable: true,
draggable: false,
keyboard: true,
title: 'this is an icon',
alt: '',
zIndexOffset: 0,
opacity: 1.0,
riseOnHover: false,
riseOffset: 250
});
marker.addTo(map);
marker.on('click', (e: L.LeafletMouseEvent) => {
map.setView(e.latlng);
});
marker.once('mouseover', () => {
marker.openPopup();
})
marker.setLatLng(marker.getLatLng());
marker.setIcon(L.icon({}));
marker.setZIndexOffset(30);
marker.setOpacity(0.8);
marker.bindPopup(popup);
marker.unbindPopup();
marker.bindPopup('hello', {
closeOnClick: true
});
marker.openPopup();
marker.closePopup();
marker.togglePopup();
marker.togglePopup();
marker.setPopupContent('hello 3')
marker.getPopup().setContent('hello 2');
marker.update();
marker.toGeoJSON();
marker.dragging.enable();
popup = L.popup({
maxWidth: 300,
minWidth: 50,
maxHeight: null,
autoPan: true,
keepInView: false,
closeButton: true,
offset: L.point(0, 6),
autoPanPaddingTopLeft: null,
autoPanPaddingBottomRight: L.point(20, 20),
autoPanPadding: L.point(5, 5),
zoomAnimation: true,
closeOnClick: null,
className: 'roger'
});
popup.setLatLng(L.latLng(12, 54)).setContent('this is nice popup').openOn(map);
popup.update();
var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {
minZoom: 0,
maxZoom: 18,
maxNativeZoom: 17,
tileSize: 256,
subdomains: ['a','b','c'],
errorTileUrl: '',
attribution: '',
tms: false,
continuousWorld: false,
noWrap: false,
zoomOffset: 0,
zoomReverse: false,
opacity: 1.0,
zIndex: null,
unloadInvisibleTiles: false,
updateWhenIdle: false,
detectRetina: true,
reuseTiles: true,
bounds: null
});
tileLayer.on('loading', L.Util.falseFn)
.off('loading', L.Util.falseFn)
.once('tileload', L.Util.falseFn);
tileLayer.addTo(map);
tileLayer.bringToBack()
.bringToFront()
.setOpacity(0.7)
.setZIndex(9)
.redraw()
.setUrl('http://perdu.com')
.getContainer();
namespace CustomControl {
export interface Options {
title: string;
position?: string;
}
}
interface CustomControl extends L.Control {
getTitle(): string;
setTitle(title: string): CustomControl;
}
var CustomControl: { new(options: CustomControl.Options): CustomControl };
CustomControl = L.Control.extend<CustomControl.Options, CustomControl>({
initialize: function(options: CustomControl.Options) {
L.Control.prototype.initialize.call(this, {
position: options.position || 'bottomleft',
});
this.title = options.title;
},
getTitle: function() {
return this.title;
},
setTitle: function(title: string) {
this.title = title;
},
});
// Different latLng and latLngBounds expressions
var latLngLiteral = [10, 20];
var latLngObjectLiteral = { lat: 10, lng: 10 };
var boundsLiteral = [[10, 20], [20, 20]];
var boundLiteralOfLatLngObjects = [latLngObjectLiteral, latLngObjectLiteral];
var circle: L.Circle = L.circle(latLngLiteral, 4);
circle = new L.Circle(latLngLiteral, 4);
circle.setLatLng(latLngLiteral);
circle = L.circle(latLngObjectLiteral, 4);
circle = new L.Circle(latLngObjectLiteral, 4);
circle.setLatLng(latLngObjectLiteral);
var circleMarker: L.CircleMarker = L.circleMarker(latLngLiteral);
circleMarker = new L.CircleMarker(latLngLiteral);
circleMarker.setLatLng(latLngLiteral);
circleMarker = L.circleMarker(latLngObjectLiteral);
circleMarker = new L.CircleMarker(latLngObjectLiteral);
circleMarker.setLatLng(latLngObjectLiteral);
var latLng: L.LatLng = L.latLng(latLngLiteral);
latLng = new L.LatLng(latLngLiteral);
latLng.distanceTo(latLngLiteral);
latLng.equals(latLngLiteral);
latLng = L.latLng(latLngObjectLiteral);
latLng = new L.LatLng(latLngObjectLiteral);
latLng.distanceTo(latLngObjectLiteral);
latLng.equals(latLngObjectLiteral);
var bounds: L.LatLngBounds = L.latLngBounds(boundsLiteral);
bounds = L.latLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(boundsLiteral);
bounds = new L.LatLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(latLngLiteral, latLngLiteral);
bounds.extend(latLngLiteral);
bounds.extend(latLngObjectLiteral);
bounds.extend(boundsLiteral);
bounds.extend(boundLiteralOfLatLngObjects);
bounds.contains(latLngLiteral);
bounds.contains(boundLiteralOfLatLngObjects);
bounds.contains(boundsLiteral);
bounds.intersects(boundsLiteral);
bounds.intersects(boundLiteralOfLatLngObjects);
bounds.equals(boundsLiteral);
bounds.equals(boundLiteralOfLatLngObjects);
map.setView(latLngLiteral);
map.setView(latLngObjectLiteral);
map.setZoomAround(latLngLiteral, 15);
map.setZoomAround(latLngObjectLiteral, 15);
map.panTo(latLngLiteral);
map.panTo(latLngObjectLiteral);
map.openPopup('test', latLngLiteral);
map.openPopup('test', latLngObjectLiteral);
map.latLngToLayerPoint(latLngLiteral);
map.latLngToLayerPoint(latLngObjectLiteral);
map.latLngToContainerPoint(latLngLiteral);
map.latLngToContainerPoint(latLngObjectLiteral);
map.project(latLngLiteral);
map.project(latLngObjectLiteral);
marker.setLatLng(latLngLiteral);
marker.setLatLng(latLngObjectLiteral);
var polygon: L.Polygon = L.polygon(boundsLiteral);
polygon = L.polygon(boundLiteralOfLatLngObjects);
polygon = new L.Polygon(boundsLiteral);
polygon = new L.Polygon(boundLiteralOfLatLngObjects);
var polyline: L.Polyline = L.polyline(boundsLiteral);
polyline = L.polyline(boundLiteralOfLatLngObjects);
polyline = new L.Polyline(boundsLiteral);
polyline = new L.Polyline(boundLiteralOfLatLngObjects);
polyline.setLatLngs(boundsLiteral);
polyline.setLatLngs(boundLiteralOfLatLngObjects);
polyline.addLatLng(latLngLiteral);
polyline.addLatLng(latLngObjectLiteral);
var popup: L.Popup = L.popup();
popup.setLatLng(latLngLiteral);
popup.setLatLng(latLngObjectLiteral);
var zoomCtrl = L.control.zoom({
position: "topleft",
zoomInText: '+',
zoomOutText: '-'
});
+4382
View File
File diff suppressed because it is too large Load Diff
+265 -425
View File
@@ -1,427 +1,267 @@
/// <reference path="leaflet.d.ts" />
// initialize the map on the "map" div with a given center and zoom
var div = document.getElementById('map');
var map : L.Map = L.map(div, {
center: L.latLng([51.505, -0.09]),
zoom: 13,
minZoom: 3,
maxZoom: 8,
maxBounds: L.latLngBounds([L.latLng(-60, -60), L.latLng(60, 60)]),
dragging: true,
touchZoom: true,
scrollWheelZoom: true,
boxZoom: true,
tap: true,
tapTolerance: 30,
trackResize: true,
worldCopyJump: false,
closePopupOnClick: true,
bounceAtZoomLimits: true,
keyboard: true,
keyboardPanOffset: 80,
keyboardZoomOffset: 1,
inertia: true,
inertiaDeceleration: 3000,
inertiaMaxSpeed: 1500,
inertiaThreshold: 32,
zoomControl: true,
attributionControl: true,
fadeAnimation: true,
zoomAnimation: true,
zoomAnimationThreshold: 4,
markerZoomAnimation: true
});
map.dragging.enable();
map.touchZoom.enable();
map.scrollWheelZoom.enable();
map.doubleClickZoom.enable();
map.boxZoom.enable();
map.tap.enable();
map.setView(new L.LatLng(42, 51));
map.setView(L.latLng(42, 51));
map.setView(L.latLng(42, 51), 12);
map.setView(L.latLng(42, 51), 12, {
reset: true,
pan: {
animate: true,
duration: 0.25,
easeLinearity: 0.25,
noMoveStart: false
},
zoom: {
animate: true
}
});
map.setZoom(50);
map.setZoom(50, {});
map.zoomIn();
map.zoomOut();
map.zoomIn(2);
map.zoomOut(2);
map.zoomIn(2, { animate: true });
map.zoomOut(2, { animate: true });
map.setZoomAround(L.latLng(42, 51), 8, { animate: false });
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)), {
paddingTopLeft: L.point(20, 20),
paddingBottomRight: L.point(20, 20),
padding: L.point(0, 0),
maxZoom: null
});
map.fitWorld();
map.fitWorld({
animate: false
});
map.panTo(L.latLng(42, 42));
map.panTo(L.latLng(42, 42), {
animate: true
});
map.invalidateSize(true);
map.invalidateSize({ reset: true });
map.setMaxBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.locate();
map.locate({
watch: false,
setView: false,
maxZoom: 18,
timeout: 10000,
maximumAge: 0,
enableHighAccuracy: false
});
map.stopLocate();
map.remove();
var center : L.LatLng = map.getCenter();
var zoom : number = map.getZoom();
var minZoom: number = map.getMinZoom();
var maxZoom: number = map.getMaxZoom();
var bounds: L.LatLngBounds = map.getBounds();
var boundsZoom: number = map.getBoundsZoom(bounds, true);
var size: L.Point = map.getSize();
var pixelBounds: L.Bounds = map.getPixelBounds();
var pixelOrigin: L.Point = map.getPixelOrigin();
var layer = L.tileLayer("http://{s}.example.net/{x}/{y}/{z}.png");
map.addLayer(layer);
map.addLayer(layer, false);
map.eachLayer(l => {});
map.removeLayer(layer);
map.hasLayer(layer);
map.openPopup("canard", L.latLng(42, 51));
var popup = L.popup({
autoPan: true
});
map.openPopup(popup);
map.closePopup(popup);
map.closePopup();
map.addControl(L.control.attribution({position: 'bottomright'}));
map.removeControl(L.control.attribution({ position: 'bottomright' }));
L.control.layers({'Base': layer}).addTo(map);
map.on('baseLayerChange', function(e: L.LeafletLayersControlEvent) {
alert(e.name);
});
map.latLngToLayerPoint(map.layerPointToLatLng(L.point(0, 0)));
map.latLngToContainerPoint(map.containerPointToLatLng(L.point(0, 0)));
map.containerPointToLayerPoint(L.point(0, 0));
map.layerPointToContainerPoint(L.point(0, 0));
map.project(map.unproject(L.point(10, 20)));
map.project(map.unproject(L.point(10, 20), 12), 12);
var mouseEvent: L.LeafletMouseEvent;
map.mouseEventToContainerPoint(mouseEvent);
map.mouseEventToLayerPoint(mouseEvent);
map.mouseEventToLatLng(mouseEvent);
map.getContainer().classList.add('roger');
map.getPanes().mapPane.classList.add('roger');
map.getPanes().markerPane.classList.add('roger');
map.getPanes().objectsPane.classList.add('roger');
map.getPanes().overlayPane.classList.add('roger');
map.getPanes().popupPane.classList.add('roger');
map.getPanes().shadowPane.classList.add('roger');
map.getPanes().tilePane.classList.add('roger');
map.whenReady((m: L.Map) => {
m.zoomOut();
});
map.on('click', () => {
map.zoomOut();
});
map.off('dblclick', L.Util.falseFn);
map.once('contextmenu', (e: L.LeafletMouseEvent) => {
map.openPopup('contextmenu', e.latlng);
});
var marker = L.marker(L.latLng(42, 51), {
icon: L.icon({
iconUrl: 'roger.png',
iconRetinaUrl: 'roger-retina.png',
iconSize: L.point(40, 40),
iconAnchor: L.point(20, 0),
shadowUrl: 'roger-shadow.png',
shadowRetinaUrl: 'roger-shadow-retina.png',
shadowSize: L.point(44, 44),
shadowAnchor: L.point(22, 0),
popupAnchor: L.point(0, 0),
className: 'roger-icon'
}),
clickable: true,
draggable: false,
keyboard: true,
title: 'this is an icon',
alt: '',
zIndexOffset: 0,
opacity: 1.0,
riseOnHover: false,
riseOffset: 250
});
marker.addTo(map);
marker.on('click', (e: L.LeafletMouseEvent) => {
map.setView(e.latlng);
});
marker.once('mouseover', () => {
marker.openPopup();
})
marker.setLatLng(marker.getLatLng());
marker.setIcon(L.icon({}));
marker.setZIndexOffset(30);
marker.setOpacity(0.8);
marker.bindPopup(popup);
marker.unbindPopup();
marker.bindPopup('hello', {
closeOnClick: true
});
marker.openPopup();
marker.closePopup();
marker.togglePopup();
marker.togglePopup();
marker.setPopupContent('hello 3')
marker.getPopup().setContent('hello 2');
marker.update();
marker.toGeoJSON();
marker.dragging.enable();
popup = L.popup({
maxWidth: 300,
minWidth: 50,
maxHeight: null,
autoPan: true,
keepInView: false,
closeButton: true,
offset: L.point(0, 6),
autoPanPaddingTopLeft: null,
autoPanPaddingBottomRight: L.point(20, 20),
autoPanPadding: L.point(5, 5),
zoomAnimation: true,
closeOnClick: null,
className: 'roger'
});
popup.setLatLng(L.latLng(12, 54)).setContent('this is nice popup').openOn(map);
popup.update();
var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {
minZoom: 0,
maxZoom: 18,
maxNativeZoom: 17,
tileSize: 256,
subdomains: ['a','b','c'],
errorTileUrl: '',
attribution: '',
tms: false,
continuousWorld: false,
noWrap: false,
zoomOffset: 0,
zoomReverse: false,
opacity: 1.0,
zIndex: null,
unloadInvisibleTiles: false,
updateWhenIdle: false,
detectRetina: true,
reuseTiles: true,
bounds: null
});
tileLayer.on('loading', L.Util.falseFn)
.off('loading', L.Util.falseFn)
.once('tileload', L.Util.falseFn);
tileLayer.addTo(map);
tileLayer.bringToBack()
.bringToFront()
.setOpacity(0.7)
.setZIndex(9)
.redraw()
.setUrl('http://perdu.com')
.getContainer();
namespace CustomControl {
export interface Options {
title: string;
position?: string;
}
}
interface CustomControl extends L.Control {
getTitle(): string;
setTitle(title: string): CustomControl;
}
var CustomControl: { new(options: CustomControl.Options): CustomControl };
CustomControl = L.Control.extend<CustomControl.Options, CustomControl>({
initialize: function(options: CustomControl.Options) {
L.Control.prototype.initialize.call(this, {
position: options.position || 'bottomleft',
});
this.title = options.title;
},
getTitle: function() {
return this.title;
},
setTitle: function(title: string) {
this.title = title;
},
});
// Different latLng and latLngBounds expressions
var latLngLiteral = [10, 20];
var latLngObjectLiteral = { lat: 10, lng: 10 };
var boundsLiteral = [[10, 20], [20, 20]];
var boundLiteralOfLatLngObjects = [latLngObjectLiteral, latLngObjectLiteral];
var circle: L.Circle = L.circle(latLngLiteral, 4);
circle = new L.Circle(latLngLiteral, 4);
circle.setLatLng(latLngLiteral);
circle = L.circle(latLngObjectLiteral, 4);
circle = new L.Circle(latLngObjectLiteral, 4);
circle.setLatLng(latLngObjectLiteral);
var circleMarker: L.CircleMarker = L.circleMarker(latLngLiteral);
circleMarker = new L.CircleMarker(latLngLiteral);
circleMarker.setLatLng(latLngLiteral);
circleMarker = L.circleMarker(latLngObjectLiteral);
circleMarker = new L.CircleMarker(latLngObjectLiteral);
circleMarker.setLatLng(latLngObjectLiteral);
var latLng: L.LatLng = L.latLng(latLngLiteral);
latLng = new L.LatLng(latLngLiteral);
latLng.distanceTo(latLngLiteral);
latLng.equals(latLngLiteral);
latLng = L.latLng(latLngObjectLiteral);
latLng = new L.LatLng(latLngObjectLiteral);
latLng.distanceTo(latLngObjectLiteral);
latLng.equals(latLngObjectLiteral);
var bounds: L.LatLngBounds = L.latLngBounds(boundsLiteral);
bounds = L.latLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(boundsLiteral);
bounds = new L.LatLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(latLngLiteral, latLngLiteral);
bounds.extend(latLngLiteral);
bounds.extend(latLngObjectLiteral);
bounds.extend(boundsLiteral);
bounds.extend(boundLiteralOfLatLngObjects);
bounds.contains(latLngLiteral);
bounds.contains(boundLiteralOfLatLngObjects);
bounds.contains(boundsLiteral);
bounds.intersects(boundsLiteral);
bounds.intersects(boundLiteralOfLatLngObjects);
bounds.equals(boundsLiteral);
bounds.equals(boundLiteralOfLatLngObjects);
map.setView(latLngLiteral);
map.setView(latLngObjectLiteral);
map.setZoomAround(latLngLiteral, 15);
map.setZoomAround(latLngObjectLiteral, 15);
map.panTo(latLngLiteral);
map.panTo(latLngObjectLiteral);
map.openPopup('test', latLngLiteral);
map.openPopup('test', latLngObjectLiteral);
map.latLngToLayerPoint(latLngLiteral);
map.latLngToLayerPoint(latLngObjectLiteral);
map.latLngToContainerPoint(latLngLiteral);
map.latLngToContainerPoint(latLngObjectLiteral);
map.project(latLngLiteral);
map.project(latLngObjectLiteral);
marker.setLatLng(latLngLiteral);
marker.setLatLng(latLngObjectLiteral);
var polygon: L.Polygon = L.polygon(boundsLiteral);
polygon = L.polygon(boundLiteralOfLatLngObjects);
polygon = new L.Polygon(boundsLiteral);
polygon = new L.Polygon(boundLiteralOfLatLngObjects);
var polyline: L.Polyline = L.polyline(boundsLiteral);
polyline = L.polyline(boundLiteralOfLatLngObjects);
polyline = new L.Polyline(boundsLiteral);
polyline = new L.Polyline(boundLiteralOfLatLngObjects);
polyline.setLatLngs(boundsLiteral);
polyline.setLatLngs(boundLiteralOfLatLngObjects);
polyline.addLatLng(latLngLiteral);
polyline.addLatLng(latLngObjectLiteral);
var popup: L.Popup = L.popup();
popup.setLatLng(latLngLiteral);
popup.setLatLng(latLngObjectLiteral);
var zoomCtrl = L.control.zoom({
position: "topleft",
zoomInText: '+',
zoomOutText: '-'
});
import L = require('leaflet');
const latLngLiteral: L.LatLngLiteral = {lat: 12, lng: 13};
const latLngTuple: L.LatLngTuple = [12, 13];
let latLng: L.LatLng;
latLng = L.latLng(12, 13);
latLng = L.latLng(12, 13, 0);
latLng = L.latLng(latLngLiteral);
latLng = L.latLng({lat: 12, lng: 13, alt: 0});
latLng = L.latLng(latLngTuple);
latLng = L.latLng([12, 13, 0]);
const latLngBoundsLiteral: L.LatLngBoundsLiteral = [[12, 13], latLngTuple];
let latLngBounds: L.LatLngBounds;
latLngBounds = L.latLngBounds(latLng, latLng);
latLngBounds = L.latLngBounds(latLngLiteral, latLngLiteral);
latLngBounds = L.latLngBounds(latLngTuple, latLngTuple);
const pointTuple: L.PointTuple = [0, 0];
let point: L.Point;
point = L.point(12, 13);
point = L.point(12, 13, true);
point = L.point(pointTuple);
point = L.point({x: 12, y: 13});
const boundsLiteral: L.BoundsLiteral = [[1, 1], pointTuple];
let bounds: L.Bounds;
bounds = L.bounds(point, point);
bounds = L.bounds(pointTuple, pointTuple);
bounds = L.bounds([point, point]);
bounds = L.bounds(boundsLiteral);
let mapOptions: L.MapOptions = {};
mapOptions = {
preferCanvas: true,
attributionControl: false,
zoomControl: true,
closePopupOnClick: false,
zoomSnap: 1,
zoomDelta: 1,
trackResize: false,
boxZoom: true,
dragging: true,
// CRS
zoom: 12,
minZoom: 10,
maxZoom: 14,
fadeAnimation: true,
markerZoomAnimation: false,
transform3DLimit: 123,
zoomAnimation: false,
zoomAnimationThreshold: 4,
inertia: false,
inertiaDeceleration: 2000,
inertiaMaxSpeed: 1000,
easeLinearity: 0.5,
worldCopyJump: true,
maxBoundsViscosity: 1.0,
keyboard: false,
keyboardPanDelta: 100,
wheelDebounceTime: 30,
wheelPxPerZoomLevel: 25,
tap: false,
tapTolerance: 10,
bounceAtZoomLimits: false
};
mapOptions.doubleClickZoom = true;
mapOptions.doubleClickZoom = 'center';
mapOptions.center = latLng;
mapOptions.center = latLngLiteral;
mapOptions.center = latLngTuple;
mapOptions.layers = [];
mapOptions.layers = [L.tileLayer('')]; // add layers of other types
mapOptions.maxBounds = latLngBounds;
mapOptions.maxBounds = [];
mapOptions.maxBounds = latLngBoundsLiteral;
// mapOptions.renderer = ?
mapOptions.scrollWheelZoom = true;
mapOptions.scrollWheelZoom = 'center';
mapOptions.touchZoom = false;
mapOptions.touchZoom = 'center';
let layer: L.Layer;
const htmlElement = document.getElementById('foo');
let popupOptions: L.PopupOptions = {};
let tooltipOptions: L.TooltipOptions = {};
let zoomPanOptions: L.ZoomPanOptions = {};
zoomPanOptions = {
animate: false,
duration: 0.5,
easeLinearity: 0.6,
noMoveStart: true
};
let zoomOptions: L.ZoomOptions = {};
let panOptions: L.PanOptions = {};
let fitBoundsOptions: L.FitBoundsOptions = {};
let map = L.map('foo');
map = L.map('foo', mapOptions);
map = L.map(htmlElement);
map = L.map(htmlElement, mapOptions);
let doesItHaveLayer: boolean;
doesItHaveLayer = map.hasLayer(L.tileLayer(''));
// map.getRenderer
let html: HTMLElement;
html = map.createPane('foo');
html = map.createPane('foo', htmlElement)
html = map.getPane('foo');
html = map.getPane(htmlElement);
html = map.getContainer();
const panes = map.getPanes();
html = panes.mapPane;
html = panes.tilePane;
html = panes.overlayPane;
html = panes.shadowPane;
html = panes.markerPane;
html = panes.tooltipPane;
html = panes.popupPane;
html = panes['foo'];
let coordinates: L.LatLng;
coordinates = map.getCenter();
let zoom: number;
zoom = map.getZoom();
zoom = map.getMinZoom();
zoom = map.getMaxZoom();
zoom = map.getBoundsZoom(latLngBounds);
zoom = map.getBoundsZoom(latLngBounds, true);
zoom = map.getBoundsZoom(latLngBoundsLiteral);
zoom = map.getBoundsZoom(latLngBoundsLiteral, true);
let mapLatLngBounds: L.LatLngBounds;
mapLatLngBounds = map.getBounds();
let mapPoint: L.Point;
mapPoint = map.getSize();
mapPoint = map.getPixelOrigin();
let mapPixelBounds: L.Bounds;
mapPixelBounds = map.getPixelBounds();
mapPixelBounds = map.getPixelWorldBounds();
mapPixelBounds = map.getPixelWorldBounds(12);
map = map
// addControl
// removeControl
.addLayer(L.tileLayer(''))
.removeLayer(L.tileLayer('')) // use a different type of layer
.eachLayer((currentLayer) => {
layer = currentLayer;
})
.eachLayer((currentLayer) => {
layer = currentLayer;
}, {})
.openPopup(L.popup())
.openPopup('Hello World', latLng)
.openPopup('Hello World', latLng, popupOptions)
.openPopup('Hello World', latLngLiteral)
.openPopup('Hello World', latLngLiteral, popupOptions)
.openPopup('Hello World', latLngTuple)
.openPopup('Hello World', latLngTuple, popupOptions)
.openPopup(htmlElement, latLng)
.openPopup(htmlElement, latLng, popupOptions)
.openPopup(htmlElement, latLngLiteral)
.openPopup(htmlElement, latLngLiteral, popupOptions)
.openPopup(htmlElement, latLngTuple)
.openPopup(htmlElement, latLngTuple, popupOptions)
.closePopup()
.closePopup(L.popup())
.openTooltip(L.tooltip())
.openTooltip('Hello Word', latLng)
.openTooltip('Hello World', latLng, tooltipOptions)
.openTooltip('Hello World', latLngLiteral)
.openTooltip('Hello World', latLngLiteral, tooltipOptions)
.openTooltip('Hello World', latLngTuple)
.openTooltip('Hello World', latLngTuple, tooltipOptions)
.openTooltip(htmlElement, latLng)
.openTooltip(htmlElement, latLng, tooltipOptions)
.openTooltip(htmlElement, latLngLiteral)
.openTooltip(htmlElement, latLngLiteral, tooltipOptions)
.openTooltip(htmlElement, latLngTuple)
.openTooltip(htmlElement, latLngTuple, tooltipOptions)
.closeTooltip()
.closeTooltip(L.tooltip())
.setView(latLng, 12)
.setView(latLng, 12, zoomPanOptions)
.setView(latLngLiteral, 12)
.setView(latLngLiteral, 12, zoomPanOptions)
.setView(latLngTuple, 12)
.setView(latLngTuple, 12, zoomPanOptions)
.setZoom(12, zoomPanOptions) // investigate if zoomPanOptions are really required
.zoomIn()
.zoomIn(1)
.zoomIn(1, zoomOptions)
.zoomOut()
.zoomOut(1)
.zoomOut(1, zoomOptions)
.setZoomAround(latLng, 12, zoomOptions) // investigate if zoom options are really required
.setZoomAround(latLngLiteral, 12, zoomOptions)
.setZoomAround(latLngTuple, 12, zoomOptions)
.setZoomAround(point, 12, zoomOptions)
.setZoomAround(pointTuple, 11, zoomOptions)
.fitBounds(latLngBounds, fitBoundsOptions) // investigate if fit bounds options are really required
.fitBounds(latLngBoundsLiteral, fitBoundsOptions)
.fitWorld()
.fitWorld(fitBoundsOptions)
.panTo(latLng)
.panTo(latLng, panOptions)
.panTo(latLngLiteral)
.panTo(latLngLiteral, panOptions)
.panTo(latLngTuple)
.panTo(latLngTuple, panOptions)
.panBy(point)
.panBy(pointTuple)
.setMaxBounds(bounds) // investigate if this really receives Bounds instead of LatLngBounds
.setMaxBounds(boundsLiteral)
.setMinZoom(5)
.setMaxZoom(10)
.panInsideBounds(latLngBounds)
.panInsideBounds(latLngBounds, panOptions)
.panInsideBounds(latLngBoundsLiteral)
.panInsideBounds(latLngBoundsLiteral, panOptions)
.invalidateSize(zoomPanOptions)
.invalidateSize(false)
.stop()
.flyTo(latLng)
.flyTo(latLng, 12)
.flyTo(latLng, 12, zoomOptions)
.flyTo(latLngLiteral)
.flyTo(latLngLiteral, 12)
.flyTo(latLngLiteral, 12, zoomPanOptions)
.flyTo(latLngTuple)
.flyTo(latLngTuple, 12)
.flyTo(latLngTuple, 12, zoomPanOptions)
.flyToBounds(latLngBounds)
.flyToBounds(latLngBounds, fitBoundsOptions)
.flyToBounds(latLngBoundsLiteral)
.flyToBounds(latLngBoundsLiteral, fitBoundsOptions)
// addHandler
.remove()
.whenReady(() => {})
.whenReady(() => {}, {});
+820 -4275
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Maxime Fabre <https://github.com/anahkiasen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts"/>
/// <reference path="../leaflet/leaflet-0.7.d.ts"/>
//////////////////////////////////////////////////////////////////////
///////////////////////////// MAP OBJECT /////////////////////////////