From 1831947ddae14f037ad88e902c91262372dcc3db Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 14:51:38 -0700 Subject: [PATCH 1/4] module -> namespace in 'leaflet'. --- leaflet/leaflet.d.ts | 158 +++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 56d702485..e148f35d6 100755 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -382,7 +382,7 @@ declare module L { onRemove(map: Map): void; } - module Control { + namespace Control { export interface ZoomStatic extends ClassStatic { /** * Creates a zoom control. @@ -478,7 +478,7 @@ declare module L { function (options?: ControlOptions): Control; } - module control { + namespace control { /** * Creates a zoom control. @@ -503,7 +503,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface ControlOptions { @@ -517,9 +517,9 @@ declare module L { } } -declare module L { +declare namespace L { - module CRS { + namespace CRS { /** * The most common CRS for online maps, used by almost all free and commercial @@ -549,7 +549,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Creates a div icon instance with the given options. @@ -568,7 +568,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface DivIconOptions { @@ -602,7 +602,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface DomEvent { @@ -663,9 +663,9 @@ declare module L { export var DomEvent: DomEvent; } -declare module L { +declare namespace L { - module DomUtil { + namespace DomUtil { /** * Returns an element with the given id if a string was passed, or just returns @@ -766,7 +766,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Creates a Draggable object for moving the given element when you start dragging @@ -816,7 +816,7 @@ declare module L { -declare module L { +declare namespace L { /** * Create a layer group, optionally given an initial set of layers. @@ -894,7 +894,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface FitBoundsOptions extends ZoomPanOptions { @@ -931,7 +931,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format @@ -994,7 +994,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface GeoJSONOptions { /** * Function that will be used for creating layers for GeoJSON points (if not @@ -1031,7 +1031,7 @@ declare module L { -declare module L { +declare namespace L { /** * Creates an icon instance with the given options. @@ -1058,7 +1058,7 @@ declare module L { export interface Icon { } - module Icon { + namespace Icon { /** * L.Icon.Default extends L.Icon and is the blue icon Leaflet uses * for markers by default. @@ -1068,7 +1068,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface IconOptions { @@ -1133,7 +1133,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface IControl { @@ -1153,7 +1153,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface ICRS { @@ -1205,7 +1205,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface IEventPowered { @@ -1285,7 +1285,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface IHandler { @@ -1310,7 +1310,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface ILayer { @@ -1329,8 +1329,8 @@ declare module L { } } -declare module L { - module Mixin { +declare namespace L { + namespace Mixin { export interface LeafletMixinEvents extends IEventPowered { } @@ -1338,7 +1338,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates an image overlay object given the URL of the image and the geographical @@ -1398,7 +1398,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface ImageOverlayOptions { @@ -1409,7 +1409,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface IProjection { @@ -1425,7 +1425,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * A constant that represents the Leaflet version in use. @@ -1439,7 +1439,7 @@ declare module L { export function noConflict(): typeof L; } -declare module L { +declare namespace L { /** * Creates an object representing a geographical point with the given latitude * and longitude. @@ -1524,7 +1524,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Creates a LatLngBounds object by defining south-west and north-east corners @@ -1650,7 +1650,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Create a layer group, optionally given an initial set of layers. @@ -1736,7 +1736,7 @@ declare module L { } -declare module L { +declare namespace L { export interface LayersOptions { @@ -1766,7 +1766,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletErrorEvent extends LeafletEvent { @@ -1782,7 +1782,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletEvent { @@ -1798,7 +1798,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletGeoJSONEvent extends LeafletEvent { @@ -1824,7 +1824,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletLayerEvent extends LeafletEvent { @@ -1835,7 +1835,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletLocationEvent extends LeafletEvent { @@ -1883,7 +1883,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletMouseEvent extends LeafletEvent { @@ -1911,7 +1911,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletPopupEvent extends LeafletEvent { @@ -1922,7 +1922,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletDragEndEvent extends LeafletEvent { @@ -1933,7 +1933,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletResizeEvent extends LeafletEvent { @@ -1949,7 +1949,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LeafletTileEvent extends LeafletEvent { @@ -1965,9 +1965,9 @@ declare module L { } } -declare module L { +declare namespace L { - module LineUtil { + namespace LineUtil { /** * Dramatically reduces the number of points in a polyline while retaining @@ -1999,7 +1999,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface LocateOptions { @@ -2052,7 +2052,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a map object given a div element and optionally an @@ -2442,7 +2442,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface MapOptions { @@ -2682,7 +2682,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface MapPanes { @@ -2723,7 +2723,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a Marker object given a geographical point and optionally @@ -2873,7 +2873,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface MarkerOptions { @@ -2953,7 +2953,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a multi-polyline object given an array of latlngs arrays (one @@ -2996,7 +2996,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a multi-polyline object given an array of arrays of geographical @@ -3037,7 +3037,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface PanOptions { @@ -3073,7 +3073,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface Path extends ILayer, IEventPowered { @@ -3171,7 +3171,7 @@ declare module L { off(eventMap?: any, context?: any): Path; } - module Path { + namespace Path { /** * True if SVG is used for vector rendering (true for most modern browsers). */ @@ -3201,7 +3201,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface PathOptions { @@ -3297,7 +3297,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Creates a Point object with the given x and y coordinates. If optional round @@ -3373,7 +3373,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a polygon object given an array of geographical points and @@ -3401,7 +3401,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a polyline object given an array of geographical points and @@ -3453,7 +3453,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface PolylineOptions extends PathOptions { @@ -3474,9 +3474,9 @@ declare module L { } } -declare module L { +declare namespace L { - module PolyUtil { + namespace PolyUtil { /** * Clips the polygon geometry defined by the given points by rectangular bounds. @@ -3488,7 +3488,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a Popup object given an optional options object that describes @@ -3567,7 +3567,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface PopupOptions { @@ -3665,7 +3665,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface PosAnimationStatic extends ClassStatic { /** @@ -3702,9 +3702,9 @@ declare module L { } } -declare module L { +declare namespace L { - module Projection { + namespace Projection { /** * Spherical Mercator projection — the most common projection for online maps, @@ -3730,7 +3730,7 @@ declare module L { } } -declare module L { +declare namespace L { /** * Instantiates a rectangle object with the given geographical bounds and @@ -3756,7 +3756,7 @@ declare module L { } -declare module L { +declare namespace L { export interface ScaleOptions { @@ -3794,7 +3794,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface TileLayerStatic extends ClassStatic { /** @@ -3894,7 +3894,7 @@ declare module L { off(eventMap?: any, context?: any): TileLayer; } - module TileLayer { + namespace TileLayer { export interface WMS extends TileLayer { /** * Merges an object with the new parameters and re-requests tiles on the current @@ -3942,7 +3942,7 @@ declare module L { export var tileLayer: TileLayerFactory; } -declare module L { +declare namespace L { export interface TileLayerOptions { @@ -4089,7 +4089,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface TransformationStatic extends ClassStatic { /** * Creates a transformation object with the given coefficients. @@ -4113,9 +4113,9 @@ declare module L { } } -declare module L { +declare namespace L { - module Util { + namespace Util { /** * Merges the properties of the src object (or multiple objects) into dest object @@ -4197,7 +4197,7 @@ declare module L { } -declare module L { +declare namespace L { export interface WMSOptions { @@ -4238,7 +4238,7 @@ declare module L { } -declare module L { +declare namespace L { export interface ZoomOptions { /** @@ -4250,7 +4250,7 @@ declare module L { } } -declare module L { +declare namespace L { export interface ZoomPanOptions { From 9f812bdeed4227cf67c953399d73dc4fcd98735d Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 15:07:49 -0700 Subject: [PATCH 2/4] Tabs to spaces for consistency with .d.ts. --- leaflet/leaflet-tests.ts | 270 +++++++++++++++++++-------------------- 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 6bec7e217..5bc58e304 100755 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -6,38 +6,38 @@ 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, + 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, + tapTolerance: 30, + trackResize: true, + worldCopyJump: false, + closePopupOnClick: true, + bounceAtZoomLimits: true, - keyboard: true, - keyboardPanOffset: 80, - keyboardZoomOffset: 1, + keyboard: true, + keyboardPanOffset: 80, + keyboardZoomOffset: 1, - inertia: true, - inertiaDeceleration: 3000, - inertiaMaxSpeed: 1500, - inertiaThreshold: 32, + inertia: true, + inertiaDeceleration: 3000, + inertiaMaxSpeed: 1500, + inertiaThreshold: 32, - zoomControl: true, - attributionControl: true, + zoomControl: true, + attributionControl: true, - fadeAnimation: true, - zoomAnimation: true, - zoomAnimationThreshold: 4, - markerZoomAnimation: true + fadeAnimation: true, + zoomAnimation: true, + zoomAnimationThreshold: 4, + markerZoomAnimation: true }); @@ -53,16 +53,16 @@ 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 - } + reset: true, + pan: { + animate: true, + duration: 0.25, + easeLinearity: 0.25, + noMoveStart: false + }, + zoom: { + animate: true + } }); map.setZoom(50); @@ -81,21 +81,21 @@ 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 + paddingTopLeft: L.point(20, 20), + paddingBottomRight: L.point(20, 20), + padding: L.point(0, 0), + maxZoom: null }); map.fitWorld(); map.fitWorld({ - animate: false + animate: false }); map.panTo(L.latLng(42, 42)); map.panTo(L.latLng(42, 42), { - animate: true + animate: true }); map.invalidateSize(true); @@ -105,12 +105,12 @@ 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 + watch: false, + setView: false, + maxZoom: 18, + timeout: 10000, + maximumAge: 0, + enableHighAccuracy: false }); map.stopLocate(); @@ -138,7 +138,7 @@ map.hasLayer(layer); map.openPopup("canard", L.latLng(42, 51)); var popup = L.popup({ - autoPan: true + autoPan: true }); map.openPopup(popup); @@ -171,51 +171,51 @@ map.getPanes().shadowPane.classList.add('roger'); map.getPanes().tilePane.classList.add('roger'); map.whenReady((m: L.Map) => { - m.zoomOut(); + m.zoomOut(); }); map.on('click', () => { - map.zoomOut(); + map.zoomOut(); }); map.off('dblclick', L.Util.falseFn); map.once('contextmenu', (e: L.LeafletMouseEvent) => { - map.openPopup('contextmenu', e.latlng); + 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 + 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); + map.setView(e.latlng); }); marker.once('mouseover', () => { - marker.openPopup(); + marker.openPopup(); }) marker.setLatLng(marker.getLatLng()); @@ -228,7 +228,7 @@ marker.setOpacity(0.8); marker.bindPopup(popup); marker.unbindPopup(); marker.bindPopup('hello', { - closeOnClick: true + closeOnClick: true }); marker.openPopup(); @@ -244,19 +244,19 @@ 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' + 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); @@ -264,65 +264,65 @@ 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 + 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); + .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(); + .bringToFront() + .setOpacity(0.7) + .setZIndex(9) + .redraw() + .setUrl('http://perdu.com') + .getContainer(); module CustomControl { - export interface Options { - title: string; - position?: string; - } + export interface Options { + title: string; + position?: string; + } } interface CustomControl extends L.Control { - getTitle(): string; - setTitle(title: string): CustomControl; + getTitle(): string; + setTitle(title: string): CustomControl; } var CustomControl: { new(options: CustomControl.Options): CustomControl }; CustomControl = L.Control.extend({ - 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; - }, + 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 From 71a002c31c057628974e2829587a096d2184751b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 15:15:44 -0700 Subject: [PATCH 3/4] Added test for 'L.control.zoom' in 'leaflet'. --- leaflet/leaflet-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 5bc58e304..6ab018a4e 100755 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -413,3 +413,9 @@ polyline.addLatLng(latLngObjectLiteral); var popup: L.Popup = L.popup(); popup.setLatLng(latLngLiteral); popup.setLatLng(latLngObjectLiteral); + +var zoomCtrl = L.control.zoom({ + position: "topleft", + zoomInText: '+', + zoomOutText: '-' +}); From 0842cf93efc6478cd0ba94941b8163a9d990edf8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Sep 2015 15:16:55 -0700 Subject: [PATCH 4/4] Namespaces are one honking great idea -- let's do more of those in 'leaflet'. --- leaflet/leaflet.d.ts | 228 ++++++++++++++++++++++++------------------- 1 file changed, 128 insertions(+), 100 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index e148f35d6..760ecd283 100755 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -387,12 +387,50 @@ declare module L { /** * Creates a zoom control. */ - new(options?: ZoomOptions): Zoom; + new (options?: ZoomOptions): Zoom; } export interface Zoom extends L.Control { } + export interface ZoomOptions { + /** + * The position of the control (one of the map corners). + * Can be 'topleft', 'topright', 'bottomleft', or 'bottomright'. + * + * Default value: 'topright'. + */ + position?: string; // 'topleft' | 'topright' | 'bottomleft' | 'bottomright' + + /** + * The text set on the zoom in button. + * + * Default value: '+' + */ + zoomInText?: string; + + /** + * The text set on the zoom out button. + * + * Default value: '-' + */ + zoomOutText?: string; + + /** + * The title set on the zoom in button. + * + * Default value: 'Zoom in' + */ + zoomInTitle?: string; + + /** + * The title set on the zoom out button. + * + * Default value: 'Zoom out' + */ + zoomOutTitle?: string; + } + export interface AttributionStatic extends ClassStatic { /** * Creates an attribution control. @@ -483,7 +521,7 @@ declare module L { /** * Creates a zoom control. */ - export function zoom(options?: ZoomOptions): L.Control.Zoom; + export function zoom(options?: Control.ZoomOptions): L.Control.Zoom; /** * Creates an attribution control. @@ -894,43 +932,6 @@ declare namespace L { } } -declare namespace L { - - export interface FitBoundsOptions extends ZoomPanOptions { - - /** - * Sets the amount of padding in the top left corner of a map container that - * shouldn't be accounted for when setting the view to fit bounds. Useful if - * you have some control overlays on the map like a sidebar and you don't - * want them to obscure objects you're zooming to. - * - * Default value: [0, 0]. - */ - paddingTopLeft?: Point; - - /** - * The same for bottom right corner of the map. - * - * Default value: [0, 0]. - */ - paddingBottomRight?: Point; - - /** - * Equivalent of setting both top left and bottom right padding to the same value. - * - * Default value: [0, 0]. - */ - padding?: Point; - - /** - * The maximum possible zoom to use. - * - * Default value: null - */ - maxZoom?: number; - } -} - declare namespace L { /** @@ -2058,13 +2059,13 @@ declare namespace L { * Instantiates a map object given a div element and optionally an * object literal with map options described below. */ - function map(id: HTMLElement, options?: MapOptions): Map; + function map(id: HTMLElement, options?: Map.MapOptions): Map; /** * Instantiates a map object given a div element id and optionally an * object literal with map options described below. */ - function map(id: string, options?: MapOptions): Map; + function map(id: string, options?: Map.MapOptions): Map; export interface MapStatic extends ClassStatic { @@ -2074,7 +2075,7 @@ declare namespace L { * * @constructor */ - new(id: HTMLElement, options?: MapOptions): Map; + new(id: HTMLElement, options?: Map.MapOptions): Map; /** * Instantiates a map object given a div element id and optionally an @@ -2082,7 +2083,7 @@ declare namespace L { * * @constructor */ - new(id: string, options?: MapOptions): Map; + new(id: string, options?: Map.MapOptions): Map; } export var Map: MapStatic; @@ -2093,40 +2094,40 @@ declare namespace L { * Sets the view of the map (geographical center and zoom) with the given * animation options. */ - setView(center: LatLngExpression, zoom?: number, options?: ZoomPanOptions): Map; + setView(center: LatLngExpression, zoom?: number, options?: Map.ZoomPanOptions): Map; /** * Sets the zoom of the map. */ - setZoom(zoom: number, options?: ZoomOptions): Map; + setZoom(zoom: number, options?: Map.ZoomPanOptions): Map; /** * Increases the zoom of the map by delta (1 by default). */ - zoomIn(delta?: number, options?: ZoomOptions): Map; + zoomIn(delta?: number, options?: Map.ZoomPanOptions): Map; /** * Decreases the zoom of the map by delta (1 by default). */ - zoomOut(delta?: number, options?: ZoomOptions): Map; + zoomOut(delta?: number, options?: Map.ZoomPanOptions): Map; /** * Zooms the map while keeping a specified point on the map stationary * (e.g. used internally for scroll zoom and double-click zoom). */ - setZoomAround(latlng: LatLngExpression, zoom: number, options?: ZoomOptions): Map; + setZoomAround(latlng: LatLngExpression, zoom: number, options?: Map.ZoomPanOptions): Map; /** * Sets a map view that contains the given geographical bounds with the maximum * zoom level possible. */ - fitBounds(bounds: LatLngBounds, options?: FitBoundsOptions): Map; + fitBounds(bounds: LatLngBounds, options?: Map.FitBoundsOptions): Map; /** * Sets a map view that mostly contains the whole world with the maximum zoom * level possible. */ - fitWorld(options?: FitBoundsOptions): Map; + fitWorld(options?: Map.FitBoundsOptions): Map; /** * Pans the map to a given center. Makes an animated pan if new center is not more @@ -2150,7 +2151,7 @@ declare namespace L { * after you've changed the map size dynamically, also animating pan by default. * If options.pan is false, panning will not occur. */ - invalidateSize(options: ZoomPanOptions): Map; + invalidateSize(options: Map.ZoomPanOptions): Map; /** * Checks if the map container size changed and updates the map if so — call it @@ -2162,7 +2163,7 @@ declare namespace L { * Restricts the map view to the given bounds (see map maxBounds option), * passing the given animation options through to `setView`, if required. */ - setMaxBounds(bounds: LatLngBounds, options?: ZoomPanOptions): Map; + setMaxBounds(bounds: LatLngBounds, options?: Map.ZoomPanOptions): Map; /** * Tries to locate the user using Geolocation API, firing locationfound event @@ -2422,7 +2423,7 @@ declare namespace L { /** * Map state options */ - options: MapOptions; + options: Map.MapOptions; //////////////// //////////////// @@ -2442,7 +2443,7 @@ declare namespace L { } } -declare namespace L { +declare namespace L.Map { export interface MapOptions { @@ -2680,6 +2681,79 @@ declare namespace L { */ bounceAtZoomLimits?: boolean; } + + export interface ZoomOptions { + /** + * If not specified, zoom animation will happen if the zoom origin is inside the current view. + * If true, the map will attempt animating zoom disregarding where zoom origin is. + * Setting false will make it always reset the view completely without animation. + */ + animate?: boolean; + } + + export interface ZoomPanOptions { + + /** + * If true, the map view will be completely reset (without any animations). + * + * Default value: false. + */ + reset?: boolean; + + /** + * Sets the options for the panning (without the zoom change) if it occurs. + */ + pan?: PanOptions; + + /** + * Sets the options for the zoom change if it occurs. + */ + zoom?: ZoomOptions; + + /** + * An equivalent of passing animate to both zoom and pan options (see below). + */ + animate?: boolean; + + /** + * If true, it will delay moveend event so that it doesn't happen many times in a row. + */ + debounceMoveend?: boolean; + } + + export interface FitBoundsOptions extends ZoomPanOptions { + + /** + * Sets the amount of padding in the top left corner of a map container that + * shouldn't be accounted for when setting the view to fit bounds. Useful if + * you have some control overlays on the map like a sidebar and you don't + * want them to obscure objects you're zooming to. + * + * Default value: [0, 0]. + */ + paddingTopLeft?: Point; + + /** + * The same for bottom right corner of the map. + * + * Default value: [0, 0]. + */ + paddingBottomRight?: Point; + + /** + * Equivalent of setting both top left and bottom right padding to the same value. + * + * Default value: [0, 0]. + */ + padding?: Point; + + /** + * The maximum possible zoom to use. + * + * Default value: null + */ + maxZoom?: number; + } } declare namespace L { @@ -4237,52 +4311,6 @@ declare namespace L { } } - -declare namespace L { - - export interface ZoomOptions { - /** - * If not specified, zoom animation will happen if the zoom origin is inside the current view. - * If true, the map will attempt animating zoom disregarding where zoom origin is. - * Setting false will make it always reset the view completely without animation. - */ - animate?: boolean; - } -} - -declare namespace L { - - export interface ZoomPanOptions { - - /** - * If true, the map view will be completely reset (without any animations). - * - * Default value: false. - */ - reset?: boolean; - - /** - * Sets the options for the panning (without the zoom change) if it occurs. - */ - pan?: PanOptions; - - /** - * Sets the options for the zoom change if it occurs. - */ - zoom?: ZoomOptions; - - /** - * An equivalent of passing animate to both zoom and pan options (see below). - */ - animate?: boolean; - - /** - * If true, it will delay moveend event so that it doesn't happen many times in a row. - */ - debounceMoveend?: boolean; - } -} - /** * Forces Leaflet to use the Canvas back-end (if available) for vector layers * instead of SVG. This can increase performance considerably in some cases