From 05e7d53486af0899a9c16d017ad5adbf37e8a092 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 3 Jul 2015 11:50:40 +0300 Subject: [PATCH 01/58] Revert "update docs keyword highlighting" This reverts commit 9fc80c0c3480ec01b5c4a0f4d702865f212c1d94. --- reference.html | 690 ++++++++++++++++++++++++------------------------- 1 file changed, 345 insertions(+), 345 deletions(-) diff --git a/reference.html b/reference.html index 162f3974..2f7c14ac 100644 --- a/reference.html +++ b/reference.html @@ -175,37 +175,37 @@ var map = L.map('map', { center LatLng - null + null Initial geographical center of the map. zoom Number - null + null Initial map zoom. layers ILayer[] - null + null Layers that will be added to the map initially. minZoom Number - null + null Minimum zoom level of the map. Overrides any minZoom set on map layers. maxZoom Number - null + null Maximum zoom level of the map. This overrides any maxZoom set on map layers. maxBounds LatLngBounds - null + null When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method @@ -228,68 +228,68 @@ var map = L.map('map', { dragging Boolean - true + true Whether the map be draggable with mouse/touch or not. touchZoom Boolean - true + true Whether the map can be zoomed by touch-dragging with two fingers. scrollWheelZoom Boolean - true - Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. + true + Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. doubleClickZoom Boolean - true - Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift. If passed 'center', double-click zoom will zoom to the center of the view regardless of where the mouse was. + true + Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift. If passed 'center', double-click zoom will zoom to the center of the view regardless of where the mouse was. boxZoom Boolean - true + true Whether the map can be zoomed to a rectangular area specified by dragging the mouse while pressing shift. tap Boolean - true + true Enables mobile hacks for supporting instant taps (fixing 200ms click delay on iOS/Android) and touch holds (fired as contextmenu events). tapTolerance Number - 15 + 15 The max number of pixels a user can shift his finger during touch for it to be considered a valid tap. trackResize Boolean - true + true Whether the map automatically handles browser window resize to update itself. worldCopyJump Boolean - false + false With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible. closePopupOnClick Boolean - true - Set it to false if you don't want popups to close when user clicks the map. + true + Set it to false if you don't want popups to close when user clicks the map. bounceAtZoomLimits Boolean - true - Set it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming. + true + Set it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming. @@ -305,19 +305,19 @@ var map = L.map('map', { keyboard Boolean - true + true Makes the map focusable and allows users to navigate the map with keyboard arrows and +/- keys. keyboardPanOffset Number - 80 + 80 Amount of pixels to pan when pressing an arrow key. keyboardZoomOffset Number - 1 + 1 Number of zoom levels to change when pressing + or - key. @@ -334,26 +334,26 @@ var map = L.map('map', { inertia Boolean - true + true If enabled, panning of the map will have an inertia effect where the map builds momentum while dragging and continues moving in the same direction for some time. Feels especially nice on touch devices. inertiaDeceleration Number - 3000 + 3000 The rate with which the inertial movement slows down, in pixels/second2. inertiaMaxSpeed Number - 1500 + 1500 Max speed of the inertial movement, in pixels/second. inertiaThreshold Number depends - Number of milliseconds that should pass between stopping the movement and releasing the mouse or touch to prevent inertial movement. 32 for touch devices and 14 for the rest by default. + Number of milliseconds that should pass between stopping the movement and releasing the mouse or touch to prevent inertial movement. 32 for touch devices and 14 for the rest by default. @@ -369,13 +369,13 @@ var map = L.map('map', { zoomControl Boolean - true + true Whether the zoom control is added to the map by default. attributionControl Boolean - true + true Whether the attribution control is added to the map by default. @@ -404,7 +404,7 @@ var map = L.map('map', { zoomAnimationThreshold Number - 4 + 4 Won't animate zoom if the zoom difference exceeds this value. @@ -613,7 +613,7 @@ var map = L.map('map', { <Number> zoom?, <zoom/pan options> options? ) - this + this Sets the view of the map (geographical center and zoom) with the given animation options. @@ -621,7 +621,7 @@ var map = L.map('map', { <Number> zoom, <zoom options> options? ) - this + this Sets the zoom of the map. @@ -629,16 +629,16 @@ var map = L.map('map', { <Number> delta?, <zoom options> options? ) - this - Increases the zoom of the map by delta (1 by default). + this + Increases the zoom of the map by delta (1 by default). zoomOut( <Number> delta?, <zoom options> options? ) - this - Decreases the zoom of the map by delta (1 by default). + this + Decreases the zoom of the map by delta (1 by default). setZoomAround( @@ -646,7 +646,7 @@ var map = L.map('map', { <Number> zoom, <zoom options> options? ) - this + this Zooms the map while keeping a specified point on the map stationary (e.g. used internally for scroll zoom and double-click zoom). @@ -654,14 +654,14 @@ var map = L.map('map', { <LatLngBounds> bounds, <fitBounds options> options? ) - this + this Sets a map view that contains the given geographical bounds with the maximum zoom level possible. fitWorld( <fitBounds options> options? ) - this + this Sets a map view that mostly contains the whole world with the maximum zoom level possible. @@ -669,7 +669,7 @@ var map = L.map('map', { <LatLng> latlng, <pan options> options? ) - this + this Pans the map to a given center. Makes an animated pan if new center is not more than one screen away from the current one. @@ -677,7 +677,7 @@ var map = L.map('map', { <LatLngBounds> bounds, <pan options> options? ) - this + this Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any. @@ -685,46 +685,46 @@ var map = L.map('map', { <Point> point, <pan options> options? ) - this + this Pans the map by a given number of pixels (animated). invalidateSize( <Boolean> animate ) - this + this Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. invalidateSize( <zoom/pan options> options ) - this - Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row. + this + Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row. setMaxBounds( <LatLngBounds> bounds - this + this Restricts the map view to the given bounds (see map maxBounds option). locate( <Locate options> options? ) - this + this Tries to locate the user using the Geolocation API, firing a locationfound event with location data on success or a locationerror event on failure, and optionally sets the map view to the user's location with respect to detection accuracy (or to the world view if geolocation failed). See Locate options for more details. stopLocate() - this + this Stops watching location previously initiated by map.locate({watch: true}) and aborts resetting the map view if map.locate was called with {setView: true}. remove() - this + this Destroys the map and clears all related event listeners. @@ -770,7 +770,7 @@ var map = L.map('map', { Number - Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety. + Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety. getSize() @@ -802,7 +802,7 @@ var map = L.map('map', { <ILayer> layer, - this + this Adds the given layer to the map. @@ -810,7 +810,7 @@ var map = L.map('map', { <ILayer> layer ) - this + this Removes the given layer from the map. @@ -819,14 +819,14 @@ var map = L.map('map', { Boolean - Returns true if the given layer is currently added to the map. + Returns true if the given layer is currently added to the map. eachLayer( <Function> fn, <Object> context? ) - this + this Iterates over the layers of the map, optionally specifying context of the iterator function.
map.eachLayer(function (layer) {
 	layer.bindPopup('Hello');
@@ -839,7 +839,7 @@ var map = L.map('map', {
 			<Popup> popup )
 		
 
-		this
+		this
 		Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).
 	
 	
@@ -849,14 +849,14 @@ var map = L.map('map', {
 			<Popup options> options? )
 		
 
-		this
+		this
 		Creates a popup with the specified options and opens it in the given point on a map.
 	
 	
 		closePopup(
 			<Popup> popup? )
 		
-		this
+		this
 		Closes the popup previously opened with openPopup (or the given one).
 	
 	
@@ -864,7 +864,7 @@ var map = L.map('map', {
 			<IControl> control )
 		
 
-		this
+		this
 		Adds the given control to the map.
 	
 	
@@ -872,7 +872,7 @@ var map = L.map('map', {
 			<IControl> control )
 		
 
-		this
+		this
 		Removes the given control from the map.
 	
 
@@ -1017,37 +1017,37 @@ var map = L.map('map', {
 	
 		watch
 		Boolean
-		false
-		If true, starts continous watching of location changes (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stopLocate() method.
+		false
+		If true, starts continous watching of location changes (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stopLocate() method.
 	
 	
 		setView
 		Boolean
-		false
-		If true, automatically sets the map view to the user location with respect to detection accuracy, or to world view if geolocation failed.
+		false
+		If true, automatically sets the map view to the user location with respect to detection accuracy, or to world view if geolocation failed.
 	
 	
 		maxZoom
 		Number
-		Infinity
+		Infinity
 		The maximum zoom for automatic view setting when using `setView` option.
 	
 	
 		timeout
 		Number
-		10000
+		10000
 		Number of milliseconds to wait for a response from geolocation before firing a locationerror event.
 	
 	
 		maximumAge
 		Number
-		0
+		0
 		Maximum age of detected location. If less than this amount of milliseconds passed since last geolocation response, locate will return a cached location.
 	
 	
 		enableHighAccuracy
 		Boolean
-		false
+		false
 		Enables high accuracy, see description in the W3C spec.
 	
 
@@ -1065,8 +1065,8 @@ var map = L.map('map', {
 	
 		reset
 		Boolean
-		false
-		If true, the map view will be completely reset (without any animations).
+		false
+		If true, the map view will be completely reset (without any animations).
 	
 	
 		pan
@@ -1083,7 +1083,7 @@ var map = L.map('map', {
 	
 		animate
 		Boolean
-		-
+		-
 		An equivalent of passing animate to both zoom and pan options (see below).
 	
 
@@ -1101,25 +1101,25 @@ var map = L.map('map', {
 		animate
 		Boolean
 		-
-		If true, panning will always be animated if possible. If false, it will not animate panning, either resetting the map view if panning more than a screen away, or just setting a new offset for the map pane (except for `panBy` which always does the latter).
+		If true, panning will always be animated if possible. If false, it will not animate panning, either resetting the map view if panning more than a screen away, or just setting a new offset for the map pane (except for `panBy` which always does the latter).
 	
 	
 		duration
 		Number
-		0.25
+		0.25
 		Duration of animated panning.
 	
 	
 		easeLinearity
 		Number
-		0.25
-		The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve.
+		0.25
+		The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve.
 	
 	
 		noMoveStart
 		Boolean
-		false
-		If true, panning won't fire movestart event on start (used internally for panning inertia).
+		false
+		If true, panning won't fire movestart event on start (used internally for panning inertia).
 	
 
 
@@ -1136,7 +1136,7 @@ var map = L.map('map', {
 		animate
 		Boolean
 		-
-		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.
+		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.
 	
 
 
@@ -1154,25 +1154,25 @@ var map = L.map('map', {
 	
 		paddingTopLeft
 		Point
-		[0, 0]
+		[0, 0]
 		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.
 	
 	
 		paddingBottomRight
 		Point
-		[0, 0]
+		[0, 0]
 		The same for bottom right corner of the map.
 	
 	
 		padding
 		Point
-		[0, 0]
+		[0, 0]
 		Equivalent of setting both top left and bottom right padding to the same value.
 	
 	
 		maxZoom
 		Number
-		null
+		null
 		The maximum possible zoom to use.
 	
 
@@ -1332,55 +1332,55 @@ var map = L.map('map', {
 	
 		clickable
 		Boolean
-		true
-		If false, the marker will not emit mouse events and will act as a part of the underlying map.
+		true
+		If false, the marker will not emit mouse events and will act as a part of the underlying map.
 	
 	
 		draggable
 		Boolean
-		false
+		false
 		Whether the marker is draggable with mouse/touch or not.
 	
 	
 		keyboard
 		Boolean
-		true
+		true
 		Whether the marker can be tabbed to with a keyboard and clicked by pressing enter.
 	
 	
 		title
 		String
-		''
+		''
 		Text for the browser tooltip that appear on marker hover (no tooltip by default).
 	
 	
 		alt
 		String
-		''
+		''
 		Text for the alt attribute of the icon image (useful for accessibility).
 	
 	
 		zIndexOffset
 		Number
-		0
+		0
 		By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively).
 	
 	
 		opacity
 		Number
-		1.0
+		1.0
 		The opacity of the marker.
 	
 	
 		riseOnHover
 		Boolean
-		false
-		If true, the marker will get on top of others when you hover the mouse over it.
+		false
+		If true, the marker will get on top of others when you hover the mouse over it.
 	
 	
 		riseOffset
 		Number
-		250
+		250
 		The z-index offset used for the riseOnHover feature.
 	
 
@@ -1480,7 +1480,7 @@ var map = L.map('map', {
 			<Map> map )
 		
 
-		this
+		this
 		Adds the marker to the map.
 	
 	
@@ -1493,7 +1493,7 @@ var map = L.map('map', {
 			<LatLng> latlng )
 		
 
-		this
+		this
 		Changes the marker position to the given point.
 	
 	
@@ -1501,7 +1501,7 @@ var map = L.map('map', {
 			<Icon> icon )
 		
 
-		this
+		this
 		Changes the marker icon.
 	
 	
@@ -1509,21 +1509,21 @@ var map = L.map('map', {
 			<Number> offset )
 		
 
-		this
+		this
 		Changes the zIndex offset of the marker.
 	
 	
 		setOpacity(
 			<Number> opacity )
 		
-		this
+		this
 		Changes the opacity of the marker.
 	
 	
 		update()
 		
 
-		this
+		this
 		Updates the marker position, useful if coordinates of its latLng object were changed directly.
 	
 	
@@ -1532,17 +1532,17 @@ var map = L.map('map', {
 			<Popup options> options? )
 		
 
-		this
+		this
 		Binds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.
 	
 	
 		unbindPopup()
-		this
+		this
 		Unbinds the popup previously bound to the marker with bindPopup.
 	
 	
 		openPopup()
-		this
+		this
 		Opens the popup previously bound by the bindPopup method.
 	
 	
@@ -1552,12 +1552,12 @@ var map = L.map('map', {
 	
 	
 		closePopup()
-		this
+		this
 		Closes the bound popup of the marker if it's opened.
 	
 	
 		togglePopup()
-		this
+		this
 		Toggles the popup previously bound by the bindPopup method.
 	
 	
@@ -1565,7 +1565,7 @@ var map = L.map('map', {
 			<String> html | <HTMLElement> el )
 		
 
-		this
+		this
 		Sets an HTML content of the popup of this marker.
 	
 	
@@ -1641,83 +1641,83 @@ var map = L.map('map', {
 	
 		maxWidth
 		Number
-		300
+		300
 		Max width of the popup.
 	
 	
 		minWidth
 		Number
-		50
+		50
 		Min width of the popup.
 	
 	
 		maxHeight
 		Number
-		null
+		null
 		If set, creates a scrollable container of the given height inside a popup if its content exceeds it.
 	
 	
 		autoPan
 		Boolean
-		true
-		Set it to false if you don't want the map to do panning animation to fit the opened popup.
+		true
+		Set it to false if you don't want the map to do panning animation to fit the opened popup.
 	
 	
 		keepInView
 		Boolean
-		false
-		Set it to true if you want to prevent users from panning the popup off of the screen while it is open.
+		false
+		Set it to true if you want to prevent users from panning the popup off of the screen while it is open.
 	
 	
 		closeButton
 		Boolean
-		true
+		true
 		Controls the presense of a close button in the popup.
 	
 	
 		offset
 		Point
-		Point(0, 6)
+		Point(0, 6)
 		
 		The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays.
 	
 	
 		autoPanPaddingTopLeft
 		Point
-		null
+		null
 		
 		The margin between the popup and the top left corner of the map view after autopanning was performed.
 	
 	
 		autoPanPaddingBottomRight
 		Point
-		null
+		null
 		
 		The margin between the popup and the bottom right corner of the map view after autopanning was performed.
 	
 	
 		autoPanPadding
 		Point
-		Point(5, 5)
+		Point(5, 5)
 		
 		Equivalent of setting both top left and bottom right autopan padding to the same value.
 	
 	
 		zoomAnimation
 		Boolean
-		true
+		true
 		Whether to animate the popup on zoom. Disable it if you have problems with Flash content inside popups.
 	
 	
 		closeOnClick
 		Boolean
-		null
-		Set it to false if you want to override the default behavior of the popup closing when user clicks the map (set globally by the Map closePopupOnClick option).
+		null
+		Set it to false if you want to override the default behavior of the popup closing when user clicks the map (set globally by the Map closePopupOnClick option).
 	
 	
 		className
 		String
-		''
+		''
 		A custom class name to assign to the popup.
 	
 
@@ -1735,7 +1735,7 @@ var map = L.map('map', {
 			<Map> map )
 		
 
-		this
+		this
 		Adds the popup to the map.
 	
 	
@@ -1743,7 +1743,7 @@ var map = L.map('map', {
 			<Map> map )
 		
 
-		this
+		this
 		Adds the popup to the map and closes the previous one. The same as map.openPopup(popup).
 	
 	
@@ -1751,7 +1751,7 @@ var map = L.map('map', {
 			<LatLng> latlng )
 		
 
-		this
+		this
 		Sets the geographical point where the popup will open.
 	
 	
@@ -1764,7 +1764,7 @@ var map = L.map('map', {
 			<String|HTMLElement> htmlContent )
 		
 
-		this
+		this
 		Sets the HTML content of the popup.
 	
 	
@@ -1775,7 +1775,7 @@ var map = L.map('map', {
 	
 		update()
 
-		this
+		this
 		Updates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded.
 	
 
@@ -1833,115 +1833,115 @@ var map = L.map('map', {
 	
 		minZoom
 		Number
-		0
+		0
 		Minimum zoom number.
 	
 	
 		maxZoom
 		Number
-		18
+		18
 		Maximum zoom number.
 	
 	
 		maxNativeZoom
 		Number
-		null
+		null
 		Maximum zoom number the tiles source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxZoom level and auto-scaled.
 	
 	
 		tileSize
 		Number
-		256
+		256
 		Tile size (width and height in pixels, assuming tiles are square).
 	
 	
 		subdomains
 		String or String[]
-		'abc'
+		'abc'
 		Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
 	
 	
 		errorTileUrl
 		String
-		''
+		''
 		URL to the tile image to show in place of the tile that failed to load.
 	
 	
 		attribution
 		String
-		''
+		''
 		e.g. "© Mapbox" — the string used by the attribution control, describes the layer data.
 	
 	
 		tms
 		Boolean
-		false
-		If true, inverses Y axis numbering for tiles (turn this on for TMS services).
+		false
+		If true, inverses Y axis numbering for tiles (turn this on for TMS services).
 	
 	
 		continuousWorld
 		Boolean
-		false
-		If set to true, the tile coordinates won't be wrapped by world width (-180 to 180 longitude) or clamped to lie within world height (-90 to 90). Use this if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor or photo maps).
+		false
+		If set to true, the tile coordinates won't be wrapped by world width (-180 to 180 longitude) or clamped to lie within world height (-90 to 90). Use this if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor or photo maps).
 	
 	
 		noWrap
 		Boolean
-		false
-		If set to true, the tiles just won't load outside the world width (-180 to 180 longitude) instead of repeating.
+		false
+		If set to true, the tiles just won't load outside the world width (-180 to 180 longitude) instead of repeating.
 	
 	
 		zoomOffset
 		Number
-		0
+		0
 		The zoom number used in tile URLs will be offset with this value.
 	
 	
 		zoomReverse
 		Boolean
-		false
-		If set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
+		false
+		If set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
 	
 	
 		opacity
 		Number
-		1.0
+		1.0
 		The opacity of the tile layer.
 	
 	
 		zIndex
 		Number
-		null
+		null
 		The explicit zIndex of the tile layer. Not set by default.
 	
 	
 		unloadInvisibleTiles
 		Boolean
 		depends
-		If true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false.
+		If true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false.
 	
 	
 		updateWhenIdle
 		Boolean
 		depends
-		If false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false.
+		If false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false.
 	
 	
 		detectRetina
 		Boolean
-		false
-		If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
+		false
+		If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
 	
 	
 		reuseTiles
 		Boolean
-		false
-		If true, all the tiles that are not visible after panning are placed in a reuse queue from which they will be fetched when new tiles become visible (as opposed to dynamically creating new ones). This will in theory keep memory usage low and eliminate the need for reserving new memory whenever a new tile is needed.
+		false
+		If true, all the tiles that are not visible after panning are placed in a reuse queue from which they will be fetched when new tiles become visible (as opposed to dynamically creating new ones). This will in theory keep memory usage low and eliminate the need for reserving new memory whenever a new tile is needed.
 	
 	
 		bounds
 		LatLngBounds
-		null
+		null
 		When this option is set, the TileLayer only loads tiles that are in the given geographical bounds.
 	
 
@@ -1996,17 +1996,17 @@ var map = L.map('map', {
 			<Map> map )
 		
 
-		this
+		this
 		Adds the layer to the map.
 	
 	
 		bringToFront()
-		this
+		this
 		Brings the tile layer to the top of all tile layers.
 	
 	
 		bringToBack()
-		this
+		this
 		Brings the tile layer to the bottom of all tile layers.
 	
 	
@@ -2014,7 +2014,7 @@ var map = L.map('map', {
 			<Number> opacity )
 		
 
-		this
+		this
 		Changes the opacity of the tile layer.
 	
 	
@@ -2022,19 +2022,19 @@ var map = L.map('map', {
 			<Number> zIndex )
 		
 
-		this
+		this
 		Sets the zIndex of the tile layer.
 	
 	
 		redraw()
-		this
+		this
 		Causes the layer to clear all the tiles and request them again.
 	
 	
 		setUrl(
 			<String> urlTemplate )
 		
-		this
+		this
 		Updates the layer's URL template and redraws it.
 	
 	
@@ -2092,37 +2092,37 @@ var map = L.map('map', {
 	
 		layers
 		String
-		''
+		''
 		(required) Comma-separated list of WMS layers to show.
 	
 	
 		styles
 		String
-		''
+		''
 		Comma-separated list of WMS styles.
 	
 	
 		format
 		String
-		'image/jpeg'
-		WMS image format (use 'image/png' for layers with transparency).
+		'image/jpeg'
+		WMS image format (use 'image/png' for layers with transparency).
 	
 	
 		transparent
 		Boolean
-		false
-		If true, the WMS service will return images with transparency.
+		false
+		If true, the WMS service will return images with transparency.
 	
 	
 		version
 		String
-		'1.1.1'
+		'1.1.1'
 		Version of the WMS service to use.
 	
 	
 		crs
 		CRS
-		null
+		null
 		Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means.
 	
 
@@ -2140,8 +2140,8 @@ var map = L.map('map', {
 			<WMS parameters> params,
 			<Boolean> noRedraw? )
 		
-		this
-		Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).
+		this
+		Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).
 	
 
 
@@ -2187,7 +2187,7 @@ canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
 	
 		async
 		Boolean
-		false
+		false
 		Indicates that tiles will be drawn asynchronously. tileDrawn method should be called for each tile after drawing completion.
 	
 
@@ -2206,7 +2206,7 @@ canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
 			<Point> tilePoint,
 			<Number> zoom )
 		
-		this
+		this
 		You need to define this method after creating the instance to draw tiles; canvas is the actual canvas tile on which you can draw, tilePoint represents the tile numbers, and zoom is the current zoom.
 	
 	
@@ -2259,13 +2259,13 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);
opacity Number - 1.0 + 1.0 The opacity of the image overlay. attribution String - '' + '' The attribution text of the image overlay. @@ -2282,7 +2282,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Map> map ) - this + this Adds the overlay to the map. @@ -2290,7 +2290,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Number> opacity ) - this + this Sets the opacity of the overlay. @@ -2298,17 +2298,17 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <String> imageUrl ) - this + this Changes the URL of the image. bringToFront() - this + this Brings the layer to the top of all overlays. bringToBack() - this + this Brings the layer to the bottom of all overlays. @@ -2328,32 +2328,32 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); stroke Boolean - true - Whether to draw stroke along the path. Set it to false to disable borders on polygons or circles. + true + Whether to draw stroke along the path. Set it to false to disable borders on polygons or circles. color String - '#03f' + '#03f' Stroke color. weight Number - 5 + 5 Stroke width in pixels. opacity Number - 0.5 + 0.5 Stroke opacity. fill Boolean depends - Whether to fill the path with color. Set it to false to disable filling on polygons or circles. + Whether to fill the path with color. Set it to false to disable filling on polygons or circles. fillColor @@ -2364,49 +2364,49 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); fillOpacity Number - 0.2 + 0.2 Fill opacity. fillRule String - 'evenodd' + 'evenodd' A string that defines how the inside of a shape is determined. dashArray String - null + null A string that defines the stroke dash pattern. Doesn't work on canvas-powered layers (e.g. Android 2). lineCap String - null + null A string that defines shape to be used at the end of the stroke. lineJoin String - null + null A string that defines shape to be used at the corners of the stroke. clickable Boolean - true - If false, the vector will not emit mouse events and will act as a part of the underlying map. + true + If false, the vector will not emit mouse events and will act as a part of the underlying map. pointerEvents String - null + null Sets the pointer-events attribute on the path if SVG backend is used. className String - '' + '' Custom class name set on an element. @@ -2485,7 +2485,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Map> map ) - this + this Adds the layer to the map. @@ -2494,7 +2494,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Popup options> options? ) - this + this Binds a popup with a particular HTML content to a click on this path. @@ -2503,12 +2503,12 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Popup options> options? ) - this + this Binds a given popup object to the path. unbindPopup() - this + this Unbinds the popup previously bound to the path with bindPopup. @@ -2516,13 +2516,13 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <LatLng> latlng? ) - this + this Opens the popup previously bound by the bindPopup method in the given point, or in one of the path's points if not specified. closePopup() - this + this Closes the path's bound popup if it is opened. @@ -2530,7 +2530,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Path options> object ) - this + this Changes the appearance of a Path based on the options in the Path options object. @@ -2540,17 +2540,17 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); bringToFront() - this + this Brings the layer to the top of all path layers. bringToBack() - this + this Brings the layer to the bottom of all path layers. redraw() - this + this Redraws the layer. Sometimes useful after you changed the coordinates that the path uses. @@ -2579,12 +2579,12 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); CANVAS Boolean depends - True if Canvas is used for vector rendering (Android 2). You can also force this by setting global variable L_PREFER_CANVAS to true before the Leaflet include on your page — sometimes it can increase performance dramatically when rendering thousands of circle markers, but currently suffers from a bug that causes removing such layers to be extremely slow. + True if Canvas is used for vector rendering (Android 2). You can also force this by setting global variable L_PREFER_CANVAS to true before the Leaflet include on your page — sometimes it can increase performance dramatically when rendering thousands of circle markers, but currently suffers from a bug that causes removing such layers to be extremely slow. CLIP_PADDING Number - 0.5 for SVG
0.02 for VML + 0.5 for SVG
0.02 for VML How much to extend the clip area around the map view (relative to its size, e.g. 0.5 is half the screen in each direction). Smaller values mean that you will see clipped ends of paths while you're dragging the map, and bigger values decrease drawing performance. @@ -2634,13 +2634,13 @@ map.fitBounds(polyline.getBounds()); smoothFactor Number - 1.0 + 1.0 How much to simplify the polyline on each zoom level. More means better performance and smoother look, and less means more accurate representation. noClip Boolean - false + false Disabled polyline clipping. @@ -2660,7 +2660,7 @@ map.fitBounds(polyline.getBounds()); <LatLng> latlng ) - this + this Adds a given point to the polyline. @@ -2668,7 +2668,7 @@ map.fitBounds(polyline.getBounds()); <LatLng[]> latlngs ) - this + this Replaces all the points in the polyline with the given array of geographical points. @@ -2742,7 +2742,7 @@ multiple line features:

<LatLng[][]> latlngs ) - this + this Replace all lines and their paths with the given array of arrays of geographical points. @@ -2851,7 +2851,7 @@ multiple polygon features:

<LatLng[][]> latlngs ) - this + this Replace all polygons and their paths with the given array of arrays of geographical points. @@ -2923,7 +2923,7 @@ map.fitBounds(bounds); <LatLngBounds> bounds ) - this + this Redraws the rectangle with the passed bounds. @@ -2978,7 +2978,7 @@ map.fitBounds(bounds); <LatLng> latlng ) - this + this Sets the position of a circle to a new location. @@ -2986,7 +2986,7 @@ map.fitBounds(bounds); <Number> radius ) - this + this Sets the radius of a circle. Units are in meters. @@ -3034,7 +3034,7 @@ map.fitBounds(bounds); <LatLng> latlng ) - this + this Sets the position of a circle marker to a new location. @@ -3042,7 +3042,7 @@ map.fitBounds(bounds); <Number> radius ) - this + this Sets the radius of a circle marker. Units are in pixels. @@ -3092,7 +3092,7 @@ map.fitBounds(bounds); <Map> map ) - this + this Adds the group of layers to the map. @@ -3100,7 +3100,7 @@ map.fitBounds(bounds); <ILayer> layer ) - this + this Adds a given layer to the group. @@ -3108,7 +3108,7 @@ map.fitBounds(bounds); <ILayer> layer ) - this + this Removes a given layer from the group. @@ -3116,7 +3116,7 @@ map.fitBounds(bounds); <String> id ) - this + this Removes a given layer of the given id from the group. @@ -3125,7 +3125,7 @@ map.fitBounds(bounds); Boolean - Returns true if the given layer is currently added to the group. + Returns true if the given layer is currently added to the group. getLayer( @@ -3142,7 +3142,7 @@ map.fitBounds(bounds); clearLayers() - this + this Removes all the layers from the group. @@ -3150,7 +3150,7 @@ map.fitBounds(bounds); <Function> fn, <Object> context? ) - this + this Iterates over the layers of the group, optionally specifying context of the iterator function.
group.eachLayer(function (layer) {
 	layer.bindPopup('Hello');
@@ -3210,7 +3210,7 @@ map.fitBounds(bounds);
<Popup options> options? ) - this + this Binds a popup with a particular HTML content to a click on any layer from the group that has a bindPopup method. @@ -3222,17 +3222,17 @@ map.fitBounds(bounds); setStyle( <Path options> style ) - this + this Sets the given path options to each layer of the group that has a setStyle method. bringToFront() - this + this Brings the layer group to the top of all other layers. bringToBack() - this + this Brings the layer group to the bottom of all other layers. @@ -3392,7 +3392,7 @@ map.fitBounds(bounds); <Function> style ) - this + this Changes styles of GeoJSON vector layers with the given style function. @@ -3400,7 +3400,7 @@ map.fitBounds(bounds); <Path> layer ) - this + this Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events. @@ -3429,7 +3429,7 @@ map.fitBounds(bounds); LatLng - Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude). + Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude). coordsToLatLngs( @@ -3439,7 +3439,7 @@ map.fitBounds(bounds); Array - Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude). + Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude). @@ -3520,7 +3520,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the given LatLng point is at the same position (within a small margin of error). + Returns true if the given LatLng point is at the same position (within a small margin of error). toString() @@ -3534,7 +3534,7 @@ map.panTo(L.latLng(50, 30)); LatLng - Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default). + Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default). @@ -3550,19 +3550,19 @@ map.panTo(L.latLng(50, 30)); DEG_TO_RAD Number - Math.PI / 180 + Math.PI / 180 A multiplier for converting degrees into radians. RAD_TO_DEG Number - 180 / Math.PI + 180 / Math.PI A multiplier for converting radians into degrees. MAX_MARGIN Number - 1.0E-9 + 1.0E-9 Max margin of error for the equality check. @@ -3624,7 +3624,7 @@ map.panTo(L.latLng(50, 30)); <LatLng|LatLngBounds> latlng ) - this + this Extends the bounds to contain the given point or bounds. @@ -3678,7 +3678,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle contains the given one. + Returns true if the rectangle contains the given one. contains( @@ -3686,7 +3686,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle contains the given point. + Returns true if the rectangle contains the given point. intersects( @@ -3694,7 +3694,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle intersects the given bounds. + Returns true if the rectangle intersects the given bounds. equals( @@ -3702,12 +3702,12 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. + Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. toBBoxString() String - Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. + Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. pad( @@ -3722,7 +3722,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the bounds are properly initialized. + Returns true if the bounds are properly initialized. @@ -3753,7 +3753,7 @@ map.panBy(L.point(200, 300)); <Boolean> round? ) - Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values. + Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values. @@ -3816,7 +3816,7 @@ map.panBy(L.point(200, 300)); Point - Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. + Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. distanceTo( @@ -3847,7 +3847,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the given point has the same coordinates. + Returns true if the given point has the same coordinates. contains( @@ -3855,7 +3855,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). + Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). toString() @@ -3952,7 +3952,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle contains the given one. + Returns true if the rectangle contains the given one. contains( @@ -3960,7 +3960,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle contains the given point. + Returns true if the rectangle contains the given point. intersects( @@ -3968,13 +3968,13 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle intersects the given bounds. + Returns true if the rectangle intersects the given bounds. isValid() Boolean - Returns true if the bounds are properly initialized. + Returns true if the bounds are properly initialized. getSize() @@ -4093,7 +4093,7 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); -

By default, it has a 'leaflet-div-icon' class and is styled as a little white square with a shadow.

+

By default, it has a 'leaflet-div-icon' class and is styled as a little white square with a shadow.

Creation

@@ -4140,7 +4140,7 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); className String - A custom class name to assign to the icon. 'leaflet-div-icon' by default. + A custom class name to assign to the icon. 'leaflet-div-icon' by default. html @@ -4189,7 +4189,7 @@ map.addControl(control); position String - 'topright' + 'topright' The initial position of the control (one of the map corners). See control positions. @@ -4206,7 +4206,7 @@ map.addControl(control); <String> position ) - this + this Sets the position of the control. See control positions. @@ -4219,7 +4219,7 @@ map.addControl(control); <Map> map ) - this + this Adds the control to the map. @@ -4227,7 +4227,7 @@ map.addControl(control); <Map> map ) - this + this Removes the control from the map. @@ -4247,19 +4247,19 @@ map.addControl(control); Description - 'topleft' + 'topleft' Top left of the map. - 'topright' + 'topright' Top right of the map. - 'bottomleft' + 'bottomleft' Bottom left of the map. - 'bottomright' + 'bottomright' Bottom right of the map. @@ -4267,7 +4267,7 @@ map.addControl(control);

Control.zoom

-

A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

+

A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

Creation

@@ -4297,31 +4297,31 @@ map.addControl(control); - + - + - + - + - +
position String'topleft''topleft' The position of the control (one of the map corners). See control positions.
zoomInText String'+''+' The text set on the zoom in button.
zoomOutText String'-''-' The text set on the zoom out button.
zoomInTitle String'Zoom in''Zoom in' The title set on the zoom in button.
zoomOutTitle String'Zoom out''Zoom out' The title set on the zoom out button.
@@ -4330,7 +4330,7 @@ map.addControl(control);

Control.Attribution

-

The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. Extends Control.

+

The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. Extends Control.

Creation

@@ -4361,14 +4361,14 @@ map.addControl(control); - + - - + +
position String'bottomright''bottomright' The position of the control (one of the map corners). See control positions.
prefix String'Leaflet'The HTML text shown before the attributions. Pass false to disable.'Leaflet'The HTML text shown before the attributions. Pass false to disable.
@@ -4383,21 +4383,21 @@ map.addControl(control); setPrefix( <String> prefix ) - this + this Sets the text before the attributions. addAttribution( <String> text ) - this - Adds an attribution text (e.g. 'Vector data &copy; Mapbox'). + this + Adds an attribution text (e.g. 'Vector data &copy; Mapbox'). removeAttribution( <String> text ) - this + this Removes an attribution text. @@ -4448,7 +4448,7 @@ L.control.layers(baseLayers, overlays).addTo(map); <ILayer> layer, <String> name ) - this + this Adds a base layer (radio button entry) with the given name to the control. @@ -4456,14 +4456,14 @@ L.control.layers(baseLayers, overlays).addTo(map); <ILayer> layer, <String> name ) - this + this Adds an overlay (checkbox entry) with the given name to the control. removeLayer( <ILayer> layer ) - this + this Remove the given layer from the control. @@ -4480,20 +4480,20 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'topright' + 'topright' The position of the control (one of the map corners). See control positions. collapsed Boolean - true - If true, the control will be collapsed into an icon and expanded on mouse hover or touch. + true + If true, the control will be collapsed into an icon and expanded on mouse hover or touch. autoZIndex Boolean - true - If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. + true + If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. @@ -4576,32 +4576,32 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'bottomleft' + 'bottomleft' The position of the control (one of the map corners). See control positions. maxWidth Number - 100 + 100 Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500). metric Boolean - true + true Whether to show the metric scale line (m/km). imperial Boolean - true + true Whether to show the imperial scale line (mi/ft). updateWhenIdle Boolean - false - If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move). + false + If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move). @@ -4609,7 +4609,7 @@ L.control.layers(baseLayers, overlays).addTo(map);

Events methods

-

A set of methods shared between event-powered classes (like Map). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map 'click' event).

+

A set of methods shared between event-powered classes (like Map). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map 'click' event).

Example

@@ -4638,8 +4638,8 @@ map.off('click', onClick);
<Object> context? )
- this - Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). + this + Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). addOneTimeEventListener( @@ -4648,7 +4648,7 @@ map.off('click', onClick); <Object> context? ) - this + this The same as above except the listener will only get fired once and then removed. @@ -4657,7 +4657,7 @@ map.off('click', onClick); <Object> context? ) - this + this Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} @@ -4667,7 +4667,7 @@ map.off('click', onClick); <Object> context? ) - this + this Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to addEventListener, you must pass the same context to removeEventListener in order to remove the listener. @@ -4676,13 +4676,13 @@ map.off('click', onClick); <Object> context? ) - this + this Removes a set of type/listener pairs. removeEventListener() - this + this Removes all listeners. An alias to clearAllEventListeners when you use it without arguments. @@ -4691,7 +4691,7 @@ map.off('click', onClick); Boolean - Returns true if a particular event type has some listeners attached to it. + Returns true if a particular event type has some listeners attached to it. fireEvent( @@ -4699,33 +4699,33 @@ map.off('click', onClick); <Object> data? ) - this + this Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. clearAllEventListeners() - this + this Removes all listeners to all events on the object. on( … ) - this + this Alias to addEventListener. once( … ) - this + this Alias to addOneTimeEventListener. off( … ) - this + this Alias to removeEventListener. fire( … ) - this + this Alias to fireEvent. @@ -4752,7 +4752,7 @@ map.off('click', onClick); type String - The event type (e.g. 'click'). + The event type (e.g. 'click'). target @@ -5176,77 +5176,77 @@ MyClass.FOO; // 'bar' ie Boolean - true for all Internet Explorer versions. + true for all Internet Explorer versions. ie6 Boolean - true for Internet Explorer 6. + true for Internet Explorer 6. ie7 Boolean - true for Internet Explorer 7. + true for Internet Explorer 7. webkit Boolean - true for webkit-based browsers like Chrome and Safari (including mobile versions). + true for webkit-based browsers like Chrome and Safari (including mobile versions). webkit3d Boolean - true for webkit-based browsers that support CSS 3D transformations. + true for webkit-based browsers that support CSS 3D transformations. android Boolean - true for Android mobile browser. + true for Android mobile browser. android23 Boolean - true for old Android stock browsers (2 and 3). + true for old Android stock browsers (2 and 3). mobile Boolean - true for modern mobile browsers (including iOS Safari and different Android browsers). + true for modern mobile browsers (including iOS Safari and different Android browsers). mobileWebkit Boolean - true for mobile webkit-based browsers. + true for mobile webkit-based browsers. mobileOpera Boolean - true for mobile Opera. + true for mobile Opera. touch Boolean - true for all browsers on touch devices. + true for all browsers on touch devices. msTouch Boolean - true for browsers with Microsoft touch model (e.g. IE10). + true for browsers with Microsoft touch model (e.g. IE10). retina Boolean - true for devices with Retina screens. + true for devices with Retina screens. @@ -5279,7 +5279,7 @@ MyClass.FOO; // 'bar' Function - Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. Not a polyfill for ES 5 bind (compare L.bind to the MDN-recommended polyfill for Function.prototype.bind). + Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. Not a polyfill for ES 5 bind (compare L.bind to the MDN-recommended polyfill for Function.prototype.bind). stamp( <Object> obj ) @@ -5317,7 +5317,7 @@ MyClass.FOO; // 'bar' falseFn() Function - Always returns false. + Always returns false. formatNum( @@ -5351,7 +5351,7 @@ MyClass.FOO; // 'bar' String - Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'. + Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'. template( @@ -5359,7 +5359,7 @@ MyClass.FOO; // 'bar' String - Simple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument. + Simple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument. isArray( @@ -5367,7 +5367,7 @@ MyClass.FOO; // 'bar' Boolean - Returns true if the given object is an array. + Returns true if the given object is an array. trim( @@ -5562,8 +5562,8 @@ MyClass.FOO; // 'bar' <Object> context? ) - this - Adds a listener fn to the element's DOM event of the specified type. this keyword inside the listener will point to context, or to the element if not specified. + this + Adds a listener fn to the element's DOM event of the specified type. this keyword inside the listener will point to context, or to the element if not specified. removeListener( @@ -5572,7 +5572,7 @@ MyClass.FOO; // 'bar' <Function> fn ) - this + this Removes an event listener from the element. @@ -5580,7 +5580,7 @@ MyClass.FOO; // 'bar' <DOMEvent> e ) - this + this Stop the given event from propagation to parent elements. Used inside the listener functions:
L.DomEvent.addListener(div, 'click', function (e) {
 	L.DomEvent.stopPropagation(e);
@@ -5592,7 +5592,7 @@ MyClass.FOO; // 'bar'
<DOMEvent> e ) - this + this Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions. @@ -5601,7 +5601,7 @@ MyClass.FOO; // 'bar' <DOMEvent> e ) - this + this Does stopPropagation and preventDefault at the same time. @@ -5609,8 +5609,8 @@ MyClass.FOO; // 'bar' <HTMLElement> el ) - this - Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events. + this + Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events. getMousePosition( @@ -5700,7 +5700,7 @@ MyClass.FOO; // 'bar' Boolean - Returns true if the element class attribute contains name. + Returns true if the element class attribute contains name. addClass( @@ -5736,8 +5736,8 @@ MyClass.FOO; // 'bar' <String[]> props ) - String or false - Goes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform. + String or false + Goes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform. getTranslateString( @@ -5764,7 +5764,7 @@ MyClass.FOO; // 'bar' - - Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true. + Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true. getPosition( @@ -5788,7 +5788,7 @@ MyClass.FOO; // 'bar' TRANSITION String - Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). + Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). TRANSFORM @@ -5837,8 +5837,8 @@ fx.run(el, [300, 500], 0.5); <Number> easeLinearity? ) - this - Run an animation of a given element to a new position, optionally setting duration in seconds (0.25 by default) and easing linearity factor (3rd argument of the cubic bezier curve, 0.5 by default) + this + Run an animation of a given element to a new position, optionally setting duration in seconds (0.25 by default) and easing linearity factor (3rd argument of the cubic bezier curve, 0.5 by default) @@ -5959,17 +5959,17 @@ draggable.enable(); START String - Name of the DOM event that initiates dragging. 'mousedown' for desktop browsers, 'touchstart' for mobile devices. + Name of the DOM event that initiates dragging. 'mousedown' for desktop browsers, 'touchstart' for mobile devices. MOVE String - Name of the DOM event for drag moving. 'mousemove' for desktop browsers, 'touchmove' for mobile devices. + Name of the DOM event for drag moving. 'mousemove' for desktop browsers, 'touchmove' for mobile devices. END String - Name of the DOM event that ends dragging. 'mouseup' for desktop browsers, 'touchend' for mobile devices. + Name of the DOM event that ends dragging. 'mouseup' for desktop browsers, 'touchend' for mobile devices. --> @@ -5997,7 +5997,7 @@ draggable.enable(); enabled() Boolean - Returns true if the handler is enabled. + Returns true if the handler is enabled. @@ -6290,7 +6290,7 @@ map.addControl(new MyControl()); code String - Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857'). + Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857'). @@ -6330,7 +6330,7 @@ map.addControl(new MyControl());

Global Switches

-

Global switches are created for rare cases and generally make Leaflet to not detect a particular browser feature even if it's there. You need to set the switch as a global variable to true before including Leaflet on the page, like this:

+

Global switches are created for rare cases and generally make Leaflet to not detect a particular browser feature even if it's there. You need to set the switch as a global variable to true before including Leaflet on the page, like this:

<script>L_PREFER_CANVAS = true;</script>
 <script src="leaflet.js"></script>
From 3bb3c3973f83d2de077c3ab583b33ba18c3e916e Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 2 Jan 2014 16:56:39 -0600 Subject: [PATCH 02/58] remove DomUtil.getViewportOffset as changelog indicates it has been removed. --- reference.html | 8 -------- 1 file changed, 8 deletions(-) diff --git a/reference.html b/reference.html index 2f7c14ac..701e3835 100644 --- a/reference.html +++ b/reference.html @@ -5663,14 +5663,6 @@ MyClass.FOO; // 'bar' String Returns the value for a certain style attribute on an element, including computed values or values set through CSS. - - getViewportOffset( - <HTMLElement> el ) - - - Point - Returns the offset to the viewport for the requested element. - create( <String> tagName, From 016d56568d7cae64cf184cedfce3db934b37c8f4 Mon Sep 17 00:00:00 2001 From: danzel Date: Wed, 29 Jan 2014 11:41:08 +1300 Subject: [PATCH 03/58] Documentation for oldLatlng in marker move event. refs #2412 --- reference.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference.html b/reference.html index 701e3835..ab04526d 100644 --- a/reference.html +++ b/reference.html @@ -1443,7 +1443,7 @@ var map = L.map('map', { move Event - Fired when the marker is moved via setLatLng. New coordinate include in event arguments. + Fired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatlng, latlng. add From f14f4070ec486211bc716a203d0af8f2338395eb Mon Sep 17 00:00:00 2001 From: danzel Date: Wed, 29 Jan 2014 14:52:41 +1300 Subject: [PATCH 04/58] oldLatLng --- reference.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference.html b/reference.html index ab04526d..8340b114 100644 --- a/reference.html +++ b/reference.html @@ -1443,7 +1443,7 @@ var map = L.map('map', { move Event - Fired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatlng, latlng. + Fired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatLng, latlng. add From ae4e53fc996a6809fba2575b0d314a4b0bbd2b64 Mon Sep 17 00:00:00 2001 From: Andrey Geonya Date: Wed, 5 Feb 2014 19:41:23 +0200 Subject: [PATCH 05/58] Update reference.html --- reference.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference.html b/reference.html index 8340b114..0b03b2fb 100644 --- a/reference.html +++ b/reference.html @@ -5915,7 +5915,7 @@ draggable.enable(); dragend - Event + DragEndEvent Fired when the dragging ends. From f4250f12e8ca8df41ce5f0e6eafff9b6f2e464d1 Mon Sep 17 00:00:00 2001 From: mtmail Date: Sat, 8 Mar 2014 13:34:06 +0100 Subject: [PATCH 06/58] Update reference related to touchZoom:center ( using the correct gh-pages-master branch now) Documenting the accepted pull request https://github.com/Leaflet/Leaflet/pull/2527 --- reference.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference.html b/reference.html index 0b03b2fb..df362aba 100644 --- a/reference.html +++ b/reference.html @@ -235,7 +235,7 @@ var map = L.map('map', { touchZoom Boolean true - Whether the map can be zoomed by touch-dragging with two fingers. + Whether the map can be zoomed by touch-dragging with two fingers. If passed 'center', it will zoom to the center of the view regardless of where the touch events (fingers) were. scrollWheelZoom From 02f28b9160f4acc7be19d89c1af5d6a61c0af4e6 Mon Sep 17 00:00:00 2001 From: bennlich Date: Tue, 22 Apr 2014 22:59:33 -0700 Subject: [PATCH 07/58] Updated reference for crossOrigin option --- reference.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reference.html b/reference.html index df362aba..b79b32d1 100644 --- a/reference.html +++ b/reference.html @@ -1943,6 +1943,12 @@ var map = L.map('map', { LatLngBounds null When this option is set, the TileLayer only loads tiles that are in the given geographical bounds. + + + crossOrigin + Boolean + false + If true, all tiles will have their crossOrigin attribute set to ''. This is needed if you want to access tile pixel data. From f5b85f05f13c200badd4db589d1ef0ea16666fab Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 5 Aug 2014 17:08:51 +0300 Subject: [PATCH 08/58] #2501, wheelDebounceTime option documented --- reference.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reference.html b/reference.html index b79b32d1..c18f6469 100644 --- a/reference.html +++ b/reference.html @@ -243,6 +243,12 @@ var map = L.map('map', { true Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. + + wheelDebounceTime + Number + 40 + Limits the rate at which a wheel can fire (in milliseconds). By default user can't zoom via wheel more often than once per 40 ms. + doubleClickZoom Boolean From bc63eb6052d8cd4c6377acc7c2ba6052e6dea1db Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 5 Aug 2014 18:16:11 +0300 Subject: [PATCH 09/58] this commit fixes #2499 documentation --- reference.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference.html b/reference.html index c18f6469..1239091f 100644 --- a/reference.html +++ b/reference.html @@ -1336,7 +1336,7 @@ var map = L.map('map', { Icon class to use for rendering the marker. See Icon documentation for details on how to customize the marker icon. Set to new L.Icon.Default() by default. - clickable + interactive Boolean true If false, the marker will not emit mouse events and will act as a part of the underlying map. @@ -2404,7 +2404,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); A string that defines shape to be used at the corners of the stroke. - clickable + interactive Boolean true If false, the vector will not emit mouse events and will act as a part of the underlying map. From a72321a30d36922163fbc5ce32600bb4af42ed80 Mon Sep 17 00:00:00 2001 From: Kevin DeLoach Date: Tue, 5 Aug 2014 14:01:23 -0400 Subject: [PATCH 10/58] Add documentation for WMS TileLayer uppercase option. --- reference.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reference.html b/reference.html index 1239091f..3a765dc9 100644 --- a/reference.html +++ b/reference.html @@ -2137,6 +2137,12 @@ var map = L.map('map', { null Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means. + + uppercase + Boolean + false + If true, WMS request parameter keys will be uppercase. +

Methods

From 2bab64fde4803463bf2fee9f6f86d1851edcdc25 Mon Sep 17 00:00:00 2001 From: bennlich Date: Mon, 29 Sep 2014 12:29:51 -0700 Subject: [PATCH 11/58] Removed documented url property of TileEvent --- reference.html | 5 ----- 1 file changed, 5 deletions(-) diff --git a/reference.html b/reference.html index 3a765dc9..d09056e6 100644 --- a/reference.html +++ b/reference.html @@ -4927,11 +4927,6 @@ map.off('click', onClick); HTMLElement The tile element (image). - - url - String - The source URL of the tile. -

ResizeEvent

From 645915e755863324ecf3ffd2a64aca04d6236263 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Sun, 21 Dec 2014 07:52:37 -0800 Subject: [PATCH 12/58] add nav links and headers --- reference.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reference.html b/reference.html index d09056e6..5d4138bd 100644 --- a/reference.html +++ b/reference.html @@ -88,6 +88,8 @@ bodyclass: api-page

Utility

  • Class
  • +
  • Evented
  • +
  • Layer
  • Browser
  • Util
  • Transformation
  • @@ -5171,6 +5173,9 @@ MyClass.FOO; // 'bar'
    MyClass.addInitHook('methodName', arg1, arg2, …);
    +

    + +

    Browser

    From 66f6c80a37371a3b21f6fc8423c9726a793672dc Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Sun, 21 Dec 2014 08:44:24 -0800 Subject: [PATCH 13/58] L.Evented docs --- reference.html | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/reference.html b/reference.html index 5d4138bd..4fc7b330 100644 --- a/reference.html +++ b/reference.html @@ -5128,7 +5128,7 @@ a.options; // {foo: 'bar', bla: 10}

    Includes

    -

    includes is a special class property that merges all specified objects into the class (such objects are called mixins). A good example of this is L.Mixin.Events that event-related methods like on, off and fire to the class.

    +

    includes is a special class property that merges all specified objects into the class (such objects are called mixins).

     var MyMixin = {
     	foo: function () { ... },
    @@ -5173,9 +5173,35 @@ MyClass.FOO; // 'bar'
    MyClass.addInitHook('methodName', arg1, arg2, …);
    -

    +

    Evented

    -

    +

    When creating a plguin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-releated methods like on, off and fire

    + +
    MyEventedClass = L.Evented.extend({
    +	fire: function(){
    +		this.fire('custom', {
    +			// you can attach optional data to an event as an object
    +		});
    +	}
    +});
    +
    +var myEvents = new MyEventedClass();
    +
    +myEvents.on('custom', function(e){
    +	// e.type will  be 'custom'
    +	// anything else you passed in the
    +});
    +
    +myEvents.fire();
    + +You can still use the old-style `L.Mixin.Events` for backward compatibility. + +
    // this class will include all event methods
    +MyEventedClass = L.Class.extend({
    +	includes: L.Mixin.Evvents
    +});
    + +

    Layer

    Browser

    From 6cd55b4c727b58eac324f1ae08c71bdadaae7596 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Sun, 21 Dec 2014 13:16:19 -0800 Subject: [PATCH 14/58] layer and evented docs --- reference-tpl.html | 17 ++++++++ reference.html | 100 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 103 insertions(+), 14 deletions(-) diff --git a/reference-tpl.html b/reference-tpl.html index 2e3cee70..82033923 100644 --- a/reference-tpl.html +++ b/reference-tpl.html @@ -70,3 +70,20 @@ [description] + + + +

    Events

    + + + + + + + + + + + + +
    EventDataDescription
    [name][type][description]
    diff --git a/reference.html b/reference.html index 4fc7b330..369827b9 100644 --- a/reference.html +++ b/reference.html @@ -5175,7 +5175,7 @@ MyClass.FOO; // 'bar'

    Evented

    -

    When creating a plguin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-releated methods like on, off and fire

    +

    When creating a plugin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-related methods like on, off and fire

    MyEventedClass = L.Evented.extend({
     	fire: function(){
    @@ -5198,11 +5198,80 @@ You can still use the old-style `L.Mixin.Events` for backward compatibility.
     
     
    // this class will include all event methods
     MyEventedClass = L.Class.extend({
    -	includes: L.Mixin.Evvents
    +	includes: L.Mixin.Events
     });

    Layer

    +

    When implementing a custom layer the L.Layer class can be extended to implementing basic functionality that all layers need to share, these methods can be used when extending L.Layer when implementing custom layers.

    + +

    Options

    + + + + + + + + + + + + + + +
    OptionTypeDefault valueDescription
    paneString'overlayPane'By default the layer will be added to the maps overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    + +

    Events

    + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map.
    removeEventFired after the layer is removed from a map.
    + +

    Methods

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map> map)thisAdds the layer to the given map.
    removeFrom(<Map> map)thisRemoves the layer to the given map.
    remove()thisRemoves the layer from the map it is currently active on.
    getPane(<String> name?)HTMLElementReturns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.
    +

    Browser

    A namespace with properties for browser/feature detection used by Leaflet internally.

    @@ -6040,7 +6109,7 @@ draggable.enable();

    ILayer

    -

    Represents an object attached to a particular location (or a set of locations) on a map. Implemented by tile layers, markers, popups, image overlays, vector layers and layer groups.

    +

    Represents an object attached to a particular location (or a set of locations) on a map. Extends the L.Layer base class and is implemented by tile layers, markers, popups, image overlays, vector layers and layer groups.

    Methods

    @@ -6070,6 +6139,8 @@ draggable.enable();

    Implementing Custom Layers

    +

    Custom layers should extend the L.Layer base class. L.Layer provides convenience methods for your layer like addTo(map), removeFrom(map) and getPane().

    +

    The most important things know about when implementing custom layers are Map viewreset event and latLngToLayerPoint method. viewreset is fired when the map needs to reposition its layers (e.g. on zoom), and latLngToLayerPoint is used to get coordinates for the layer's new position.

    Another event often used in layer implementations is moveend which fires after any movement of the map (panning, zooming, etc.).

    @@ -6080,29 +6151,32 @@ draggable.enable();

    Here's how a custom layer implementation usually looks:

    -
    var MyCustomLayer = L.Class.extend({
    +
    var MyCustomLayer = L.Layer.extend({
     
     	initialize: function (latlng) {
     		// save position of the layer or any options from the constructor
     		this._latlng = latlng;
     	},
     
    -	onAdd: function (map) {
    -		this._map = map;
    +	// these events will be added and removed from the map with the layer
    +	getEvents: function(){
    +		return {
    +			viewreset: this._reset
    +		}
    +	},
     
    -		// create a DOM element and put it into one of the map panes
    +	onAdd: function (map) {
    +		// create a DOM element and put it into one of the map panes, by default the overlayPane
     		this._el = L.DomUtil.create('div', 'my-custom-layer leaflet-zoom-hide');
    -		map.getPanes().overlayPane.appendChild(this._el);
    +		this.getPane().appendChild(this._el);
     
     		// add a viewreset event listener for updating layer's position, do the latter
    -		map.on('viewreset', this._reset, this);
     		this._reset();
     	},
     
     	onRemove: function (map) {
     		// remove layer's DOM elements and listeners
    -		map.getPanes().overlayPane.removeChild(this._el);
    -		map.off('viewreset', this._reset, this);
    +		this.getPane().overlayPane.removeChild(this._el);
     	},
     
     	_reset: function () {
    @@ -6112,11 +6186,9 @@ draggable.enable();
     	}
     });
     
    -map.addLayer(new MyCustomLayer(latlng));
    +var myLayer = new MyCustomLayer(latlng).addTo(map);
     
    - -

    IControl

    Represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls.

    From 5445a488e14f4dabbb5241af694a8bec812b1c35 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Fri, 26 Dec 2014 15:19:27 -0800 Subject: [PATCH 15/58] refactory into utilities and base classes --- reference.html | 929 ++++++++++++++++++++++++------------------------- 1 file changed, 449 insertions(+), 480 deletions(-) diff --git a/reference.html b/reference.html index 369827b9..94bf9e5f 100644 --- a/reference.html +++ b/reference.html @@ -72,7 +72,6 @@ bodyclass: api-page

Controls

Utility

-

Interfaces

+

Base Classes

Misc

@@ -188,7 +186,7 @@ var map = L.map('map', { layers - ILayer[] + ILayer[] null Layers that will be added to the map initially. @@ -212,7 +210,7 @@ var map = L.map('map', { crs - CRS + CRS L.CRS.
EPSG3857
Coordinate Reference System to use. Don't change this if you're not sure what it means. @@ -807,7 +805,7 @@ var map = L.map('map', { addLayer( - <ILayer> layer, + <ILayer> layer this @@ -815,7 +813,7 @@ var map = L.map('map', { removeLayer( - <ILayer> layer ) + <ILayer> layer ) this @@ -823,7 +821,7 @@ var map = L.map('map', { hasLayer( - <ILayer> layer ) + <ILayer> layer ) Boolean @@ -869,7 +867,7 @@ var map = L.map('map', { addControl( - <IControl> control ) + <IControl> control ) this @@ -877,7 +875,7 @@ var map = L.map('map', { removeControl( - <IControl> control ) + <IControl> control ) this @@ -1188,7 +1186,7 @@ var map = L.map('map', {

Properties

-

Map properties include interaction handlers that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging or touch zoom (see IHandler methods). Example:

+

Map properties include interaction handlers that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging or touch zoom (see IHandler methods). Example:

map.doubleClickZoom.disable();
@@ -1204,37 +1202,37 @@ var map = L.map('map', { dragging - IHandler + IHandler Map dragging handler (by both mouse and touch). touchZoom - IHandler + IHandler Touch zoom handler. doubleClickZoom - IHandler + IHandler Double click zoom handler. scrollWheelZoom - IHandler + IHandler Scroll wheel zoom handler. boxZoom - IHandler + IHandler Box (shift-drag with mouse) zoom handler. keyboard - IHandler + IHandler Keyboard navigation handler. tap - IHandler + IHandler Mobile touch hacks (quick tap and touch hold) handler. @@ -1585,7 +1583,7 @@ var map = L.map('map', {

Interaction handlers

-

Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see IHandler methods). Example:

+

Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see IHandler methods). Example:

marker.dragging.disable();
@@ -1597,7 +1595,7 @@ var map = L.map('map', { dragging - IHandler + IHandler Marker dragging handler (by both mouse and touch). @@ -1629,7 +1627,7 @@ var map = L.map('map', { L.popup( <Popup options> options?, - <ILayer> source? ) + <ILayer> source? ) @@ -1792,7 +1790,7 @@ var map = L.map('map', {

TileLayer

-

Used to load and display tile layers on the map, implements ILayer interface.

+

Used to load and display tile layers on the map, implements ILayer interface.

Usage example

@@ -2135,7 +2133,7 @@ var map = L.map('map', { crs - CRS + CRS null Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means. @@ -2239,7 +2237,7 @@ canvasTiles.drawTile = function(canvas, tilePoint, zoom) {

ImageOverlay

-

Used to load and display a single image over specific bounds of the map, implements ILayer interface.

+

Used to load and display a single image over specific bounds of the map, implements ILayer interface.

Usage example

@@ -3076,7 +3074,7 @@ map.fitBounds(bounds);

LayerGroup

-

Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.

+

Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.

L.layerGroup([marker1, marker2])
 	.addLayer(polyline)
@@ -3090,8 +3088,8 @@ map.fitBounds(bounds);
Description - L.layerGroup( - <ILayer[]> layers? ) + L.LayerGroup( + <ILayer[]> layers? ) @@ -3117,7 +3115,7 @@ map.fitBounds(bounds); addLayer( - <ILayer> layer ) + <ILayer> layer ) this @@ -3125,7 +3123,7 @@ map.fitBounds(bounds);
removeLayer( - <ILayer> layer ) + <ILayer> layer ) this @@ -3141,7 +3139,7 @@ map.fitBounds(bounds); hasLayer( - <ILayer> layer ) + <ILayer> layer ) Boolean @@ -3152,7 +3150,7 @@ map.fitBounds(bounds); <String> id ) - ILayer + ILayer Returns the layer with the given id. @@ -3188,7 +3186,7 @@ map.fitBounds(bounds);

FeatureGroup

-

Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.

+

Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.

L.featureGroup([marker1, marker2, polyline])
 	.bindPopup('Hello world!')
@@ -3205,7 +3203,7 @@ map.fitBounds(bounds);
L.featureGroup( - <ILayer[]> layers? ) + <ILayer[]> layers? ) @@ -3367,7 +3365,7 @@ map.fitBounds(bounds); onEachFeature( <GeoJSON> featureData, - <ILayer> layer ) + <ILayer> layer ) Function that will be called on each created feature layer. Useful for attaching events and popups to features. @@ -3375,7 +3373,7 @@ map.fitBounds(bounds); filter( <GeoJSON> featureData, - <ILayer> layer ) + <ILayer> layer ) Function that will be used to decide whether to show a feature or not. @@ -3439,7 +3437,7 @@ map.fitBounds(bounds); <Function> pointToLayer? ) - ILayer + ILayer Creates a layer from a given GeoJSON feature. @@ -4169,122 +4167,6 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); - - - -

Control

- -

The base class for all Leaflet controls. Implements IControl interface. You can add controls to the map like this:

- -
control.addTo(map);
-// the same as
-map.addControl(control);
- -

Creation

- - - - - - - - - - - - - -
FactoryDescription
L.control( - <Control options> options? ) - Creates a control with the given options.
- -

Options

- - - - - - - - - - - - - -
OptionTypeDefaultDescription
positionString'topright'The initial position of the control (one of the map corners). See control positions.
- -

Methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setPosition( - <String> position ) - thisSets the position of the control. See control positions.
getPosition()StringReturns the current position of the control.
addTo( - <Map> map ) - thisAdds the control to the map.
removeFrom( - <Map> map ) - thisRemoves the control from the map.
getContainer()HTMLElementReturns the HTML container of the control.
- -

Control Positions

- -

Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

- - - - - - - - - - - - - - - - - - - - - - -
PositionDescription
'topleft'Top left of the map.
'topright'Top right of the map.
'bottomleft'Bottom left of the map.
'bottomright'Bottom right of the map.
- -

Control.zoom

A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

@@ -4465,7 +4347,7 @@ L.control.layers(baseLayers, overlays).addTo(map); addBaseLayer( - <ILayer> layer, + <ILayer> layer, <String> name ) this @@ -4473,7 +4355,7 @@ L.control.layers(baseLayers, overlays).addTo(map); addOverlay( - <ILayer> layer, + <ILayer> layer, <String> name ) this @@ -4481,7 +4363,7 @@ L.control.layers(baseLayers, overlays).addTo(map); removeLayer( - <ILayer> layer ) + <ILayer> layer ) this Remove the given layer from the control. @@ -4891,7 +4773,7 @@ map.off('click', onClick); layer - ILayer + ILayer The layer that was added or removed. @@ -4906,7 +4788,7 @@ map.off('click', onClick); layer - ILayer + ILayer The layer that was added or removed. @@ -4961,7 +4843,7 @@ map.off('click', onClick); layer - ILayer + ILayer The layer for the GeoJSON feature that is being added to the map. @@ -5014,264 +4896,6 @@ map.off('click', onClick); - - -

Class

- -

L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

-

In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

- -
var MyClass = L.Class.extend({
-	initialize: function (greeter) {
-		this.greeter = greeter;
-		// class constructor
-	},
-
-	greet: function (name) {
-		alert(this.greeter + ', ' + name)
-	}
-});
-
-// create instance of MyClass, passing "Hello" to the constructor
-var a = new MyClass("Hello");
-
-// call greet method, alerting "Hello, World"
-a.greet("World");
-
- -

The initialize method is your class's constructor function, meaning that it gets called when you do new MyClass(...).

- - -

Class Factories

- -

You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:

- -
new L.Map('map'); // becomes:
-L.map('map');
- -

The factories are implemented very easily, and you can do this for your own classes:

- -
L.map = function (id, options) {
-	return new L.Map(id, options);
-};
- - -

Inheritance

- -

You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

- -
var MyChildClass = MyClass.extend({
-	// ... new properties and methods
-});
- -

This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

- -
var a = new MyChildClass();
-a instanceof MyChildClass; // true
-a instanceof MyClass; // true
-
- -

You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

- -
var MyChildClass = MyClass.extend({
-	initialize: function () {
-		MyClass.prototype.initialize.call(this, "Yo");
-	},
-
-	greet: function (name) {
-		MyClass.prototype.greet.call(this, 'bro ' + name + '!');
-	}
-});
-
-var a = new MyChildClass();
-a.greet('Jason'); // alerts "Yo, bro Jason!"
- -

Options

- -

options is a special property that unlike other objects that you pass to extend will be merged with the parent one instead of overriding it completely, which makes managing configuration of objects and default values convenient:

- -
var MyClass = L.Class.extend({
-	options: {
-		myOption1: 'foo',
-		myOption2: 'bar'
-	}
-});
-
-var MyChildClass = MyClass.extend({
-	options: {
-		myOption1: 'baz',
-		myOption3: 5
-	}
-});
-
-var a = new MyChildClass();
-a.options.myOption1; // 'baz'
-a.options.myOption2; // 'bar'
-a.options.myOption3; // 5
- -

There's also L.Util.setOptions, a method for conveniently merging options passed to constructor with the defaults defined in the class:

- -
var MyClass = L.Class.extend({
-	options: {
-		foo: 'bar',
-		bla: 5
-	},
-
-	initialize: function (options) {
-		L.Util.setOptions(this, options);
-		...
-	}
-});
-
-var a = new MyClass({bla: 10});
-a.options; // {foo: 'bar', bla: 10}
- -

Includes

- -

includes is a special class property that merges all specified objects into the class (such objects are called mixins). - -

 var MyMixin = {
-	foo: function () { ... },
-	bar: 5
-};
-
-var MyClass = L.Class.extend({
-	includes: MyMixin
-});
-
-var a = new MyClass();
-a.foo();
- -

You can also do such includes in runtime with the include method:

- -
MyClass.include(MyMixin);
- -

Statics

- -

statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

- -
var MyClass = L.Class.extend({
-	statics: {
-		FOO: 'bar',
-		BLA: 5
-	}
-});
-
-MyClass.FOO; // 'bar'
- - -

Constructor Hooks

- -

If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

- -
MyClass.addInitHook(function () {
-	// ... do something in constructor additionally
-	// e.g. add event listeners, set custom properties etc.
-});
- -

You can also use the following shortcut when you just need to make one additional method call:

- -
MyClass.addInitHook('methodName', arg1, arg2, …);
- -

Evented

- -

When creating a plugin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-related methods like on, off and fire

- -
MyEventedClass = L.Evented.extend({
-	fire: function(){
-		this.fire('custom', {
-			// you can attach optional data to an event as an object
-		});
-	}
-});
-
-var myEvents = new MyEventedClass();
-
-myEvents.on('custom', function(e){
-	// e.type will  be 'custom'
-	// anything else you passed in the
-});
-
-myEvents.fire();
- -You can still use the old-style `L.Mixin.Events` for backward compatibility. - -
// this class will include all event methods
-MyEventedClass = L.Class.extend({
-	includes: L.Mixin.Events
-});
- -

Layer

- -

When implementing a custom layer the L.Layer class can be extended to implementing basic functionality that all layers need to share, these methods can be used when extending L.Layer when implementing custom layers.

- -

Options

- - - - - - - - - - - - - - -
OptionTypeDefault valueDescription
paneString'overlayPane'By default the layer will be added to the maps overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
- -

Events

- - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map.
removeEventFired after the layer is removed from a map.
- -

Methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map> map)thisAdds the layer to the given map.
removeFrom(<Map> map)thisRemoves the layer to the given map.
remove()thisRemoves the layer from the map it is currently active on.
getPane(<String> name?)HTMLElementReturns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.
-

Browser

A namespace with properties for browser/feature detection used by Leaflet internally.

@@ -5392,6 +5016,7 @@ MyEventedClass = L.Class.extend({ Function + Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. Not a polyfill for ES 5 bind (compare L.bind to the MDN-recommended polyfill for Function.prototype.bind). @@ -6078,64 +5703,192 @@ draggable.enable(); --> +

Class

+ +

L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

+

In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

+ +
var MyClass = L.Class.extend({
+	initialize: function (greeter) {
+		this.greeter = greeter;
+		// class constructor
+	},
+
+	greet: function (name) {
+		alert(this.greeter + ', ' + name)
+	}
+});
+
+// create instance of MyClass, passing "Hello" to the constructor
+var a = new MyClass("Hello");
+
+// call greet method, alerting "Hello, World"
+a.greet("World");
+
-

IHandler

-

An interface implemented by interaction handlers.

+

Class Factories

- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
enable()-Enables the handler.
disable()-Disables the handler.
enabled()BooleanReturns true if the handler is enabled.
+

You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:

+ +
new L.Map('map'); // becomes:
+L.map('map');
+ +

The factories are implemented very easily, and you can do this for your own classes:

+ +
L.map = function (id, options) {
+	return new L.Map(id, options);
+};
-

ILayer

+

Inheritance

-

Represents an object attached to a particular location (or a set of locations) on a map. Extends the L.Layer base class and is implemented by tile layers, markers, popups, image overlays, vector layers and layer groups.

+

You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

-

Methods

+
var MyChildClass = MyClass.extend({
+	// ... new properties and methods
+});
- - - - - - - - +

This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

- - - - - +
var a = new MyChildClass();
+a instanceof MyChildClass; // true
+a instanceof MyClass; // true
+
- - - -
MethodReturnsDescription
onAdd( - <Map> map ) - -Should contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).
onRemove( - <Map> map ) - -Should contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
+

You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

+ +
var MyChildClass = MyClass.extend({
+	initialize: function () {
+		MyClass.prototype.initialize.call("Yo");
+	},
+
+	greet: function (name) {
+		MyClass.prototype.greet.call(this, 'bro ' + name + '!');
+	}
+});
+
+var a = new MyChildClass();
+a.greet('Jason'); // alerts "Yo, bro Jason!"
+ +

Options

+ +

options is a special property that unlike other objects that you pass to extend will be merged with the parent one instead of overriding it completely, which makes managing configuration of objects and default values convenient:

+ +
var MyClass = L.Class.extend({
+	options: {
+		myOption1: 'foo',
+		myOption2: 'bar'
+	}
+});
+
+var MyChildClass = L.Class.extend({
+	options: {
+		myOption1: 'baz',
+		myOption3: 5
+	}
+});
+
+var a = new MyChildClass();
+a.options.myOption1; // 'baz'
+a.options.myOption2; // 'bar'
+a.options.myOption3; // 5
+ +

There's also L.Util.setOptions, a method for conveniently merging options passed to constructor with the defauls defines in the class:

+ +
var MyClass = L.Class.extend({
+	options: {
+		foo: 'bar',
+		bla: 5
+	},
+
+	initialize: function (options) {
+		L.Util.setOptions(this, options);
+		...
+	}
+});
+
+var a = new MyClass({bla: 10});
+a.options; // {foo: 'bar', bla: 10}
+ +

Includes

+ +

includes is a special class property that merges all specified objects into the class (such objects are called mixins). + +

 var MyMixin = {
+	foo: function () { ... },
+	bar: 5
+};
+
+var MyClass = L.Class.extend({
+	includes: MyMixin
+});
+
+var a = new MyClass();
+a.foo();
+ +

You can also do such includes in runtime with the include method:

+ +
MyClass.include(MyMixin);
+ +

Statics

+ +

statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

+ +
var MyClass = L.Class.extend({
+	statics: {
+		FOO: 'bar',
+		BLA: 5
+	}
+});
+
+MyClass.FOO; // 'bar'
+ + +

Constructor Hooks

+ +

If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

+ +
MyClass.addInitHook(function () {
+	// ... do something in constructor additionally
+	// e.g. add event listeners, set custom properties etc.
+});
+ +

You can also use the following shortcut when you just need to make one additional method call:

+ +
MyClass.addInitHook('methodName', arg1, arg2, …);
+ +

Evented

+ +

When creating a plugin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-related methods like on, off and fire

+ +
MyEventedClass = L.Evented.extend({
+	fire: function(){
+		this.fire('custom', {
+			// you can attach optional data to an event as an object
+		});
+	}
+});
+
+var myEvents = new MyEventedClass();
+
+myEvents.on('custom', function(e){
+	// e.type will  be 'custom'
+	// anything else you passed in the
+});
+
+myEvents.fire();
+ +You can still use the old-style `L.Mixin.Events` for backward compatibility. + +
// this class will include all event methods
+MyEventedClass = L.Class.extend({
+	includes: L.Mixin.Events
+});
+ +

Layer

+ +

The base class for all Leaflet layers that impliments basic shared methods and functionality. Can be extended to create custom layers by extending L.Layer and implimenting the onAdd and onRemove methods.

Implementing Custom Layers

@@ -6147,6 +5900,33 @@ draggable.enable();

Another thing to note is that you'll usually need to add leaflet-zoom-hide class to the DOM elements you create for the layer so that it hides during zoom animation. Implementing zoom animation for custom layers is a complex topic and will be documented separately in future, but meanwhile you can take a look at how it's done for Leaflet layers (e.g. ImageOverlay) in the source.

+

Methods

+ +

Every layer should extend from L.Layer and impliment the following methods:

+ + + + + + + + + + + + + + + + + + + + + + +
MethodReturnsDescription
onAdd(<Map> map)thisShould contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).
onRemove(<Map> map)thisShould contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
getEvents()ObjectThis optional method should return an object like { viewreset: this._reset }for addEventListener. These events will be automatically added and removed from the map with your layer.
+

Custom Layer Example

Here's how a custom layer implementation usually looks:

@@ -6176,7 +5956,7 @@ draggable.enable(); onRemove: function (map) { // remove layer's DOM elements and listeners - this.getPane().overlayPane.removeChild(this._el); + this.getPane().removeChild(this._el); }, _reset: function () { @@ -6189,9 +5969,82 @@ draggable.enable(); var myLayer = new MyCustomLayer(latlng).addTo(map); -

IControl

+

Inherited Options

-

Represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls.

+

Classes extending from L.Layer will also inherit the following options:

+ + + + + + + + + + + + + + +
OptionTypeDefault valueDescription
paneString'overlayPane'By default the layer will be added to the maps overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
+ +

Inherited Events

+ +

Classes extending from L.Layer will also fire the following events:

+ + + + + + + + + + + + + + + + + +
EventDataDescription
addEventFired after the layer is added to a map.
removeEventFired after the layer is removed from a map.
+ +

Inherited Methods

+ +

Classes extending from L.Layer will also inherit the following methods:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodReturnsDescription
addTo(<Map> map)thisAdds the layer to the given map.
removeFrom(<Map> map)thisRemoves the layer to the given map.
remove()thisRemoves the layer from the map it is currently active on.
getPane(<String> name?)HTMLElementReturns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.
+ +

Control

+ +

Controls represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls. Can be used to create custom controls by extending L.Control and implimenting the onAdd and onRemove methods.

Methods

@@ -6255,16 +6108,132 @@ map.addControl(new MyControl());
map.addControl(new MyControl('bar', {position: 'bottomleft'}));
+

Options

+ +

Classes extending from L.Control will also inherit the following options:

+ + + + + + + + + + + + + + +
OptionTypeDefaultDescription
positionString'topright'The initial position of the control (one of the map corners). See control positions.
+ +

Inherited Methods

+ +

Classes extending from L.Control will also inherit the following methods:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodReturnsDescription
setPosition( + <String> position ) + thisSets the position of the control. See control positions.
getPosition()StringReturns the current position of the control.
addTo( + <Map> map ) + thisAdds the control to the map.
removeFrom( + <Map> map ) + thisRemoves the control from the map.
getContainer()HTMLElementReturns the HTML container of the control.
+ +

Control Positions

+ +

Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

+ + + + + + + + + + + + + + + + + + + + + + +
PositionDescription
'topleft'Top left of the map.
'topright'Top right of the map.
'bottomleft'Bottom left of the map.
'bottomright'Bottom right of the map.
+

Handler

+

An interface implemented by interaction handlers.

-

IProjection

+ + + + + + + + + + + + + + + + + + + + + +
MethodReturnsDescription
enable()-Enables the handler.
disable()-Disables the handler.
enabled()BooleanReturns true if the handler is enabled.
+ +

Projection

An object with methods for projecting geographical coordinates of the world onto a flat surface (and back). See Map projection.

Methods

- +
@@ -6317,13 +6286,13 @@ map.addControl(new MyControl()); -

ICRS

+

CRS

Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back (and to coordinates in other units for WMS services). See Spatial reference system.

Methods

-
Method Returns
+
@@ -6375,7 +6344,7 @@ map.addControl(new MyControl());

Properties

-
Method Returns
+
@@ -6384,7 +6353,7 @@ map.addControl(new MyControl()); - + From f25f97a381729d9220843f59e07eda038261bd88 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Fri, 26 Dec 2014 15:25:11 -0800 Subject: [PATCH 16/58] remove interface references --- reference.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reference.html b/reference.html index 94bf9e5f..a8ece6e6 100644 --- a/reference.html +++ b/reference.html @@ -1790,7 +1790,7 @@ var map = L.map('map', {

TileLayer

-

Used to load and display tile layers on the map, implements ILayer interface.

+

Used to load and display tile layers on the map. Extends Layer.

Usage example

@@ -2237,7 +2237,7 @@ canvasTiles.drawTile = function(canvas, tilePoint, zoom) {

ImageOverlay

-

Used to load and display a single image over specific bounds of the map, implements ILayer interface.

+

Used to load and display a single image over specific bounds of the map. Extends Layer.

Usage example

@@ -3074,7 +3074,7 @@ map.fitBounds(bounds);

LayerGroup

-

Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.

+

Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Extends Layer.

L.layerGroup([marker1, marker2])
 	.addLayer(polyline)
@@ -3186,7 +3186,7 @@ map.fitBounds(bounds);

FeatureGroup

-

Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.

+

Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Extends Layer.

L.featureGroup([marker1, marker2, polyline])
 	.bindPopup('Hello world!')
@@ -6202,7 +6202,7 @@ map.addControl(new MyControl());
 
 
 

Handler

-

An interface implemented by interaction handlers.

+

Implemented by map interaction handlers.

Property Type
projectionIProjectionIProjection Projection that this CRS uses.
From 68308085fd7b32ba8ffabf7834d991fb187f7013 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 6 Mar 2015 12:48:46 +0200 Subject: [PATCH 17/58] impliment -> implement typo fixes --- reference.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference.html b/reference.html index a8ece6e6..a38465d2 100644 --- a/reference.html +++ b/reference.html @@ -5888,7 +5888,7 @@ MyEventedClass = L.Class.extend({

Layer

-

The base class for all Leaflet layers that impliments basic shared methods and functionality. Can be extended to create custom layers by extending L.Layer and implimenting the onAdd and onRemove methods.

+

The base class for all Leaflet layers that implements basic shared methods and functionality. Can be extended to create custom layers by extending L.Layer and implementing the onAdd and onRemove methods.

Implementing Custom Layers

@@ -5902,7 +5902,7 @@ MyEventedClass = L.Class.extend({

Methods

-

Every layer should extend from L.Layer and impliment the following methods:

+

Every layer should extend from L.Layer and implement the following methods:

@@ -6044,7 +6044,7 @@ var myLayer = new MyCustomLayer(latlng).addTo(map);

Control

-

Controls represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls. Can be used to create custom controls by extending L.Control and implimenting the onAdd and onRemove methods.

+

Controls represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls. Can be used to create custom controls by extending L.Control and implementing the onAdd and onRemove methods.

Methods

From 8ec0d3fdfc2ad3728ac7f089525cef0702d9c2d8 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Mon, 22 Dec 2014 08:18:59 -0800 Subject: [PATCH 18/58] remove multi shapes from ref, examples for polygon+polyline --- reference.html | 208 +++++++++++++++++-------------------------------- 1 file changed, 72 insertions(+), 136 deletions(-) diff --git a/reference.html b/reference.html index a38465d2..2e853a09 100644 --- a/reference.html +++ b/reference.html @@ -46,9 +46,7 @@ bodyclass: api-page
  • Path
  • Polyline
  • -
  • MultiPolyline
  • Polygon
  • -
  • MultiPolygon
  • Rectangle
  • Circle
  • CircleMarker
  • @@ -2614,6 +2612,33 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);

    Usage example

    // create a red polyline from an array of LatLng points
    +var latlngs = [
    +  [-122.68, 45.51],
    +  [-122.43, 37.77],
    +  [-118.2, 34.04]
    +];
    +
    +var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
    +
    +// zoom the map to the polyline
    +map.fitBounds(polyline.getBounds());
    + +

    You can also pass a multi-dimensional array to represent a MultiPolyline shape.

    + +
    // create a red polyline from an arrays  of arrays of LatLng points
    +var latlngs = [
    +	[
    +	  [-122.68, 45.51],
    +	  [-122.43, 37.77],
    +	  [-118.2, 34.04]
    +	],
    +	[
    +	  [-73.91, 40.78],
    +	  [-87.62, 41.83],
    +	  [-96.72, 32.76]
    +	]
    +]
    +
     var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
     
     // zoom the map to the polyline
    @@ -2634,7 +2659,7 @@ map.fitBounds(polyline.getBounds());
    -
+
Instantiates a polyline object given an array of geographical points and optionally an options object.Instantiates a polyline object given an array of geographical points and optionally an options object. You can create a a Polyline with multiple separate lines (MultiPolyline) by passing an array that contains arrays of geographic points.
@@ -2717,81 +2742,55 @@ map.fitBounds(polyline.getBounds()); - -

MultiPolyline

- -

Extends FeatureGroup to allow creating multi-polylines (single layer that consists of several polylines that share styling/popup).

- -

Creation

- - - - - - - - - - - - - - -
FactoryDescription
L.multiPolyline( - <LatLng[][]> latlngs, - <Polyline options> options? ) - Instantiates a multi-polyline object given an array of arrays of geographical points (one for each individual polyline) and optionally an options object.
- - -

Methods

- -

MultiPolylines accept all Polyline methods but -have different behavior around their coordinate contents since they can contain -multiple line features:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setLatLngs( - <LatLng[][]> latlngs ) - thisReplace all lines and their paths with the given array of arrays of - geographical points.
getLatLngs()<LatLng[][]> latlngs - Returns an array of arrays of geographical points in each line.
openPopup()thisOpens the popup previously bound by bindPopup.
toGeoJSON()ObjectReturns a GeoJSON representation of the multipolyline (GeoJSON MultiLineString Feature).
- - -

Polygon

A class for drawing polygon overlays on a map. Extends Polyline. Use Map#addLayer to add it to the map.

Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

+

Usage example

+
// create a red polygon from an arrays of LatLng points
+var latlngs = [
+  [ [-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41] ]
+];
+
+var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
+
+// zoom the map to the polygon
+map.fitBounds(polygon.getBounds());
+ +

You can also pass a array of arrays of latlngs, the first array represents the outer shape and the other arrays represent holes in the outer shape.

+ +
// create a red polygon from an arrays of LatLng points
+var latlngs = [
+  [ [-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41] ]
+  [ [-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29] ]
+];
+
+var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
+
+// zoom the map to the polygon
+map.fitBounds(polygon.getBounds());
+ +

You can also pass a multi-dimensional array to represent a MultiPolyline shape.

+ +
// create a red polygon from an arrays of arrays of LatLng points
+var latlngs = [
+  [
+    [ [-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41] ],
+    [ [-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29] ]
+  ],
+  [
+    [ [-109.05, 37],[-109.03, 41],[-102.05, 41],[-102.04, 37],[-109.05, 38] ]
+  ]
+]
+
+var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
+
+// zoom the map to the polygon
+map.fitBounds(polygon.getBounds());
+ +

Creation

@@ -2807,7 +2806,7 @@ multiple line features:

- +
Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside.Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside. You can create a a Polygon with multiple separate lines (MultiPolygon) by passing an array of Polygon coordinates.
@@ -2829,69 +2828,6 @@ multiple line features:

-

MultiPolygon

- -

Extends FeatureGroup to allow creating multi-polygons (single layer that consists of several polygons that share styling/popup).

- -

Creation

- - - - - - - - - - - - - -
FactoryDescription
L.multiPolygon( - <LatLng[][]> latlngs, - <Polyline options> options? ) - Instantiates a multi-polygon object given an array of latlngs arrays (one for each individual polygon) and optionally an options object (the same as for MultiPolyline).
- -

Methods

- -

MultiPolygons accept all Polyline methods but -have different behavior around their coordinate contents since they can contain -multiple polygon features:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setLatLngs( - <LatLng[][]> latlngs ) - thisReplace all polygons and their paths with the given array of arrays of - geographical points.
getLatLngs()<LatLng[][]> latlngs - Returns an array of arrays of geographical points in each polygon.
openPopup()thisOpens the popup previously bound by bindPopup.
toGeoJSON()ObjectReturns a GeoJSON representation of the multipolygon (GeoJSON MultiPolygon Feature).

Rectangle

From 4b0e4d7c5aa6f3c6201102ca817f54064d9ff980 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Mon, 22 Dec 2014 08:23:26 -0800 Subject: [PATCH 19/58] update default path options --- reference.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reference.html b/reference.html index 2e853a09..805436b2 100644 --- a/reference.html +++ b/reference.html @@ -2350,19 +2350,19 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); color String - '#03f' + '#3388ff' Stroke color. weight Number - 5 + 3 Stroke width in pixels. opacity Number - 0.5 + 1 Stroke opacity. @@ -2398,13 +2398,13 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); lineCap String - null + 'round' A string that defines shape to be used at the end of the stroke. lineJoin String - null + 'round' A string that defines shape to be used at the corners of the stroke. @@ -2417,7 +2417,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); pointerEvents String null - Sets the pointer-events attribute on the path if SVG backend is used. + Sets the pointer-events attribute on the path if SVG renderer is used. className From ceed74ba5068014875ba19af720b3c6520b86f68 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Mon, 22 Dec 2014 08:26:20 -0800 Subject: [PATCH 20/58] getCenter() docs --- reference.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reference.html b/reference.html index 805436b2..f0c60f09 100644 --- a/reference.html +++ b/reference.html @@ -2734,6 +2734,11 @@ map.fitBounds(polyline.getBounds()); LatLngBounds Returns the LatLngBounds of the polyline. + + getCenter() + LatLng + Returns the center (centroid) of the polyline. + toGeoJSON() Object From 98d83e5b921b3a96b023b1483c8cbd6f91de1f50 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Mon, 22 Dec 2014 08:28:45 -0800 Subject: [PATCH 21/58] flip Circle/CircleMarker inheritance --- reference.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference.html b/reference.html index f0c60f09..a1cfc3a7 100644 --- a/reference.html +++ b/reference.html @@ -2890,7 +2890,7 @@ map.fitBounds(bounds);

Circle

-

A class for drawing circle overlays on a map. Extends Path. Use Map#addLayer to add it to the map.

+

A class for drawing circle overlays on a map. Extends CircleMarker. Use Map#addLayer to add it to the map.

L.circle([50.5, 30.5], 200).addTo(map);
@@ -2959,7 +2959,7 @@ map.fitBounds(bounds);

CircleMarker

-

A circle of a fixed size with radius specified in pixels. Extends Circle. Use Map#addLayer to add it to the map.

+

A circle of a fixed size with radius specified in pixels. Extends Path. Use Map#addLayer to add it to the map.

Creation

From d7c6788211015cd97727576d813d5a405aa68f25 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Mon, 22 Dec 2014 08:50:35 -0800 Subject: [PATCH 22/58] renderer docs and methods --- reference.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/reference.html b/reference.html index a1cfc3a7..f806a103 100644 --- a/reference.html +++ b/reference.html @@ -212,6 +212,12 @@ var map = L.map('map', { L.CRS.
EPSG3857
Coordinate Reference System to use. Don't change this if you're not sure what it means. + + renderer + Renderer + depends + The default method for drawing vector layers on the map. L.SVG or L.Canvas by default depending on browser support. +

Interaction Options

@@ -879,6 +885,13 @@ var map = L.map('map', { this Removes the given control from the map. + getRenderer( + <ILayer> layer) + + + Renderer + Returns the renderer for the given layer. + @@ -2413,6 +2426,12 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); true If false, the vector will not emit mouse events and will act as a part of the underlying map. + + renderer + Renderer + depends + L.SVG or L.Canvas by default depending on browser support. + pointerEvents String From 62de364d2edba35e36726a3ee680a0cc592f5e17 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 6 Mar 2015 13:05:28 +0200 Subject: [PATCH 23/58] polygon/polyline docs fixes and cleanup --- reference.html | 73 ++++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/reference.html b/reference.html index f806a103..9987207f 100644 --- a/reference.html +++ b/reference.html @@ -2642,26 +2642,17 @@ var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map); // zoom the map to the polyline map.fitBounds(polyline.getBounds()); -

You can also pass a multi-dimensional array to represent a MultiPolyline shape.

+

You can also pass a multi-dimensional array to represent a MultiPolyline shape:

-
// create a red polyline from an arrays  of arrays of LatLng points
+
// create a red polyline from an array of arrays of LatLng points
 var latlngs = [
-	[
-	  [-122.68, 45.51],
-	  [-122.43, 37.77],
-	  [-118.2, 34.04]
-	],
-	[
-	  [-73.91, 40.78],
-	  [-87.62, 41.83],
-	  [-96.72, 32.76]
-	]
-]
-
-var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
-
-// zoom the map to the polyline
-map.fitBounds(polyline.getBounds());
+ [[-122.68, 45.51], + [-122.43, 37.77], + [-118.2, 34.04]], + [[-73.91, 40.78], + [-87.62, 41.83], + [-96.72, 32.76]] +];

Creation

@@ -2678,7 +2669,7 @@ map.fitBounds(polyline.getBounds()); - Instantiates a polyline object given an array of geographical points and optionally an options object. You can create a a Polyline with multiple separate lines (MultiPolyline) by passing an array that contains arrays of geographic points. + Instantiates a polyline object given an array of geographical points and optionally an options object. You can create a Polyline object with multiple separate lines (MultiPolyline) by passing an array of arrays of geographic points. @@ -2773,46 +2764,34 @@ map.fitBounds(polyline.getBounds());

Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

Usage example

-
// create a red polygon from an arrays of LatLng points
-var latlngs = [
-  [ [-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41] ]
-];
+
// create a red polygon from an array of LatLng points
+var latlngs = [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]];
 
 var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
 
 // zoom the map to the polygon
 map.fitBounds(polygon.getBounds());
-

You can also pass a array of arrays of latlngs, the first array represents the outer shape and the other arrays represent holes in the outer shape.

+

You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape:

-
// create a red polygon from an arrays of LatLng points
+

 var latlngs = [
-  [ [-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41] ]
-  [ [-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29] ]
-];
+  [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring
+  [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole
+];
-var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map); +

Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.

-// zoom the map to the polygon -map.fitBounds(polygon.getBounds());
- -

You can also pass a multi-dimensional array to represent a MultiPolyline shape.

- -
// create a red polygon from an arrays of arrays of LatLng points
+

 var latlngs = [
-  [
-    [ [-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41] ],
-    [ [-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29] ]
+  [ // first polygon
+    [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring
+    [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole
   ],
-  [
-    [ [-109.05, 37],[-109.03, 41],[-102.05, 41],[-102.04, 37],[-109.05, 38] ]
+  [ // second polygon
+    [[-109.05, 37],[-109.03, 41],[-102.05, 41],[-102.04, 37],[-109.05, 38]]
   ]
-]
-
-var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
-
-// zoom the map to the polygon
-map.fitBounds(polygon.getBounds());
+];

Creation

@@ -2830,7 +2809,7 @@ map.fitBounds(polygon.getBounds());
- Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside. You can create a a Polygon with multiple separate lines (MultiPolygon) by passing an array of Polygon coordinates. + Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside. You can create a a Polygon with multiple separate shapes (MultiPolygon) by passing an array of Polygon coordinates. From 62860ca4148e33f2dcf48eb7ae3344c97a7f0b03 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Mon, 29 Dec 2014 09:49:56 -0800 Subject: [PATCH 24/58] more layer docs --- reference-tpl.html | 2 +- reference.html | 1044 +++++++++++++++++++++++++++----------------- 2 files changed, 654 insertions(+), 392 deletions(-) diff --git a/reference-tpl.html b/reference-tpl.html index 82033923..8c789bf7 100644 --- a/reference-tpl.html +++ b/reference-tpl.html @@ -45,7 +45,7 @@ Description - [method]( argument, argument ) + [method](<type> argument, <type> argument) [return-type] [description] diff --git a/reference.html b/reference.html index 9987207f..b260d313 100644 --- a/reference.html +++ b/reference.html @@ -39,7 +39,6 @@ bodyclass: api-page

Vector Layers

@@ -58,6 +57,7 @@ bodyclass: api-page
  • LayerGroup
  • FeatureGroup
  • GeoJSON
  • +
  • GridLayer
  • Basic Types

      @@ -77,10 +77,11 @@ bodyclass: api-page
    -

    Events

    +

    Shared Methods

    Utility

      @@ -113,6 +114,7 @@ bodyclass: api-page

      Misc

        +
      • Event objects
      • global switches
      • noConflict
      • version
      • @@ -1008,6 +1010,20 @@ var map = L.map('map', { HTMLElement Returns the container element of the map. + + createPane( + <String> name, <HTMLElement> contianer? + ) + MapPane + Creates a pane with the given name. Created panes will be given a generated class based on the name like .leaflet-pane-name" + + + getPane( + <String> name + ) + MapPane + Returns the HTML element representing the named map pane. + getPanes() MapPanes @@ -1261,47 +1277,51 @@ var map = L.map('map', {

        Map Panes

        -

        An object literal (returned by map.getPanes) that contains different map panes that you can use to put your custom overlays in. The difference is mostly in zIndex order that such overlays get.

        +

        Panes are DOM elements used to control the ordering of layers on the map. You can access panes with map.getPane or map.getPanesmethods. New panes can be created with the map.createPane method.

        + +

        Every map has the following panes that differ only in zIndex.

        - + + + + - - - - - - - - - - + + + + + + + + +
        PropertyPane TypeZ Index Description
        mapPane HTMLElement'auto' Pane that contains all other map panes.
        tilePane HTMLElement2 Pane for tile layers.
        objectsPaneHTMLElementPane that contains all the panes except tile pane.
        shadowPaneHTMLElementPane for overlay shadows (e.g. marker shadows).
        overlayPane HTMLElement4 Pane for overlays like polylines and polygons.
        shadowPaneHTMLElement5Pane for overlay shadows (e.g. marker shadows).
        markerPane HTMLElement6 Pane for marker icons.
        popupPane HTMLElement7 Pane for popups.
        @@ -1309,7 +1329,7 @@ var map = L.map('map', {

        Marker

        -

        Used to put markers on the map.

        +

        Used to put markers on the map. Extends Layer.

        L.marker([50.5, 30.5]).addTo(map);
        @@ -1400,6 +1420,18 @@ var map = L.map('map', { 250 The z-index offset used for the riseOnHover feature. + + pane + String + 'markerPane' + Map pane where the markers icon will be added. + + + shadowPane + String + 'shadowPane' + Map pane where the markers shadow will be added. +

        Events

        @@ -1486,20 +1518,14 @@ var map = L.map('map', {

        Methods

        +

        In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        + - - - - - - @@ -1739,22 +1765,36 @@ var map = L.map('map', {
        Method Returns Description
        addTo( - <Map> map ) - thisAdds the marker to the map.
        getLatLng() LatLng
        +

        Events

        + + + + + + + + + + + + + + + + + +
        EventDataDescription
        addedPopupEventFired when the popup is added to the map.
        removedPopupEventFired when the popup is removed from the map.
        +

        Methods

        +

        In addition to shared layer methods like addTo() and remove() you can also use the following methods:

        + - - - - - - + + + + + + @@ -2004,6 +2050,11 @@ var map = L.map('map', { + + + + +
        Method Returns Description
        addTo( - <Map> map ) - thisAdds the popup to the map.
        openOn( <Map> map ) @@ -1830,9 +1870,9 @@ var map = L.map('map', {

        A string of the following form:

        -
        'http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png'
        +
        'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'
        -

        {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates.

        +

        {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates. {r} can be used to add @2x to the URL to load retina tiles.

        You can use custom keys in the template, which will be evaluated from TileLayer options, like this:

        @@ -1931,6 +1971,12 @@ var map = L.map('map', {
        null The explicit zIndex of the tile layer. Not set by default.
        updateIntervalNumber200Tiles will not update more then once every updateInterval.
        unloadInvisibleTiles BooleanTileEvent Fired when a tile is removed (e.g. when you have unloadInvisibleTiles on).
        tileerrorTileEventFired when there is an error loading a tile.

        Methods

        @@ -2175,77 +2226,6 @@ var map = L.map('map', { -

        TileLayer.Canvas

        - -

        Used to create Canvas-based tile layers where tiles get drawn on the browser side. Extends TileLayer.

        - -

        Usage example

        - -
        var canvasTiles = L.tileLayer.canvas();
        -
        -canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
        -	var ctx = canvas.getContext('2d');
        -	// draw something on the tile canvas
        -}
        - -

        Creation

        - - - - - - - - - - - - -
        FactoryDescription
        L.tileLayer.canvas( - <TileLayer options> options? ) - Instantiates a Canvas tile layer object given an options object (optionally).
        - -

        Options

        - - - - - - - - - - - - - -
        OptionTypeDefaultDescription
        asyncBooleanfalseIndicates that tiles will be drawn asynchronously. tileDrawn method should be called for each tile after drawing completion.
        - -

        Methods

        - - - - - - - - - - - - - - - - - -
        MethodReturnsDescription
        drawTile( - <HTMLCanvasElement> canvas, - <Point> tilePoint, - <Number> zoom ) - thisYou need to define this method after creating the instance to draw tiles; canvas is the actual canvas tile on which you can draw, tilePoint represents the tile numbers, and zoom is the current zoom.
        tileDrawn( <HTMLCanvasElement> canvas )-If async option is defined, this function should be called for each tile after drawing completion. canvas is the same canvas element, that was passed to drawTile.
        - -

        ImageOverlay

        Used to load and display a single image over specific bounds of the map. Extends Layer.

        @@ -2344,7 +2324,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);

        Path

        -

        An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly. +

        An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly. Extends Layer.

        Options

        @@ -2509,43 +2489,15 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);

        Methods

        + +

        In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Method Returns Description
        addTo( - <Map> map ) - thisAdds the layer to the map.
        bindPopup( - <String> html | <HTMLElement> el | <Popup> popup, - <Popup options> options? ) - thisBinds a popup with a particular HTML content to a click on this path.
        bindPopup( - <Popup> popup, - <Popup options> options? ) - thisBinds a given popup object to the path.
        unbindPopup()thisUnbinds the popup previously bound to the path with bindPopup.
        openPopup( <LatLng> latlng? ) @@ -2554,12 +2506,6 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); this Opens the popup previously bound by the bindPopup method in the given point, or in one of the path's points if not specified.
        closePopup()thisCloses the path's bound popup if it is opened.
        setStyle( <Path options> object ) @@ -2700,7 +2646,7 @@ var latlngs = [

        Methods

        -

        You can use Path methods and additionally the following methods:

        +

        In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        @@ -2815,7 +2761,7 @@ var latlngs = [

        Methods

        -

        Polygon has the same options and methods as Polyline, with the following differences:

        +

        In addition to Path methods like redraw() and bringToFront(), Polyline mehtods like setLatLngs() and getLatLngs(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        @@ -2867,7 +2813,7 @@ map.fitBounds(bounds);

        Methods

        -

        You can use Path methods and additionally the following methods:

        +

        In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        @@ -2914,6 +2860,8 @@ map.fitBounds(bounds);

        Methods

        +

        In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        +
        @@ -2980,6 +2928,8 @@ map.fitBounds(bounds);

        Methods

        +

        In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        +
        Method
        @@ -3153,8 +3103,6 @@ map.fitBounds(bounds);

        Methods

        -

        Has all layerGroup methods and additionally:

        -
        Method
        @@ -3400,8 +3348,216 @@ map.fitBounds(bounds);
        Method
        +

        GridLayer

        +

        Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces TileLayer.Canvas.

        +

        GridLayer can be extended to create a tiled grid of HTML Elements like <canvas>, <img> or <div>.GridLayer will handle creating and animating these DOM elements for you.

        + +

        Synchronous usage example

        + +

        To create a custom layer, extend GridLayer and impliment the createTile() method, which will be passed a Point object with the x, y, and z (zoom level) coordinates to draw your tile.

        + +
        var CanvasLayer = L.GridLayer.extend({
        +	createTile: function(coords){
        +		// create a <canvas> element for drawing
        +		var tile = L.DomUtil.create('canvas', 'leaflet-tile');
        +
        +		// setup tile width and height according to the options
        +		tile.width = tile.height = this.options.tileSize;
        +
        +		// get a canvas context and draw something on it using coords.x, coords.y and coords.z
        +		var ctx = canvas.getContext('2d');
        +
        +		// return the tile so it can be rendered on screen
        +		return tile;
        +	}
        +});
        + +

        Asyncronous usage example

        + +

        Tile creation can also be asyncronous, this is useful when using a third-party drawing library. Once the tile is finsihed drawing it can be passed to the done() callback.

        + +
        var CanvasLayer = L.GridLayer.extend({
        +	createTile: function(coords, done){
        +		var error;
        +
        +		// create a <canvas> element for drawing
        +		var tile = L.DomUtil.create('canvas', 'leaflet-tile');
        +
        +		// setup tile width and height according to the options
        +		tile.width = tile.height = this.options.tileSize;
        +
        +		// draw something and pass the tile to the done() callback
        +		done(error, tile);
        +	}
        +});
        + +

        Constructor

        + + + + + + + + + + +
        FactoryDescription
        L.gridLayer(<GridLayer options> options?)Creates a new instance of GridLayer with the supplied options.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefault valueDescription
        maxZoomNumber'tilePane'The map pane the layer will be added to.
        tileSizeNumber256Width and height of tiles in the grid. Can be used in the createTile() function.
        opacityNumber1Opacity of the tiles. Can be used in the createTile() function.
        unloadInvisibleTilesBooleandependsIf true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false.
        updateWhenIdleBooleandependsIf false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false.
        updateIntervalNumber200Tiles will not update more then once every updateInterval.
        zIndexNumbernullThe explicit zIndex of the tile layer. Not set by default.
        boundsLatLngBoundsnullIf set tiles will only be loaded inside inside the set LatLngBounds.
        boundsLatLngBoundsnullIf set tiles will only be loaded inside inside the set LatLngBounds.
        minZoomNumber0The minimum zoom level that tiles will be loaded at. By default the entire map.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        bringToFront()thisBrings the tile layer to the top of all tile layers.
        bringToBack()thisBrings the tile layer to the bottom of all tile layers.
        setOpacity( + <Number> opacity ) + thisChanges the opacity of the tile layer.
        setZIndex( + <Number> zIndex ) + thisSets the zIndex of the tile layer.
        redraw()thisCauses the layer to clear all the tiles and request them again.
        getContainer() + HTMLElementReturns the HTML element that contains the tiles for this layer.
        + +

        Events

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        loadingEventFired when the tile layer starts loading tiles.
        loadEventFired when the tile layer loaded all visible tiles.
        tileloadstartTileEventFired when a tile is requested and starts loading.
        tileloadTileEventFired when a tile loads.
        tileunloadTileEventFired when a tile is removed (e.g. when you have unloadInvisibleTiles on).
        tileerrorTileEventFired when there is an error loading a tile.

        LatLng

        @@ -4447,10 +4603,9 @@ L.control.layers(baseLayers, overlays).addTo(map);
        -

        Events methods

        -

        A set of methods shared between event-powered classes (like Map). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map 'click' event).

        +

        A set of methods shared between event-powered classes (like Map and Marker). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire 'click' event).

        Example

        @@ -4572,269 +4727,99 @@ map.off('click', onClick); -

        Event objects

        +

        Layer methods

        -

        Event object is an object that you receive as an argument in a listener function when some event is fired, containing useful information about that event. For example:

        +A set of methods inherited from the Layer base class that all Leaflet layers use. -
        map.on('click', function(e) {
        -	alert(e.latlng); // e is an event object (MouseEvent in this case)
        -});
        +
        var layer = L.Marker(latlng).addTo(map);
        +layer.addTo(map);
        +layer.remove();
        -

        Event

        +

        Methods

        -

        The base event object. All other event objects contain these properties too.

        - - +
        - - - + + + - - - + + + - - - - -
        propertytypedescriptionMethodReturnsDescription
        typeStringThe event type (e.g. 'click').addTo(<Map> map)thisAdds the layer to the given map.
        targetObjectThe object that fired the event.
        - -

        MouseEvent

        - - - - - - + + + - - - + + + - - - - - - - - - - - - - - -
        propertytypedescriptionremoveFrom(<Map> map)thisRemoves the layer to the given map.
        latlngLatLngThe geographical point where the mouse event occured.remove()thisRemoves the layer from the map it is currently active on.
        layerPointPointPixel coordinates of the point where the mouse event occured relative to the map layer.
        containerPointPointPixel coordinates of the point where the mouse event occured relative to the map сontainer.
        originalEventDOMMouseEventThe original DOM mouse event fired by the browser.
        - -

        LocationEvent

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        propertytypedescription
        latlngLatLngDetected geographical location of the user.
        boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
        accuracyNumberAccuracy of location in meters.
        altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
        altitudeAccuracyNumberAccuracy of altitude in meters.
        headingNumberThe direction of travel in degrees counting clockwise from true North.
        speedNumberCurrent velocity in meters per second.
        timestampNumberThe time when the position was acquired.
        - -

        ErrorEvent

        - - - - - - - - - - - - - - - - - -
        propertytypedescription
        messageStringError message.
        codeNumberError code (if applicable).
        - -

        LayerEvent

        - - - - - - - - - - - - -
        propertytypedescription
        layerILayerThe layer that was added or removed.
        - -

        LayersControlEvent

        - - - - - - - - - - - - - - - - - -
        propertytypedescription
        layerILayerThe layer that was added or removed.
        nameStringThe name of the layer that was added or removed.
        - -

        TileEvent

        - - - - - - - - - + - +
        propertytypedescription
        tilegetPane(<String> name?) HTMLElementThe tile element (image).Returns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.
        -

        ResizeEvent

        +

        Popup methods

        - - - - - - - - - - - - - - - - -
        propertytypedescription
        oldSizePointThe old size before resize event.
        newSizePointThe new size after the resize event.
        +A set of methods inherited from the Layer base class that all Leaflet layers use. These methods provide convieniant ways of binding popups to any layer. -

        GeoJSON event

        +
        var layer = L.Polgon(latlngs).bindPopup('Hi There!').addTo(map);
        +layer.openPopup();
        +layer.closePopup();
        +
        - - - - - - - - - - - - - - - - - - - - - - - - - - -
        propertytypedescription
        layerILayerThe layer for the GeoJSON feature that is being added to the map.
        propertiesObjectGeoJSON properties of the feature.
        geometryTypeStringGeoJSON geometry type of the feature.
        idStringGeoJSON ID of the feature (if present).
        +Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened. - - - +

        Methods

        +
        - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - +
        propertytypedescriptionMethodReturnsDescription
        popupbindPopup(<String|HTMLElement|Popup> content, <PopupOptions> options?)thisBinds the passed content to the layer and sets up the neccessary event listeners.
        unbindPopup()thisRemoves the popup previously bound with bindPopup.
        openPopup(LatLng latlng?)thisOpens the bound popup at the specificed latlng or at the default popup anchor if no latlng is passed.
        closePopup()thisCloses the popup if it is open.
        togglePopup()thisOpens or closes the popup depending on its current state.
        setPopupContent(<String|HTMLElement|Popup> content, <PopupOptions> options?)thisSets the content of the popup.
        getPopup() PopupThe popup that was opened or closed.Returns the popup bound to this layer.
        -

        DragEndEvent

        - - - - - - - - - - - - -
        propertytypedescription
        distanceNumberThe distance in pixels the draggable element was moved by.
        - - - -

        Browser

        A namespace with properties for browser/feature detection used by Leaflet internally.

        @@ -4953,10 +4938,8 @@ map.off('click', onClick);
        <Function> fn, <Object> obj ) - Function - - Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. Not a polyfill for ES 5 bind (compare L.bind to the MDN-recommended polyfill for Function.prototype.bind). + Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. stamp( <Object> obj ) @@ -4994,7 +4977,7 @@ map.off('click', onClick); falseFn() Function - Always returns false. + Returns a function which always returns false. formatNum( @@ -5315,6 +5298,7 @@ map.off('click', onClick);

        Utility functions to work with the DOM tree, used by Leaflet internally.

        +>>>>>>> more layer docs

        Methods

        @@ -5368,9 +5352,13 @@ map.off('click', onClick); - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1818,11 +1776,11 @@ var map = L.map('map', { - + @@ -3103,21 +3061,14 @@ map.fitBounds(bounds);

        Methods

        +

        In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        +
        BooleanReturns true if the element class attribute contains name.
        falseFn()FunctionAlways returns false.
        addClass( <HTMLElement> el, @@ -6343,6 +6331,280 @@ map.addControl(new MyControl());

        If you want to use some obscure CRS not listed here, take a look at the Proj4Leaflet plugin.

        +

        Event objects

        + +

        Event object is an object that you recieve as an argument in a listener function when some event is fired, containing useful information about that event. For example:

        + +
        map.on('click', function(e) {
        +	alert(e.latlng); // e is an event object (MouseEvent in this case)
        +});
        + +

        Event

        + +

        The base event object. All other event objects contain these properties too.

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        typeStringThe event type (e.g. 'click').
        targetObjectThe object that fired the event.
        + +

        MouseEvent

        + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        propertytypedescription
        latlngLatLngThe geographical point where the mouse event occured.
        layerPointPointPixel coordinates of the point where the mouse event occured relative to the map layer.
        containerPointPointPixel coordinates of the point where the mouse event occured relative to the map сontainer.
        originalEventDOMMouseEventThe original DOM mouse event fired by the browser.
        + +

        LocationEvent

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        propertytypedescription
        latlngLatLngDetected geographical location of the user.
        boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
        accuracyNumberAccuracy of location in meters.
        altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
        altitudeAccuracyNumberAccuracy of altitude in meters.
        headingNumberThe direction of travel in degrees counting clockwise from true North.
        speedNumberCurrent velocity in meters per second.
        timestampNumberThe time when the position was acquired.
        + +

        ErrorEvent

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        messageStringError message.
        codeNumberError code (if applicable).
        + +

        LayerEvent

        + + + + + + + + + + + + +
        propertytypedescription
        layerILayerThe layer that was added or removed.
        + +

        LayersControlEvent

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        layerILayerThe layer that was added or removed.
        nameStringThe name of the layer that was added or removed.
        + +

        TileEvent

        + + + + + + + + + + + + +
        propertytypedescription
        tileHTMLElementThe tile element (image).
        + +

        TileErrorEvent

        + + + + + + + + + + + + +
        propertytypedescription
        tileHTMLElementThe tile element (image).
        + +

        ResizeEvent

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        oldSizePointThe old size before resize event.
        newSizePointThe new size after the resize event.
        + +

        GeoJSON event

        + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        propertytypedescription
        layerILayerThe layer for the GeoJSON feature that is being added to the map.
        propertiesObjectGeoJSON properties of the feature.
        geometryTypeStringGeoJSON geometry type of the feature.
        idStringGeoJSON ID of the feature (if present).
        + + + + + + + + + + + + + + +
        propertytypedescription
        popupPopupThe popup that was opened or closed.
        + +

        DragEndEvent

        + + + + + + + + + + + + +
        propertytypedescription
        distanceNumberThe distance in pixels the draggable element was moved by.

        Global Switches

        From e708fbc94bd65cd0118bacc6da495a3eb0c72629 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 6 Mar 2015 13:42:58 +0200 Subject: [PATCH 25/58] clean up docs merges --- reference.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference.html b/reference.html index b260d313..8d749ab1 100644 --- a/reference.html +++ b/reference.html @@ -5787,7 +5787,7 @@ MyClass.FOO; // 'bar'

        Evented

        -

        When creating a plugin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-related methods like on, off and fire

        +

        When creating a plugin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-related methods like on, off and fire

        MyEventedClass = L.Evented.extend({
         	fire: function(){
        
        From acd56a00961df63ba5fd165c0e13c4050244dd71 Mon Sep 17 00:00:00 2001
        From: Patrick Arlt 
        Date: Sat, 28 Mar 2015 19:00:21 -0700
        Subject: [PATCH 26/58] remove shared methods from method lists
        
        ---
         reference.html | 71 +++++++++-----------------------------------------
         1 file changed, 13 insertions(+), 58 deletions(-)
        
        diff --git a/reference.html b/reference.html
        index 8d749ab1..dc626760 100644
        --- a/reference.html
        +++ b/reference.html
        @@ -1569,48 +1569,6 @@ var map = L.map('map', {
         		
        this Updates the marker position, useful if coordinates of its latLng object were changed directly.
        bindPopup( - <String> html | <HTMLElement> el | <Popup> popup, - <Popup options> options? ) - thisBinds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.
        unbindPopup()thisUnbinds the popup previously bound to the marker with bindPopup.
        openPopup()thisOpens the popup previously bound by the bindPopup method.
        getPopup()PopupReturns the popup previously bound by the bindPopup method.
        closePopup()thisCloses the bound popup of the marker if it's opened.
        togglePopup()thisToggles the popup previously bound by the bindPopup method.
        setPopupContent( - <String> html | <HTMLElement> el ) - thisSets an HTML content of the popup of this marker.
        toGeoJSON() Object
        setContent( - <String|HTMLElement> htmlContent ) + <String|HTMLElement|Function> htmlContent ) thisSets the HTML content of the popup.Sets the HTML content of the popup. If a function is passed the source layer will be passed to the function. The function should return a String or HTMLElement to be used in the popup.
        getContent()
        - - - - - - @@ -3202,10 +3153,9 @@ map.fitBounds(bounds);
        L.geoJson(data, {
         	style: function (feature) {
         		return {color: feature.properties.color};
        -	},
        -	onEachFeature: function (feature, layer) {
        -		layer.bindPopup(feature.properties.description);
         	}
        +}).bindPopup(function (layer) {
        +	return layer.feature.properties.description;
         }).addTo(map);

        Each feature layer created by it gets a feature property that links to the GeoJSON feature data the layer was created from (so that you can access its properties later).

        @@ -3278,6 +3228,8 @@ map.fitBounds(bounds);

        Methods

        +

        In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

        +
        Method Returns Description
        bindPopup( - <String> htmlContent, - <Popup options> options? ) - thisBinds a popup with a particular HTML content to a click on any layer from the group that has a bindPopup method.
        getBounds() LatLngBounds
        @@ -4784,9 +4736,12 @@ Popups will also be automatically opened when the layer is clicked on and closed - + - + +
        featureGroup.bindPopup(function(layer){
        +	return "a unique template for this layer.";
        +});
        From 7b7b56622f1d6346e3fcede196927c64a0311a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 22 Apr 2015 23:10:14 +0200 Subject: [PATCH 27/58] Add flyTo() and flyToBounds() to the API reference --- reference.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/reference.html b/reference.html index dc626760..16d23093 100644 --- a/reference.html +++ b/reference.html @@ -739,6 +739,23 @@ var map = L.map('map', { + + + + + + + + + +
        MethodDescription
        bindPopup(<String|HTMLElement|Popup> content, <PopupOptions> options?)bindPopup(<String|HTMLElement|Function|Popup> content, <PopupOptions> options?) thisBinds the passed content to the layer and sets up the neccessary event listeners.Binds the passed content to the layer and sets up the neccessary event listeners. If a Function is passed the function will recive a layer as the first argument and should return a String or HTMLElement.
        unbindPopup()this Destroys the map and clears all related event listeners.
        flyTo( + <LatLng> latlng, + <Number> zoom?, + <zoom/pan options> options? ) + thisSets the view of the map (geographical center and zoom) performing a smooth pan-zoom animation.
        flyToBounds( + <LatLngBounds> bounds, + <fitBounds options> options? ) + thisSets the view of the map with a smooth animation like flyTo, but takes a bounds parameter like fitBounds.

        Methods for Getting Map State

        From f947853f3b8bdf70b002c9c5b6b5dcd74bf951b3 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 8 May 2015 18:21:25 +0200 Subject: [PATCH 28/58] Update L.Polyline.addLatLng doc --- reference.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reference.html b/reference.html index 16d23093..aab82817 100644 --- a/reference.html +++ b/reference.html @@ -2631,11 +2631,12 @@ var latlngs = [ addLatLng( -
        <LatLng> latlng ) + <LatLng> latlng, + <LatLng[]> latlngs ) this - Adds a given point to the polyline. + Adds a given point to the polyline. By default, adds to the first ring of the polyline in case of a multi-polyline, but can be overriden passing another LatLngs group with latlngs parameter. setLatLngs( From 86c0649d443267828a94d9fe463657850d1db96f Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 8 May 2015 18:39:39 +0200 Subject: [PATCH 29/58] More L.Polyline doc on LatLng related methods --- reference.html | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/reference.html b/reference.html index aab82817..ff155bbf 100644 --- a/reference.html +++ b/reference.html @@ -2636,7 +2636,7 @@ var latlngs = [ this - Adds a given point to the polyline. By default, adds to the first ring of the polyline in case of a multi-polyline, but can be overriden passing another LatLngs group with latlngs parameter. + Adds a given point to the polyline. By default, adds to the first ring of the polyline in case of a multi-polyline, but can be overridden by passing a specific ring as a LatLng array (that you can earlier access with getLatLngs). setLatLngs( @@ -2649,17 +2649,7 @@ var latlngs = [ getLatLngs() LatLng[] - Returns an array of the points in the path. - - - spliceLatLngs( - <Number> index, - <Number> pointsToRemove, - <LatLng> latlng?, … ) - - - LatLng[] - Allows adding, removing or replacing points in the polyline. Syntax is the same as in Array#splice. Returns the array of removed points (if any). + Returns an array of the points in the path, or nested arrays of points in case of multi-polyline. getBounds() From 08afc5a10409c098ede0f0e9dbd6ffba0b0e08a2 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 9 May 2015 23:08:39 +0200 Subject: [PATCH 30/58] Add Polyline.isEmpty to the doc --- reference.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reference.html b/reference.html index ff155bbf..f75adf91 100644 --- a/reference.html +++ b/reference.html @@ -2651,6 +2651,11 @@ var latlngs = [ LatLng[] Returns an array of the points in the path, or nested arrays of points in case of multi-polyline. + + isEmpty() + Boolean + Returns true if the Polyline has no LatLng. + getBounds() LatLngBounds From f15fd92bd3afe549ac7695650b3bb0a56fba5850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 3 Jun 2015 22:33:50 +0200 Subject: [PATCH 31/58] Documentation for maxBoundsViscosity (see #3510) --- reference.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/reference.html b/reference.html index f75adf91..472483cb 100644 --- a/reference.html +++ b/reference.html @@ -206,8 +206,14 @@ var map = L.map('map', { maxBounds LatLngBounds null - When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method - + When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method. + + + maxBoundsViscosity + Number + 0.0 + If maxBounds is set, this options will control how solid the bounds are when dragging the map around. The default value of 0.0 allows the user to drag outside the bounds at normal speed, higher values will slow down map dragging outside bounds, and 1.0 makes the bounds fully solid, preventing the user from dragging outside the bounds. + crs CRS From 2396b9714380962e1d48b02a72b4178de75a2c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Thu, 4 Jun 2015 14:31:03 +0200 Subject: [PATCH 32/58] Document Bounds.overlap and LatLngBounds.overlap (see #3508) --- reference.html | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/reference.html b/reference.html index 472483cb..38b5fe3c 100644 --- a/reference.html +++ b/reference.html @@ -3778,7 +3778,15 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle intersects the given bounds. + Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. + + + overlaps( + <LatLngBounds> otherBounds ) + + + Boolean + Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. equals( @@ -4052,7 +4060,15 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle intersects the given bounds. + Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. + + + overlaps( + <Bounds> otherBounds ) + + + Boolean + Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. isValid() From 745cad469fc1307036935cb0416bae5bab980a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Mon, 8 Jun 2015 13:39:34 +0200 Subject: [PATCH 33/58] Miscellaneous bits of documentation (see #3098) --- reference.html | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/reference.html b/reference.html index 38b5fe3c..57eac7c5 100644 --- a/reference.html +++ b/reference.html @@ -3600,11 +3600,12 @@ map.panTo(L.latLng(50, 30)); equals( - <LatLng> otherLatlng ) + <LatLng> otherLatlng, + <Number> maxMargin? ) Boolean - Returns true if the given LatLng point is at the same position (within a small margin of error). + Returns true if the given LatLng point is at the same position (within a small margin of error). The margin of error can be overriden by setting maxMargin to a small number. toString() @@ -3933,6 +3934,11 @@ map.panBy(L.point(200, 300)); Point Returns a copy of the current point with floored coordinates (rounded down). + + ceil() + Point + Returns a copy of the current point with ceiled coordinates (rounded up). + equals( <Point> otherPoint ) @@ -4926,10 +4932,13 @@ Popups will also be automatically opened when the layer is clicked on and closed bind( <Function> fn, - <Object> obj ) + <Object> obj, + <Any> arg1?, + <Any> arg2?, + <Any> arg3?, … ) Function - Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. + Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). The arguments received by the bound function will be any arguments passed when binding the function, followed by any arguments passed when invoking the bound function. Has an L.bind shortcut. Works exactly like Function.prototype.bind in modern browsers compliant with ECMAScript 5. stamp( <Object> obj ) @@ -4978,6 +4987,16 @@ Popups will also be automatically opened when the layer is clicked on and closed Number Returns the number num rounded to digits decimals. + + wrapNum( + <Number> num, + <Array> range, + <Boolean> includeMax ) + + + Number + Returns the number num modulo range in such a way so it lies within range[0] and range[1]. The returned value will be always smaller than range[1] unless includeMax is set to true. + splitWords( <String> str ) @@ -5369,6 +5388,25 @@ Popups will also be automatically opened when the layer is clicked on and closed Removes name from the element's class attribute. + + getClass( + <Element> el ) + + + <String> + + Returns the element's CSS class (for HTML elements) or SVG class (for SVG elements). + + + setClass( + <HTMLElement> el, + <String> name ) + + + - + + Sets the element's CSS class (for HTML elements) or SVG class (for SVG elements). + setOpacity( <HTMLElement> el, From 3c177564f6b97034ff248b955b421fa9eee0d373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 10 Jun 2015 12:43:56 +0200 Subject: [PATCH 34/58] Bits of documentation for L.DomEvent and L.DomUtil (see #3098) --- reference.html | 72 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/reference.html b/reference.html index 57eac7c5..ee394994 100644 --- a/reference.html +++ b/reference.html @@ -5224,25 +5224,46 @@ Popups will also be automatically opened when the layer is clicked on and closed Description - addListener( + on( <HTMLElement> el, - <String> type, + <String> types, <Function> fn, <Object> context? ) this - Adds a listener fn to the element's DOM event of the specified type. this keyword inside the listener will point to context, or to the element if not specified. + Adds a listener fn to the element's DOM events. types is a space-separated list of DOM event types to listen to. this keyword inside the listener will point to context, or to the element if not specified. - removeListener( + addListener( <HTMLElement> el, - <String> type, + <String> types, + <Function> fn, + <Object> context? ) + + + this + Alias for DomEvent.on. + + + off( + <HTMLElement> el, + <String> types, <Function> fn ) this - Removes an event listener from the element. + Removes the event listener fn from the element, for the DOM event types in types (a space-separated list). fn must be equal to the function currently listening to the event for it to be removed. + + + removeListener( + <HTMLElement> el, + <String> types, + <Function> fn ) + + + this + Alias for DomEvent.off. stopPropagation( @@ -5344,6 +5365,20 @@ Popups will also be automatically opened when the layer is clicked on and closed Creates an element with tagName, sets the className, and optionally appends it to container element. + + remove( + <HTMLElement> el ) + + - + Removes el from its parent element. + + + empty( + <HTMLElement> el ) + + - + Removes all of el's children elements from el. + disableTextSelection() - @@ -5425,31 +5460,22 @@ Popups will also be automatically opened when the layer is clicked on and closed Goes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform. - getTranslateString( - <Point> point ) + setTransform( + <HTMLElement> el, + <Point> offset, + <Number> scale? ) - - String - Returns a CSS transform string to move an element by the offset provided in the given point. Uses 3D translate on WebKit for hardware-accelerated transforms and 2D on other browsers. - - - getScaleString( - <Number> scale, - <Point> origin ) - - - String - Returns a CSS transform string to scale an element (with the given scale origin). + - + Resets the 3D CSS transform of el so it is translated by offset and optionally scaled by scale. Does not have an effect if the browser doesn't support 3D CSS transforms. setPosition( <HTMLElement> el, - <Point> point, - <Boolean> disable3D? ) + <Point> point ) - - Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true. + Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). getPosition( From b64655535ad06fd4d58284171e70402a04066def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 10 Jun 2015 13:07:12 +0200 Subject: [PATCH 35/58] Bits of documentation for L.DomUtil's methods used internally --- reference.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/reference.html b/reference.html index ee394994..79eceab9 100644 --- a/reference.html +++ b/reference.html @@ -5485,6 +5485,28 @@ Popups will also be automatically opened when the layer is clicked on and closed Point Returns the coordinates of an element previously positioned with setPosition. + + disableImageDrag() + - + Prevents the user from generating dragstart DOM events, usually generated when the user drags an image. Used internally by Leaflet to override the behaviour of any click-and-drag interaction on the map. Affects drag interactions on the whole document. + + + enableImageDrag() + - + Cancels the effects of a previous L.DomUtil.disableImageDrag. + + + preventOutline( + <HTMLElement> el ) + + - + Makes the outline of the element el invisible. Used internally by Leaflet to prevent focusable elements from displaying an outline when the user performs a drag interaction on them. + + + restoreOutline() + - + Cancels the effects of a previous L.DomUtil.preventOutline. +

        Properties

        From fdddb648e8e7b9ed2223983d87350341f9d205c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 10 Jun 2015 13:13:16 +0200 Subject: [PATCH 36/58] Cleanup L.DomUtil docs (see #3098). --- reference.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reference.html b/reference.html index 79eceab9..e51ddf97 100644 --- a/reference.html +++ b/reference.html @@ -5249,17 +5249,19 @@ Popups will also be automatically opened when the layer is clicked on and closed off( <HTMLElement> el, <String> types, - <Function> fn ) + <Function> fn, + <Object> context? ) this - Removes the event listener fn from the element, for the DOM event types in types (a space-separated list). fn must be equal to the function currently listening to the event for it to be removed. + Removes the event listener fn from the element, for the DOM event types in types (a space-separated list). Both fn and context must be equal to the function and context used previously on a L.DomEvent.on call. removeListener( <HTMLElement> el, <String> types, - <Function> fn ) + <Function> fn, + <Object> context? ) this From 7192bde5f9a318a474a4bf5fa9bc5cead0ef3473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 10 Jun 2015 15:17:27 +0200 Subject: [PATCH 37/58] Misc docs: Evented aliases, deprecated LatLng stuff, Util.throttle. See #3098. --- reference.html | 91 ++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 58 deletions(-) diff --git a/reference.html b/reference.html index e51ddf97..437b97fe 100644 --- a/reference.html +++ b/reference.html @@ -3623,36 +3623,6 @@ map.panTo(L.latLng(50, 30));
        -

        Constants

        - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ConstantTypeValueDescription
        DEG_TO_RADNumberMath.PI / 180A multiplier for converting degrees into radians.
        RAD_TO_DEGNumber180 / Math.PIA multiplier for converting radians into degrees.
        MAX_MARGINNumber1.0E-9Max margin of error for the equality check.
        - -

        LatLngBounds

        @@ -4621,7 +4591,7 @@ map.off('click', onClick);
        Description - addEventListener( + on( <String> type, <Function> fn, <Object> context? ) @@ -4631,7 +4601,7 @@ map.off('click', onClick); Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). - addOneTimeEventListener( + once( <String> type, <Function> fn, <Object> context? ) @@ -4641,7 +4611,7 @@ map.off('click', onClick); The same as above except the listener will only get fired once and then removed. - addEventListener( + on( <Object> eventMap, <Object> context? ) @@ -4650,17 +4620,17 @@ map.off('click', onClick); Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - removeEventListener( + off( <String> type, <Function> fn?, <Object> context? ) this - Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to addEventListener, you must pass the same context to removeEventListener in order to remove the listener. + Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener. - removeEventListener( + off( <Object> eventMap, <Object> context? ) @@ -4669,21 +4639,21 @@ map.off('click', onClick); Removes a set of type/listener pairs. - removeEventListener() + off() this - Removes all listeners. An alias to clearAllEventListeners when you use it without arguments. + Removes all listeners to all events on the object. - hasEventListeners( + listens( <String> type ) Boolean - Returns true if a particular event type has some listeners attached to it. + Returns true if a particular event type has any listeners attached to it. - fireEvent( + fire( <String> type, <Object> data? ) @@ -4691,31 +4661,36 @@ map.off('click', onClick); this Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. + + addEventListener( … ) + this + Alias to on. + + + addOneTimeEventListener( … ) + this + Alias to once. + + + removeEventListener( … ) + this + Alias to off. + clearAllEventListeners() this - Removes all listeners to all events on the object. + Alias to off(). - on( … ) + hasEventListeners( … ) this - Alias to addEventListener. + Alias to listens. - once( … ) + fireEvent( … ) this - Alias to addOneTimeEventListener. - - - off( … ) - this - Alias to removeEventListener. - - - fire( … ) - this - Alias to fireEvent. + Alias to fire. @@ -4963,14 +4938,14 @@ Popups will also be automatically opened when the layer is clicked on and closed Cancels a previous request to requestAnimFrame. - limitExecByInterval( + throttle( <Function> fn, <Number> time, <Object> context? ) Function - Returns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time, but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called. + Returns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time (in milliseconds), but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called. From 2f287ba1dd4da88ce5a7663ae10919e0c6d1f8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 10 Jun 2015 17:30:34 +0200 Subject: [PATCH 38/58] More consistency between L.Evented and L.DomEvent docs. (see #3098) --- reference.html | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/reference.html b/reference.html index 437b97fe..c3e1bda4 100644 --- a/reference.html +++ b/reference.html @@ -5207,18 +5207,18 @@ Popups will also be automatically opened when the layer is clicked on and closed this - Adds a listener fn to the element's DOM events. types is a space-separated list of DOM event types to listen to. this keyword inside the listener will point to context, or to the element if not specified. + + Adds a listener function (fn) to a particular DOM event type of the element el. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). - addListener( + on( <HTMLElement> el, - <String> types, - <Function> fn, + <Object> eventMap, <Object> context? ) this - Alias for DomEvent.on. + Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} off( @@ -5229,7 +5229,28 @@ Popups will also be automatically opened when the layer is clicked on and closed this - Removes the event listener fn from the element, for the DOM event types in types (a space-separated list). Both fn and context must be equal to the function and context used previously on a L.DomEvent.on call. + + Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular DOM event from the element. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener. + + + off( + <HTMLElement> el, + <Object> eventMap, + <Object> context? ) + + + this + Removes a set of type/listener pairs. + + addListener( + <HTMLElement> el, + <String> types, + <Function> fn, + <Object> context? ) + + + this + Alias to on. removeListener( @@ -5240,7 +5261,7 @@ Popups will also be automatically opened when the layer is clicked on and closed this - Alias for DomEvent.off. + Alias to off. stopPropagation( From 30233fba26849185c0787892536b319b1749ceed Mon Sep 17 00:00:00 2001 From: Per Liedman Date: Tue, 9 Jun 2015 20:42:53 +0200 Subject: [PATCH 39/58] Document Projection bounds property --- reference.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/reference.html b/reference.html index c3e1bda4..d662ac38 100644 --- a/reference.html +++ b/reference.html @@ -6232,6 +6232,21 @@ map.addControl(new MyControl());

        An object with methods for projecting geographical coordinates of the world onto a flat surface (and back). See Map projection.

        +

        Properties

        + + + + + + + + + + + + +
        PropertyTypeDescription
        boundsLatLngBoundsThe bounds where the projection is valid
        +

        Methods

        From 41315ecf800fcf97dd75baad9b1590e97cc76b19 Mon Sep 17 00:00:00 2001 From: Per Liedman Date: Tue, 9 Jun 2015 21:04:55 +0200 Subject: [PATCH 40/58] Document CRS wrapLat, wrapLng, infinite and getProjectedBounds --- reference.html | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/reference.html b/reference.html index d662ac38..9d83777e 100644 --- a/reference.html +++ b/reference.html @@ -6234,7 +6234,7 @@ map.addControl(new MyControl());

        Properties

        -
        +
        @@ -6349,12 +6349,12 @@ map.addControl(new MyControl()); - - - + +
        Property TypeReturns the scale used when transforming projected coordinates into pixel coordinates for a particular zoom. For example, it returns 256 * 2^zoom for Mercator-based CRS.
        getSize( + getProjectedBounds( <Number> zoom ) PointReturns the size of the world in pixels for a particular zoom.BoundsReturns the projection's bounds scaled and transformed for the provided zoom.
        @@ -6385,6 +6385,21 @@ map.addControl(new MyControl()); String Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857'). + + wrapLat + Number[] + Latitude bounds, lower followed by upper, at which latitudes should wrap around, or null to disable wrapping + + + wrapLng + Number[] + Longitude bounds, lower followed by upper, at which longitudes should wrap around, or null to disable wrapping + + + infinite + Boolean + true if the CRS bounds should be ignored; coordinates in an infinite CRS will not be wrapped +

        Defined CRS

        From 7e3a82d4a3ee3061ff38e59fe72da05b967684b7 Mon Sep 17 00:00:00 2001 From: Per Liedman Date: Tue, 9 Jun 2015 21:15:07 +0200 Subject: [PATCH 41/58] Document Map getPixelWorldBounds --- reference.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reference.html b/reference.html index 9d83777e..95d8649a 100644 --- a/reference.html +++ b/reference.html @@ -822,6 +822,14 @@ var map = L.map('map', { Point Returns the projected pixel coordinates of the top left point of the map layer (useful in custom layer and overlay implementations). + + getPixelWorldBounds( + <Number> zoom? ) + + Bounds + Returns the world's bounds in pixel coordinates for zoom level zoom. If zoom is omitted, the map's + current zoom is used. +

        Methods for Layers and Controls

        From d6336dc7ebc92912cdd9f724a1054d473b39b199 Mon Sep 17 00:00:00 2001 From: Per Liedman Date: Tue, 9 Jun 2015 22:39:07 +0200 Subject: [PATCH 42/58] Document CRS unproject --- reference.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reference.html b/reference.html index 95d8649a..e4f92ee2 100644 --- a/reference.html +++ b/reference.html @@ -6348,6 +6348,14 @@ map.addControl(new MyControl()); Point Projects geographical coordinates into coordinates in units accepted for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). + + unproject( + <Point> point ) + + + LatLng + Given a projected coordinate returns the corresponding LatLng. The inverse of project. + scale( <Number> zoom ) From 6e1e54c9c8b9f147c2cf9285a99aa302f6ddc65d Mon Sep 17 00:00:00 2001 From: Per Liedman Date: Tue, 9 Jun 2015 22:48:15 +0200 Subject: [PATCH 43/58] Document CRS and Map wrapLatLng --- reference.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/reference.html b/reference.html index e4f92ee2..cbab7a50 100644 --- a/reference.html +++ b/reference.html @@ -1026,6 +1026,14 @@ var map = L.map('map', { LatLng Returns the geographical coordinates of the point the mouse clicked on given the click's event object. + + wrapLatLng( + <LatLng> latlng ) + + + LatLng + Returns a LatLng where lat and lng has been wrapped according to the map's CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds. +

        Other Methods

        @@ -6372,6 +6380,14 @@ map.addControl(new MyControl()); Bounds Returns the projection's bounds scaled and transformed for the provided zoom. + + wrapLatLng( + <LatLng> latlng ) + + + LatLng + Returns a LatLng where lat and lng has been wrapped according to the CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds. +

        Properties

        From e28c59f41d496fa0dd1b24feeec4d42d79f24fd6 Mon Sep 17 00:00:00 2001 From: Per Liedman Date: Wed, 10 Jun 2015 21:41:21 +0200 Subject: [PATCH 44/58] Document L.CRS.Earth --- reference.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reference.html b/reference.html index cbab7a50..5ddabb20 100644 --- a/reference.html +++ b/reference.html @@ -6443,6 +6443,13 @@ map.addControl(new MyControl()); Projection Description + + L.CRS.Earth + + Serves as the base for CRS that are global such that they cover the earth. Can only be used as the base for + other CRS and cannot be used directly, since it does not have a code, projection or + transformation. + L.CRS.EPSG3857 From 4bc3a7708cf1abda627f092afc92a62bf93c799d Mon Sep 17 00:00:00 2001 From: Per Liedman Date: Wed, 10 Jun 2015 22:05:09 +0200 Subject: [PATCH 45/58] Document Map and CRS distance --- reference.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/reference.html b/reference.html index 5ddabb20..287115ca 100644 --- a/reference.html +++ b/reference.html @@ -1034,6 +1034,15 @@ var map = L.map('map', { LatLng Returns a LatLng where lat and lng has been wrapped according to the map's CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds. + + distance( + <LatLng> latlng1, + <LatLng> latlng2 ) + + + LatLng + Returns the distance in meters between two geographic coordinates in the map's CRS. +

        Other Methods

        @@ -6380,6 +6389,15 @@ map.addControl(new MyControl()); Bounds Returns the projection's bounds scaled and transformed for the provided zoom. + + distance( + <LatLng> latlng1, + <LatLng> latlng2 ) + + + Number + Returns the distance in meters between two geographic coordinates in this CRS. + wrapLatLng( <LatLng> latlng ) From f2673ff0d97c463fbfa4e8c288618c7d7c243810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Tue, 30 Jun 2015 15:07:27 +0200 Subject: [PATCH 46/58] Document changes introduced by non-square tiles in #3570/#3573. --- reference.html | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/reference.html b/reference.html index 287115ca..fd9f4a7f 100644 --- a/reference.html +++ b/reference.html @@ -3360,7 +3360,9 @@ map.fitBounds(bounds); var tile = L.DomUtil.create('canvas', 'leaflet-tile'); // setup tile width and height according to the options - tile.width = tile.height = this.options.tileSize; + var size = this.getTileSize(); + tile.width = size.x; + tile.height = size.y; // get a canvas context and draw something on it using coords.x, coords.y and coords.z var ctx = canvas.getContext('2d'); @@ -3382,7 +3384,9 @@ map.fitBounds(bounds);
        var tile = L.DomUtil.create('canvas', 'leaflet-tile'); // setup tile width and height according to the options - tile.width = tile.height = this.options.tileSize; + var size = this.getTileSize(); + tile.width = size.x; + tile.height = size.y; // draw something and pass the tile to the done() callback done(error, tile); @@ -3419,9 +3423,9 @@ map.fitBounds(bounds);
        tileSize - Number + Number or Point 256 - Width and height of tiles in the grid. Can be used in the createTile() function. + Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise. opacity @@ -3513,6 +3517,12 @@ map.fitBounds(bounds);
        HTMLElement Returns the HTML element that contains the tiles for this layer. + + getTileSize() + + Point + Normalizes the tileSize option into a point. Used by the createTile() method. +

        Events

        @@ -3906,6 +3916,22 @@ map.panBy(L.point(200, 300));
        Point Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. + + scaleBy( + <Point> scale ) + + + Point + Multiply each coordinate of the current point by each coordinate of scale. In linear algebra terms, multiply the point by the scaling matrix defined by scale. + + + unscaleBy( + <Point> otherPoint ) + + + Point + Inverse of multiplyCoordinates. Divide each coordinate of the current point by each coordinate of scale. + distanceTo( <Point> otherPoint ) From 416a22747c7e02df74bb275f9d86315792a566eb Mon Sep 17 00:00:00 2001 From: Alex Paterson Date: Fri, 3 Jul 2015 11:37:09 +0100 Subject: [PATCH 47/58] Added Leaflet.EdgeBuffer to plugins.md --- plugins.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins.md b/plugins.md index f32a4153..756614d6 100644 --- a/plugins.md +++ b/plugins.md @@ -436,6 +436,15 @@ The following plugins change the way that tile layers are loaded into the map. Eric Brelsford + + + Leaflet.EdgeBuffer + + Buffer tiles beyond the edge of the viewport. Demo. + + Alex Paterson + + From d083eaaa7d2895c8fb4ba7ec9a83b800e842812e Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 15 Jul 2015 15:30:32 +0300 Subject: [PATCH 48/58] update docs version notice --- reference.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reference.html b/reference.html index 393e261a..4be3fe65 100644 --- a/reference.html +++ b/reference.html @@ -125,8 +125,7 @@ bodyclass: api-page
        -

        This reference reflects Leaflet 0.7. -Docs for 0.6 are available in the source form (see instructions for running docs).

        +

        This reference reflects Leaflet 1.0.

        Map

        @@ -6491,7 +6490,7 @@ map.addControl(new MyControl()); L.CRS.Earth Serves as the base for CRS that are global such that they cover the earth. Can only be used as the base for - other CRS and cannot be used directly, since it does not have a code, projection or + other CRS and cannot be used directly, since it does not have a code, projection or transformation. From 44bc29ba1c2e74b44af15d21b4b086ca557964ff Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 16 Jul 2015 14:25:53 +0300 Subject: [PATCH 49/58] Manual tuning: replaced all ILayer words with just Layer --- reference.html | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/reference.html b/reference.html index 4be3fe65..0d1ce1b0 100644 --- a/reference.html +++ b/reference.html @@ -185,7 +185,7 @@ var map = L.map('map', { layers - ILayer[] + Layer[] null Layers that will be added to the map initially. @@ -841,7 +841,7 @@ var map = L.map('map', { addLayer( - <ILayer> layer + <Layer> layer this @@ -849,7 +849,7 @@ var map = L.map('map', { removeLayer( - <ILayer> layer ) + <Layer> layer ) this @@ -857,7 +857,7 @@ var map = L.map('map', { hasLayer( - <ILayer> layer ) + <Layer> layer ) Boolean @@ -918,7 +918,7 @@ var map = L.map('map', { Removes the given control from the map. getRenderer( - <ILayer> layer) + <Layer> layer) Renderer @@ -1669,11 +1669,11 @@ var map = L.map('map', { L.popup( <Popup options> options?, - <ILayer> source? ) + <Layer> source? ) - Instantiates a Popup object given an optional options object that describes its appearance and location and an optional source object that is used to tag the popup with a reference to the ILayer to which it refers. + Instantiates a Popup object given an optional options object that describes its appearance and location and an optional source object that is used to tag the popup with a reference to the Layer to which it refers. @@ -2979,7 +2979,7 @@ map.fitBounds(bounds);
        L.LayerGroup( - <ILayer[]> layers? ) + <Layer[]> layers? ) @@ -3005,7 +3005,7 @@ map.fitBounds(bounds);
        addLayer( - <ILayer> layer ) + <Layer> layer ) this @@ -3013,7 +3013,7 @@ map.fitBounds(bounds);
        removeLayer( - <ILayer> layer ) + <Layer> layer ) this @@ -3029,7 +3029,7 @@ map.fitBounds(bounds); hasLayer( - <ILayer> layer ) + <Layer> layer ) Boolean @@ -3040,7 +3040,7 @@ map.fitBounds(bounds); <String> id ) - ILayer + Layer Returns the layer with the given id. @@ -3093,7 +3093,7 @@ map.fitBounds(bounds); L.featureGroup( - <ILayer[]> layers? ) + <Layer[]> layers? ) @@ -3245,7 +3245,7 @@ map.fitBounds(bounds); onEachFeature( <GeoJSON> featureData, - <ILayer> layer ) + <Layer> layer ) Function that will be called on each created feature layer. Useful for attaching events and popups to features. @@ -3253,7 +3253,7 @@ map.fitBounds(bounds); filter( <GeoJSON> featureData, - <ILayer> layer ) + <Layer> layer ) Function that will be used to decide whether to show a feature or not. @@ -3319,7 +3319,7 @@ map.fitBounds(bounds); <Function> pointToLayer? ) - ILayer + Layer Creates a layer from a given GeoJSON feature. @@ -4455,7 +4455,7 @@ L.control.layers(baseLayers, overlays).addTo(map); addBaseLayer( - <ILayer> layer, + <Layer> layer, <String> name ) this @@ -4463,7 +4463,7 @@ L.control.layers(baseLayers, overlays).addTo(map); addOverlay( - <ILayer> layer, + <Layer> layer, <String> name ) this @@ -4471,7 +4471,7 @@ L.control.layers(baseLayers, overlays).addTo(map); removeLayer( - <ILayer> layer ) + <Layer> layer ) this Remove the given layer from the control. @@ -6657,7 +6657,7 @@ map.addControl(new MyControl()); layer - ILayer + Layer The layer that was added or removed. @@ -6672,7 +6672,7 @@ map.addControl(new MyControl()); layer - ILayer + Layer The layer that was added or removed. @@ -6742,7 +6742,7 @@ map.addControl(new MyControl()); layer - ILayer + Layer The layer for the GeoJSON feature that is being added to the map. From 187b7cb2639f15a1b3cf30bc049591cce0cfe69d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 16 Jul 2015 14:36:21 +0300 Subject: [PATCH 50/58] Fixed couple of remaining ilayer anchors --- reference.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reference.html b/reference.html index 0d1ce1b0..12141d07 100644 --- a/reference.html +++ b/reference.html @@ -918,7 +918,7 @@ var map = L.map('map', { Removes the given control from the map. getRenderer( - <Layer> layer) + <Layer> layer) Renderer @@ -6657,7 +6657,7 @@ map.addControl(new MyControl()); layer - Layer + Layer The layer that was added or removed. @@ -6672,7 +6672,7 @@ map.addControl(new MyControl()); layer - Layer + Layer The layer that was added or removed. @@ -6742,7 +6742,7 @@ map.addControl(new MyControl()); layer - Layer + Layer The layer for the GeoJSON feature that is being added to the map. From 485c1987f08001bed5ec5c64b4e445504c903384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Tue, 11 Aug 2015 10:04:21 +0200 Subject: [PATCH 51/58] Document createTile async mode --- reference.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/reference.html b/reference.html index 12141d07..45d9b8fb 100644 --- a/reference.html +++ b/reference.html @@ -3373,9 +3373,10 @@ map.fitBounds(bounds);

        Asyncronous usage example

        -

        Tile creation can also be asyncronous, this is useful when using a third-party drawing library. Once the tile is finsihed drawing it can be passed to the done() callback.

        +

        Tile creation can also be asyncronous, this is useful when using a third-party drawing library. Once the tile has finished drawing it must be passed to the done() callback.

        var CanvasLayer = L.GridLayer.extend({
        +	// createTile has a 'done' parameter when on async mode
         	createTile: function(coords, done){
         		var error;
         
        @@ -3387,8 +3388,14 @@ map.fitBounds(bounds);
        tile.width = size.x; tile.height = size.y; - // draw something and pass the tile to the done() callback - done(error, tile); + // For this example simply wait one second before tile is ready + window.setTimeout(function(){ + // draw something and pass the tile to the done() callback + done(error, tile); + }, 1000); + + // return the tile so its progress can be tracked + return tile; } }); From 471bec5f9a0075a8404cc7f8685d9a5ae48cc1a4 Mon Sep 17 00:00:00 2001 From: Vladimir Kulev Date: Mon, 7 Sep 2015 21:26:06 +0300 Subject: [PATCH 52/58] Fix typo in popup event names --- reference.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference.html b/reference.html index 45d9b8fb..fae3b197 100644 --- a/reference.html +++ b/reference.html @@ -1779,12 +1779,12 @@ var map = L.map('map', { Description - added + add PopupEvent Fired when the popup is added to the map. - removed + remove PopupEvent Fired when the popup is removed from the map. From 5c529f51759f20306708947090fd857e3e054b6a Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 9 Oct 2015 10:11:56 +1300 Subject: [PATCH 53/58] Fix a bunch of unbalanced tags --- reference.html | 56 ++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/reference.html b/reference.html index fae3b197..aef5bee8 100644 --- a/reference.html +++ b/reference.html @@ -886,7 +886,7 @@ var map = L.map('map', { openPopup( - <String> html | <HTMLElement> el, + <String> html | <HTMLElement> el, <LatLng> latlng, <Popup options> options? ) @@ -917,6 +917,7 @@ var map = L.map('map', { this Removes the given control from the map. + getRenderer( <Layer> layer) @@ -1059,16 +1060,16 @@ var map = L.map('map', { createPane( - <String> name, <HTMLElement> contianer? + <String> name, <HTMLElement> container? ) - MapPane + MapPane Creates a pane with the given name. Created panes will be given a generated class based on the name like .leaflet-pane-name" getPane( - <String> name + <String> name ) - MapPane + MapPane Returns the HTML element representing the named map pane. @@ -1234,19 +1235,19 @@ var map = L.map('map', { paddingTopLeft Point - [0, 0] + [0, 0] 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. paddingBottomRight Point - [0, 0] + [0, 0] The same for bottom right corner of the map. padding Point - [0, 0] + [0, 0] Equivalent of setting both top left and bottom right padding to the same value. @@ -1733,14 +1734,12 @@ var map = L.map('map', { autoPanPaddingTopLeft Point null - The margin between the popup and the top left corner of the map view after autopanning was performed. autoPanPaddingBottomRight Point null - The margin between the popup and the bottom right corner of the map view after autopanning was performed. @@ -2151,7 +2150,7 @@ var map = L.map('map', { L.tileLayer.wms( <String> baseUrl, <TileLayer.WMS options> options ) - + Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object. @@ -2837,7 +2836,7 @@ map.fitBounds(bounds);

        A class for drawing circle overlays on a map. Extends CircleMarker. Use Map#addLayer to add it to the map.

        -
        L.circle([50.5, 30.5], 200).addTo(map);
        +
        L.circle([50.5, 30.5], 200).addTo(map);

        Creation

        @@ -4314,31 +4313,31 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); position String - 'topleft' + 'topleft' The position of the control (one of the map corners). See control positions. zoomInText String - '+' + '+' The text set on the zoom in button. zoomOutText String - '-' + '-' The text set on the zoom out button. zoomInTitle String - 'Zoom in' + 'Zoom in' The title set on the zoom in button. zoomOutTitle String - 'Zoom out' + 'Zoom out' The title set on the zoom out button. @@ -4378,13 +4377,13 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); position String - 'bottomright' + 'bottomright' The position of the control (one of the map corners). See control positions. prefix String - 'Leaflet' + 'Leaflet' The HTML text shown before the attributions. Pass false to disable. @@ -4497,7 +4496,7 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'topright' + 'topright' The position of the control (one of the map corners). See control positions. @@ -4593,7 +4592,7 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'bottomleft' + 'bottomleft' The position of the control (one of the map corners). See control positions. @@ -4693,7 +4692,7 @@ map.off('click', onClick); this - Removes a set of type/listener pairs. + Removes a set of type/listener pairs. off() @@ -4737,7 +4736,7 @@ map.off('click', onClick); clearAllEventListeners() this - Alias to off(). + Alias to off(). hasEventListeners( … ) @@ -4973,7 +4972,7 @@ Popups will also be automatically opened when the layer is clicked on and closed Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). The arguments received by the bound function will be any arguments passed when binding the function, followed by any arguments passed when invoking the bound function. Has an L.bind shortcut. Works exactly like Function.prototype.bind in modern browsers compliant with ECMAScript 5. - stamp( <Object> obj ) + stamp( <Object> obj ) String Applies a unique key to the object and returns that key. Has an L.stamp shortcut. @@ -5035,7 +5034,7 @@ Popups will also be automatically opened when the layer is clicked on and closed String[] - Trims and splits the string on whitespace and returns the array of parts. + Trims and splits the string on whitespace and returns the array of parts. setOptions( @@ -5297,7 +5296,7 @@ Popups will also be automatically opened when the layer is clicked on and closed this - Removes a set of type/listener pairs. + Removes a set of type/listener pairs. addListener( <HTMLElement> el, @@ -5338,8 +5337,7 @@ Popups will also be automatically opened when the layer is clicked on and closed this - Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions. - + Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions. stop( @@ -6180,7 +6178,7 @@ map.addControl(new MyControl()); position String - 'topright' + 'topright' The initial position of the control (one of the map corners). See control positions. From 5be98d630a1e4e7f890d29b595c19629348ea493 Mon Sep 17 00:00:00 2001 From: perliedman Date: Fri, 27 Nov 2015 19:12:54 +0100 Subject: [PATCH 54/58] Remove continuousWorld from docs, since it's not in the API --- reference.html | 6 ------ 1 file changed, 6 deletions(-) diff --git a/reference.html b/reference.html index aef5bee8..42e1fd51 100644 --- a/reference.html +++ b/reference.html @@ -1939,12 +1939,6 @@ var map = L.map('map', { false If true, inverses Y axis numbering for tiles (turn this on for TMS services). - - continuousWorld - Boolean - false - If set to true, the tile coordinates won't be wrapped by world width (-180 to 180 longitude) or clamped to lie within world height (-90 to 90). Use this if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor or photo maps). - noWrap Boolean From 8744644c2520989c5fcdecf9895f26d1e61e254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Sat, 12 Dec 2015 19:11:53 +0100 Subject: [PATCH 55/58] Add 0.7.x docs and move reference to other doc versions around. --- reference-0.7.x.html | 6399 ++++++++++++++++++++++++++++++++++++++++++ reference.html | 6 +- 2 files changed, 6404 insertions(+), 1 deletion(-) create mode 100644 reference-0.7.x.html diff --git a/reference-0.7.x.html b/reference-0.7.x.html new file mode 100644 index 00000000..e833fb5e --- /dev/null +++ b/reference-0.7.x.html @@ -0,0 +1,6399 @@ +--- +layout: v2 +title: Documentation +bodyclass: api-page +--- + +

        API Reference

        + +

        This reference reflects Leaflet 0.7.

        + +

        Docs for 1.0 are available here. + +Docs for 0.6 are available in the source form (see instructions for running docs).

        + + +
        + +
        +

        UI Layers

        + +

        Raster Layers

        + +

        Vector Layers

        + +
        +
        +

        Other Layers

        + +

        Basic Types

        + +

        Controls

        + +
        +
        +

        Events

        + +

        Utility

        + +

        DOM Utility

        + +
        +
        +

        Interfaces

        + + +

        Misc

        + +
        +
        + + + +
        + +

        Map

        + +

        The central class of the API — it is used to create a map on a page and manipulate it.

        + +

        Usage example

        + +
        // initialize the map on the "map" div with a given center and zoom
        +var map = L.map('map', {
        +	center: [51.505, -0.09],
        +	zoom: 13
        +});
        + +

        Creation

        + + + + + + + + + + + + +
        FactoryDescription
        L.map( + <HTMLElement|String> id, + <Map options> options? ) + Instantiates a map object given a div element (or its id) and optionally an object literal with map options described below.
        + + + + +

        Options

        + +

        Map State Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        centerLatLngnullInitial geographical center of the map.
        zoomNumbernullInitial map zoom.
        layersILayer[]nullLayers that will be added to the map initially.
        minZoomNumbernullMinimum zoom level of the map. Overrides any minZoom set on map layers.
        maxZoomNumbernullMaximum zoom level of the map. This overrides any maxZoom set on map layers.
        maxBoundsLatLngBoundsnullWhen this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method
        crsCRSL.CRS.
        EPSG3857
        Coordinate Reference System to use. Don't change this if you're not sure what it means.
        + +

        Interaction Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        draggingBooleantrueWhether the map be draggable with mouse/touch or not.
        touchZoomBooleantrueWhether the map can be zoomed by touch-dragging with two fingers.
        scrollWheelZoomBooleantrueWhether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was.
        doubleClickZoomBooleantrueWhether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift. If passed 'center', double-click zoom will zoom to the center of the view regardless of where the mouse was.
        boxZoomBooleantrueWhether the map can be zoomed to a rectangular area specified by dragging the mouse while pressing shift.
        tapBooleantrueEnables mobile hacks for supporting instant taps (fixing 200ms click delay on iOS/Android) and touch holds (fired as contextmenu events).
        tapToleranceNumber15The max number of pixels a user can shift his finger during touch for it to be considered a valid tap.
        trackResizeBooleantrueWhether the map automatically handles browser window resize to update itself.
        worldCopyJumpBooleanfalseWith this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible.
        closePopupOnClickBooleantrueSet it to false if you don't want popups to close when user clicks the map.
        bounceAtZoomLimitsBooleantrueSet it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming.
        + +

        Keyboard Navigation Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        keyboardBooleantrueMakes the map focusable and allows users to navigate the map with keyboard arrows and +/- keys.
        keyboardPanOffsetNumber80Amount of pixels to pan when pressing an arrow key.
        keyboardZoomOffsetNumber1Number of zoom levels to change when pressing + or - key.
        + +

        Panning Inertia Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        inertiaBooleantrueIf enabled, panning of the map will have an inertia effect where the map builds momentum while dragging and continues moving in the same direction for some time. Feels especially nice on touch devices.
        inertiaDecelerationNumber3000The rate with which the inertial movement slows down, in pixels/second2.
        inertiaMaxSpeedNumber1500Max speed of the inertial movement, in pixels/second.
        inertiaThresholdNumberdependsNumber of milliseconds that should pass between stopping the movement and releasing the mouse or touch to prevent inertial movement. 32 for touch devices and 14 for the rest by default.
        + +

        Control options

        + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        zoomControlBooleantrueWhether the zoom control is added to the map by default.
        attributionControlBooleantrueWhether the attribution control is added to the map by default.
        + +

        Animation options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        fadeAnimationBooleandependsWhether the tile fade animation is enabled. By default it's enabled in all browsers that support CSS3 Transitions except Android.
        zoomAnimationBooleandependsWhether the tile zoom animation is enabled. By default it's enabled in all browsers that support CSS3 Transitions except Android.
        zoomAnimationThresholdNumber4Won't animate zoom if the zoom difference exceeds this value.
        markerZoomAnimationBooleandependsWhether markers animate their zoom with the zoom animation, if disabled they will disappear for the length of the animation. By default it's enabled in all browsers that support CSS3 Transitions except Android.
        + + +

        Events

        + +

        You can subscribe to the following events using these methods.

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        clickMouseEventFired when the user clicks (or taps) the map.
        dblclickMouseEventFired when the user double-clicks (or double-taps) the map.
        mousedownMouseEventFired when the user pushes the mouse button on the map.
        mouseupMouseEventFired when the user releases the mouse button on the map.
        mouseoverMouseEventFired when the mouse enters the map.
        mouseoutMouseEventFired when the mouse leaves the map.
        mousemoveMouseEventFired while the mouse moves over the map.
        contextmenuMouseEventFired when the user pushes the right mouse button on the map, prevents default browser context menu from showing if there are listeners on this event. Also fired on mobile when the user holds a single touch for a second (also called long press).
        focusEventFired when the user focuses the map either by tabbing to it or clicking/panning.
        blurEventFired when the map loses focus.
        preclickMouseEventFired before mouse click on the map (sometimes useful when you want something to happen on click before any existing click handlers start running).
        loadEventFired when the map is initialized (when its center and zoom are set for the first time).
        unloadEventFired when the map is destroyed with remove method.
        viewresetEventFired when the map needs to redraw its content (this usually happens on map zoom or load). Very useful for creating custom overlays.
        movestartEventFired when the view of the map starts changing (e.g. user starts dragging the map).
        moveEventFired on any movement of the map view.
        moveendEventFired when the view of the map stops changing (e.g. user stopped dragging the map).
        dragstartEventFired when the user starts dragging the map.
        dragEventFired repeatedly while the user drags the map.
        dragendDragEndEventFired when the user stops dragging the map.
        zoomstartEventFired when the map zoom is about to change (e.g. before zoom animation).
        zoomendEventFired when the map zoom changes.
        zoomlevelschangeEventFired when the number of zoomlevels on the map is changed due to adding or removing a layer.
        resizeResizeEventFired when the map is resized.
        autopanstartEventFired when the map starts autopanning when opening a popup.
        layeraddLayerEventFired when a new layer is added to the map.
        layerremoveLayerEventFired when some layer is removed from the map.
        baselayerchangeLayerEvent + Fired when the base layer is changed through the layer control.
        overlayaddLayerEvent + Fired when an overlay is selected through the layer control.
        overlayremoveLayerEvent + Fired when an overlay is deselected through the layer control.
        locationfoundLocationEvent + Fired when geolocation (using the locate method) went successfully.
        locationerrorErrorEvent + Fired when geolocation (using the locate method) failed.
        popupopenPopupEventFired when a popup is opened (using openPopup method).
        popupclosePopupEventFired when a popup is closed (using closePopup method).
        + + +

        Methods for Modifying Map State

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        setView( + <LatLng> center, + <Number> zoom?, + <zoom/pan options> options? ) + thisSets the view of the map (geographical center and zoom) with the given animation options.
        setZoom( + <Number> zoom, + <zoom options> options? ) + thisSets the zoom of the map.
        zoomIn( + <Number> delta?, + <zoom options> options? ) + thisIncreases the zoom of the map by delta (1 by default).
        zoomOut( + <Number> delta?, + <zoom options> options? ) + thisDecreases the zoom of the map by delta (1 by default).
        setZoomAround( + <LatLng> latlng, + <Number> zoom, + <zoom options> options? ) + thisZooms the map while keeping a specified point on the map stationary (e.g. used internally for scroll zoom and double-click zoom).
        fitBounds( + <LatLngBounds> bounds, + <fitBounds options> options? ) + thisSets a map view that contains the given geographical bounds with the maximum zoom level possible.
        fitWorld( + <fitBounds options> options? ) + thisSets a map view that mostly contains the whole world with the maximum zoom level possible.
        panTo( + <LatLng> latlng, + <pan options> options? ) + thisPans the map to a given center. Makes an animated pan if new center is not more than one screen away from the current one.
        panInsideBounds( + <LatLngBounds> bounds, + <pan options> options? ) + thisPans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any.
        panBy( + <Point> point, + <pan options> options? ) + thisPans the map by a given number of pixels (animated).
        invalidateSize( + <Boolean> animate ) + thisChecks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default.
        invalidateSize( + <zoom/pan options> options ) + thisChecks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row.
        setMaxBounds( + <LatLngBounds> bounds + thisRestricts the map view to the given bounds (see map maxBounds option).
        locate( + <Locate options> options? ) + thisTries to locate the user using the Geolocation API, firing a locationfound event with location data on success or a locationerror event on failure, and optionally sets the map view to the user's location with respect to detection accuracy (or to the world view if geolocation failed). See Locate options for more details.
        stopLocate()thisStops watching location previously initiated by map.locate({watch: true}) and aborts resetting the map view if map.locate was called with {setView: true}.
        remove()thisDestroys the map and clears all related event listeners.
        + +

        Methods for Getting Map State

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        getCenter()LatLngReturns the geographical center of the map view.
        getZoom()NumberReturns the current zoom of the map view.
        getMinZoom()NumberReturns the minimum zoom level of the map.
        getMaxZoom()NumberReturns the maximum zoom level of the map.
        getBounds()LatLngBoundsReturns the LatLngBounds of the current map view.
        getBoundsZoom( + <LatLngBounds> bounds, + <Boolean> inside? ) + NumberReturns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety.
        getSize()PointReturns the current size of the map container.
        getPixelBounds()BoundsReturns the bounds of the current map view in projected pixel coordinates (sometimes useful in layer and overlay implementations).
        getPixelOrigin()PointReturns the projected pixel coordinates of the top left point of the map layer (useful in custom layer and overlay implementations).
        + +

        Methods for Layers and Controls

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addLayer( + <ILayer> layer, + thisAdds the given layer to the map.
        removeLayer( + <ILayer> layer ) + thisRemoves the given layer from the map.
        hasLayer( + <ILayer> layer ) + BooleanReturns true if the given layer is currently added to the map.
        eachLayer( + <Function> fn, + <Object> context? ) + thisIterates over the layers of the map, optionally specifying context of the iterator function. +
        map.eachLayer(function (layer) {
        +	layer.bindPopup('Hello');
        +});
        +
        openPopup( + <Popup> popup ) + thisOpens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).
        openPopup( + <String> html | <HTMLElement> el, + <LatLng> latlng, + <Popup options> options? ) + thisCreates a popup with the specified options and opens it in the given point on a map.
        closePopup( + <Popup> popup? ) + thisCloses the popup previously opened with openPopup (or the given one).
        addControl( + <IControl> control ) + thisAdds the given control to the map.
        removeControl( + <IControl> control ) + thisRemoves the given control from the map.
        + + +

        Conversion Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        latLngToLayerPoint( + <LatLng> latlng ) + PointReturns the map layer point that corresponds to the given geographical coordinates (useful for placing overlays on the map).
        layerPointToLatLng( + <Point> point ) + LatLngReturns the geographical coordinates of a given map layer point.
        containerPointToLayerPoint( + <Point> point ) + PointConverts the point relative to the map container to a point relative to the map layer.
        layerPointToContainerPoint( + <Point> point ) + PointConverts the point relative to the map layer to a point relative to the map container.
        latLngToContainerPoint( + <LatLng> latlng ) + PointReturns the map container point that corresponds to the given geographical coordinates.
        containerPointToLatLng( + <Point> point ) + LatLngReturns the geographical coordinates of a given map container point.
        project( + <LatLng> latlng, + <Number> zoom? ) + PointProjects the given geographical coordinates to absolute pixel coordinates for the given zoom level (current zoom level by default).
        unproject( + <Point> point, + <Number> zoom? ) + LatLngProjects the given absolute pixel coordinates to geographical coordinates for the given zoom level (current zoom level by default).
        mouseEventToContainerPoint( + <MouseEvent> event ) + PointReturns the pixel coordinates of a mouse click (relative to the top left corner of the map) given its event object.
        mouseEventToLayerPoint( + <MouseEvent> event ) + PointReturns the pixel coordinates of a mouse click relative to the map layer given its event object. +
        mouseEventToLatLng( + <MouseEvent> event ) + LatLngReturns the geographical coordinates of the point the mouse clicked on given the click's event object.
        + +

        Other Methods

        + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        getContainer()HTMLElementReturns the container element of the map.
        getPanes()MapPanesReturns an object with different map panes (to render overlays in).
        whenReady( + <Function> fn, + <Object> context? )thisRuns the given callback when the map gets initialized with a place and zoom, or immediately if it happened already, optionally passing a function context.
        + +

        Locate options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        watchBooleanfalseIf true, starts continuous watching of location changes (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stopLocate() method.
        setViewBooleanfalseIf true, automatically sets the map view to the user location with respect to detection accuracy, or to world view if geolocation failed.
        maxZoomNumberInfinityThe maximum zoom for automatic view setting when using `setView` option.
        timeoutNumber10000Number of milliseconds to wait for a response from geolocation before firing a locationerror event.
        maximumAgeNumber0Maximum age of detected location. If less than this amount of milliseconds passed since last geolocation response, locate will return a cached location.
        enableHighAccuracyBooleanfalseEnables high accuracy, see description in the W3C spec.
        + + +

        Zoom/pan options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        resetBooleanfalseIf true, the map view will be completely reset (without any animations).
        panpan options-Sets the options for the panning (without the zoom change) if it occurs.
        zoomzoom options-Sets the options for the zoom change if it occurs.
        animateBoolean-An equivalent of passing animate to both zoom and pan options (see below).
        + +

        Pan options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        animateBoolean-If true, panning will always be animated if possible. If false, it will not animate panning, either resetting the map view if panning more than a screen away, or just setting a new offset for the map pane (except for `panBy` which always does the latter).
        durationNumber0.25Duration of animated panning.
        easeLinearityNumber0.25The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve.
        noMoveStartBooleanfalseIf true, panning won't fire movestart event on start (used internally for panning inertia).
        + +

        Zoom options

        + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        animateBoolean-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.
        + +

        fitBounds options

        + +

        The same as zoom/pan options and additionally:

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        paddingTopLeftPoint[0, 0] + 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.
        paddingBottomRightPoint[0, 0] + The same for bottom right corner of the map.
        paddingPoint[0, 0] + Equivalent of setting both top left and bottom right padding to the same value.
        maxZoomNumbernullThe maximum possible zoom to use.
        + + +

        Properties

        + +

        Map properties include interaction handlers that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging or touch zoom (see IHandler methods). Example:

        + +
        map.doubleClickZoom.disable();
        + +

        You can also access default map controls like attribution control through map properties:

        + +
        map.attributionControl.addAttribution("Earthquake data &copy; GeoNames");
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        PropertyTypeDescription
        draggingIHandlerMap dragging handler (by both mouse and touch).
        touchZoomIHandlerTouch zoom handler.
        doubleClickZoomIHandlerDouble click zoom handler.
        scrollWheelZoomIHandlerScroll wheel zoom handler.
        boxZoomIHandlerBox (shift-drag with mouse) zoom handler.
        keyboardIHandlerKeyboard navigation handler.
        tapIHandlerMobile touch hacks (quick tap and touch hold) handler.
        zoomControlControl.ZoomZoom control.
        attributionControlControl.AttributionAttribution control.
        + + +

        Map Panes

        + +

        An object literal (returned by map.getPanes) that contains different map panes that you can use to put your custom overlays in. The difference is mostly in zIndex order that such overlays get.

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        PropertyTypeDescription
        mapPaneHTMLElementPane that contains all other map panes.
        tilePaneHTMLElementPane for tile layers.
        objectsPaneHTMLElementPane that contains all the panes except tile pane.
        shadowPaneHTMLElementPane for overlay shadows (e.g. marker shadows).
        overlayPaneHTMLElementPane for overlays like polylines and polygons.
        markerPaneHTMLElementPane for marker icons.
        popupPaneHTMLElementPane for popups.
        + + +

        Marker

        + +

        Used to put markers on the map.

        + +
        L.marker([50.5, 30.5]).addTo(map);
        + +

        Creation

        + + + + + + + + + + + + +
        FactoryDescription
        L.marker( + <LatLng> latlng, + <Marker options> options? ) + Instantiates a Marker object given a geographical point and optionally an options object.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        iconL.Icon*Icon class to use for rendering the marker. See Icon documentation for details on how to customize the marker icon. Set to new L.Icon.Default() by default.
        clickableBooleantrueIf false, the marker will not emit mouse events and will act as a part of the underlying map.
        draggableBooleanfalseWhether the marker is draggable with mouse/touch or not.
        keyboardBooleantrueWhether the marker can be tabbed to with a keyboard and clicked by pressing enter.
        titleString''Text for the browser tooltip that appear on marker hover (no tooltip by default).
        altString''Text for the alt attribute of the icon image (useful for accessibility).
        zIndexOffsetNumber0By default, zIndex for the marker image is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively).
        opacityNumber1.0The opacity of the marker.
        riseOnHoverBooleanfalseIf true, the marker will get on top of others when you hover the mouse over it.
        riseOffsetNumber250The z-index offset used for the riseOnHover feature.
        + +

        Events

        + +

        You can subscribe to the following events using these methods.

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        clickMouseEventFired when the user clicks (or taps) the marker.
        dblclickMouseEventFired when the user double-clicks (or double-taps) the marker.
        mousedownMouseEventFired when the user pushes the mouse button on the marker.
        mouseoverMouseEventFired when the mouse enters the marker.
        mouseoutMouseEventFired when the mouse leaves the marker.
        contextmenuMouseEvent + Fired when the user right-clicks on the marker.
        dragstartEventFired when the user starts dragging the marker.
        dragEventFired repeatedly while the user drags the marker.
        dragendDragEndEventFired when the user stops dragging the marker.
        moveEventFired when the marker is moved via setLatLng. New coordinate include in event arguments.
        addEventFired when the marker is added to the map.
        removeEventFired when the marker is removed from the map.
        popupopenPopupEventFired when a popup bound to the marker is open.
        popupclosePopupEventFired when a popup bound to the marker is closed.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addTo( + <Map> map ) + thisAdds the marker to the map.
        getLatLng()LatLngReturns the current geographical position of the marker.
        setLatLng( + <LatLng> latlng ) + thisChanges the marker position to the given point.
        setIcon( + <Icon> icon ) + thisChanges the marker icon.
        setZIndexOffset( + <Number> offset ) + thisChanges the zIndex offset of the marker.
        setOpacity( + <Number> opacity ) + thisChanges the opacity of the marker.
        update() + thisUpdates the marker position, useful if coordinates of its latLng object were changed directly.
        bindPopup( + <String> html | <HTMLElement> el | <Popup> popup, + <Popup options> options? ) + thisBinds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.
        unbindPopup()thisUnbinds the popup previously bound to the marker with bindPopup.
        openPopup()thisOpens the popup previously bound by the bindPopup method.
        getPopup()PopupReturns the popup previously bound by the bindPopup method.
        closePopup()thisCloses the bound popup of the marker if it's opened.
        togglePopup()thisToggles the popup previously bound by the bindPopup method.
        setPopupContent( + <String> html | <HTMLElement> el ) + thisSets an HTML content of the popup of this marker.
        toGeoJSON()ObjectReturns a GeoJSON representation of the marker (GeoJSON Point Feature).
        + +

        Interaction handlers

        + +

        Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see IHandler methods). Example:

        + +
        marker.dragging.disable();
        + + + + + + + + + + + + +
        PropertyTypeDescription
        draggingIHandlerMarker dragging handler (by both mouse and touch).
        + + + + + +

        Used to open popups in certain places of the map. Use Map#openPopup to open popups while making sure that only one popup is open at one time (recommended for usability), or use Map#addLayer to open as many as you want.

        + +

        Usage example

        +

        If you want to just bind a popup to marker click and then open it, it's really easy:

        +
        marker.bindPopup(popupContent).openPopup();
        +

        Path overlays like polylines also have a bindPopup method. Here's a more complicated way to open a popup on a map:

        + +
        var popup = L.popup()
        +	.setLatLng(latlng)
        +	.setContent('<p>Hello world!<br />This is a nice popup.</p>')
        +	.openOn(map);
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.popup( + <Popup options> options?, + <ILayer> source? ) + Instantiates a Popup object given an optional options object that describes its appearance and location and an optional source object that is used to tag the popup with a reference to the ILayer to which it refers.
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        maxWidthNumber300Max width of the popup.
        minWidthNumber50Min width of the popup.
        maxHeightNumbernullIf set, creates a scrollable container of the given height inside a popup if its content exceeds it.
        autoPanBooleantrueSet it to false if you don't want the map to do panning animation to fit the opened popup.
        keepInViewBooleanfalseSet it to true if you want to prevent users from panning the popup off of the screen while it is open.
        closeButtonBooleantrueControls the presense of a close button in the popup.
        offsetPointPoint(0, 6) + The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays.
        autoPanPaddingTopLeftPointnullThe margin between the popup and the top left corner of the map view after autopanning was performed.
        autoPanPaddingBottomRightPointnullThe margin between the popup and the bottom right corner of the map view after autopanning was performed.
        autoPanPaddingPointPoint(5, 5) + Equivalent of setting both top left and bottom right autopan padding to the same value.
        zoomAnimationBooleantrueWhether to animate the popup on zoom. Disable it if you have problems with Flash content inside popups.
        closeOnClickBooleannullSet it to false if you want to override the default behavior of the popup closing when user clicks the map (set globally by the Map closePopupOnClick option).
        classNameString''A custom class name to assign to the popup.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addTo( + <Map> map ) + thisAdds the popup to the map.
        openOn( + <Map> map ) + thisAdds the popup to the map and closes the previous one. The same as map.openPopup(popup).
        setLatLng( + <LatLng> latlng ) + thisSets the geographical point where the popup will open.
        getLatLng()LatLngReturns the geographical point of popup.
        setContent( + <String|HTMLElement> htmlContent ) + thisSets the HTML content of the popup.
        getContent()<String|HTMLElement>Returns the content of the popup.
        update()thisUpdates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded.
        + + + +

        TileLayer

        + +

        Used to load and display tile layers on the map, implements ILayer interface.

        + +

        Usage example

        + +
        L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar'}).addTo(map);
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.tileLayer( + <String> urlTemplate, + <TileLayer options> options? ) + Instantiates a tile layer object given a URL template and optionally an options object.
        + +

        URL template

        + +

        A string of the following form:

        + +
        'http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png'
        + +

        {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates.

        + +

        You can use custom keys in the template, which will be evaluated from TileLayer options, like this:

        + +
        L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        minZoomNumber0Minimum zoom number.
        maxZoomNumber18Maximum zoom number.
        maxNativeZoomNumbernullMaximum zoom number the tiles source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxZoom level and auto-scaled.
        tileSizeNumber256Tile size (width and height in pixels, assuming tiles are square).
        subdomainsString or String[]'abc'Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
        errorTileUrlString''URL to the tile image to show in place of the tile that failed to load.
        attributionString''e.g. "© Mapbox" — the string used by the attribution control, describes the layer data.
        tmsBooleanfalseIf true, inverses Y axis numbering for tiles (turn this on for TMS services).
        continuousWorldBooleanfalseIf set to true, the tile coordinates won't be wrapped by world width (-180 to 180 longitude) or clamped to lie within world height (-90 to 90). Use this if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor or photo maps).
        noWrapBooleanfalseIf set to true, the tiles just won't load outside the world width (-180 to 180 longitude) instead of repeating.
        zoomOffsetNumber0The zoom number used in tile URLs will be offset with this value.
        zoomReverseBooleanfalseIf set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
        opacityNumber1.0The opacity of the tile layer.
        zIndexNumbernullThe explicit zIndex of the tile layer. Not set by default.
        unloadInvisibleTilesBooleandependsIf true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false.
        updateWhenIdleBooleandependsIf false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false.
        detectRetinaBooleanfalseIf true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
        reuseTilesBooleanfalseIf true, all the tiles that are not visible after panning are placed in a reuse queue from which they will be fetched when new tiles become visible (as opposed to dynamically creating new ones). This will in theory keep memory usage low and eliminate the need for reserving new memory whenever a new tile is needed.
        boundsLatLngBoundsnullWhen this option is set, the TileLayer only loads tiles that are in the given geographical bounds.
        + +

        Events

        + +

        You can subscribe to the following events using these methods.

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        loadingEventFired when the tile layer starts loading tiles.
        loadEventFired when the tile layer loaded all visible tiles.
        tileloadstartTileEventFired when a tile is requested and starts loading.
        tileloadTileEventFired when a tile loads.
        tileunloadTileEventFired when a tile is removed (e.g. when you have unloadInvisibleTiles on).
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addTo( + <Map> map ) + thisAdds the layer to the map.
        bringToFront()thisBrings the tile layer to the top of all tile layers.
        bringToBack()thisBrings the tile layer to the bottom of all tile layers.
        setOpacity( + <Number> opacity ) + thisChanges the opacity of the tile layer.
        setZIndex( + <Number> zIndex ) + thisSets the zIndex of the tile layer.
        redraw()thisCauses the layer to clear all the tiles and request them again.
        setUrl( + <String> urlTemplate ) + thisUpdates the layer's URL template and redraws it.
        getContainer() + HTMLElementReturns the HTML element that contains the tiles for this layer.
        + + + +

        TileLayer.WMS

        + +

        Used to display WMS services as tile layers on the map. Extends TileLayer.

        + +

        Usage example

        + +
        var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
        +	layers: 'nexrad-n0r-900913',
        +	format: 'image/png',
        +	transparent: true,
        +	attribution: "Weather data © 2012 IEM Nexrad"
        +});
        + +

        Creation

        + + + + + + + + + + +
        FactoryDescription
        L.tileLayer.wms( + <String> baseUrl, + <TileLayer.WMS options> options ) + + + Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.
        + +

        Options

        + +

        Includes all TileLayer options and additionally:

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        layersString''(required) Comma-separated list of WMS layers to show.
        stylesString''Comma-separated list of WMS styles.
        formatString'image/jpeg'WMS image format (use 'image/png' for layers with transparency).
        transparentBooleanfalseIf true, the WMS service will return images with transparency.
        versionString'1.1.1'Version of the WMS service to use.
        crsCRSnullCoordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means.
        + +

        Methods

        + + + + + + + + + + + + +
        MethodReturnsDescription
        setParams( + <WMS parameters> params, + <Boolean> noRedraw? ) + thisMerges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).
        + + +

        TileLayer.Canvas

        + +

        Used to create Canvas-based tile layers where tiles get drawn on the browser side. Extends TileLayer.

        + +

        Usage example

        + +
        var canvasTiles = L.tileLayer.canvas();
        +
        +canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
        +	var ctx = canvas.getContext('2d');
        +	// draw something on the tile canvas
        +}
        + +

        Creation

        + + + + + + + + + + + + +
        FactoryDescription
        L.tileLayer.canvas( + <TileLayer options> options? ) + Instantiates a Canvas tile layer object given an options object (optionally).
        + +

        Options

        + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        asyncBooleanfalseIndicates that tiles will be drawn asynchronously. tileDrawn method should be called for each tile after drawing completion.
        + +

        Methods

        + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        drawTile( + <HTMLCanvasElement> canvas, + <Point> tilePoint, + <Number> zoom ) + thisYou need to define this method after creating the instance to draw tiles; canvas is the actual canvas tile on which you can draw, tilePoint represents the tile numbers, and zoom is the current zoom.
        tileDrawn( <HTMLCanvasElement> canvas )-If async option is defined, this function should be called for each tile after drawing completion. canvas is the same canvas element, that was passed to drawTile.
        + + +

        ImageOverlay

        + +

        Used to load and display a single image over specific bounds of the map, implements ILayer interface.

        + +

        Usage example

        + +
        var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',
        +	imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];
        +
        +L.imageOverlay(imageUrl, imageBounds).addTo(map);
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.ImageOverlay( + <String> imageUrl, + <LatLngBounds> bounds, + <ImageOverlay options> options? ) + Instantiates an image overlay object given the URL of the image and the geographical bounds it is tied to.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        opacityNumber1.0The opacity of the image overlay.
        attributionString''The attribution text of the image overlay.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addTo( + <Map> map ) + thisAdds the overlay to the map.
        setOpacity( + <Number> opacity ) + thisSets the opacity of the overlay.
        setUrl( + <String> imageUrl ) + thisChanges the URL of the image.
        bringToFront()thisBrings the layer to the top of all overlays.
        bringToBack()thisBrings the layer to the bottom of all overlays.
        + + +

        Path

        +

        An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly. + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
        colorString'#03f'Stroke color.
        weightNumber5Stroke width in pixels.
        opacityNumber0.5Stroke opacity.
        fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
        fillColorStringsame as colorFill color.
        fillOpacityNumber0.2Fill opacity.
        fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
        dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on canvas-powered layers (e.g. Android 2).
        lineCapStringnullA string that defines shape to be used at the end of the stroke.
        lineJoinStringnullA string that defines shape to be used at the corners of the stroke.
        clickableBooleantrueIf false, the vector will not emit mouse events and will act as a part of the underlying map.
        pointerEventsStringnullSets the pointer-events attribute on the path if SVG backend is used.
        classNameString''Custom class name set on an element.
        + +

        Events

        + +

        You can subscribe to the following events using these methods.

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        clickMouseEventFired when the user clicks (or taps) the object.
        dblclickMouseEventFired when the user double-clicks (or double-taps) the object.
        mousedownMouseEventFired when the user pushes the mouse button on the object.
        mouseoverMouseEventFired when the mouse enters the object.
        mouseoutMouseEventFired when the mouse leaves the object.
        contextmenuMouseEventFired when the user pushes the right mouse button on the object, prevents default browser context menu from showing if there are listeners on this event.
        addEvent + Fired when the path is added to the map.
        removeEventFired when the path is removed from the map.
        popupopenPopupEventFired when a popup bound to the path is open.
        popupclosePopupEventFired when a popup bound to the path is closed.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addTo( + <Map> map ) + thisAdds the layer to the map.
        bindPopup( + <String> html | <HTMLElement> el | <Popup> popup, + <Popup options> options? ) + thisBinds a popup with a particular HTML content to a click on this path.
        bindPopup( + <Popup> popup, + <Popup options> options? ) + thisBinds a given popup object to the path.
        unbindPopup()thisUnbinds the popup previously bound to the path with bindPopup.
        openPopup( + <LatLng> latlng? ) + thisOpens the popup previously bound by the bindPopup method in the given point, or in one of the path's points if not specified.
        closePopup()thisCloses the path's bound popup if it is opened.
        setStyle( + <Path options> object ) + thisChanges the appearance of a Path based on the options in the Path options object.
        getBounds()LatLngBoundsReturns the LatLngBounds of the path.
        bringToFront()thisBrings the layer to the top of all path layers.
        bringToBack()thisBrings the layer to the bottom of all path layers.
        redraw()thisRedraws the layer. Sometimes useful after you changed the coordinates that the path uses.
        + +

        Static properties

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        ConstantTypeValueDescription
        SVGBooleandependsTrue if SVG is used for vector rendering (true for most modern browsers).
        VMLBooleandependsTrue if VML is used for vector rendering (IE 6-8).
        CANVASBooleandependsTrue if Canvas is used for vector rendering (Android 2). You can also force this by setting global variable L_PREFER_CANVAS to true before the Leaflet include on your page — sometimes it can increase performance dramatically when rendering thousands of circle markers, but currently suffers from a bug that causes removing such layers to be extremely slow.
        CLIP_PADDINGNumber0.5 for SVG
        0.02 for VML
        How much to extend the clip area around the map view (relative to its size, e.g. 0.5 is half the screen in each direction). Smaller values mean that you will see clipped ends of paths while you're dragging the map, and bigger values decrease drawing performance.
        + + +

        Polyline

        + +

        A class for drawing polyline overlays on a map. Extends Path. Use Map#addLayer to add it to the map.

        + +

        Usage example

        +
        // create a red polyline from an array of LatLng points
        +var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
        +
        +// zoom the map to the polyline
        +map.fitBounds(polyline.getBounds());
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.polyline( + <LatLng[]> latlngs, + <Polyline options> options? ) + Instantiates a polyline object given an array of geographical points and optionally an options object.
        + +

        Options

        + +

        You can use Path options and additionally the following options:

        + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        smoothFactorNumber1.0How much to simplify the polyline on each zoom level. More means better performance and smoother look, and less means more accurate representation.
        noClipBooleanfalseDisabled polyline clipping.
        + +

        Methods

        + +

        You can use Path methods and additionally the following methods:

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addLatLng( + <LatLng> latlng ) + thisAdds a given point to the polyline.
        setLatLngs( + <LatLng[]> latlngs ) + thisReplaces all the points in the polyline with the given array of geographical points.
        getLatLngs()LatLng[]Returns an array of the points in the path.
        spliceLatLngs( + <Number> index, + <Number> pointsToRemove, + <LatLng> latlng?, … ) + LatLng[]Allows adding, removing or replacing points in the polyline. Syntax is the same as in Array#splice. Returns the array of removed points (if any).
        getBounds()LatLngBoundsReturns the LatLngBounds of the polyline.
        toGeoJSON()ObjectReturns a GeoJSON representation of the polyline (GeoJSON LineString Feature).
        + + + +

        MultiPolyline

        + +

        Extends FeatureGroup to allow creating multi-polylines (single layer that consists of several polylines that share styling/popup).

        + +

        Creation

        + + + + + + + + + + + + + + +
        FactoryDescription
        L.multiPolyline( + <LatLng[][]> latlngs, + <Polyline options> options? ) + Instantiates a multi-polyline object given an array of arrays of geographical points (one for each individual polyline) and optionally an options object.
        + + +

        Methods

        + +

        MultiPolylines accept all Polyline methods but +have different behavior around their coordinate contents since they can contain +multiple line features:

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        setLatLngs( + <LatLng[][]> latlngs ) + thisReplace all lines and their paths with the given array of arrays of + geographical points.
        getLatLngs()<LatLng[][]> latlngs + Returns an array of arrays of geographical points in each line.
        openPopup()thisOpens the popup previously bound by bindPopup.
        toGeoJSON()ObjectReturns a GeoJSON representation of the multipolyline (GeoJSON MultiLineString Feature).
        + + + +

        Polygon

        + +

        A class for drawing polygon overlays on a map. Extends Polyline. Use Map#addLayer to add it to the map.

        + +

        Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.polygon( + <LatLng[]> latlngs, + <Polyline options> options? ) + Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside.
        + +

        Methods

        + +

        Polygon has the same options and methods as Polyline, with the following differences:

        + + + + + + + + + + + + +
        MethodReturnsDescription
        toGeoJSON()ObjectReturns a GeoJSON representation of the polygon (GeoJSON Polygon Feature).
        + + +

        MultiPolygon

        + +

        Extends FeatureGroup to allow creating multi-polygons (single layer that consists of several polygons that share styling/popup).

        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.multiPolygon( + <LatLng[][]> latlngs, + <Polyline options> options? ) + Instantiates a multi-polygon object given an array of latlngs arrays (one for each individual polygon) and optionally an options object (the same as for MultiPolyline).
        + +

        Methods

        + +

        MultiPolygons accept all Polyline methods but +have different behavior around their coordinate contents since they can contain +multiple polygon features:

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        setLatLngs( + <LatLng[][]> latlngs ) + thisReplace all polygons and their paths with the given array of arrays of + geographical points.
        getLatLngs()<LatLng[][]> latlngs + Returns an array of arrays of geographical points in each polygon.
        openPopup()thisOpens the popup previously bound by bindPopup.
        toGeoJSON()ObjectReturns a GeoJSON representation of the multipolygon (GeoJSON MultiPolygon Feature).
        + +

        Rectangle

        + +

        A class for drawing rectangle overlays on a map. Extends Polygon. Use Map#addLayer to add it to the map.

        + +

        Usage example

        +
        // define rectangle geographical bounds
        +var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];
        +
        +// create an orange rectangle
        +L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map);
        +
        +// zoom the map to the rectangle bounds
        +map.fitBounds(bounds);
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.rectangle( + <LatLngBounds> bounds, + <Path options> options? ) + Instantiates a rectangle object with the given geographical bounds and optionally an options object.
        + +

        Methods

        + +

        You can use Path methods and additionally the following methods:

        + + + + + + + + + + + + + +
        MethodReturnsDescription
        setBounds( + <LatLngBounds> bounds ) + thisRedraws the rectangle with the passed bounds.
        + + +

        Circle

        + +

        A class for drawing circle overlays on a map. Extends Path. Use Map#addLayer to add it to the map.

        + +
        L.circle([50.5, 30.5], 200).addTo(map);
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.circle( + <LatLng> latlng, + <Number> radius, + <Path options> options? ) + Instantiates a circle object given a geographical point, a radius in meters and optionally an options object.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        getLatLng()LatLngReturns the current geographical position of the circle.
        getRadius()NumberReturns the current radius of a circle. Units are in meters.
        setLatLng( + <LatLng> latlng ) + thisSets the position of a circle to a new location.
        setRadius( + <Number> radius ) + thisSets the radius of a circle. Units are in meters.
        toGeoJSON()ObjectReturns a GeoJSON representation of the circle (GeoJSON Point Feature).
        + + + +

        CircleMarker

        + +

        A circle of a fixed size with radius specified in pixels. Extends Circle. Use Map#addLayer to add it to the map.

        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.circleMarker( + <LatLng> latlng, + <Path options> options? ) + Instantiates a circle marker given a geographical point and optionally an options object. The default radius is 10 and can be altered by passing a "radius" member in the path options object.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        setLatLng( + <LatLng> latlng ) + thisSets the position of a circle marker to a new location.
        setRadius( + <Number> radius ) + thisSets the radius of a circle marker. Units are in pixels.
        toGeoJSON()ObjectReturns a GeoJSON representation of the circle marker (GeoJSON Point Feature).
        + + + +

        LayerGroup

        + +

        Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.

        + +
        L.layerGroup([marker1, marker2])
        +	.addLayer(polyline)
        +	.addTo(map);
        + +

        Creation

        + + + + + + + + + + + + +
        FactoryDescription
        L.layerGroup( + <ILayer[]> layers? ) + Create a layer group, optionally given an initial set of layers.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addTo( + <Map> map ) + thisAdds the group of layers to the map.
        addLayer( + <ILayer> layer ) + thisAdds a given layer to the group.
        removeLayer( + <ILayer> layer ) + thisRemoves a given layer from the group.
        removeLayer( + <String> id ) + thisRemoves a given layer of the given id from the group.
        hasLayer( + <ILayer> layer ) + BooleanReturns true if the given layer is currently added to the group.
        getLayer( + <String> id ) + ILayerReturns the layer with the given id.
        getLayers()ArrayReturns an array of all the layers added to the group.
        clearLayers()thisRemoves all the layers from the group.
        eachLayer( + <Function> fn, + <Object> context? ) + thisIterates over the layers of the group, optionally specifying context of the iterator function. +
        group.eachLayer(function (layer) {
        +	layer.bindPopup('Hello');
        +});
        +
        toGeoJSON()ObjectReturns a GeoJSON representation of the layer group (GeoJSON FeatureCollection).
        + + + +

        FeatureGroup

        + +

        Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.

        + +
        L.featureGroup([marker1, marker2, polyline])
        +	.bindPopup('Hello world!')
        +	.on('click', function() { alert('Clicked on a group!'); })
        +	.addTo(map);
        + +

        Creation

        + + + + + + + + + + + + + + +
        FactoryDescription
        L.featureGroup( + <ILayer[]> layers? ) + Create a layer group, optionally given an initial set of layers.
        + +

        Methods

        + +

        Has all layerGroup methods and additionally:

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        bindPopup( + <String> htmlContent, + <Popup options> options? ) + thisBinds a popup with a particular HTML content to a click on any layer from the group that has a bindPopup method.
        getBounds()LatLngBoundsReturns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).
        setStyle( + <Path options> style ) + thisSets the given path options to each layer of the group that has a setStyle method.
        bringToFront()thisBrings the layer group to the top of all other layers.
        bringToBack()thisBrings the layer group to the bottom of all other layers.
        + +

        Events

        + +

        You can subscribe to the following events using these methods.

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        clickMouseEventFired when the user clicks (or taps) the group.
        dblclickMouseEventFired when the user double-clicks (or double-taps) the group.
        mouseoverMouseEventFired when the mouse enters the group.
        mouseoutMouseEventFired when the mouse leaves the group.
        mousemoveMouseEventFired while the mouse moves over the layers of the group.
        contextmenuMouseEventFired when the user right-clicks on one of the layers.
        layeraddLayerEvent + Fired when a layer is added to the group.
        layerremoveLayerEvent + Fired when a layer is removed from the map.
        + + +

        GeoJson

        + +

        Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup.

        + +
        L.geoJson(data, {
        +	style: function (feature) {
        +		return {color: feature.properties.color};
        +	},
        +	onEachFeature: function (feature, layer) {
        +		layer.bindPopup(feature.properties.description);
        +	}
        +}).addTo(map);
        + +

        Each feature layer created by it gets a feature property that links to the GeoJSON feature data the layer was created from (so that you can access its properties later).

        + +

        Creation

        + + + + + + + + + + + +
        FactoryDescription
        L.geoJson( + <Object> geojson?, + <GeoJSON options> options? ) + Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format to display on the map (you can alternatively add it later with addData method) and an options object.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionDescription
        pointToLayer( + <GeoJSON> featureData, + <LatLng> latlng ) + Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created).
        style( + <GeoJSON> featureData ) + Function that will be used to get style options for vector layers created for GeoJSON features.
        onEachFeature( + <GeoJSON> featureData, + <ILayer> layer ) + Function that will be called on each created feature layer. Useful for attaching events and popups to features.
        filter( + <GeoJSON> featureData, + <ILayer> layer ) + Function that will be used to decide whether to show a feature or not.
        coordsToLatLng( + <Array> coords ) + Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 — standard [longitude, latitude] values in degrees).
        + +

        Additionally accepts all Path options for polylines and polygons.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addData( + <GeoJSON> data ) + thisAdds a GeoJSON object to the layer.
        setStyle( + <Function> style ) + thisChanges styles of GeoJSON vector layers with the given style function.
        resetStyle( + <Path> layer ) + thisResets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.
        + +

        Static methods

        + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        geometryToLayer( + <GeoJSON> featureData, + <Function> pointToLayer? ) + ILayerCreates a layer from a given GeoJSON feature.
        coordsToLatLng( + <Array> coords, + <Boolean> reverse? ) + LatLngCreates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude).
        coordsToLatLngs( + <Array> coords, + <Number> levelsDeep?, + <Boolean> reverse? ) + ArrayCreates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude).
        + + + + +

        LatLng

        + +

        Represents a geographical point with a certain latitude and longitude.

        +
        var latlng = L.latLng(50.5, 30.5);
        + +

        All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:

        + +
        map.panTo([50, 30]);
        +map.panTo({lon: 30, lat: 50});
        +map.panTo({lat: 50, lng: 30});
        +map.panTo(L.latLng(50, 30));
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.latLng( + <Number> latitude, + <Number> longitude, + <Number> altitude? ) + Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).
        + +

        Properties

        + + + + + + + + + + + + + + + + + +
        PropertyTypeDescription
        latNumberLatitude in degrees.
        lngNumberLongitude in degrees.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        distanceTo( + <LatLng> otherLatlng ) + NumberReturns the distance (in meters) to the given LatLng calculated using the Haversine formula. See description on wikipedia
        equals( + <LatLng> otherLatlng ) + BooleanReturns true if the given LatLng point is at the same position (within a small margin of error).
        toString()StringReturns a string representation of the point (for debugging purposes).
        wrap( + <Number> left, + <Number> right ) + LatLngReturns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default).
        + +

        Constants

        + + + + + + + + + + + + + + + + + + + + + + + + + + +
        ConstantTypeValueDescription
        DEG_TO_RADNumberMath.PI / 180A multiplier for converting degrees into radians.
        RAD_TO_DEGNumber180 / Math.PIA multiplier for converting radians into degrees.
        MAX_MARGINNumber1.0E-9Max margin of error for the equality check.
        + + + + +

        LatLngBounds

        + +

        Represents a rectangular geographical area on a map.

        +
        var southWest = L.latLng(40.712, -74.227),
        +	northEast = L.latLng(40.774, -74.125),
        +	bounds = L.latLngBounds(southWest, northEast);
        + +

        All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:

        + +
        map.fitBounds([
        +	[40.712, -74.227],
        +	[40.774, -74.125]
        +]);
        + +

        Creation

        + + + + + + + + + + + + + + + + + + +
        FactoryDescription
        + L.latLngBounds( + <LatLng> southWest, + <LatLng> northEast ) + Creates a latLngBounds object by defining south-west and north-east corners of the rectangle.
        L.latLngBounds( + <LatLng[]> latlngs ) + Creates a LatLngBounds object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with fitBounds.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        extend( + <LatLng|LatLngBounds> latlng ) + thisExtends the bounds to contain the given point or bounds.
        getSouthWest()LatLngReturns the south-west point of the bounds.
        getNorthEast()LatLngReturns the north-east point of the bounds.
        getNorthWest()LatLngReturns the north-west point of the bounds.
        getSouthEast()LatLngReturns the south-east point of the bounds.
        getWest()NumberReturns the west longitude of the bounds.
        getSouth()NumberReturns the south latitude of the bounds.
        getEast()NumberReturns the east longitude of the bounds.
        getNorth()NumberReturns the north latitude of the bounds.
        getCenter()LatLngReturns the center point of the bounds.
        contains( + <LatLngBounds> otherBounds ) + BooleanReturns true if the rectangle contains the given one.
        contains( + <LatLng> latlng ) + BooleanReturns true if the rectangle contains the given point.
        intersects( + <LatLngBounds> otherBounds ) + BooleanReturns true if the rectangle intersects the given bounds.
        equals( + <LatLngBounds> otherBounds ) + BooleanReturns true if the rectangle is equivalent (within a small margin of error) to the given bounds.
        toBBoxString()StringReturns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.
        pad( + <Number> bufferRatio ) + LatLngBoundsReturns bigger bounds created by extending the current bounds by a given percentage in each direction.
        isValid() + BooleanReturns true if the bounds are properly initialized.
        + + + + +

        Point

        + +

        Represents a point with x and y coordinates in pixels.

        + +
        var point = L.point(200, 300);
        + +

        All Leaflet methods and options that accept Point objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:

        + +
        map.panBy([200, 300]);
        +map.panBy(L.point(200, 300));
        + +

        Creation

        + + + + + + + + + + + +
        FactoryDescription
        L.point( + <Number> x, <Number> y, + <Boolean> round? ) + Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values.
        + +

        Properties

        + + + + + + + + + + + + + + + + + +
        PropertyTypeDescription
        xNumberThe x coordinate.
        yNumberThe y coordinate.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        add( + <Point> otherPoint ) + PointReturns the result of addition of the current and the given points.
        subtract( + <Point> otherPoint ) + PointReturns the result of subtraction of the given point from the current.
        multiplyBy( + <Number> number ) + PointReturns the result of multiplication of the current point by the given number.
        divideBy( + <Number> number, + <Boolean> round? ) + PointReturns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result.
        distanceTo( + <Point> otherPoint ) + NumberReturns the distance between the current and the given points.
        clone()PointReturns a copy of the current point.
        round()PointReturns a copy of the current point with rounded coordinates.
        floor()PointReturns a copy of the current point with floored coordinates (rounded down).
        equals( + <Point> otherPoint ) + BooleanReturns true if the given point has the same coordinates.
        contains( + <Point> otherPoint ) + BooleanReturns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).
        toString()StringReturns a string representation of the point for debugging purposes.
        + + + +

        Bounds

        + +

        Represents a rectangular area in pixel coordinates.

        +
        var p1 = L.point(10, 10),
        +	p2 = L.point(40, 60),
        +	bounds = L.bounds(p1, p2);
        + +

        All Leaflet methods that accept Bounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:

        + +
        otherBounds.intersects([[10, 10], [40, 60]]);
        + +

        Creation

        + + + + + + + + + + + + + + + + + + + + +
        FactoryDescription
        L.bounds( + <Point> topLeft, + <Point> bottomRight ) + Creates a Bounds object from two coordinates (usually top-left and bottom-right corners).
        L.bounds( + <Point[]> points ) + Creates a Bounds object defined by the points it contains.
        + +

        Properties

        + + + + + + + + + + + + + + + + + +
        PropertyTypeDescription
        minPointThe top left corner of the rectangle.
        maxPointThe bottom right corner of the rectangle.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        extend( + <Point> point ) + -Extends the bounds to contain the given point.
        getCenter()PointReturns the center point of the bounds.
        contains( + <Bounds> otherBounds ) + BooleanReturns true if the rectangle contains the given one.
        contains( + <Point> point ) + BooleanReturns true if the rectangle contains the given point.
        intersects( + <Bounds> otherBounds ) + BooleanReturns true if the rectangle intersects the given bounds.
        isValid()BooleanReturns true if the bounds are properly initialized.
        getSize()PointReturns the size of the given bounds.
        + + +

        Icon

        + +

        Represents an icon to provide when creating a marker.

        + +
        var myIcon = L.icon({
        +	iconUrl: 'my-icon.png',
        +	iconRetinaUrl: 'my-icon@2x.png',
        +	iconSize: [38, 95],
        +	iconAnchor: [22, 94],
        +	popupAnchor: [-3, -76],
        +	shadowUrl: 'my-icon-shadow.png',
        +	shadowRetinaUrl: 'my-icon-shadow@2x.png',
        +	shadowSize: [68, 95],
        +	shadowAnchor: [22, 94]
        +});
        +
        +L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
        + +

        L.Icon.Default extends L.Icon and is the blue icon Leaflet uses for markers by default.

        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.icon( + <Icon options> options ) + Creates an icon instance with the given options.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDescription
        iconUrlString + (required) The URL to the icon image (absolute or relative to your script path).
        iconRetinaUrlString + The URL to a retina sized version of the icon image (absolute or relative to your script path). Used for Retina screen devices.
        iconSizePointSize of the icon image in pixels.
        iconAnchorPointThe coordinates of the "tip" of the icon (relative to its top left corner). The icon will be aligned so that this point is at the marker's geographical location. Centered by default if size is specified, also can be set in CSS with negative margins.
        shadowUrlString + The URL to the icon shadow image. If not specified, no shadow image will be created.
        shadowRetinaUrlString + The URL to the retina sized version of the icon shadow image. If not specified, no shadow image will be created. Used for Retina screen devices.
        shadowSizePointSize of the shadow image in pixels.
        shadowAnchorPointThe coordinates of the "tip" of the shadow (relative to its top left corner) (the same as iconAnchor if not specified).
        popupAnchorPointThe coordinates of the point from which popups will "open", relative to the icon anchor.
        classNameString + A custom class name to assign to both icon and shadow images. Empty by default.
        + + +

        DivIcon

        + +

        Represents a lightweight icon for markers that uses a simple div element instead of an image.

        + +
        var myIcon = L.divIcon({className: 'my-div-icon'});
        +// you can set .my-div-icon styles in CSS
        +
        +L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
        + +

        By default, it has a 'leaflet-div-icon' class and is styled as a little white square with a shadow.

        + +

        Creation

        + + + + + + + + + + + + + + +
        FactoryDescription
        L.divIcon( + <DivIcon options> options ) + Creates a div icon instance with the given options.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDescription
        iconSizePointSize of the icon in pixels. Can be also set through CSS.
        iconAnchorPointThe coordinates of the "tip" of the icon (relative to its top left corner). The icon will be aligned so that this point is at the marker's geographical location. Centered by default if size is specified, also can be set in CSS with negative margins.
        popupAnchorPointThe coordinates of the point from which popups will "open", relative to the icon anchor.
        classNameString + A custom class name to assign to the icon. 'leaflet-div-icon' by default.
        htmlString + A custom HTML code to put inside the div element, empty by default.
        + + + + +

        Control

        + +

        The base class for all Leaflet controls. Implements IControl interface. You can add controls to the map like this:

        + +
        control.addTo(map);
        +// the same as
        +map.addControl(control);
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.control( + <Control options> options? ) + Creates a control with the given options.
        + +

        Options

        + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        positionString'topright'The initial position of the control (one of the map corners). See control positions.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        setPosition( + <String> position ) + thisSets the position of the control. See control positions.
        getPosition()StringReturns the current position of the control.
        addTo( + <Map> map ) + thisAdds the control to the map.
        removeFrom( + <Map> map ) + thisRemoves the control from the map.
        getContainer()HTMLElementReturns the HTML container of the control.
        + +

        Control Positions

        + +

        Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

        + + + + + + + + + + + + + + + + + + + + + + +
        PositionDescription
        'topleft'Top left of the map.
        'topright'Top right of the map.
        'bottomleft'Bottom left of the map.
        'bottomright'Bottom right of the map.
        + + +

        Control.zoom

        + +

        A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

        + +

        Creation

        + + + + + + + + + + + + +
        FactoryDescription
        L.control.zoom( + <Control.Zoom options> options? ) + Creates a zoom control.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        positionString'topleft'The position of the control (one of the map corners). See control positions.
        zoomInTextString'+'The text set on the zoom in button.
        zoomOutTextString'-'The text set on the zoom out button.
        zoomInTitleString'Zoom in'The title set on the zoom in button.
        zoomOutTitleString'Zoom out'The title set on the zoom out button.
        + + + +

        Control.Attribution

        + +

        The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. Extends Control.

        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.control.attribution( + <Control.Attribution options> options? ) + Creates an attribution control.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        positionString'bottomright'The position of the control (one of the map corners). See control positions.
        prefixString'Leaflet'The HTML text shown before the attributions. Pass false to disable.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        setPrefix( + <String> prefix ) + thisSets the text before the attributions.
        addAttribution( + <String> text ) + thisAdds an attribution text (e.g. 'Vector data &copy; Mapbox').
        removeAttribution( + <String> text ) + thisRemoves an attribution text.
        + + +

        Control.Layers

        + +

        The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the detailed example). Extends Control.

        + +
        var baseLayers = {
        +	"Mapbox": mapbox,
        +	"OpenStreetMap": osm
        +};
        +
        +var overlays = {
        +	"Marker": marker,
        +	"Roads": roadsLayer
        +};
        +
        +L.control.layers(baseLayers, overlays).addTo(map);
        + +

        Creation

        + + + + + + + + + + +
        FactoryDescription
        L.control.layers( + <Layer Config> baseLayers?, + <Layer Config> overlays?, + <Control.Layers options> options? ) + Creates an attribution control with the given layers. Base layers will be switched with radio buttons, while overlays will be switched with checkboxes. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addBaseLayer( + <ILayer> layer, + <String> name ) + thisAdds a base layer (radio button entry) with the given name to the control.
        addOverlay( + <ILayer> layer, + <String> name ) + thisAdds an overlay (checkbox entry) with the given name to the control.
        removeLayer( + <ILayer> layer ) + thisRemove the given layer from the control.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        positionString'topright'The position of the control (one of the map corners). See control positions.
        collapsedBooleantrueIf true, the control will be collapsed into an icon and expanded on mouse hover or touch.
        autoZIndexBooleantrueIf true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.
        + + +

        Layer Config

        + +

        An object literal with layer names as keys and layer objects as values:

        + +
        {
        +	"<someName1>": layer1,
        +	"<someName2>": layer2
        +}
        + +

        The layer names can contain HTML, which allows you to add additional styling to the items:

        + +
        {"<img src='my-layer-icon' /> <span class='my-layer-item'>My Layer</span>": myLayer}
        + + +

        Events

        + +

        You can subscribe to the following events on the Map object using these methods.

        + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        baselayerchangeLayersControlEvent + Fired when the base layer is changed through the control.
        overlayaddLayersControlEvent + Fired when an overlay is selected through the control.
        overlayremoveLayersControlEvent + Fired when an overlay is deselected through the control.
        + + +

        Control.Scale

        + +

        A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends Control.

        + +
        L.control.scale().addTo(map);
        + +

        Creation

        + + + + + + + + + + + + + +
        FactoryDescription
        L.control.scale( + <Control.Scale options> options? ) + Creates an scale control with the given options.
        + +

        Options

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        OptionTypeDefaultDescription
        positionString'bottomleft'The position of the control (one of the map corners). See control positions.
        maxWidthNumber100Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
        metricBooleantrueWhether to show the metric scale line (m/km).
        imperialBooleantrueWhether to show the imperial scale line (mi/ft).
        updateWhenIdleBooleanfalseIf true, the control is updated on moveend, otherwise it's always up-to-date (updated on move).
        + + + +

        Events methods

        + +

        A set of methods shared between event-powered classes (like Map). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map 'click' event).

        + +

        Example

        + +
        map.on('click', function(e) {
        +	alert(e.latlng);
        +});
        + +

        Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:

        + +
        function onClick(e) { ... }
        +
        +map.on('click', onClick);
        +map.off('click', onClick);
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addEventListener( + <String> type, + <Function> fn, + <Object> context? ) + thisAdds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').
        addOneTimeEventListener( + <String> type, + <Function> fn, + <Object> context? ) + thisThe same as above except the listener will only get fired once and then removed.
        addEventListener( + <Object> eventMap, + <Object> context? ) + thisAdds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
        removeEventListener( + <String> type, + <Function> fn?, + <Object> context? ) + thisRemoves a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to addEventListener, you must pass the same context to removeEventListener in order to remove the listener.
        removeEventListener( + <Object> eventMap, + <Object> context? ) + thisRemoves a set of type/listener pairs.
        removeEventListener()thisRemoves all listeners. An alias to clearAllEventListeners when you use it without arguments.
        hasEventListeners( + <String> type ) + BooleanReturns true if a particular event type has some listeners attached to it.
        fireEvent( + <String> type, + <Object> data? ) + thisFires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties.
        clearAllEventListeners()thisRemoves all listeners to all events on the object.
        on( … )thisAlias to addEventListener.
        once( … )thisAlias to addOneTimeEventListener.
        off( … )thisAlias to removeEventListener.
        fire( … )thisAlias to fireEvent.
        + + +

        Event objects

        + +

        Event object is an object that you receive as an argument in a listener function when some event is fired, containing useful information about that event. For example:

        + +
        map.on('click', function(e) {
        +	alert(e.latlng); // e is an event object (MouseEvent in this case)
        +});
        + +

        Event

        + +

        The base event object. All other event objects contain these properties too.

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        typeStringThe event type (e.g. 'click').
        targetObjectThe object that fired the event.
        + +

        MouseEvent

        + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        propertytypedescription
        latlngLatLngThe geographical point where the mouse event occurred.
        layerPointPointPixel coordinates of the point where the mouse event occurred relative to the map layer.
        containerPointPointPixel coordinates of the point where the mouse event occurred relative to the map сontainer.
        originalEventDOMMouseEventThe original DOM mouse event fired by the browser.
        + +

        LocationEvent

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        propertytypedescription
        latlngLatLngDetected geographical location of the user.
        boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
        accuracyNumberAccuracy of location in meters.
        altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
        altitudeAccuracyNumberAccuracy of altitude in meters.
        headingNumberThe direction of travel in degrees counting clockwise from true North.
        speedNumberCurrent velocity in meters per second.
        timestampNumberThe time when the position was acquired.
        + +

        ErrorEvent

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        messageStringError message.
        codeNumberError code (if applicable).
        + +

        LayerEvent

        + + + + + + + + + + + + +
        propertytypedescription
        layerILayerThe layer that was added or removed.
        + +

        LayersControlEvent

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        layerILayerThe layer that was added or removed.
        nameStringThe name of the layer that was added or removed.
        + +

        TileEvent

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        tileHTMLElementThe tile element (image).
        urlStringThe source URL of the tile.
        + +

        ResizeEvent

        + + + + + + + + + + + + + + + + + +
        propertytypedescription
        oldSizePointThe old size before resize event.
        newSizePointThe new size after the resize event.
        + +

        GeoJSON event

        + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        propertytypedescription
        layerILayerThe layer for the GeoJSON feature that is being added to the map.
        propertiesObjectGeoJSON properties of the feature.
        geometryTypeStringGeoJSON geometry type of the feature.
        idStringGeoJSON ID of the feature (if present).
        + + + + + + + + + + + + + + +
        propertytypedescription
        popupPopupThe popup that was opened or closed.
        + +

        DragEndEvent

        + + + + + + + + + + + + +
        propertytypedescription
        distanceNumberThe distance in pixels the draggable element was moved by.
        + + + + + + +

        Class

        + +

        L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

        +

        In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

        + +
        var MyClass = L.Class.extend({
        +	initialize: function (greeter) {
        +		this.greeter = greeter;
        +		// class constructor
        +	},
        +
        +	greet: function (name) {
        +		alert(this.greeter + ', ' + name)
        +	}
        +});
        +
        +// create instance of MyClass, passing "Hello" to the constructor
        +var a = new MyClass("Hello");
        +
        +// call greet method, alerting "Hello, World"
        +a.greet("World");
        +
        + +

        The initialize method is your class's constructor function, meaning that it gets called when you do new MyClass(...).

        + + +

        Class Factories

        + +

        You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:

        + +
        new L.Map('map'); // becomes:
        +L.map('map');
        + +

        The factories are implemented very easily, and you can do this for your own classes:

        + +
        L.map = function (id, options) {
        +	return new L.Map(id, options);
        +};
        + + +

        Inheritance

        + +

        You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

        + +
        var MyChildClass = MyClass.extend({
        +	// ... new properties and methods
        +});
        + +

        This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

        + +
        var a = new MyChildClass();
        +a instanceof MyChildClass; // true
        +a instanceof MyClass; // true
        +
        + +

        You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

        + +
        var MyChildClass = MyClass.extend({
        +	initialize: function () {
        +		MyClass.prototype.initialize.call(this, "Yo");
        +	},
        +
        +	greet: function (name) {
        +		MyClass.prototype.greet.call(this, 'bro ' + name + '!');
        +	}
        +});
        +
        +var a = new MyChildClass();
        +a.greet('Jason'); // alerts "Yo, bro Jason!"
        + +

        Options

        + +

        options is a special property that unlike other objects that you pass to extend will be merged with the parent one instead of overriding it completely, which makes managing configuration of objects and default values convenient:

        + +
        var MyClass = L.Class.extend({
        +	options: {
        +		myOption1: 'foo',
        +		myOption2: 'bar'
        +	}
        +});
        +
        +var MyChildClass = MyClass.extend({
        +	options: {
        +		myOption1: 'baz',
        +		myOption3: 5
        +	}
        +});
        +
        +var a = new MyChildClass();
        +a.options.myOption1; // 'baz'
        +a.options.myOption2; // 'bar'
        +a.options.myOption3; // 5
        + +

        There's also L.Util.setOptions, a method for conveniently merging options passed to constructor with the defaults defined in the class:

        + +
        var MyClass = L.Class.extend({
        +	options: {
        +		foo: 'bar',
        +		bla: 5
        +	},
        +
        +	initialize: function (options) {
        +		L.Util.setOptions(this, options);
        +		...
        +	}
        +});
        +
        +var a = new MyClass({bla: 10});
        +a.options; // {foo: 'bar', bla: 10}
        + +

        Includes

        + +

        includes is a special class property that merges all specified objects into the class (such objects are called mixins). A good example of this is L.Mixin.Events that event-related methods like on, off and fire to the class.

        + +
         var MyMixin = {
        +	foo: function () { ... },
        +	bar: 5
        +};
        +
        +var MyClass = L.Class.extend({
        +	includes: MyMixin
        +});
        +
        +var a = new MyClass();
        +a.foo();
        + +

        You can also do such includes in runtime with the include method:

        + +
        MyClass.include(MyMixin);
        + +

        Statics

        + +

        statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

        + +
        var MyClass = L.Class.extend({
        +	statics: {
        +		FOO: 'bar',
        +		BLA: 5
        +	}
        +});
        +
        +MyClass.FOO; // 'bar'
        + + +

        Constructor Hooks

        + +

        If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

        + +
        MyClass.addInitHook(function () {
        +	// ... do something in constructor additionally
        +	// e.g. add event listeners, set custom properties etc.
        +});
        + +

        You can also use the following shortcut when you just need to make one additional method call:

        + +
        MyClass.addInitHook('methodName', arg1, arg2, …);
        + + +

        Browser

        + +

        A namespace with properties for browser/feature detection used by Leaflet internally.

        + +
        if (L.Browser.ie6) {
        +	alert('Upgrade your browser, dude!');
        +}
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        propertytypedescription
        ieBooleantrue for all Internet Explorer versions.
        ie6Booleantrue for Internet Explorer 6.
        ie7Booleantrue for Internet Explorer 7.
        webkitBooleantrue for webkit-based browsers like Chrome and Safari (including mobile versions).
        webkit3dBooleantrue for webkit-based browsers that support CSS 3D transformations.
        androidBooleantrue for Android mobile browser.
        android23Booleantrue for old Android stock browsers (2 and 3).
        mobileBooleantrue for modern mobile browsers (including iOS Safari and different Android browsers).
        mobileWebkitBooleantrue for mobile webkit-based browsers.
        mobileOperaBooleantrue for mobile Opera.
        touchBooleantrue for all browsers on touch devices.
        msTouchBooleantrue for browsers with Microsoft touch model (e.g. IE10).
        retinaBooleantrue for devices with Retina screens.
        + + +

        Util

        + +

        Various utility functions, used by Leaflet internally.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        extend( + <Object> dest, + <Object> src?.. ) + ObjectMerges the properties of the src object (or multiple objects) into dest object and returns the latter. Has an L.extend shortcut.
        bind( + <Function> fn, + <Object> obj ) + FunctionReturns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. Not a polyfill for ES 5 bind (compare L.bind to the MDN-recommended polyfill for Function.prototype.bind).
        stamp( <Object> obj )StringApplies a unique key to the object and returns that key. Has an L.stamp shortcut.
        requestAnimFrame( + <Function> fn, + <Object> context?, + <Boolean> immediate?, + <HTMLElement> element? ) + NumberSchedules fn to be executed when the browser repaints. When immediate is set, fn is called immediately if the browser doesn't have native support for requestAnimationFrame, otherwise it's delayed. Returns an id that can be used to cancel the request
        cancelAnimFrame( + <Number> id ) + -Cancels a previous request to requestAnimFrame.
        limitExecByInterval( + <Function> fn, + <Number> time, + <Object> context? ) + FunctionReturns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time, but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called.
        falseFn()FunctionAlways returns false.
        formatNum( + <Number> num, + <Number> digits ) + NumberReturns the number num rounded to digits decimals.
        splitWords( + <String> str ) + String[]Trims and splits the string on whitespace and returns the array of parts.
        setOptions( + <Object> obj, + <Object> options ) + ObjectMerges the given properties to the options of the obj object, returning the resulting options. See Class options. Has an L.setOptions shortcut.
        getParamString( + <Object> obj ) + StringConverts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'.
        template( + <String> str, <Object> data ) + StringSimple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument.
        isArray( + <Object> obj ) + BooleanReturns true if the given object is an array.
        trim( + <String> str ) + StringTrims the whitespace from both ends of the string and returns the result.
        + +

        Properties

        + + + + + + + + + + + + +
        PropertyTypeDescription
        emptyImageUrlStringData URI string containing a base64-encoded empty GIF image. Used as a hack to free memory from unused images on WebKit-powered mobile devices (by setting image src to this string).
        + + + +

        Transformation

        + +

        Represents an affine transformation: a set of coefficients a, b, c, d for transforming a point of a form (x, y) into (a*x + b, c*y + d) and doing the reverse. Used by Leaflet in its projections code.

        + +
        var transformation = new L.Transformation(2, 5, -1, 10),
        +	p = L.point(1, 2),
        +	p2 = transformation.transform(p), //  L.point(7, 8)
        +	p3 = transformation.untransform(p2); //  L.point(1, 2)
        +
        + +

        Creation

        + + + + + + + + + + + +
        CreationDescription
        new L.Transformation( + <Number> a, + <Number> b, + <Number> c, + <Number> d ) + Creates a transformation object with the given coefficients.
        + +

        Methods

        + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        transform( + <Point> point, + <Number> scale? ) + PointReturns a transformed point, optionally multiplied by the given scale. Only accepts real L.Point instances, not arrays.
        untransform( + <Point> point, + <Number> scale? ) + PointReturns the reverse transformation of the given point, optionally divided by the given scale. Only accepts real L.Point instances, not arrays.
        + + + + +

        LineUtil

        + +

        Various utility functions for polyline points processing, used by Leaflet internally to make polylines lightning-fast.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        simplify( + <Point[]> points, + <Number> tolerance ) + Point[]Dramatically reduces the number of points in a polyline while retaining its shape and returns a new array of simplified points. Used for a huge performance boost when processing/displaying Leaflet polylines for each zoom level and also reducing visual noise. tolerance affects the amount of simplification (lesser value means higher quality but slower and with more points). Also released as a separated micro-library Simplify.js.
        pointToSegmentDistance( + <Point> p, + <Point> p1, + <Point> p2 ) + NumberReturns the distance between point p and segment p1 to p2.
        closestPointOnSegment( + <Point> p, + <Point> p1, + <Point> p2 ) + PointReturns the closest point from a point p on a segment p1 to p2.
        clipSegment( + <Point> a, + <Point> b, + <Bounds> bounds ) + -Clips the segment a to b by rectangular bounds (modifying the segment points directly!). Used by Leaflet to only show polyline points that are on the screen or near, increasing performance.
        + + + +

        PolyUtil

        + +

        Various utility functions for polygon geometries.

        + +

        Methods

        + + + + + + + + + + + + + + +
        MethodReturnsDescription
        clipPolygon( + <Point[]> points, + <Bounds> bounds ) + Point[]Clips the polygon geometry defined by the given points by rectangular bounds. Used by Leaflet to only show polygon points that are on the screen or near, increasing performance. Note that polygon points needs different algorithm for clipping than polyline, so there's a separate method for it.
        + + + + +

        DomEvent

        + +

        Utility functions to work with the DOM events, used by Leaflet internally.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        addListener( + <HTMLElement> el, + <String> type, + <Function> fn, + <Object> context? ) + thisAdds a listener fn to the element's DOM event of the specified type. this keyword inside the listener will point to context, or to the element if not specified.
        removeListener( + <HTMLElement> el, + <String> type, + <Function> fn ) + thisRemoves an event listener from the element.
        stopPropagation( + <DOMEvent> e ) + thisStop the given event from propagation to parent elements. Used inside the listener functions: +
        L.DomEvent.addListener(div, 'click', function (e) {
        +	L.DomEvent.stopPropagation(e);
        +});
        +
        preventDefault( + <DOMEvent> e ) + thisPrevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions. +
        stop( + <DOMEvent> e ) + thisDoes stopPropagation and preventDefault at the same time.
        disableClickPropagation( + <HTMLElement> el ) + thisAdds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events.
        getMousePosition( + <DOMEvent> e, + <HTMLElement> container? ) + PointGets normalized mouse position from a DOM event relative to the container or to the whole page if not specified.
        getWheelDelta( + <DOMEvent> e ) + NumberGets normalized wheel delta from a mousewheel DOM event.
        + + + + +

        DomUtil

        + +

        Utility functions to work with the DOM tree, used by Leaflet internally.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        get( + <String or HTMLElement> id ) + HTMLElementReturns an element with the given id if a string was passed, or just returns the element if it was passed directly.
        getStyle( + <HTMLElement> el, + <String> style ) + StringReturns the value for a certain style attribute on an element, including computed values or values set through CSS.
        getViewportOffset( + <HTMLElement> el ) + PointReturns the offset to the viewport for the requested element.
        create( + <String> tagName, + <String> className, + <HTMLElement> container? ) + HTMLElementCreates an element with tagName, sets the className, and optionally appends it to container element.
        disableTextSelection()-Makes sure text cannot be selected, for example during dragging.
        enableTextSelection()-Makes text selection possible again.
        hasClass( + <HTMLElement> el, + <String> name ) + BooleanReturns true if the element class attribute contains name.
        addClass( + <HTMLElement> el, + <String> name ) + -Adds name to the element's class attribute.
        removeClass( + <HTMLElement> el, + <String> name ) + -Removes name from the element's class attribute.
        setOpacity( + <HTMLElement> el, + <Number> value ) + -Set the opacity of an element (including old IE support). Value must be from 0 to 1.
        testProp( + <String[]> props ) + String or falseGoes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform.
        getTranslateString( + <Point> point ) + StringReturns a CSS transform string to move an element by the offset provided in the given point. Uses 3D translate on WebKit for hardware-accelerated transforms and 2D on other browsers.
        getScaleString( + <Number> scale, + <Point> origin ) + StringReturns a CSS transform string to scale an element (with the given scale origin).
        setPosition( + <HTMLElement> el, + <Point> point, + <Boolean> disable3D? ) + -Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true.
        getPosition( + <HTMLElement> el ) + PointReturns the coordinates of an element previously positioned with setPosition.
        + +

        Properties

        + + + + + + + + + + + + + + + + + +
        PropertyTypeDescription
        TRANSITION + StringVendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit).
        TRANSFORM + StringVendor-prefixed transform style name.
        + + + +

        PosAnimation

        + +

        Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9.

        + +
        var fx = new L.PosAnimation();
        +fx.run(el, [300, 500], 0.5);
        + +

        Creation

        + + + + + + + + + + + +
        CreationDescription
        new L.PosAnimation()Creates a PosAnimation object.
        + +

        Methods

        + + + + + + + + + + + + + +
        MethodReturnsDescription
        run( + <HTMLElement> element, + <Point> newPos, + <Number> duration?, + <Number> easeLinearity? ) + thisRun an animation of a given element to a new position, optionally setting duration in seconds (0.25 by default) and easing linearity factor (3rd argument of the cubic bezier curve, 0.5 by default)
        + +

        Events

        + +

        You can subscribe to the following events using these methods.

        + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        startEventFired when the animation starts.
        stepEventFired continuously during the animation.
        endEventFired when the animation ends.
        + + + +

        Draggable

        + +

        A class for making DOM elements draggable (including touch support). Used internally for map and marker dragging. Only works for elements that were positioned with DomUtil#setPosition

        + +
        var draggable = new L.Draggable(elementToDrag);
        +draggable.enable();
        +
        + +

        Creation

        + + + + + + + + + + + +
        CreationDescription
        new L.Draggable( + <HTMLElement> element, + <HTMLElement> dragHandle? ) + Creates a Draggable object for moving the given element when you start dragging the dragHandle element (equals the element itself by default).
        + +

        Events

        + +

        You can subscribe to the following events using these methods.

        + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        EventDataDescription
        dragstartEventFired when the dragging starts.
        predragEventFired continuously during dragging before each corresponding update of the element position.
        dragEventFired continuously during dragging.
        dragendEventFired when the dragging ends.
        + +

        Methods

        + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        enable()-Enables the dragging ability.
        disable()-Disables the dragging ability.
        + + + + + +

        IHandler

        +

        An interface implemented by interaction handlers.

        + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        enable()-Enables the handler.
        disable()-Disables the handler.
        enabled()BooleanReturns true if the handler is enabled.
        + + +

        ILayer

        + +

        Represents an object attached to a particular location (or a set of locations) on a map. Implemented by tile layers, markers, popups, image overlays, vector layers and layer groups.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        onAdd( + <Map> map ) + -Should contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).
        onRemove( + <Map> map ) + -Should contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
        + +

        Implementing Custom Layers

        + +

        The most important things know about when implementing custom layers are Map viewreset event and latLngToLayerPoint method. viewreset is fired when the map needs to reposition its layers (e.g. on zoom), and latLngToLayerPoint is used to get coordinates for the layer's new position.

        + +

        Another event often used in layer implementations is moveend which fires after any movement of the map (panning, zooming, etc.).

        + +

        Another thing to note is that you'll usually need to add leaflet-zoom-hide class to the DOM elements you create for the layer so that it hides during zoom animation. Implementing zoom animation for custom layers is a complex topic and will be documented separately in future, but meanwhile you can take a look at how it's done for Leaflet layers (e.g. ImageOverlay) in the source.

        + +

        Custom Layer Example

        + +

        Here's how a custom layer implementation usually looks:

        + +
        var MyCustomLayer = L.Class.extend({
        +
        +	initialize: function (latlng) {
        +		// save position of the layer or any options from the constructor
        +		this._latlng = latlng;
        +	},
        +
        +	onAdd: function (map) {
        +		this._map = map;
        +
        +		// create a DOM element and put it into one of the map panes
        +		this._el = L.DomUtil.create('div', 'my-custom-layer leaflet-zoom-hide');
        +		map.getPanes().overlayPane.appendChild(this._el);
        +
        +		// add a viewreset event listener for updating layer's position, do the latter
        +		map.on('viewreset', this._reset, this);
        +		this._reset();
        +	},
        +
        +	onRemove: function (map) {
        +		// remove layer's DOM elements and listeners
        +		map.getPanes().overlayPane.removeChild(this._el);
        +		map.off('viewreset', this._reset, this);
        +	},
        +
        +	_reset: function () {
        +		// update layer's position
        +		var pos = this._map.latLngToLayerPoint(this._latlng);
        +		L.DomUtil.setPosition(this._el, pos);
        +	}
        +});
        +
        +map.addLayer(new MyCustomLayer(latlng));
        +
        + + + +

        IControl

        + +

        Represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls.

        + +

        Methods

        + +

        Every control in Leaflet should extend from Control class and additionally have the following methods:

        + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        onAdd( + <Map> map ) + HTMLElementShould contain code that creates all the neccessary DOM elements for the control, adds listeners on relevant map events, and returns the element containing the control. Called on map.addControl(control) or control.addTo(map).
        onRemove( + <Map> map ) + -Optional, should contain all clean up code (e.g. removes control's event listeners). Called on map.removeControl(control) or control.removeFrom(map). The control's DOM container is removed automatically.
        + +

        Custom Control Example

        + +
        var MyControl = L.Control.extend({
        +	options: {
        +		position: 'topright'
        +	},
        +
        +	onAdd: function (map) {
        +		// create the control container with a particular class name
        +		var container = L.DomUtil.create('div', 'my-custom-control');
        +
        +		// ... initialize other DOM elements, add listeners, etc.
        +
        +		return container;
        +	}
        +});
        +
        +map.addControl(new MyControl());
        +
        + +

        If specify your own constructor for the control, you'll also probably want to process options properly:

        + +
        var MyControl = L.Control.extend({
        +	initialize: function (foo, options) {
        +		// ...
        +		L.Util.setOptions(this, options);
        +	},
        +	// ...
        +});
        + +

        This will allow you to pass options like position when creating the control instances:

        + +
        map.addControl(new MyControl('bar', {position: 'bottomleft'}));
        + + + + +

        IProjection

        + +

        An object with methods for projecting geographical coordinates of the world onto a flat surface (and back). See Map projection.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        project( + <LatLng> latlng ) + PointProjects geographical coordinates into a 2D point.
        unproject( + <Point> point ) + LatLngThe inverse of project. Projects a 2D point into geographical location.
        + +

        Defined Projections

        + +

        Leaflet comes with a set of already defined projections out of the box:

        + + + + + + + + + + + + + + + + + + + + + +
        ProjectionDescription
        L.Projection.SphericalMercatorSpherical Mercator projection — the most common projection for online maps, used by almost all free and commercial tile providers. Assumes that Earth is a sphere. Used by the EPSG:3857 CRS.
        L.Projection.MercatorElliptical Mercator projection — more complex than Spherical Mercator. Takes into account that Earth is a geoid, not a perfect sphere. Used by the EPSG:3395 CRS.
        L.Projection.LonLatEquirectangular, or Plate Carree projection — the most simple projection, mostly used by GIS enthusiasts. Directly maps x as longitude, and y as latitude. Also suitable for flat worlds, e.g. game maps. Used by the EPSG:3395 and Simple CRS.
        + + + + +

        ICRS

        + +

        Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back (and to coordinates in other units for WMS services). See Spatial reference system.

        + +

        Methods

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        MethodReturnsDescription
        latLngToPoint( + <LatLng> latlng, + <Number> zoom ) + PointProjects geographical coordinates on a given zoom into pixel coordinates.
        pointToLatLng( + <Point> point, + <Number> zoom ) + LatLngThe inverse of latLngToPoint. Projects pixel coordinates on a given zoom into geographical coordinates.
        project( + <LatLng> latlng ) + PointProjects geographical coordinates into coordinates in units accepted for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
        scale( + <Number> zoom ) + NumberReturns the scale used when transforming projected coordinates into pixel coordinates for a particular zoom. For example, it returns 256 * 2^zoom for Mercator-based CRS.
        getSize( + <Number> zoom ) + PointReturns the size of the world in pixels for a particular zoom.
        + +

        Properties

        + + + + + + + + + + + + + + + + + + + + + + + + + + +
        PropertyTypeDescription
        projectionIProjectionProjection that this CRS uses.
        transformationTransformationTransformation that this CRS uses to turn projected coordinates into screen coordinates for a particular tile service.
        codeStringStandard code name of the CRS passed into WMS services (e.g. 'EPSG:3857').
        + +

        Defined CRS

        + +

        Leaflet comes with a set of already defined CRS to use out of the box:

        + + + + + + + + + + + + + + + + + + + + + + + + + + +
        ProjectionDescription
        L.CRS.EPSG3857The most common CRS for online maps, used by almost all free and commercial tile providers. Uses Spherical Mercator projection. Set in by default in Map's crs option.
        L.CRS.EPSG4326A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
        L.CRS.EPSG3395Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
        L.CRS.SimpleA simple CRS that maps longitude and latitude into x and y directly. May be used for maps of flat surfaces (e.g. game maps). Note that the y axis should still be inverted (going from bottom to top).
        + +

        If you want to use some obscure CRS not listed here, take a look at the Proj4Leaflet plugin.

        + + +

        Global Switches

        + +

        Global switches are created for rare cases and generally make Leaflet to not detect a particular browser feature even if it's there. You need to set the switch as a global variable to true before including Leaflet on the page, like this:

        + +
        <script>L_PREFER_CANVAS = true;</script>
        +<script src="leaflet.js"></script>
        + + + + + + + + + + + + + + + + + + +
        SwitchDescription
        L_PREFER_CANVASForces Leaflet to use the Canvas back-end (if available) for vector layers instead of SVG. This can increase performance considerably in some cases (e.g. many thousands of circle markers on the map).
        L_NO_TOUCHForces Leaflet to not use touch events even if it detects them.
        L_DISABLE_3DForces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning (which may cause glitches in some rare environments) even if they're supported.
        + +

        noConflict

        + +

        This method restores the L global variable to the original value it had before Leaflet inclusion, and returns the real Leaflet namespace so you can put it elsewhere, like this:

        + +

        // L points to some other library
        +...
        +// you include Leaflet, it replaces the L variable to Leaflet namespace
        +
        +var Leaflet = L.noConflict();
        +// now L points to that other library again, and you can use Leaflet.Map etc.
        + + +

        version

        + +

        A constant that represents the Leaflet version in use.

        + +

        L.version // contains "0.5" (or whatever version is currently in use)
        + + diff --git a/reference.html b/reference.html index 42e1fd51..d9a13161 100644 --- a/reference.html +++ b/reference.html @@ -6,6 +6,11 @@ bodyclass: api-page

        API Reference

        +

        This reference reflects Leaflet 1.0.

        + +

        Docs for 0.7 are available here. +Docs for 0.6 are available in the source form (see instructions for running docs).

        +

        Map

        @@ -125,7 +130,6 @@ bodyclass: api-page
        -

        This reference reflects Leaflet 1.0.

        Map

        From 077ba0cbdf015ac4cc1207343d6053a0a00f5e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Fri, 8 Jan 2016 10:49:40 +0100 Subject: [PATCH 56/58] Point to 0.7.x docs by default --- _layouts/v2.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_layouts/v2.html b/_layouts/v2.html index ed303745..87058321 100644 --- a/_layouts/v2.html +++ b/_layouts/v2.html @@ -73,7 +73,7 @@ {% if page.title == 'Documentation' %} Docs {% else %} - Docs + Docs {% endif %}
      • From f890b4984d970fe875754f973ce4f0304f05d03f Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 19 Jan 2016 15:41:52 +0100 Subject: [PATCH 57/58] Fix link to "map.createPane" method --- reference.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference.html b/reference.html index d9a13161..ac276fe5 100644 --- a/reference.html +++ b/reference.html @@ -1329,7 +1329,7 @@ var map = L.map('map', {

        Map Panes

        -

        Panes are DOM elements used to control the ordering of layers on the map. You can access panes with map.getPane or map.getPanesmethods. New panes can be created with the map.createPane method.

        +

        Panes are DOM elements used to control the ordering of layers on the map. You can access panes with map.getPane or map.getPanesmethods. New panes can be created with the map.createPane method.

        Every map has the following panes that differ only in zIndex.

        From 3feeb99680d51b5148687a0d665f135c5c538490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Fri, 5 Feb 2016 10:23:18 +0100 Subject: [PATCH 58/58] Renamed files so 0.7.x docs live at 'reference.html' --- _layouts/v2.html | 2 +- reference-0.7.x.html => reference-1.0.0.html | 3290 ++++++++++-------- reference.html | 3290 ++++++++---------- 3 files changed, 3291 insertions(+), 3291 deletions(-) rename reference-0.7.x.html => reference-1.0.0.html (66%) diff --git a/_layouts/v2.html b/_layouts/v2.html index 87058321..ed303745 100644 --- a/_layouts/v2.html +++ b/_layouts/v2.html @@ -73,7 +73,7 @@ {% if page.title == 'Documentation' %} Docs {% else %} - Docs + Docs {% endif %}
      • diff --git a/reference-0.7.x.html b/reference-1.0.0.html similarity index 66% rename from reference-0.7.x.html rename to reference-1.0.0.html index e833fb5e..94bad8f0 100644 --- a/reference-0.7.x.html +++ b/reference-1.0.0.html @@ -6,13 +6,11 @@ bodyclass: api-page

        API Reference

        -

        This reference reflects Leaflet 0.7.

        - -

        Docs for 1.0 are available here. +

        This reference reflects Leaflet 1.0.

        +

        Docs for 0.7 are available here. Docs for 0.6 are available in the source form (see instructions for running docs).

        -

        Map

        @@ -46,16 +44,13 @@ Docs for 0.6 are available TileLayer
      • TileLayer.WMS
      • -
      • TileLayer.Canvas
      • ImageOverlay

      Vector Layers

      Basic Types

        @@ -79,7 +75,6 @@ Docs for 0.6 are available Control
      • Zoom
      • Attribution
      • Layers
      • @@ -87,14 +82,14 @@ Docs for 0.6 are available -

        Events

        +

        Shared Methods

        Utility

          -
        • Class
        • Browser
        • Util
        • Transformation
        • @@ -110,18 +105,21 @@ Docs for 0.6 are available -

          Interfaces

          +

          Base Classes

          Misc

            +
          • Event objects
          • global switches
          • noConflict
          • version
          • @@ -180,45 +178,57 @@ var map = L.map('map', { center LatLng - null + null Initial geographical center of the map. zoom Number - null + null Initial map zoom. layers - ILayer[] - null + Layer[] + null Layers that will be added to the map initially. minZoom Number - null + null Minimum zoom level of the map. Overrides any minZoom set on map layers. maxZoom Number - null + null Maximum zoom level of the map. This overrides any maxZoom set on map layers. maxBounds LatLngBounds - null - When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method - + null + When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method. + + + maxBoundsViscosity + Number + 0.0 + If maxBounds is set, this options will control how solid the bounds are when dragging the map around. The default value of 0.0 allows the user to drag outside the bounds at normal speed, higher values will slow down map dragging outside bounds, and 1.0 makes the bounds fully solid, preventing the user from dragging outside the bounds. + crs - CRS + CRS L.CRS.
            EPSG3857
            Coordinate Reference System to use. Don't change this if you're not sure what it means. + + renderer + Renderer + depends + The default method for drawing vector layers on the map. L.SVG or L.Canvas by default depending on browser support. +

            Interaction Options

            @@ -233,68 +243,74 @@ var map = L.map('map', { dragging Boolean - true + true Whether the map be draggable with mouse/touch or not. touchZoom Boolean - true - Whether the map can be zoomed by touch-dragging with two fingers. + true + Whether the map can be zoomed by touch-dragging with two fingers. If passed 'center', it will zoom to the center of the view regardless of where the touch events (fingers) were. scrollWheelZoom Boolean - true - Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. + true + Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. + + + wheelDebounceTime + Number + 40 + Limits the rate at which a wheel can fire (in milliseconds). By default user can't zoom via wheel more often than once per 40 ms. doubleClickZoom Boolean - true - Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift. If passed 'center', double-click zoom will zoom to the center of the view regardless of where the mouse was. + true + Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift. If passed 'center', double-click zoom will zoom to the center of the view regardless of where the mouse was. boxZoom Boolean - true + true Whether the map can be zoomed to a rectangular area specified by dragging the mouse while pressing shift. tap Boolean - true + true Enables mobile hacks for supporting instant taps (fixing 200ms click delay on iOS/Android) and touch holds (fired as contextmenu events). tapTolerance Number - 15 + 15 The max number of pixels a user can shift his finger during touch for it to be considered a valid tap. trackResize Boolean - true + true Whether the map automatically handles browser window resize to update itself. worldCopyJump Boolean - false + false With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible. closePopupOnClick Boolean - true - Set it to false if you don't want popups to close when user clicks the map. + true + Set it to false if you don't want popups to close when user clicks the map. bounceAtZoomLimits Boolean - true - Set it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming. + true + Set it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming. @@ -310,19 +326,19 @@ var map = L.map('map', { keyboard Boolean - true + true Makes the map focusable and allows users to navigate the map with keyboard arrows and +/- keys. keyboardPanOffset Number - 80 + 80 Amount of pixels to pan when pressing an arrow key. keyboardZoomOffset Number - 1 + 1 Number of zoom levels to change when pressing + or - key. @@ -339,26 +355,26 @@ var map = L.map('map', { inertia Boolean - true + true If enabled, panning of the map will have an inertia effect where the map builds momentum while dragging and continues moving in the same direction for some time. Feels especially nice on touch devices. inertiaDeceleration Number - 3000 + 3000 The rate with which the inertial movement slows down, in pixels/second2. inertiaMaxSpeed Number - 1500 + 1500 Max speed of the inertial movement, in pixels/second. inertiaThreshold Number depends - Number of milliseconds that should pass between stopping the movement and releasing the mouse or touch to prevent inertial movement. 32 for touch devices and 14 for the rest by default. + Number of milliseconds that should pass between stopping the movement and releasing the mouse or touch to prevent inertial movement. 32 for touch devices and 14 for the rest by default. @@ -374,13 +390,13 @@ var map = L.map('map', { zoomControl Boolean - true + true Whether the zoom control is added to the map by default. attributionControl Boolean - true + true Whether the attribution control is added to the map by default. @@ -409,7 +425,7 @@ var map = L.map('map', { zoomAnimationThreshold Number - 4 + 4 Won't animate zoom if the zoom difference exceeds this value. @@ -618,7 +634,7 @@ var map = L.map('map', { <Number> zoom?, <zoom/pan options> options? )
            - this + this Sets the view of the map (geographical center and zoom) with the given animation options. @@ -626,7 +642,7 @@ var map = L.map('map', { <Number> zoom, <zoom options> options? ) - this + this Sets the zoom of the map. @@ -634,16 +650,16 @@ var map = L.map('map', { <Number> delta?, <zoom options> options? ) - this - Increases the zoom of the map by delta (1 by default). + this + Increases the zoom of the map by delta (1 by default). zoomOut( <Number> delta?, <zoom options> options? ) - this - Decreases the zoom of the map by delta (1 by default). + this + Decreases the zoom of the map by delta (1 by default). setZoomAround( @@ -651,7 +667,7 @@ var map = L.map('map', { <Number> zoom, <zoom options> options? ) - this + this Zooms the map while keeping a specified point on the map stationary (e.g. used internally for scroll zoom and double-click zoom). @@ -659,14 +675,14 @@ var map = L.map('map', { <LatLngBounds> bounds, <fitBounds options> options? ) - this + this Sets a map view that contains the given geographical bounds with the maximum zoom level possible. fitWorld( <fitBounds options> options? ) - this + this Sets a map view that mostly contains the whole world with the maximum zoom level possible. @@ -674,7 +690,7 @@ var map = L.map('map', { <LatLng> latlng, <pan options> options? ) - this + this Pans the map to a given center. Makes an animated pan if new center is not more than one screen away from the current one. @@ -682,7 +698,7 @@ var map = L.map('map', { <LatLngBounds> bounds, <pan options> options? ) - this + this Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any. @@ -690,48 +706,65 @@ var map = L.map('map', { <Point> point, <pan options> options? ) - this + this Pans the map by a given number of pixels (animated). invalidateSize( <Boolean> animate ) - this + this Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. invalidateSize( <zoom/pan options> options ) - this - Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row. + this + Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row. setMaxBounds( <LatLngBounds> bounds - this + this Restricts the map view to the given bounds (see map maxBounds option). locate( <Locate options> options? ) - this + this Tries to locate the user using the Geolocation API, firing a locationfound event with location data on success or a locationerror event on failure, and optionally sets the map view to the user's location with respect to detection accuracy (or to the world view if geolocation failed). See Locate options for more details. stopLocate() - this + this Stops watching location previously initiated by map.locate({watch: true}) and aborts resetting the map view if map.locate was called with {setView: true}. remove() - this + this Destroys the map and clears all related event listeners. + + flyTo( + <LatLng> latlng, + <Number> zoom?, + <zoom/pan options> options? ) + + this + Sets the view of the map (geographical center and zoom) performing a smooth pan-zoom animation. + + + flyToBounds( + <LatLngBounds> bounds, + <fitBounds options> options? ) + + this + Sets the view of the map with a smooth animation like flyTo, but takes a bounds parameter like fitBounds. +

            Methods for Getting Map State

            @@ -775,7 +808,7 @@ var map = L.map('map', { Number - Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety. + Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety. getSize() @@ -792,6 +825,14 @@ var map = L.map('map', { Point Returns the projected pixel coordinates of the top left point of the map layer (useful in custom layer and overlay implementations). + + getPixelWorldBounds( + <Number> zoom? ) + + Bounds + Returns the world's bounds in pixel coordinates for zoom level zoom. If zoom is omitted, the map's + current zoom is used. +

            Methods for Layers and Controls

            @@ -804,34 +845,34 @@ var map = L.map('map', { addLayer( - <ILayer> layer, + <Layer> layer - this + this Adds the given layer to the map. removeLayer( - <ILayer> layer ) + <Layer> layer ) - this + this Removes the given layer from the map. hasLayer( - <ILayer> layer ) + <Layer> layer ) Boolean - Returns true if the given layer is currently added to the map. + Returns true if the given layer is currently added to the map. eachLayer( <Function> fn, <Object> context? ) - this + this Iterates over the layers of the map, optionally specifying context of the iterator function.
            map.eachLayer(function (layer) {
             	layer.bindPopup('Hello');
            @@ -844,42 +885,50 @@ var map = L.map('map', {
             			<Popup> popup )
             		
             
            -		this
            +		this
             		Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).
             	
             	
             		openPopup(
            -			<String> html  | <HTMLElement> el,
            +			<String> html  | <HTMLElement> el,
             			<LatLng> latlng,
             			<Popup options> options? )
             		
             
            -		this
            +		this
             		Creates a popup with the specified options and opens it in the given point on a map.
             	
             	
             		closePopup(
             			<Popup> popup? )
             		
            -		this
            +		this
             		Closes the popup previously opened with openPopup (or the given one).
             	
             	
             		addControl(
            -			<IControl> control )
            +			<IControl> control )
             		
             
            -		this
            +		this
             		Adds the given control to the map.
             	
             	
             		removeControl(
            -			<IControl> control )
            +			<IControl> control )
             		
             
            -		this
            +		this
             		Removes the given control from the map.
             	
            +	
            +		getRenderer(
            +			<Layer> layer)
            +		
            +
            +		Renderer
            +		Returns the renderer for the given layer.
            +	
             
             
             
            @@ -981,6 +1030,23 @@ var map = L.map('map', {
             		LatLng
             		Returns the geographical coordinates of the point the mouse clicked on given the click's event object.
             	
            +	
            +		wrapLatLng(
            +			<LatLng> latlng )
            +		
            +
            +		LatLng
            +		Returns a LatLng where lat and lng has been wrapped according to the map's CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds.
            +	
            +	
            +		distance(
            +			<LatLng> latlng1,
            +			<LatLng> latlng2 )
            +		
            +
            +		LatLng
            +		Returns the distance in meters between two geographic coordinates in the map's CRS.
            +	
             
             
             

            Other Methods

            @@ -996,6 +1062,20 @@ var map = L.map('map', { HTMLElement Returns the container element of the map. + + createPane( + <String> name, <HTMLElement> container? + ) + MapPane + Creates a pane with the given name. Created panes will be given a generated class based on the name like .leaflet-pane-name" + + + getPane( + <String> name + ) + MapPane + Returns the HTML element representing the named map pane. + getPanes() MapPanes @@ -1022,37 +1102,37 @@ var map = L.map('map', { watch Boolean - false - If true, starts continuous watching of location changes (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stopLocate() method. + false + If true, starts continous watching of location changes (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stopLocate() method. setView Boolean - false - If true, automatically sets the map view to the user location with respect to detection accuracy, or to world view if geolocation failed. + false + If true, automatically sets the map view to the user location with respect to detection accuracy, or to world view if geolocation failed. maxZoom Number - Infinity + Infinity The maximum zoom for automatic view setting when using `setView` option. timeout Number - 10000 + 10000 Number of milliseconds to wait for a response from geolocation before firing a locationerror event. maximumAge Number - 0 + 0 Maximum age of detected location. If less than this amount of milliseconds passed since last geolocation response, locate will return a cached location. enableHighAccuracy Boolean - false + false Enables high accuracy, see description in the W3C spec. @@ -1070,8 +1150,8 @@ var map = L.map('map', { reset Boolean - false - If true, the map view will be completely reset (without any animations). + false + If true, the map view will be completely reset (without any animations). pan @@ -1088,7 +1168,7 @@ var map = L.map('map', { animate Boolean - - + - An equivalent of passing animate to both zoom and pan options (see below). @@ -1106,25 +1186,25 @@ var map = L.map('map', { animate Boolean - - If true, panning will always be animated if possible. If false, it will not animate panning, either resetting the map view if panning more than a screen away, or just setting a new offset for the map pane (except for `panBy` which always does the latter). + If true, panning will always be animated if possible. If false, it will not animate panning, either resetting the map view if panning more than a screen away, or just setting a new offset for the map pane (except for `panBy` which always does the latter). duration Number - 0.25 + 0.25 Duration of animated panning. easeLinearity Number - 0.25 - The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve. + 0.25 + The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve. noMoveStart Boolean - false - If true, panning won't fire movestart event on start (used internally for panning inertia). + false + If true, panning won't fire movestart event on start (used internally for panning inertia). @@ -1141,7 +1221,7 @@ var map = L.map('map', { animate Boolean - - 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. + 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. @@ -1159,25 +1239,25 @@ var map = L.map('map', { paddingTopLeft Point - [0, 0] + [0, 0] 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. paddingBottomRight Point - [0, 0] + [0, 0] The same for bottom right corner of the map. padding Point - [0, 0] + [0, 0] Equivalent of setting both top left and bottom right padding to the same value. maxZoom Number - null + null The maximum possible zoom to use. @@ -1185,7 +1265,7 @@ var map = L.map('map', {

            Properties

            -

            Map properties include interaction handlers that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging or touch zoom (see IHandler methods). Example:

            +

            Map properties include interaction handlers that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging or touch zoom (see IHandler methods). Example:

            map.doubleClickZoom.disable();
            @@ -1201,37 +1281,37 @@ var map = L.map('map', { dragging - IHandler + IHandler Map dragging handler (by both mouse and touch). touchZoom - IHandler + IHandler Touch zoom handler. doubleClickZoom - IHandler + IHandler Double click zoom handler. scrollWheelZoom - IHandler + IHandler Scroll wheel zoom handler. boxZoom - IHandler + IHandler Box (shift-drag with mouse) zoom handler. keyboard - IHandler + IHandler Keyboard navigation handler. tap - IHandler + IHandler Mobile touch hacks (quick tap and touch hold) handler. @@ -1249,47 +1329,51 @@ var map = L.map('map', {

            Map Panes

            -

            An object literal (returned by map.getPanes) that contains different map panes that you can use to put your custom overlays in. The difference is mostly in zIndex order that such overlays get.

            +

            Panes are DOM elements used to control the ordering of layers on the map. You can access panes with map.getPane or map.getPanesmethods. New panes can be created with the map.createPane method.

            + +

            Every map has the following panes that differ only in zIndex.

            - + + + + - - - - - - - - - - + + + + + + + + +
            PropertyPane TypeZ Index Description
            mapPane HTMLElement'auto' Pane that contains all other map panes.
            tilePane HTMLElement2 Pane for tile layers.
            objectsPaneHTMLElementPane that contains all the panes except tile pane.
            shadowPaneHTMLElementPane for overlay shadows (e.g. marker shadows).
            overlayPane HTMLElement4 Pane for overlays like polylines and polygons.
            shadowPaneHTMLElement5Pane for overlay shadows (e.g. marker shadows).
            markerPane HTMLElement6 Pane for marker icons.
            popupPane HTMLElement7 Pane for popups.
            @@ -1297,7 +1381,7 @@ var map = L.map('map', {

            Marker

            -

            Used to put markers on the map.

            +

            Used to put markers on the map. Extends Layer.

            L.marker([50.5, 30.5]).addTo(map);
            @@ -1335,59 +1419,71 @@ var map = L.map('map', { Icon class to use for rendering the marker. See Icon documentation for details on how to customize the marker icon. Set to new L.Icon.Default() by default. - clickable + interactive Boolean - true - If false, the marker will not emit mouse events and will act as a part of the underlying map. + true + If false, the marker will not emit mouse events and will act as a part of the underlying map. draggable Boolean - false + false Whether the marker is draggable with mouse/touch or not. keyboard Boolean - true + true Whether the marker can be tabbed to with a keyboard and clicked by pressing enter. title String - '' + '' Text for the browser tooltip that appear on marker hover (no tooltip by default). alt String - '' + '' Text for the alt attribute of the icon image (useful for accessibility). zIndexOffset Number - 0 - By default, zIndex for the marker image is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively). + 0 + By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively). opacity Number - 1.0 + 1.0 The opacity of the marker. riseOnHover Boolean - false - If true, the marker will get on top of others when you hover the mouse over it. + false + If true, the marker will get on top of others when you hover the mouse over it. riseOffset Number - 250 + 250 The z-index offset used for the riseOnHover feature. + + pane + String + 'markerPane' + Map pane where the markers icon will be added. + + + shadowPane + String + 'shadowPane' + Map pane where the markers shadow will be added. +

            Events

            @@ -1448,7 +1544,7 @@ var map = L.map('map', { move Event - Fired when the marker is moved via setLatLng. New coordinate include in event arguments. + Fired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatLng, latlng. add @@ -1474,20 +1570,14 @@ var map = L.map('map', {

            Methods

            +

            In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            + - - - - - - @@ -1498,7 +1588,7 @@ var map = L.map('map', { <LatLng> latlng ) - + @@ -1506,7 +1596,7 @@ var map = L.map('map', { <Icon> icon ) - + @@ -1514,65 +1604,23 @@ var map = L.map('map', { <Number> offset ) - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1582,7 +1630,7 @@ var map = L.map('map', {

            Interaction handlers

            -

            Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see IHandler methods). Example:

            +

            Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see IHandler methods). Example:

            marker.dragging.disable();
            @@ -1594,7 +1642,7 @@ var map = L.map('map', { - +
            Method Returns Description
            addTo( - <Map> map ) - thisAdds the marker to the map.
            getLatLng() LatLng thisthis Changes the marker position to the given point.
            thisthis Changes the marker icon.
            thisthis Changes the zIndex offset of the marker.
            setOpacity( <Number> opacity ) thisthis Changes the opacity of the marker.
            update() thisthis Updates the marker position, useful if coordinates of its latLng object were changed directly.
            bindPopup( - <String> html | <HTMLElement> el | <Popup> popup, - <Popup options> options? ) - thisBinds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.
            unbindPopup()thisUnbinds the popup previously bound to the marker with bindPopup.
            openPopup()thisOpens the popup previously bound by the bindPopup method.
            getPopup()PopupReturns the popup previously bound by the bindPopup method.
            closePopup()thisCloses the bound popup of the marker if it's opened.
            togglePopup()thisToggles the popup previously bound by the bindPopup method.
            setPopupContent( - <String> html | <HTMLElement> el ) - thisSets an HTML content of the popup of this marker.
            toGeoJSON() Object
            draggingIHandlerIHandler Marker dragging handler (by both mouse and touch).
            @@ -1626,11 +1674,11 @@ var map = L.map('map', { L.popup( <Popup options> options?, - <ILayer> source? ) + <Layer> source? ) - Instantiates a Popup object given an optional options object that describes its appearance and location and an optional source object that is used to tag the popup with a reference to the ILayer to which it refers. + Instantiates a Popup object given an optional options object that describes its appearance and location and an optional source object that is used to tag the popup with a reference to the Layer to which it refers. @@ -1646,109 +1694,121 @@ var map = L.map('map', { maxWidth Number - 300 + 300 Max width of the popup. minWidth Number - 50 + 50 Min width of the popup. maxHeight Number - null + null If set, creates a scrollable container of the given height inside a popup if its content exceeds it. autoPan Boolean - true - Set it to false if you don't want the map to do panning animation to fit the opened popup. + true + Set it to false if you don't want the map to do panning animation to fit the opened popup. keepInView Boolean - false - Set it to true if you want to prevent users from panning the popup off of the screen while it is open. + false + Set it to true if you want to prevent users from panning the popup off of the screen while it is open. closeButton Boolean - true + true Controls the presense of a close button in the popup. offset Point - Point(0, 6) + Point(0, 6) The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays. autoPanPaddingTopLeft Point - null - + null The margin between the popup and the top left corner of the map view after autopanning was performed. autoPanPaddingBottomRight Point - null -
            + null The margin between the popup and the bottom right corner of the map view after autopanning was performed. autoPanPadding Point - Point(5, 5) + Point(5, 5) Equivalent of setting both top left and bottom right autopan padding to the same value. zoomAnimation Boolean - true + true Whether to animate the popup on zoom. Disable it if you have problems with Flash content inside popups. closeOnClick Boolean - null - Set it to false if you want to override the default behavior of the popup closing when user clicks the map (set globally by the Map closePopupOnClick option). + null + Set it to false if you want to override the default behavior of the popup closing when user clicks the map (set globally by the Map closePopupOnClick option). className String - '' + '' A custom class name to assign to the popup. +

            Events

            + + + + + + + + + + + + + + + + + +
            EventDataDescription
            addPopupEventFired when the popup is added to the map.
            removePopupEventFired when the popup is removed from the map.
            +

            Methods

            +

            In addition to shared layer methods like addTo() and remove() you can also use the following methods:

            + - - - - - - - + @@ -1756,7 +1816,7 @@ var map = L.map('map', { <LatLng> latlng ) - + @@ -1766,11 +1826,11 @@ var map = L.map('map', { - - + + @@ -1780,7 +1840,7 @@ var map = L.map('map', { - +
            Method Returns Description
            addTo( - <Map> map ) - thisAdds the popup to the map.
            openOn( <Map> map ) thisthis Adds the popup to the map and closes the previous one. The same as map.openPopup(popup).
            thisthis Sets the geographical point where the popup will open.
            setContent( - <String|HTMLElement> htmlContent ) + <String|HTMLElement|Function> htmlContent ) thisSets the HTML content of the popup.thisSets the HTML content of the popup. If a function is passed the source layer will be passed to the function. The function should return a String or HTMLElement to be used in the popup.
            getContent()
            update()thisthis Updates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded.
            @@ -1789,7 +1849,7 @@ var map = L.map('map', {

            TileLayer

            -

            Used to load and display tile layers on the map, implements ILayer interface.

            +

            Used to load and display tile layers on the map. Extends Layer.

            Usage example

            @@ -1818,9 +1878,9 @@ var map = L.map('map', {

            A string of the following form:

            -
            'http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png'
            +
            'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'
            -

            {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates.

            +

            {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates. {r} can be used to add @2x to the URL to load retina tiles.

            You can use custom keys in the template, which will be evaluated from TileLayer options, like this:

            @@ -1838,116 +1898,122 @@ var map = L.map('map', { minZoom Number - 0 + 0 Minimum zoom number. maxZoom Number - 18 + 18 Maximum zoom number. maxNativeZoom Number - null + null Maximum zoom number the tiles source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxZoom level and auto-scaled. tileSize Number - 256 + 256 Tile size (width and height in pixels, assuming tiles are square). subdomains String or String[] - 'abc' + 'abc' Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings. errorTileUrl String - '' + '' URL to the tile image to show in place of the tile that failed to load. attribution String - '' + '' e.g. "© Mapbox" — the string used by the attribution control, describes the layer data. tms Boolean - false - If true, inverses Y axis numbering for tiles (turn this on for TMS services). - - - continuousWorld - Boolean - false - If set to true, the tile coordinates won't be wrapped by world width (-180 to 180 longitude) or clamped to lie within world height (-90 to 90). Use this if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor or photo maps). + false + If true, inverses Y axis numbering for tiles (turn this on for TMS services). noWrap Boolean - false - If set to true, the tiles just won't load outside the world width (-180 to 180 longitude) instead of repeating. + false + If set to true, the tiles just won't load outside the world width (-180 to 180 longitude) instead of repeating. zoomOffset Number - 0 + 0 The zoom number used in tile URLs will be offset with this value. zoomReverse Boolean - false - If set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom) + false + If set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom) opacity Number - 1.0 + 1.0 The opacity of the tile layer. zIndex Number - null + null The explicit zIndex of the tile layer. Not set by default. + + updateInterval + Number + 200 + Tiles will not update more then once every updateInterval. + unloadInvisibleTiles Boolean depends - If true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false. + If true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false. updateWhenIdle Boolean depends - If false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false. + If false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false. detectRetina Boolean - false - If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution. + false + If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution. reuseTiles Boolean - false - If true, all the tiles that are not visible after panning are placed in a reuse queue from which they will be fetched when new tiles become visible (as opposed to dynamically creating new ones). This will in theory keep memory usage low and eliminate the need for reserving new memory whenever a new tile is needed. + false + If true, all the tiles that are not visible after panning are placed in a reuse queue from which they will be fetched when new tiles become visible (as opposed to dynamically creating new ones). This will in theory keep memory usage low and eliminate the need for reserving new memory whenever a new tile is needed. bounds LatLngBounds - null + null When this option is set, the TileLayer only loads tiles that are in the given geographical bounds. + + + crossOrigin + Boolean + false + If true, all tiles will have their crossOrigin attribute set to ''. This is needed if you want to access tile pixel data. @@ -1986,6 +2052,11 @@ var map = L.map('map', { TileEvent Fired when a tile is removed (e.g. when you have unloadInvisibleTiles on). + + tileerror + TileEvent + Fired when there is an error loading a tile. +

            Methods

            @@ -2001,17 +2072,17 @@ var map = L.map('map', { <Map> map )
            - this + this Adds the layer to the map. bringToFront() - this + this Brings the tile layer to the top of all tile layers. bringToBack() - this + this Brings the tile layer to the bottom of all tile layers. @@ -2019,7 +2090,7 @@ var map = L.map('map', { <Number> opacity )
            - this + this Changes the opacity of the tile layer. @@ -2027,19 +2098,19 @@ var map = L.map('map', { <Number> zIndex ) - this + this Sets the zIndex of the tile layer. redraw() - this + this Causes the layer to clear all the tiles and request them again. setUrl( <String> urlTemplate ) - this + this Updates the layer's URL template and redraws it. @@ -2077,7 +2148,7 @@ var map = L.map('map', { L.tileLayer.wms( <String> baseUrl, <TileLayer.WMS options> options ) - + Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object. @@ -2097,39 +2168,45 @@ var map = L.map('map', { layers String - '' + '' (required) Comma-separated list of WMS layers to show. styles String - '' + '' Comma-separated list of WMS styles. format String - 'image/jpeg' - WMS image format (use 'image/png' for layers with transparency). + 'image/jpeg' + WMS image format (use 'image/png' for layers with transparency). transparent Boolean - false - If true, the WMS service will return images with transparency. + false + If true, the WMS service will return images with transparency. version String - '1.1.1' + '1.1.1' Version of the WMS service to use. crs - CRS - null + CRS + null Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means. + + uppercase + Boolean + false + If true, WMS request parameter keys will be uppercase. +

            Methods

            @@ -2145,86 +2222,15 @@ var map = L.map('map', { <WMS parameters> params, <Boolean> noRedraw? ) - this - Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true). - - - - -

            TileLayer.Canvas

            - -

            Used to create Canvas-based tile layers where tiles get drawn on the browser side. Extends TileLayer.

            - -

            Usage example

            - -
            var canvasTiles = L.tileLayer.canvas();
            -
            -canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
            -	var ctx = canvas.getContext('2d');
            -	// draw something on the tile canvas
            -}
            - -

            Creation

            - - - - - - - - - - - - -
            FactoryDescription
            L.tileLayer.canvas( - <TileLayer options> options? ) - Instantiates a Canvas tile layer object given an options object (optionally).
            - -

            Options

            - - - - - - - - - - - - - -
            OptionTypeDefaultDescription
            asyncBooleanfalseIndicates that tiles will be drawn asynchronously. tileDrawn method should be called for each tile after drawing completion.
            - -

            Methods

            - - - - - - - - - - - - - - - - + +
            MethodReturnsDescription
            drawTile( - <HTMLCanvasElement> canvas, - <Point> tilePoint, - <Number> zoom ) - thisYou need to define this method after creating the instance to draw tiles; canvas is the actual canvas tile on which you can draw, tilePoint represents the tile numbers, and zoom is the current zoom.
            tileDrawn( <HTMLCanvasElement> canvas )-If async option is defined, this function should be called for each tile after drawing completion. canvas is the same canvas element, that was passed to drawTile.thisMerges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).

            ImageOverlay

            -

            Used to load and display a single image over specific bounds of the map, implements ILayer interface.

            +

            Used to load and display a single image over specific bounds of the map. Extends Layer.

            Usage example

            @@ -2264,13 +2270,13 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);
            opacity Number - 1.0 + 1.0 The opacity of the image overlay. attribution String - '' + '' The attribution text of the image overlay. @@ -2287,7 +2293,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Map> map ) - this + this Adds the overlay to the map. @@ -2295,7 +2301,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Number> opacity ) - this + this Sets the opacity of the overlay. @@ -2303,24 +2309,24 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <String> imageUrl ) - this + this Changes the URL of the image. bringToFront() - this + this Brings the layer to the top of all overlays. bringToBack() - this + this Brings the layer to the bottom of all overlays.

            Path

            -

            An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly. +

            An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly. Extends Layer.

            Options

            @@ -2333,32 +2339,32 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); - - + + - + - + - + - + @@ -2369,49 +2375,55 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); - + - + - + - + - + - + - - + + + + + + + + - - + + - +
            stroke BooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.trueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
            color String'#03f''#3388ff' Stroke color.
            weight Number53 Stroke width in pixels.
            opacity Number0.51 Stroke opacity.
            fill Boolean dependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.Whether to fill the path with color. Set it to false to disable filling on polygons or circles.
            fillColor
            fillOpacity Number0.20.2 Fill opacity.
            fillRule String'evenodd''evenodd' A string that defines how the inside of a shape is determined.
            dashArray Stringnullnull A string that defines the stroke dash pattern. Doesn't work on canvas-powered layers (e.g. Android 2).
            lineCap Stringnull'round' A string that defines shape to be used at the end of the stroke.
            lineJoin Stringnull'round' A string that defines shape to be used at the corners of the stroke.
            clickableinteractive BooleantrueIf false, the vector will not emit mouse events and will act as a part of the underlying map.trueIf false, the vector will not emit mouse events and will act as a part of the underlying map.
            rendererRendererdependsL.SVG or L.Canvas by default depending on browser support.
            pointerEvents StringnullSets the pointer-events attribute on the path if SVG backend is used.nullSets the pointer-events attribute on the path if SVG renderer is used.
            className String'''' Custom class name set on an element.
            @@ -2479,63 +2491,29 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);

            Methods

            + +

            In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + @@ -2545,17 +2523,17 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); - + - + - +
            Method Returns Description
            addTo( - <Map> map ) - thisAdds the layer to the map.
            bindPopup( - <String> html | <HTMLElement> el | <Popup> popup, - <Popup options> options? ) - thisBinds a popup with a particular HTML content to a click on this path.
            bindPopup( - <Popup> popup, - <Popup options> options? ) - thisBinds a given popup object to the path.
            unbindPopup()thisUnbinds the popup previously bound to the path with bindPopup.
            openPopup( <LatLng> latlng? ) thisthis Opens the popup previously bound by the bindPopup method in the given point, or in one of the path's points if not specified.
            closePopup()thisCloses the path's bound popup if it is opened.
            setStyle( <Path options> object ) thisthis Changes the appearance of a Path based on the options in the Path options object.
            bringToFront()thisthis Brings the layer to the top of all path layers.
            bringToBack()thisthis Brings the layer to the bottom of all path layers.
            redraw()thisthis Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.
            @@ -2584,12 +2562,12 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); CANVAS Boolean depends - True if Canvas is used for vector rendering (Android 2). You can also force this by setting global variable L_PREFER_CANVAS to true before the Leaflet include on your page — sometimes it can increase performance dramatically when rendering thousands of circle markers, but currently suffers from a bug that causes removing such layers to be extremely slow. + True if Canvas is used for vector rendering (Android 2). You can also force this by setting global variable L_PREFER_CANVAS to true before the Leaflet include on your page — sometimes it can increase performance dramatically when rendering thousands of circle markers, but currently suffers from a bug that causes removing such layers to be extremely slow. CLIP_PADDING Number - 0.5 for SVG
            0.02 for VML + 0.5 for SVG
            0.02 for VML How much to extend the clip area around the map view (relative to its size, e.g. 0.5 is half the screen in each direction). Smaller values mean that you will see clipped ends of paths while you're dragging the map, and bigger values decrease drawing performance. @@ -2601,11 +2579,29 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);

            Usage example

            // create a red polyline from an array of LatLng points
            +var latlngs = [
            +  [-122.68, 45.51],
            +  [-122.43, 37.77],
            +  [-118.2, 34.04]
            +];
            +
             var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
             
             // zoom the map to the polyline
             map.fitBounds(polyline.getBounds());
            +

            You can also pass a multi-dimensional array to represent a MultiPolyline shape:

            + +
            // create a red polyline from an array of arrays of LatLng points
            +var latlngs = [
            +  [[-122.68, 45.51],
            +   [-122.43, 37.77],
            +   [-118.2, 34.04]],
            +  [[-73.91, 40.78],
            +   [-87.62, 41.83],
            +   [-96.72, 32.76]]
            +];
            +

            Creation

            @@ -2621,7 +2617,7 @@ map.fitBounds(polyline.getBounds()); - +
            Instantiates a polyline object given an array of geographical points and optionally an options object.Instantiates a polyline object given an array of geographical points and optionally an options object. You can create a Polyline object with multiple separate lines (MultiPolyline) by passing an array of arrays of geographic points.
            @@ -2639,20 +2635,20 @@ map.fitBounds(polyline.getBounds()); smoothFactor Number - 1.0 + 1.0 How much to simplify the polyline on each zoom level. More means better performance and smoother look, and less means more accurate representation. noClip Boolean - false + false Disabled polyline clipping.

            Methods

            -

            You can use Path methods and additionally the following methods:

            +

            In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            @@ -2662,40 +2658,41 @@ map.fitBounds(polyline.getBounds()); - - + + - + - + - - - - + + + + + + + + @@ -2704,81 +2701,43 @@ map.fitBounds(polyline.getBounds());
            addLatLng( - <LatLng> latlng ) + <LatLng> latlng, + <LatLng[]> latlngs ) thisAdds a given point to the polyline.thisAdds a given point to the polyline. By default, adds to the first ring of the polyline in case of a multi-polyline, but can be overridden by passing a specific ring as a LatLng array (that you can earlier access with getLatLngs).
            setLatLngs( <LatLng[]> latlngs ) thisthis Replaces all the points in the polyline with the given array of geographical points.
            getLatLngs() LatLng[]Returns an array of the points in the path.Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.
            spliceLatLngs( - <Number> index, - <Number> pointsToRemove, - <LatLng> latlng?, … ) - LatLng[]Allows adding, removing or replacing points in the polyline. Syntax is the same as in Array#splice. Returns the array of removed points (if any).isEmpty()BooleanReturns true if the Polyline has no LatLng.
            getBounds() LatLngBounds Returns the LatLngBounds of the polyline.
            getCenter()LatLngReturns the center (centroid) of the polyline.
            toGeoJSON() Object
            - -

            MultiPolyline

            - -

            Extends FeatureGroup to allow creating multi-polylines (single layer that consists of several polylines that share styling/popup).

            - -

            Creation

            - - - - - - - - - - - - - - -
            FactoryDescription
            L.multiPolyline( - <LatLng[][]> latlngs, - <Polyline options> options? ) - Instantiates a multi-polyline object given an array of arrays of geographical points (one for each individual polyline) and optionally an options object.
            - - -

            Methods

            - -

            MultiPolylines accept all Polyline methods but -have different behavior around their coordinate contents since they can contain -multiple line features:

            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            MethodReturnsDescription
            setLatLngs( - <LatLng[][]> latlngs ) - thisReplace all lines and their paths with the given array of arrays of - geographical points.
            getLatLngs()<LatLng[][]> latlngs - Returns an array of arrays of geographical points in each line.
            openPopup()thisOpens the popup previously bound by bindPopup.
            toGeoJSON()ObjectReturns a GeoJSON representation of the multipolyline (GeoJSON MultiLineString Feature).
            - - -

            Polygon

            A class for drawing polygon overlays on a map. Extends Polyline. Use Map#addLayer to add it to the map.

            Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

            +

            Usage example

            +
            // create a red polygon from an array of LatLng points
            +var latlngs = [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]];
            +
            +var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
            +
            +// zoom the map to the polygon
            +map.fitBounds(polygon.getBounds());
            + +

            You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape:

            + +
            
            +var latlngs = [
            +  [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring
            +  [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole
            +];
            + +

            Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.

            + +
            
            +var latlngs = [
            +  [ // first polygon
            +    [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring
            +    [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole
            +  ],
            +  [ // second polygon
            +    [[-109.05, 37],[-109.03, 41],[-102.05, 41],[-102.04, 37],[-109.05, 38]]
            +  ]
            +];
            + +

            Creation

            @@ -2794,13 +2753,13 @@ multiple line features:

            - +
            Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside.Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside. You can create a a Polygon with multiple separate shapes (MultiPolygon) by passing an array of Polygon coordinates.

            Methods

            -

            Polygon has the same options and methods as Polyline, with the following differences:

            +

            In addition to Path methods like redraw() and bringToFront(), Polyline mehtods like setLatLngs() and getLatLngs(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            @@ -2816,69 +2775,6 @@ multiple line features:

            -

            MultiPolygon

            - -

            Extends FeatureGroup to allow creating multi-polygons (single layer that consists of several polygons that share styling/popup).

            - -

            Creation

            - - - - - - - - - - - - - -
            FactoryDescription
            L.multiPolygon( - <LatLng[][]> latlngs, - <Polyline options> options? ) - Instantiates a multi-polygon object given an array of latlngs arrays (one for each individual polygon) and optionally an options object (the same as for MultiPolyline).
            - -

            Methods

            - -

            MultiPolygons accept all Polyline methods but -have different behavior around their coordinate contents since they can contain -multiple polygon features:

            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            MethodReturnsDescription
            setLatLngs( - <LatLng[][]> latlngs ) - thisReplace all polygons and their paths with the given array of arrays of - geographical points.
            getLatLngs()<LatLng[][]> latlngs - Returns an array of arrays of geographical points in each polygon.
            openPopup()thisOpens the popup previously bound by bindPopup.
            toGeoJSON()ObjectReturns a GeoJSON representation of the multipolygon (GeoJSON MultiPolygon Feature).

            Rectangle

            @@ -2915,7 +2811,7 @@ map.fitBounds(bounds);

            Methods

            -

            You can use Path methods and additionally the following methods:

            +

            In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            @@ -2928,7 +2824,7 @@ map.fitBounds(bounds);<LatLngBounds> bounds ) - +
            thisthis Redraws the rectangle with the passed bounds.
            @@ -2936,9 +2832,9 @@ map.fitBounds(bounds);

            Circle

            -

            A class for drawing circle overlays on a map. Extends Path. Use Map#addLayer to add it to the map.

            +

            A class for drawing circle overlays on a map. Extends CircleMarker. Use Map#addLayer to add it to the map.

            -
            L.circle([50.5, 30.5], 200).addTo(map);
            +
            L.circle([50.5, 30.5], 200).addTo(map);

            Creation

            @@ -2962,6 +2858,8 @@ map.fitBounds(bounds);

            Methods

            +

            In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            + @@ -2983,7 +2881,7 @@ map.fitBounds(bounds);<LatLng> latlng ) - + @@ -2991,7 +2889,7 @@ map.fitBounds(bounds);<Number> radius ) - + @@ -3005,7 +2903,7 @@ map.fitBounds(bounds);

            CircleMarker

            -

            A circle of a fixed size with radius specified in pixels. Extends Circle. Use Map#addLayer to add it to the map.

            +

            A circle of a fixed size with radius specified in pixels. Extends Path. Use Map#addLayer to add it to the map.

            Creation

            @@ -3028,6 +2926,8 @@ map.fitBounds(bounds);

            Methods

            +

            In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            +
            Method thisthis Sets the position of a circle to a new location.
            thisthis Sets the radius of a circle. Units are in meters.
            @@ -3039,7 +2939,7 @@ map.fitBounds(bounds);<LatLng> latlng ) - + @@ -3047,7 +2947,7 @@ map.fitBounds(bounds);<Number> radius ) - + @@ -3061,7 +2961,7 @@ map.fitBounds(bounds);

            LayerGroup

            -

            Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.

            +

            Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Extends Layer.

            L.layerGroup([marker1, marker2])
             	.addLayer(polyline)
            @@ -3075,8 +2975,8 @@ map.fitBounds(bounds);
            - @@ -3097,23 +2997,23 @@ map.fitBounds(bounds);<Map> map ) - + - + - + @@ -3121,23 +3021,23 @@ map.fitBounds(bounds);<String> id ) - + - + - + @@ -3147,7 +3047,7 @@ map.fitBounds(bounds); - + @@ -3155,7 +3055,7 @@ map.fitBounds(bounds);<Function> fn, <Object> context? ) - + @@ -3201,7 +3101,7 @@ map.fitBounds(bounds);

            Methods

            -

            Has all layerGroup methods and additionally:

            +

            In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            Method thisthis Sets the position of a circle marker to a new location.
            thisthis Sets the radius of a circle marker. Units are in pixels.
            Description
            L.layerGroup( - <ILayer[]> layers? ) + L.LayerGroup( + <Layer[]> layers? ) thisthis Adds the group of layers to the map.
            addLayer( - <ILayer> layer ) + <Layer> layer ) thisthis Adds a given layer to the group.
            removeLayer( - <ILayer> layer ) + <Layer> layer ) thisthis Removes a given layer from the group.
            thisthis Removes a given layer of the given id from the group.
            hasLayer( - <ILayer> layer ) + <Layer> layer ) BooleanReturns true if the given layer is currently added to the group.Returns true if the given layer is currently added to the group.
            getLayer( <String> id ) ILayerLayer Returns the layer with the given id.
            clearLayers()thisthis Removes all the layers from the group.
            thisthis Iterates over the layers of the group, optionally specifying context of the iterator function.
            group.eachLayer(function (layer) {
             	layer.bindPopup('Hello');
            @@ -3173,7 +3073,7 @@ map.fitBounds(bounds);

            FeatureGroup

            -

            Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.

            +

            Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Extends Layer.

            L.featureGroup([marker1, marker2, polyline])
             	.bindPopup('Hello world!')
            @@ -3190,7 +3090,7 @@ map.fitBounds(bounds);
            L.featureGroup( - <ILayer[]> layers? ) + <Layer[]> layers? )
            @@ -3209,15 +3109,6 @@ map.fitBounds(bounds); - - - - - - @@ -3227,17 +3118,17 @@ map.fitBounds(bounds); - + - + - +
            Returns Description
            bindPopup( - <String> htmlContent, - <Popup options> options? ) - thisBinds a popup with a particular HTML content to a click on any layer from the group that has a bindPopup method.
            getBounds() LatLngBounds setStyle( <Path options> style ) thisthis Sets the given path options to each layer of the group that has a setStyle method.
            bringToFront()thisthis Brings the layer group to the top of all other layers.
            bringToBack()thisthis Brings the layer group to the bottom of all other layers.
            @@ -3302,10 +3193,9 @@ map.fitBounds(bounds);
            L.geoJson(data, {
             	style: function (feature) {
             		return {color: feature.properties.color};
            -	},
            -	onEachFeature: function (feature, layer) {
            -		layer.bindPopup(feature.properties.description);
             	}
            +}).bindPopup(function (layer) {
            +	return layer.feature.properties.description;
             }).addTo(map);

            Each feature layer created by it gets a feature property that links to the GeoJSON feature data the layer was created from (so that you can access its properties later).

            @@ -3352,7 +3242,7 @@ map.fitBounds(bounds); onEachFeature( <GeoJSON> featureData, - <ILayer> layer ) + <Layer> layer ) Function that will be called on each created feature layer. Useful for attaching events and popups to features. @@ -3360,7 +3250,7 @@ map.fitBounds(bounds); filter( <GeoJSON> featureData, - <ILayer> layer ) + <Layer> layer ) Function that will be used to decide whether to show a feature or not. @@ -3378,6 +3268,8 @@ map.fitBounds(bounds);

            Methods

            +

            In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

            + @@ -3397,7 +3289,7 @@ map.fitBounds(bounds);<Function> style ) - + @@ -3405,7 +3297,7 @@ map.fitBounds(bounds);<Path> layer ) - +
            Method thisthis Changes styles of GeoJSON vector layers with the given style function.
            thisthis Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.
            @@ -3424,7 +3316,7 @@ map.fitBounds(bounds); <Function> pointToLayer? ) - ILayer + Layer Creates a layer from a given GeoJSON feature. @@ -3434,7 +3326,7 @@ map.fitBounds(bounds); LatLng - Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude). + Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude). coordsToLatLngs( @@ -3444,12 +3336,237 @@ map.fitBounds(bounds); Array - Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude). + Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude). +

            GridLayer

            +

            Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces TileLayer.Canvas.

            +

            GridLayer can be extended to create a tiled grid of HTML Elements like <canvas>, <img> or <div>.GridLayer will handle creating and animating these DOM elements for you.

            + +

            Synchronous usage example

            + +

            To create a custom layer, extend GridLayer and impliment the createTile() method, which will be passed a Point object with the x, y, and z (zoom level) coordinates to draw your tile.

            + +
            var CanvasLayer = L.GridLayer.extend({
            +	createTile: function(coords){
            +		// create a <canvas> element for drawing
            +		var tile = L.DomUtil.create('canvas', 'leaflet-tile');
            +
            +		// setup tile width and height according to the options
            +		var size = this.getTileSize();
            +		tile.width = size.x;
            +		tile.height = size.y;
            +
            +		// get a canvas context and draw something on it using coords.x, coords.y and coords.z
            +		var ctx = canvas.getContext('2d');
            +
            +		// return the tile so it can be rendered on screen
            +		return tile;
            +	}
            +});
            + +

            Asyncronous usage example

            + +

            Tile creation can also be asyncronous, this is useful when using a third-party drawing library. Once the tile has finished drawing it must be passed to the done() callback.

            + +
            var CanvasLayer = L.GridLayer.extend({
            +	// createTile has a 'done' parameter when on async mode
            +	createTile: function(coords, done){
            +		var error;
            +
            +		// create a <canvas> element for drawing
            +		var tile = L.DomUtil.create('canvas', 'leaflet-tile');
            +
            +		// setup tile width and height according to the options
            +		var size = this.getTileSize();
            +		tile.width = size.x;
            +		tile.height = size.y;
            +
            +		// For this example simply wait one second before tile is ready
            +		window.setTimeout(function(){
            +			// draw something and pass the tile to the done() callback
            +			done(error, tile);
            +		}, 1000);
            +
            +		// return the tile so its progress can be tracked
            +		return tile;
            +	}
            +});
            + +

            Constructor

            + + + + + + + + + + +
            FactoryDescription
            L.gridLayer(<GridLayer options> options?)Creates a new instance of GridLayer with the supplied options.
            + +

            Options

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            OptionTypeDefault valueDescription
            maxZoomNumber'tilePane'The map pane the layer will be added to.
            tileSizeNumber or Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
            opacityNumber1Opacity of the tiles. Can be used in the createTile() function.
            unloadInvisibleTilesBooleandependsIf true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false.
            updateWhenIdleBooleandependsIf false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false.
            updateIntervalNumber200Tiles will not update more then once every updateInterval.
            zIndexNumbernullThe explicit zIndex of the tile layer. Not set by default.
            boundsLatLngBoundsnullIf set tiles will only be loaded inside inside the set LatLngBounds.
            boundsLatLngBoundsnullIf set tiles will only be loaded inside inside the set LatLngBounds.
            minZoomNumber0The minimum zoom level that tiles will be loaded at. By default the entire map.
            + +

            Methods

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            bringToFront()thisBrings the tile layer to the top of all tile layers.
            bringToBack()thisBrings the tile layer to the bottom of all tile layers.
            setOpacity( + <Number> opacity ) + thisChanges the opacity of the tile layer.
            setZIndex( + <Number> zIndex ) + thisSets the zIndex of the tile layer.
            redraw()thisCauses the layer to clear all the tiles and request them again.
            getContainer() + HTMLElementReturns the HTML element that contains the tiles for this layer.
            getTileSize() + PointNormalizes the tileSize option into a point. Used by the createTile() method.
            + +

            Events

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            EventDataDescription
            loadingEventFired when the tile layer starts loading tiles.
            loadEventFired when the tile layer loaded all visible tiles.
            tileloadstartTileEventFired when a tile is requested and starts loading.
            tileloadTileEventFired when a tile loads.
            tileunloadTileEventFired when a tile is removed (e.g. when you have unloadInvisibleTiles on).
            tileerrorTileEventFired when there is an error loading a tile.

            LatLng

            @@ -3521,11 +3638,12 @@ map.panTo(L.latLng(50, 30)); equals( - <LatLng> otherLatlng ) + <LatLng> otherLatlng, + <Number> maxMargin? ) Boolean - Returns true if the given LatLng point is at the same position (within a small margin of error). + Returns true if the given LatLng point is at the same position (within a small margin of error). The margin of error can be overriden by setting maxMargin to a small number. toString() @@ -3539,40 +3657,10 @@ map.panTo(L.latLng(50, 30)); LatLng - Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default). + Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default). -

            Constants

            - - - - - - - - - - - - - - - - - - - - - - - - - - -
            ConstantTypeValueDescription
            DEG_TO_RADNumberMath.PI / 180A multiplier for converting degrees into radians.
            RAD_TO_DEGNumber180 / Math.PIA multiplier for converting radians into degrees.
            MAX_MARGINNumber1.0E-9Max margin of error for the equality check.
            - -

            LatLngBounds

            @@ -3629,7 +3717,7 @@ map.panTo(L.latLng(50, 30)); <LatLng|LatLngBounds> latlng ) - this + this Extends the bounds to contain the given point or bounds. @@ -3683,7 +3771,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle contains the given one. + Returns true if the rectangle contains the given one. contains( @@ -3691,7 +3779,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle contains the given point. + Returns true if the rectangle contains the given point. intersects( @@ -3699,7 +3787,15 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle intersects the given bounds. + Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. + + + overlaps( + <LatLngBounds> otherBounds ) + + + Boolean + Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. equals( @@ -3707,12 +3803,12 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. + Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. toBBoxString() String - Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. + Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. pad( @@ -3727,7 +3823,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the bounds are properly initialized. + Returns true if the bounds are properly initialized. @@ -3758,7 +3854,7 @@ map.panBy(L.point(200, 300)); <Boolean> round? ) - Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values. + Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values. @@ -3821,7 +3917,23 @@ map.panBy(L.point(200, 300)); Point - Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. + Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. + + + scaleBy( + <Point> scale ) + + + Point + Multiply each coordinate of the current point by each coordinate of scale. In linear algebra terms, multiply the point by the scaling matrix defined by scale. + + + unscaleBy( + <Point> otherPoint ) + + + Point + Inverse of multiplyCoordinates. Divide each coordinate of the current point by each coordinate of scale. distanceTo( @@ -3846,13 +3958,18 @@ map.panBy(L.point(200, 300)); Point Returns a copy of the current point with floored coordinates (rounded down). + + ceil() + Point + Returns a copy of the current point with ceiled coordinates (rounded up). + equals( <Point> otherPoint ) Boolean - Returns true if the given point has the same coordinates. + Returns true if the given point has the same coordinates. contains( @@ -3860,7 +3977,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). + Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). toString() @@ -3957,7 +4074,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle contains the given one. + Returns true if the rectangle contains the given one. contains( @@ -3965,7 +4082,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle contains the given point. + Returns true if the rectangle contains the given point. intersects( @@ -3973,13 +4090,21 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle intersects the given bounds. + Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. + + + overlaps( + <Bounds> otherBounds ) + + + Boolean + Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. isValid() Boolean - Returns true if the bounds are properly initialized. + Returns true if the bounds are properly initialized. getSize() @@ -4098,7 +4223,7 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); -

            By default, it has a 'leaflet-div-icon' class and is styled as a little white square with a shadow.

            +

            By default, it has a 'leaflet-div-icon' class and is styled as a little white square with a shadow.

            Creation

            @@ -4145,7 +4270,7 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); className String - A custom class name to assign to the icon. 'leaflet-div-icon' by default. + A custom class name to assign to the icon. 'leaflet-div-icon' by default. html @@ -4154,125 +4279,9 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); - - - -

            Control

            - -

            The base class for all Leaflet controls. Implements IControl interface. You can add controls to the map like this:

            - -
            control.addTo(map);
            -// the same as
            -map.addControl(control);
            - -

            Creation

            - - - - - - - - - - - - - -
            FactoryDescription
            L.control( - <Control options> options? ) - Creates a control with the given options.
            - -

            Options

            - - - - - - - - - - - - - -
            OptionTypeDefaultDescription
            positionString'topright'The initial position of the control (one of the map corners). See control positions.
            - -

            Methods

            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            MethodReturnsDescription
            setPosition( - <String> position ) - thisSets the position of the control. See control positions.
            getPosition()StringReturns the current position of the control.
            addTo( - <Map> map ) - thisAdds the control to the map.
            removeFrom( - <Map> map ) - thisRemoves the control from the map.
            getContainer()HTMLElementReturns the HTML container of the control.
            - -

            Control Positions

            - -

            Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

            - - - - - - - - - - - - - - - - - - - - - - -
            PositionDescription
            'topleft'Top left of the map.
            'topright'Top right of the map.
            'bottomleft'Bottom left of the map.
            'bottomright'Bottom right of the map.
            - -

            Control.zoom

            -

            A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

            +

            A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

            Creation

            @@ -4302,31 +4311,31 @@ map.addControl(control); - + - + - + - + - +
            position String'topleft''topleft' The position of the control (one of the map corners). See control positions.
            zoomInText String'+''+' The text set on the zoom in button.
            zoomOutText String'-''-' The text set on the zoom out button.
            zoomInTitle String'Zoom in''Zoom in' The title set on the zoom in button.
            zoomOutTitle String'Zoom out''Zoom out' The title set on the zoom out button.
            @@ -4335,7 +4344,7 @@ map.addControl(control);

            Control.Attribution

            -

            The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. Extends Control.

            +

            The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. Extends Control.

            Creation

            @@ -4366,14 +4375,14 @@ map.addControl(control); - + - - + +
            position String'bottomright''bottomright' The position of the control (one of the map corners). See control positions.
            prefix String'Leaflet'The HTML text shown before the attributions. Pass false to disable.'Leaflet'The HTML text shown before the attributions. Pass false to disable.
            @@ -4388,21 +4397,21 @@ map.addControl(control); setPrefix( <String> prefix ) - this + this Sets the text before the attributions. addAttribution( <String> text ) - this - Adds an attribution text (e.g. 'Vector data &copy; Mapbox'). + this + Adds an attribution text (e.g. 'Vector data &copy; Mapbox'). removeAttribution( <String> text ) - this + this Removes an attribution text. @@ -4450,25 +4459,25 @@ L.control.layers(baseLayers, overlays).addTo(map); addBaseLayer( - <ILayer> layer, + <Layer> layer, <String> name ) - this + this Adds a base layer (radio button entry) with the given name to the control. addOverlay( - <ILayer> layer, + <Layer> layer, <String> name ) - this + this Adds an overlay (checkbox entry) with the given name to the control. removeLayer( - <ILayer> layer ) + <Layer> layer ) - this + this Remove the given layer from the control. @@ -4485,20 +4494,20 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'topright' + 'topright' The position of the control (one of the map corners). See control positions. collapsed Boolean - true - If true, the control will be collapsed into an icon and expanded on mouse hover or touch. + true + If true, the control will be collapsed into an icon and expanded on mouse hover or touch. autoZIndex Boolean - true - If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. + true + If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. @@ -4581,40 +4590,39 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'bottomleft' + 'bottomleft' The position of the control (one of the map corners). See control positions. maxWidth Number - 100 + 100 Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500). metric Boolean - true + true Whether to show the metric scale line (m/km). imperial Boolean - true + true Whether to show the imperial scale line (mi/ft). updateWhenIdle Boolean - false - If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move). + false + If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move). -

            Events methods

            -

            A set of methods shared between event-powered classes (like Map). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map 'click' event).

            +

            A set of methods shared between event-powered classes (like Map and Marker). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire 'click' event).

            Example

            @@ -4637,533 +4645,206 @@ map.off('click', onClick);
            Description - addEventListener( + on( <String> type, <Function> fn, <Object> context? ) - this - Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). + this + Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). - addOneTimeEventListener( + once( <String> type, <Function> fn, <Object> context? ) - this + this The same as above except the listener will only get fired once and then removed. - addEventListener( + on( <Object> eventMap, <Object> context? ) - this + this Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - removeEventListener( + off( <String> type, <Function> fn?, <Object> context? ) - this - Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to addEventListener, you must pass the same context to removeEventListener in order to remove the listener. + this + Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener. - removeEventListener( + off( <Object> eventMap, <Object> context? ) - this - Removes a set of type/listener pairs. + this + Removes a set of type/listener pairs. - removeEventListener() + off() - this - Removes all listeners. An alias to clearAllEventListeners when you use it without arguments. + this + Removes all listeners to all events on the object. - hasEventListeners( + listens( <String> type ) Boolean - Returns true if a particular event type has some listeners attached to it. + Returns true if a particular event type has any listeners attached to it. - fireEvent( + fire( <String> type, <Object> data? ) - this + this Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. + + addEventListener( … ) + this + Alias to on. + + + addOneTimeEventListener( … ) + this + Alias to once. + + + removeEventListener( … ) + this + Alias to off. + clearAllEventListeners() - this - Removes all listeners to all events on the object. + this + Alias to off(). - on( … ) - this - Alias to addEventListener. + hasEventListeners( … ) + this + Alias to listens. - once( … ) - this - Alias to addOneTimeEventListener. - - - off( … ) - this - Alias to removeEventListener. - - - fire( … ) - this - Alias to fireEvent. + fireEvent( … ) + this + Alias to fire. -

            Event objects

            +

            Layer methods

            -

            Event object is an object that you receive as an argument in a listener function when some event is fired, containing useful information about that event. For example:

            +A set of methods inherited from the Layer base class that all Leaflet layers use. -
            map.on('click', function(e) {
            -	alert(e.latlng); // e is an event object (MouseEvent in this case)
            -});
            +
            var layer = L.Marker(latlng).addTo(map);
            +layer.addTo(map);
            +layer.remove();
            -

            Event

            +

            Methods

            -

            The base event object. All other event objects contain these properties too.

            - - +
            - - - + + + - - - + + + - - - - -
            propertytypedescriptionMethodReturnsDescription
            typeStringThe event type (e.g. 'click').addTo(<Map> map)thisAdds the layer to the given map.
            targetObjectThe object that fired the event.
            - -

            MouseEvent

            - - - - - - + + + - - - + + + - - - - - - - - - - - - - - -
            propertytypedescriptionremoveFrom(<Map> map)thisRemoves the layer to the given map.
            latlngLatLngThe geographical point where the mouse event occurred.remove()thisRemoves the layer from the map it is currently active on.
            layerPointPointPixel coordinates of the point where the mouse event occurred relative to the map layer.
            containerPointPointPixel coordinates of the point where the mouse event occurred relative to the map сontainer.
            originalEventDOMMouseEventThe original DOM mouse event fired by the browser.
            - -

            LocationEvent

            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            propertytypedescription
            latlngLatLngDetected geographical location of the user.
            boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
            accuracyNumberAccuracy of location in meters.
            altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
            altitudeAccuracyNumberAccuracy of altitude in meters.
            headingNumberThe direction of travel in degrees counting clockwise from true North.
            speedNumberCurrent velocity in meters per second.
            timestampNumberThe time when the position was acquired.
            - -

            ErrorEvent

            - - - - - - - - - - - - - - - - - -
            propertytypedescription
            messageStringError message.
            codeNumberError code (if applicable).
            - -

            LayerEvent

            - - - - - - - - - - - - -
            propertytypedescription
            layerILayerThe layer that was added or removed.
            - -

            LayersControlEvent

            - - - - - - - - - - - - - - - - - -
            propertytypedescription
            layerILayerThe layer that was added or removed.
            nameStringThe name of the layer that was added or removed.
            - -

            TileEvent

            - - - - - - - - - + - - - - - - +
            propertytypedescription
            tilegetPane(<String> name?) HTMLElementThe tile element (image).
            urlStringThe source URL of the tile.Returns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.
            -

            ResizeEvent

            +

            Popup methods

            - - - - - - - - - - - - - - - - -
            propertytypedescription
            oldSizePointThe old size before resize event.
            newSizePointThe new size after the resize event.
            +A set of methods inherited from the Layer base class that all Leaflet layers use. These methods provide convieniant ways of binding popups to any layer. -

            GeoJSON event

            +
            var layer = L.Polgon(latlngs).bindPopup('Hi There!').addTo(map);
            +layer.openPopup();
            +layer.closePopup();
            +
            - - - - - - - - - - - - - - - - - - - - - - - - - - -
            propertytypedescription
            layerILayerThe layer for the GeoJSON feature that is being added to the map.
            propertiesObjectGeoJSON properties of the feature.
            geometryTypeStringGeoJSON geometry type of the feature.
            idStringGeoJSON ID of the feature (if present).
            +Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened. - - - +

            Methods

            +
            - - - + + + - + + + +
            featureGroup.bindPopup(function(layer){
            +	return "a unique template for this layer.";
            +});
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + - +
            propertytypedescriptionMethodReturnsDescription
            popupbindPopup(<String|HTMLElement|Function|Popup> content, <PopupOptions> options?)thisBinds the passed content to the layer and sets up the neccessary event listeners. If a Function is passed the function will recive a layer as the first argument and should return a String or HTMLElement.
            unbindPopup()thisRemoves the popup previously bound with bindPopup.
            openPopup(LatLng latlng?)thisOpens the bound popup at the specificed latlng or at the default popup anchor if no latlng is passed.
            closePopup()thisCloses the popup if it is open.
            togglePopup()thisOpens or closes the popup depending on its current state.
            setPopupContent(<String|HTMLElement|Popup> content, <PopupOptions> options?)thisSets the content of the popup.
            getPopup() PopupThe popup that was opened or closed.Returns the popup bound to this layer.
            -

            DragEndEvent

            - - - - - - - - - - - - -
            propertytypedescription
            distanceNumberThe distance in pixels the draggable element was moved by.
            - - - - - - -

            Class

            - -

            L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

            -

            In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

            - -
            var MyClass = L.Class.extend({
            -	initialize: function (greeter) {
            -		this.greeter = greeter;
            -		// class constructor
            -	},
            -
            -	greet: function (name) {
            -		alert(this.greeter + ', ' + name)
            -	}
            -});
            -
            -// create instance of MyClass, passing "Hello" to the constructor
            -var a = new MyClass("Hello");
            -
            -// call greet method, alerting "Hello, World"
            -a.greet("World");
            -
            - -

            The initialize method is your class's constructor function, meaning that it gets called when you do new MyClass(...).

            - - -

            Class Factories

            - -

            You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:

            - -
            new L.Map('map'); // becomes:
            -L.map('map');
            - -

            The factories are implemented very easily, and you can do this for your own classes:

            - -
            L.map = function (id, options) {
            -	return new L.Map(id, options);
            -};
            - - -

            Inheritance

            - -

            You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

            - -
            var MyChildClass = MyClass.extend({
            -	// ... new properties and methods
            -});
            - -

            This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

            - -
            var a = new MyChildClass();
            -a instanceof MyChildClass; // true
            -a instanceof MyClass; // true
            -
            - -

            You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

            - -
            var MyChildClass = MyClass.extend({
            -	initialize: function () {
            -		MyClass.prototype.initialize.call(this, "Yo");
            -	},
            -
            -	greet: function (name) {
            -		MyClass.prototype.greet.call(this, 'bro ' + name + '!');
            -	}
            -});
            -
            -var a = new MyChildClass();
            -a.greet('Jason'); // alerts "Yo, bro Jason!"
            - -

            Options

            - -

            options is a special property that unlike other objects that you pass to extend will be merged with the parent one instead of overriding it completely, which makes managing configuration of objects and default values convenient:

            - -
            var MyClass = L.Class.extend({
            -	options: {
            -		myOption1: 'foo',
            -		myOption2: 'bar'
            -	}
            -});
            -
            -var MyChildClass = MyClass.extend({
            -	options: {
            -		myOption1: 'baz',
            -		myOption3: 5
            -	}
            -});
            -
            -var a = new MyChildClass();
            -a.options.myOption1; // 'baz'
            -a.options.myOption2; // 'bar'
            -a.options.myOption3; // 5
            - -

            There's also L.Util.setOptions, a method for conveniently merging options passed to constructor with the defaults defined in the class:

            - -
            var MyClass = L.Class.extend({
            -	options: {
            -		foo: 'bar',
            -		bla: 5
            -	},
            -
            -	initialize: function (options) {
            -		L.Util.setOptions(this, options);
            -		...
            -	}
            -});
            -
            -var a = new MyClass({bla: 10});
            -a.options; // {foo: 'bar', bla: 10}
            - -

            Includes

            - -

            includes is a special class property that merges all specified objects into the class (such objects are called mixins). A good example of this is L.Mixin.Events that event-related methods like on, off and fire to the class.

            - -
             var MyMixin = {
            -	foo: function () { ... },
            -	bar: 5
            -};
            -
            -var MyClass = L.Class.extend({
            -	includes: MyMixin
            -});
            -
            -var a = new MyClass();
            -a.foo();
            - -

            You can also do such includes in runtime with the include method:

            - -
            MyClass.include(MyMixin);
            - -

            Statics

            - -

            statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

            - -
            var MyClass = L.Class.extend({
            -	statics: {
            -		FOO: 'bar',
            -		BLA: 5
            -	}
            -});
            -
            -MyClass.FOO; // 'bar'
            - - -

            Constructor Hooks

            - -

            If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

            - -
            MyClass.addInitHook(function () {
            -	// ... do something in constructor additionally
            -	// e.g. add event listeners, set custom properties etc.
            -});
            - -

            You can also use the following shortcut when you just need to make one additional method call:

            - -
            MyClass.addInitHook('methodName', arg1, arg2, …);
            - -

            Browser

            A namespace with properties for browser/feature detection used by Leaflet internally.

            @@ -5181,77 +4862,77 @@ MyClass.FOO; // 'bar'
            ie Boolean - true for all Internet Explorer versions. + true for all Internet Explorer versions. ie6 Boolean - true for Internet Explorer 6. + true for Internet Explorer 6. ie7 Boolean - true for Internet Explorer 7. + true for Internet Explorer 7. webkit Boolean - true for webkit-based browsers like Chrome and Safari (including mobile versions). + true for webkit-based browsers like Chrome and Safari (including mobile versions). webkit3d Boolean - true for webkit-based browsers that support CSS 3D transformations. + true for webkit-based browsers that support CSS 3D transformations. android Boolean - true for Android mobile browser. + true for Android mobile browser. android23 Boolean - true for old Android stock browsers (2 and 3). + true for old Android stock browsers (2 and 3). mobile Boolean - true for modern mobile browsers (including iOS Safari and different Android browsers). + true for modern mobile browsers (including iOS Safari and different Android browsers). mobileWebkit Boolean - true for mobile webkit-based browsers. + true for mobile webkit-based browsers. mobileOpera Boolean - true for mobile Opera. + true for mobile Opera. touch Boolean - true for all browsers on touch devices. + true for all browsers on touch devices. msTouch Boolean - true for browsers with Microsoft touch model (e.g. IE10). + true for browsers with Microsoft touch model (e.g. IE10). retina Boolean - true for devices with Retina screens. + true for devices with Retina screens. @@ -5280,14 +4961,16 @@ MyClass.FOO; // 'bar'
            bind( <Function> fn, - <Object> obj ) + <Object> obj, + <Any> arg1?, + <Any> arg2?, + <Any> arg3?, … ) - Function - Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. Not a polyfill for ES 5 bind (compare L.bind to the MDN-recommended polyfill for Function.prototype.bind). + Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). The arguments received by the bound function will be any arguments passed when binding the function, followed by any arguments passed when invoking the bound function. Has an L.bind shortcut. Works exactly like Function.prototype.bind in modern browsers compliant with ECMAScript 5. - stamp( <Object> obj ) + stamp( <Object> obj ) String Applies a unique key to the object and returns that key. Has an L.stamp shortcut. @@ -5309,20 +4992,20 @@ MyClass.FOO; // 'bar'
            Cancels a previous request to requestAnimFrame. - limitExecByInterval( + throttle( <Function> fn, <Number> time, <Object> context? ) Function - Returns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time, but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called. + Returns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time (in milliseconds), but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called. falseFn() Function - Always returns false. + Returns a function which always returns false. formatNum( @@ -5333,13 +5016,23 @@ MyClass.FOO; // 'bar' Number Returns the number num rounded to digits decimals. + + wrapNum( + <Number> num, + <Array> range, + <Boolean> includeMax ) + + + Number + Returns the number num modulo range in such a way so it lies within range[0] and range[1]. The returned value will be always smaller than range[1] unless includeMax is set to true. + splitWords( <String> str ) String[] - Trims and splits the string on whitespace and returns the array of parts. + Trims and splits the string on whitespace and returns the array of parts. setOptions( @@ -5356,7 +5049,7 @@ MyClass.FOO; // 'bar'
            String - Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'. + Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'. template( @@ -5364,7 +5057,7 @@ MyClass.FOO; // 'bar'
            String - Simple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument. + Simple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument. isArray( @@ -5372,7 +5065,7 @@ MyClass.FOO; // 'bar' Boolean - Returns true if the given object is an array. + Returns true if the given object is an array. trim( @@ -5463,7 +5156,7 @@ MyClass.FOO; // 'bar'

            LineUtil

            -

            Various utility functions for polyline points processing, used by Leaflet internally to make polylines lightning-fast.

            +

            Various utility functions for polyine points processing, used by Leaflet internally to make polylines lightning-fast.

            Methods

            @@ -5540,7 +5233,7 @@ MyClass.FOO; // 'bar' Point[] - Clips the polygon geometry defined by the given points by rectangular bounds. Used by Leaflet to only show polygon points that are on the screen or near, increasing performance. Note that polygon points needs different algorithm for clipping than polyline, so there's a separate method for it. + Clips the polygon geometry defined by the given points by rectangular bounds. Used by Leaflet to only show polygon points that are on the screen or near, increasing performance. Note that polygon points needs different algorithm for clipping than polyline, so there's a seperate method for it. @@ -5560,32 +5253,76 @@ MyClass.FOO; // 'bar' Description - addListener( + on( <HTMLElement> el, - <String> type, + <String> types, <Function> fn, <Object> context? ) - this - Adds a listener fn to the element's DOM event of the specified type. this keyword inside the listener will point to context, or to the element if not specified. + this + + Adds a listener function (fn) to a particular DOM event type of the element el. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). + + + on( + <HTMLElement> el, + <Object> eventMap, + <Object> context? ) + + + this + Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} + + + off( + <HTMLElement> el, + <String> types, + <Function> fn, + <Object> context? ) + + + this + + Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular DOM event from the element. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener. + + + off( + <HTMLElement> el, + <Object> eventMap, + <Object> context? ) + + + this + Removes a set of type/listener pairs. + + addListener( + <HTMLElement> el, + <String> types, + <Function> fn, + <Object> context? ) + + + this + Alias to on. removeListener( <HTMLElement> el, - <String> type, - <Function> fn ) + <String> types, + <Function> fn, + <Object> context? ) - this - Removes an event listener from the element. + this + Alias to off. stopPropagation( <DOMEvent> e ) - this + this Stop the given event from propagation to parent elements. Used inside the listener functions:
            L.DomEvent.addListener(div, 'click', function (e) {
             	L.DomEvent.stopPropagation(e);
            @@ -5597,16 +5334,15 @@ MyClass.FOO; // 'bar'
            <DOMEvent> e )
            - this - Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions. - + this + Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions. stop( <DOMEvent> e ) - this + this Does stopPropagation and preventDefault at the same time. @@ -5614,8 +5350,8 @@ MyClass.FOO; // 'bar' <HTMLElement> el ) - this - Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events. + this + Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events. getMousePosition( @@ -5643,6 +5379,7 @@ MyClass.FOO; // 'bar'

            Utility functions to work with the DOM tree, used by Leaflet internally.

            +>>>>>>> more layer docs

            Methods

            @@ -5668,14 +5405,6 @@ MyClass.FOO; // 'bar' - - - - - - + + + + + + + + + + @@ -5704,8 +5447,12 @@ MyClass.FOO; // 'bar' - - + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + + + +
            String Returns the value for a certain style attribute on an element, including computed values or values set through CSS.
            getViewportOffset( - <HTMLElement> el ) - PointReturns the offset to the viewport for the requested element.
            create( <String> tagName, @@ -5687,6 +5416,20 @@ MyClass.FOO; // 'bar' Creates an element with tagName, sets the className, and optionally appends it to container element.
            remove( + <HTMLElement> el ) + -Removes el from its parent element.
            empty( + <HTMLElement> el ) + -Removes all of el's children elements from el.
            disableTextSelection() - BooleanReturns true if the element class attribute contains name.Returns true if the element class attribute contains name.
            falseFn()FunctionAlways returns false.
            addClass( @@ -5727,6 +5474,25 @@ MyClass.FOO; // 'bar' Removes name from the element's class attribute.
            getClass( + <Element> el ) + <String>Returns the element's CSS class (for HTML elements) or SVG class (for SVG elements).
            setClass( + <HTMLElement> el, + <String> name ) + -Sets the element's CSS class (for HTML elements) or SVG class (for SVG elements).
            setOpacity( <HTMLElement> el, @@ -5741,35 +5507,26 @@ MyClass.FOO; // 'bar' <String[]> props ) String or falseGoes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform.String or falseGoes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform.
            getTranslateString( - <Point> point ) + setTransform( + <HTMLElement> el, + <Point> offset, + <Number> scale? ) StringReturns a CSS transform string to move an element by the offset provided in the given point. Uses 3D translate on WebKit for hardware-accelerated transforms and 2D on other browsers.
            getScaleString( - <Number> scale, - <Point> origin ) - StringReturns a CSS transform string to scale an element (with the given scale origin).-Resets the 3D CSS transform of el so it is translated by offset and optionally scaled by scale. Does not have an effect if the browser doesn't support 3D CSS transforms.
            setPosition( <HTMLElement> el, - <Point> point, - <Boolean> disable3D? ) + <Point> point ) -Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true.Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers).
            getPosition( @@ -5779,6 +5536,28 @@ MyClass.FOO; // 'bar' Point Returns the coordinates of an element previously positioned with setPosition.
            disableImageDrag()-Prevents the user from generating dragstart DOM events, usually generated when the user drags an image. Used internally by Leaflet to override the behaviour of any click-and-drag interaction on the map. Affects drag interactions on the whole document.
            enableImageDrag()-Cancels the effects of a previous L.DomUtil.disableImageDrag.
            preventOutline( + <HTMLElement> el ) + -Makes the outline of the element el invisible. Used internally by Leaflet to prevent focusable elements from displaying an outline when the user performs a drag interaction on them.
            restoreOutline()-Cancels the effects of a previous L.DomUtil.preventOutline.

            Properties

            @@ -5793,7 +5572,7 @@ MyClass.FOO; // 'bar' TRANSITION String - Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). + Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). TRANSFORM @@ -5842,8 +5621,8 @@ fx.run(el, [300, 500], 0.5); <Number> easeLinearity? ) - this - Run an animation of a given element to a new position, optionally setting duration in seconds (0.25 by default) and easing linearity factor (3rd argument of the cubic bezier curve, 0.5 by default) + this + Run an animation of a given element to a new position, optionally setting duration in seconds (0.25 by default) and easing linearity factor (3rd argument of the cubic bezier curve, 0.5 by default) @@ -5928,7 +5707,7 @@ draggable.enable(); dragend - Event + DragEndEvent Fired when the dragging ends. @@ -5964,114 +5743,274 @@ draggable.enable(); START String - Name of the DOM event that initiates dragging. 'mousedown' for desktop browsers, 'touchstart' for mobile devices. + Name of the DOM event that initiates dragging. 'mousedown' for desktop browsers, 'touchstart' for mobile devices. MOVE String - Name of the DOM event for drag moving. 'mousemove' for desktop browsers, 'touchmove' for mobile devices. + Name of the DOM event for drag moving. 'mousemove' for desktop browsers, 'touchmove' for mobile devices. END String - Name of the DOM event that ends dragging. 'mouseup' for desktop browsers, 'touchend' for mobile devices. + Name of the DOM event that ends dragging. 'mouseup' for desktop browsers, 'touchend' for mobile devices. --> +

            Class

            + +

            L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

            +

            In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

            + +
            var MyClass = L.Class.extend({
            +	initialize: function (greeter) {
            +		this.greeter = greeter;
            +		// class constructor
            +	},
            +
            +	greet: function (name) {
            +		alert(this.greeter + ', ' + name)
            +	}
            +});
            +
            +// create instance of MyClass, passing "Hello" to the constructor
            +var a = new MyClass("Hello");
            +
            +// call greet method, alerting "Hello, World"
            +a.greet("World");
            +
            -

            IHandler

            -

            An interface implemented by interaction handlers.

            +

            Class Factories

            - - - - - - - - - - - - - - - - - - - - - -
            MethodReturnsDescription
            enable()-Enables the handler.
            disable()-Disables the handler.
            enabled()BooleanReturns true if the handler is enabled.
            +

            You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:

            + +
            new L.Map('map'); // becomes:
            +L.map('map');
            + +

            The factories are implemented very easily, and you can do this for your own classes:

            + +
            L.map = function (id, options) {
            +	return new L.Map(id, options);
            +};
            -

            ILayer

            +

            Inheritance

            -

            Represents an object attached to a particular location (or a set of locations) on a map. Implemented by tile layers, markers, popups, image overlays, vector layers and layer groups.

            +

            You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

            -

            Methods

            +
            var MyChildClass = MyClass.extend({
            +	// ... new properties and methods
            +});
            - - - - - - - - +

            This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

            - - - - - +
            var a = new MyChildClass();
            +a instanceof MyChildClass; // true
            +a instanceof MyClass; // true
            +
            - - - -
            MethodReturnsDescription
            onAdd( - <Map> map ) - -Should contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).
            onRemove( - <Map> map ) - -Should contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
            +

            You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

            + +
            var MyChildClass = MyClass.extend({
            +	initialize: function () {
            +		MyClass.prototype.initialize.call("Yo");
            +	},
            +
            +	greet: function (name) {
            +		MyClass.prototype.greet.call(this, 'bro ' + name + '!');
            +	}
            +});
            +
            +var a = new MyChildClass();
            +a.greet('Jason'); // alerts "Yo, bro Jason!"
            + +

            Options

            + +

            options is a special property that unlike other objects that you pass to extend will be merged with the parent one instead of overriding it completely, which makes managing configuration of objects and default values convenient:

            + +
            var MyClass = L.Class.extend({
            +	options: {
            +		myOption1: 'foo',
            +		myOption2: 'bar'
            +	}
            +});
            +
            +var MyChildClass = L.Class.extend({
            +	options: {
            +		myOption1: 'baz',
            +		myOption3: 5
            +	}
            +});
            +
            +var a = new MyChildClass();
            +a.options.myOption1; // 'baz'
            +a.options.myOption2; // 'bar'
            +a.options.myOption3; // 5
            + +

            There's also L.Util.setOptions, a method for conveniently merging options passed to constructor with the defauls defines in the class:

            + +
            var MyClass = L.Class.extend({
            +	options: {
            +		foo: 'bar',
            +		bla: 5
            +	},
            +
            +	initialize: function (options) {
            +		L.Util.setOptions(this, options);
            +		...
            +	}
            +});
            +
            +var a = new MyClass({bla: 10});
            +a.options; // {foo: 'bar', bla: 10}
            + +

            Includes

            + +

            includes is a special class property that merges all specified objects into the class (such objects are called mixins). + +

             var MyMixin = {
            +	foo: function () { ... },
            +	bar: 5
            +};
            +
            +var MyClass = L.Class.extend({
            +	includes: MyMixin
            +});
            +
            +var a = new MyClass();
            +a.foo();
            + +

            You can also do such includes in runtime with the include method:

            + +
            MyClass.include(MyMixin);
            + +

            Statics

            + +

            statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

            + +
            var MyClass = L.Class.extend({
            +	statics: {
            +		FOO: 'bar',
            +		BLA: 5
            +	}
            +});
            +
            +MyClass.FOO; // 'bar'
            + + +

            Constructor Hooks

            + +

            If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

            + +
            MyClass.addInitHook(function () {
            +	// ... do something in constructor additionally
            +	// e.g. add event listeners, set custom properties etc.
            +});
            + +

            You can also use the following shortcut when you just need to make one additional method call:

            + +
            MyClass.addInitHook('methodName', arg1, arg2, …);
            + +

            Evented

            + +

            When creating a plugin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-related methods like on, off and fire

            + +
            MyEventedClass = L.Evented.extend({
            +	fire: function(){
            +		this.fire('custom', {
            +			// you can attach optional data to an event as an object
            +		});
            +	}
            +});
            +
            +var myEvents = new MyEventedClass();
            +
            +myEvents.on('custom', function(e){
            +	// e.type will  be 'custom'
            +	// anything else you passed in the
            +});
            +
            +myEvents.fire();
            + +You can still use the old-style `L.Mixin.Events` for backward compatibility. + +
            // this class will include all event methods
            +MyEventedClass = L.Class.extend({
            +	includes: L.Mixin.Events
            +});
            + +

            Layer

            + +

            The base class for all Leaflet layers that implements basic shared methods and functionality. Can be extended to create custom layers by extending L.Layer and implementing the onAdd and onRemove methods.

            Implementing Custom Layers

            +

            Custom layers should extend the L.Layer base class. L.Layer provides convenience methods for your layer like addTo(map), removeFrom(map) and getPane().

            +

            The most important things know about when implementing custom layers are Map viewreset event and latLngToLayerPoint method. viewreset is fired when the map needs to reposition its layers (e.g. on zoom), and latLngToLayerPoint is used to get coordinates for the layer's new position.

            Another event often used in layer implementations is moveend which fires after any movement of the map (panning, zooming, etc.).

            Another thing to note is that you'll usually need to add leaflet-zoom-hide class to the DOM elements you create for the layer so that it hides during zoom animation. Implementing zoom animation for custom layers is a complex topic and will be documented separately in future, but meanwhile you can take a look at how it's done for Leaflet layers (e.g. ImageOverlay) in the source.

            +

            Methods

            + +

            Every layer should extend from L.Layer and implement the following methods:

            + + + + + + + + + + + + + + + + + + + + + + +
            MethodReturnsDescription
            onAdd(<Map> map)thisShould contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).
            onRemove(<Map> map)thisShould contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
            getEvents()ObjectThis optional method should return an object like { viewreset: this._reset }for addEventListener. These events will be automatically added and removed from the map with your layer.
            +

            Custom Layer Example

            Here's how a custom layer implementation usually looks:

            -
            var MyCustomLayer = L.Class.extend({
            +
            var MyCustomLayer = L.Layer.extend({
             
             	initialize: function (latlng) {
             		// save position of the layer or any options from the constructor
             		this._latlng = latlng;
             	},
             
            -	onAdd: function (map) {
            -		this._map = map;
            +	// these events will be added and removed from the map with the layer
            +	getEvents: function(){
            +		return {
            +			viewreset: this._reset
            +		}
            +	},
             
            -		// create a DOM element and put it into one of the map panes
            +	onAdd: function (map) {
            +		// create a DOM element and put it into one of the map panes, by default the overlayPane
             		this._el = L.DomUtil.create('div', 'my-custom-layer leaflet-zoom-hide');
            -		map.getPanes().overlayPane.appendChild(this._el);
            +		this.getPane().appendChild(this._el);
             
             		// add a viewreset event listener for updating layer's position, do the latter
            -		map.on('viewreset', this._reset, this);
             		this._reset();
             	},
             
             	onRemove: function (map) {
             		// remove layer's DOM elements and listeners
            -		map.getPanes().overlayPane.removeChild(this._el);
            -		map.off('viewreset', this._reset, this);
            +		this.getPane().removeChild(this._el);
             	},
             
             	_reset: function () {
            @@ -6081,14 +6020,85 @@ draggable.enable();
             	}
             });
             
            -map.addLayer(new MyCustomLayer(latlng));
            +var myLayer = new MyCustomLayer(latlng).addTo(map);
             
            +

            Inherited Options

            +

            Classes extending from L.Layer will also inherit the following options:

            -

            IControl

            + + + + + + + + + + + + + +
            OptionTypeDefault valueDescription
            paneString'overlayPane'By default the layer will be added to the maps overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
            -

            Represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls.

            +

            Inherited Events

            + +

            Classes extending from L.Layer will also fire the following events:

            + + + + + + + + + + + + + + + + + +
            EventDataDescription
            addEventFired after the layer is added to a map.
            removeEventFired after the layer is removed from a map.
            + +

            Inherited Methods

            + +

            Classes extending from L.Layer will also inherit the following methods:

            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            MethodReturnsDescription
            addTo(<Map> map)thisAdds the layer to the given map.
            removeFrom(<Map> map)thisRemoves the layer to the given map.
            remove()thisRemoves the layer from the map it is currently active on.
            getPane(<String> name?)HTMLElementReturns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.
            + +

            Control

            + +

            Controls represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls. Can be used to create custom controls by extending L.Control and implementing the onAdd and onRemove methods.

            Methods

            @@ -6152,16 +6162,147 @@ map.addControl(new MyControl());
            map.addControl(new MyControl('bar', {position: 'bottomleft'}));
            +

            Options

            + +

            Classes extending from L.Control will also inherit the following options:

            + + + + + + + + + + + + + + +
            OptionTypeDefaultDescription
            positionString'topright'The initial position of the control (one of the map corners). See control positions.
            + +

            Inherited Methods

            + +

            Classes extending from L.Control will also inherit the following methods:

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            MethodReturnsDescription
            setPosition( + <String> position ) + thisSets the position of the control. See control positions.
            getPosition()StringReturns the current position of the control.
            addTo( + <Map> map ) + thisAdds the control to the map.
            removeFrom( + <Map> map ) + thisRemoves the control from the map.
            getContainer()HTMLElementReturns the HTML container of the control.
            + +

            Control Positions

            + +

            Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

            + + + + + + + + + + + + + + + + + + + + + + +
            PositionDescription
            'topleft'Top left of the map.
            'topright'Top right of the map.
            'bottomleft'Bottom left of the map.
            'bottomright'Bottom right of the map.
            +

            Handler

            +

            Implemented by map interaction handlers.

            -

            IProjection

            + + + + + + + + + + + + + + + + + + + + + +
            MethodReturnsDescription
            enable()-Enables the handler.
            disable()-Disables the handler.
            enabled()BooleanReturns true if the handler is enabled.
            + +

            Projection

            An object with methods for projecting geographical coordinates of the world onto a flat surface (and back). See Map projection.

            +

            Properties

            + + + + + + + + + + + + +
            PropertyTypeDescription
            boundsLatLngBoundsThe bounds where the projection is valid
            +

            Methods

            - +
            @@ -6214,13 +6355,13 @@ map.addControl(new MyControl()); -

            ICRS

            +

            CRS

            Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back (and to coordinates in other units for WMS services). See Spatial reference system.

            Methods

            -
            Method Returns
            +
            @@ -6252,6 +6393,14 @@ map.addControl(new MyControl()); + + + + + + - - - + + + + + + + + + + + + + +
            Method ReturnsPoint Projects geographical coordinates into coordinates in units accepted for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
            unproject( + <Point> point ) + LatLngGiven a projected coordinate returns the corresponding LatLng. The inverse of project.
            scale( <Number> zoom ) @@ -6261,18 +6410,35 @@ map.addControl(new MyControl()); Returns the scale used when transforming projected coordinates into pixel coordinates for a particular zoom. For example, it returns 256 * 2^zoom for Mercator-based CRS.
            getSize( + getProjectedBounds( <Number> zoom ) PointReturns the size of the world in pixels for a particular zoom.BoundsReturns the projection's bounds scaled and transformed for the provided zoom.
            distance( + <LatLng> latlng1, + <LatLng> latlng2 ) + NumberReturns the distance in meters between two geographic coordinates in this CRS.
            wrapLatLng( + <LatLng> latlng ) + LatLngReturns a LatLng where lat and lng has been wrapped according to the CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds.

            Properties

            - +
            @@ -6281,7 +6447,7 @@ map.addControl(new MyControl()); - + @@ -6295,7 +6461,22 @@ map.addControl(new MyControl()); - + + + + + + + + + + + + + + + +
            Property Type
            projectionIProjectionIProjection Projection that this CRS uses.
            code StringStandard code name of the CRS passed into WMS services (e.g. 'EPSG:3857').Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857').
            wrapLatNumber[]Latitude bounds, lower followed by upper, at which latitudes should wrap around, or null to disable wrapping
            wrapLngNumber[]Longitude bounds, lower followed by upper, at which longitudes should wrap around, or null to disable wrapping
            infiniteBooleantrue if the CRS bounds should be ignored; coordinates in an infinite CRS will not be wrapped
            @@ -6308,6 +6489,13 @@ map.addControl(new MyControl()); Projection Description + + L.CRS.Earth + + Serves as the base for CRS that are global such that they cover the earth. Can only be used as the base for + other CRS and cannot be used directly, since it does not have a code, projection or + transformation. + L.CRS.EPSG3857 @@ -6332,10 +6520,284 @@ map.addControl(new MyControl());

            If you want to use some obscure CRS not listed here, take a look at the Proj4Leaflet plugin.

            +

            Event objects

            + +

            Event object is an object that you recieve as an argument in a listener function when some event is fired, containing useful information about that event. For example:

            + +
            map.on('click', function(e) {
            +	alert(e.latlng); // e is an event object (MouseEvent in this case)
            +});
            + +

            Event

            + +

            The base event object. All other event objects contain these properties too.

            + + + + + + + + + + + + + + + + + +
            propertytypedescription
            typeStringThe event type (e.g. 'click').
            targetObjectThe object that fired the event.
            + +

            MouseEvent

            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            propertytypedescription
            latlngLatLngThe geographical point where the mouse event occured.
            layerPointPointPixel coordinates of the point where the mouse event occured relative to the map layer.
            containerPointPointPixel coordinates of the point where the mouse event occured relative to the map сontainer.
            originalEventDOMMouseEventThe original DOM mouse event fired by the browser.
            + +

            LocationEvent

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            propertytypedescription
            latlngLatLngDetected geographical location of the user.
            boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
            accuracyNumberAccuracy of location in meters.
            altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
            altitudeAccuracyNumberAccuracy of altitude in meters.
            headingNumberThe direction of travel in degrees counting clockwise from true North.
            speedNumberCurrent velocity in meters per second.
            timestampNumberThe time when the position was acquired.
            + +

            ErrorEvent

            + + + + + + + + + + + + + + + + + +
            propertytypedescription
            messageStringError message.
            codeNumberError code (if applicable).
            + +

            LayerEvent

            + + + + + + + + + + + + +
            propertytypedescription
            layerLayerThe layer that was added or removed.
            + +

            LayersControlEvent

            + + + + + + + + + + + + + + + + + +
            propertytypedescription
            layerLayerThe layer that was added or removed.
            nameStringThe name of the layer that was added or removed.
            + +

            TileEvent

            + + + + + + + + + + + + +
            propertytypedescription
            tileHTMLElementThe tile element (image).
            + +

            TileErrorEvent

            + + + + + + + + + + + + +
            propertytypedescription
            tileHTMLElementThe tile element (image).
            + +

            ResizeEvent

            + + + + + + + + + + + + + + + + + +
            propertytypedescription
            oldSizePointThe old size before resize event.
            newSizePointThe new size after the resize event.
            + +

            GeoJSON event

            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            propertytypedescription
            layerLayerThe layer for the GeoJSON feature that is being added to the map.
            propertiesObjectGeoJSON properties of the feature.
            geometryTypeStringGeoJSON geometry type of the feature.
            idStringGeoJSON ID of the feature (if present).
            + + + + + + + + + + + + + + +
            propertytypedescription
            popupPopupThe popup that was opened or closed.
            + +

            DragEndEvent

            + + + + + + + + + + + + +
            propertytypedescription
            distanceNumberThe distance in pixels the draggable element was moved by.

            Global Switches

            -

            Global switches are created for rare cases and generally make Leaflet to not detect a particular browser feature even if it's there. You need to set the switch as a global variable to true before including Leaflet on the page, like this:

            +

            Global switches are created for rare cases and generally make Leaflet to not detect a particular browser feature even if it's there. You need to set the switch as a global variable to true before including Leaflet on the page, like this:

            <script>L_PREFER_CANVAS = true;</script>
             <script src="leaflet.js"></script>
            diff --git a/reference.html b/reference.html index ac276fe5..c35812fe 100644 --- a/reference.html +++ b/reference.html @@ -6,11 +6,13 @@ bodyclass: api-page

            API Reference

            -

            This reference reflects Leaflet 1.0.

            +

            This reference reflects Leaflet 0.7.

            + +

            Docs for 1.0 are available here. -

            Docs for 0.7 are available here. Docs for 0.6 are available in the source form (see instructions for running docs).

            +

            Map

            @@ -44,13 +46,16 @@ Docs for 0.6 are available TileLayer
          • TileLayer.WMS
          • +
          • TileLayer.Canvas
          • ImageOverlay

          Vector Layers

          Basic Types

            @@ -75,6 +79,7 @@ Docs for 0.6 are available Control
          • Zoom
          • Attribution
          • Layers
          • @@ -82,14 +87,14 @@ Docs for 0.6 are available -

            Shared Methods

            +

            Events

            Utility

              +
            • Class
            • Browser
            • Util
            • Transformation
            • @@ -105,21 +110,18 @@ Docs for 0.6 are available -

              Base Classes

              +

              Interfaces

              Misc

                -
              • Event objects
              • global switches
              • noConflict
              • version
              • @@ -178,57 +180,45 @@ var map = L.map('map', { center LatLng - null + null Initial geographical center of the map. zoom Number - null + null Initial map zoom. layers - Layer[] - null + ILayer[] + null Layers that will be added to the map initially. minZoom Number - null + null Minimum zoom level of the map. Overrides any minZoom set on map layers. maxZoom Number - null + null Maximum zoom level of the map. This overrides any maxZoom set on map layers. maxBounds LatLngBounds - null - When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method. - - - maxBoundsViscosity - Number - 0.0 - If maxBounds is set, this options will control how solid the bounds are when dragging the map around. The default value of 0.0 allows the user to drag outside the bounds at normal speed, higher values will slow down map dragging outside bounds, and 1.0 makes the bounds fully solid, preventing the user from dragging outside the bounds. - + null + When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method + crs - CRS + CRS L.CRS.
                EPSG3857
                Coordinate Reference System to use. Don't change this if you're not sure what it means. - - renderer - Renderer - depends - The default method for drawing vector layers on the map. L.SVG or L.Canvas by default depending on browser support. -

                Interaction Options

                @@ -243,74 +233,68 @@ var map = L.map('map', { dragging Boolean - true + true Whether the map be draggable with mouse/touch or not. touchZoom Boolean - true - Whether the map can be zoomed by touch-dragging with two fingers. If passed 'center', it will zoom to the center of the view regardless of where the touch events (fingers) were. + true + Whether the map can be zoomed by touch-dragging with two fingers. scrollWheelZoom Boolean - true - Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. - - - wheelDebounceTime - Number - 40 - Limits the rate at which a wheel can fire (in milliseconds). By default user can't zoom via wheel more often than once per 40 ms. + true + Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. doubleClickZoom Boolean - true - Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift. If passed 'center', double-click zoom will zoom to the center of the view regardless of where the mouse was. + true + Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift. If passed 'center', double-click zoom will zoom to the center of the view regardless of where the mouse was. boxZoom Boolean - true + true Whether the map can be zoomed to a rectangular area specified by dragging the mouse while pressing shift. tap Boolean - true + true Enables mobile hacks for supporting instant taps (fixing 200ms click delay on iOS/Android) and touch holds (fired as contextmenu events). tapTolerance Number - 15 + 15 The max number of pixels a user can shift his finger during touch for it to be considered a valid tap. trackResize Boolean - true + true Whether the map automatically handles browser window resize to update itself. worldCopyJump Boolean - false + false With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible. closePopupOnClick Boolean - true - Set it to false if you don't want popups to close when user clicks the map. + true + Set it to false if you don't want popups to close when user clicks the map. bounceAtZoomLimits Boolean - true - Set it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming. + true + Set it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming. @@ -326,19 +310,19 @@ var map = L.map('map', { keyboard Boolean - true + true Makes the map focusable and allows users to navigate the map with keyboard arrows and +/- keys. keyboardPanOffset Number - 80 + 80 Amount of pixels to pan when pressing an arrow key. keyboardZoomOffset Number - 1 + 1 Number of zoom levels to change when pressing + or - key. @@ -355,26 +339,26 @@ var map = L.map('map', { inertia Boolean - true + true If enabled, panning of the map will have an inertia effect where the map builds momentum while dragging and continues moving in the same direction for some time. Feels especially nice on touch devices. inertiaDeceleration Number - 3000 + 3000 The rate with which the inertial movement slows down, in pixels/second2. inertiaMaxSpeed Number - 1500 + 1500 Max speed of the inertial movement, in pixels/second. inertiaThreshold Number depends - Number of milliseconds that should pass between stopping the movement and releasing the mouse or touch to prevent inertial movement. 32 for touch devices and 14 for the rest by default. + Number of milliseconds that should pass between stopping the movement and releasing the mouse or touch to prevent inertial movement. 32 for touch devices and 14 for the rest by default. @@ -390,13 +374,13 @@ var map = L.map('map', { zoomControl Boolean - true + true Whether the zoom control is added to the map by default. attributionControl Boolean - true + true Whether the attribution control is added to the map by default. @@ -425,7 +409,7 @@ var map = L.map('map', { zoomAnimationThreshold Number - 4 + 4 Won't animate zoom if the zoom difference exceeds this value. @@ -634,7 +618,7 @@ var map = L.map('map', { <Number> zoom?, <zoom/pan options> options? )
                - this + this Sets the view of the map (geographical center and zoom) with the given animation options. @@ -642,7 +626,7 @@ var map = L.map('map', { <Number> zoom, <zoom options> options? ) - this + this Sets the zoom of the map. @@ -650,16 +634,16 @@ var map = L.map('map', { <Number> delta?, <zoom options> options? ) - this - Increases the zoom of the map by delta (1 by default). + this + Increases the zoom of the map by delta (1 by default). zoomOut( <Number> delta?, <zoom options> options? ) - this - Decreases the zoom of the map by delta (1 by default). + this + Decreases the zoom of the map by delta (1 by default). setZoomAround( @@ -667,7 +651,7 @@ var map = L.map('map', { <Number> zoom, <zoom options> options? ) - this + this Zooms the map while keeping a specified point on the map stationary (e.g. used internally for scroll zoom and double-click zoom). @@ -675,14 +659,14 @@ var map = L.map('map', { <LatLngBounds> bounds, <fitBounds options> options? ) - this + this Sets a map view that contains the given geographical bounds with the maximum zoom level possible. fitWorld( <fitBounds options> options? ) - this + this Sets a map view that mostly contains the whole world with the maximum zoom level possible. @@ -690,7 +674,7 @@ var map = L.map('map', { <LatLng> latlng, <pan options> options? ) - this + this Pans the map to a given center. Makes an animated pan if new center is not more than one screen away from the current one. @@ -698,7 +682,7 @@ var map = L.map('map', { <LatLngBounds> bounds, <pan options> options? ) - this + this Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any. @@ -706,65 +690,48 @@ var map = L.map('map', { <Point> point, <pan options> options? ) - this + this Pans the map by a given number of pixels (animated). invalidateSize( <Boolean> animate ) - this + this Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. invalidateSize( <zoom/pan options> options ) - this - Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row. + this + Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row. setMaxBounds( <LatLngBounds> bounds - this + this Restricts the map view to the given bounds (see map maxBounds option). locate( <Locate options> options? ) - this + this Tries to locate the user using the Geolocation API, firing a locationfound event with location data on success or a locationerror event on failure, and optionally sets the map view to the user's location with respect to detection accuracy (or to the world view if geolocation failed). See Locate options for more details. stopLocate() - this + this Stops watching location previously initiated by map.locate({watch: true}) and aborts resetting the map view if map.locate was called with {setView: true}. remove() - this + this Destroys the map and clears all related event listeners. - - flyTo( - <LatLng> latlng, - <Number> zoom?, - <zoom/pan options> options? ) - - this - Sets the view of the map (geographical center and zoom) performing a smooth pan-zoom animation. - - - flyToBounds( - <LatLngBounds> bounds, - <fitBounds options> options? ) - - this - Sets the view of the map with a smooth animation like flyTo, but takes a bounds parameter like fitBounds. -

                Methods for Getting Map State

                @@ -808,7 +775,7 @@ var map = L.map('map', { Number - Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety. + Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety. getSize() @@ -825,14 +792,6 @@ var map = L.map('map', { Point Returns the projected pixel coordinates of the top left point of the map layer (useful in custom layer and overlay implementations). - - getPixelWorldBounds( - <Number> zoom? ) - - Bounds - Returns the world's bounds in pixel coordinates for zoom level zoom. If zoom is omitted, the map's - current zoom is used. -

                Methods for Layers and Controls

                @@ -845,34 +804,34 @@ var map = L.map('map', { addLayer( - <Layer> layer + <ILayer> layer, - this + this Adds the given layer to the map. removeLayer( - <Layer> layer ) + <ILayer> layer ) - this + this Removes the given layer from the map. hasLayer( - <Layer> layer ) + <ILayer> layer ) Boolean - Returns true if the given layer is currently added to the map. + Returns true if the given layer is currently added to the map. eachLayer( <Function> fn, <Object> context? ) - this + this Iterates over the layers of the map, optionally specifying context of the iterator function.
                map.eachLayer(function (layer) {
                 	layer.bindPopup('Hello');
                @@ -885,50 +844,42 @@ var map = L.map('map', {
                 			<Popup> popup )
                 		
                 
                -		this
                +		this
                 		Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).
                 	
                 	
                 		openPopup(
                -			<String> html  | <HTMLElement> el,
                +			<String> html  | <HTMLElement> el,
                 			<LatLng> latlng,
                 			<Popup options> options? )
                 		
                 
                -		this
                +		this
                 		Creates a popup with the specified options and opens it in the given point on a map.
                 	
                 	
                 		closePopup(
                 			<Popup> popup? )
                 		
                -		this
                +		this
                 		Closes the popup previously opened with openPopup (or the given one).
                 	
                 	
                 		addControl(
                -			<IControl> control )
                +			<IControl> control )
                 		
                 
                -		this
                +		this
                 		Adds the given control to the map.
                 	
                 	
                 		removeControl(
                -			<IControl> control )
                +			<IControl> control )
                 		
                 
                -		this
                +		this
                 		Removes the given control from the map.
                 	
                -	
                -		getRenderer(
                -			<Layer> layer)
                -		
                -
                -		Renderer
                -		Returns the renderer for the given layer.
                -	
                 
                 
                 
                @@ -1030,23 +981,6 @@ var map = L.map('map', {
                 		LatLng
                 		Returns the geographical coordinates of the point the mouse clicked on given the click's event object.
                 	
                -	
                -		wrapLatLng(
                -			<LatLng> latlng )
                -		
                -
                -		LatLng
                -		Returns a LatLng where lat and lng has been wrapped according to the map's CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds.
                -	
                -	
                -		distance(
                -			<LatLng> latlng1,
                -			<LatLng> latlng2 )
                -		
                -
                -		LatLng
                -		Returns the distance in meters between two geographic coordinates in the map's CRS.
                -	
                 
                 
                 

                Other Methods

                @@ -1062,20 +996,6 @@ var map = L.map('map', { HTMLElement Returns the container element of the map. - - createPane( - <String> name, <HTMLElement> container? - ) - MapPane - Creates a pane with the given name. Created panes will be given a generated class based on the name like .leaflet-pane-name" - - - getPane( - <String> name - ) - MapPane - Returns the HTML element representing the named map pane. - getPanes() MapPanes @@ -1102,37 +1022,37 @@ var map = L.map('map', { watch Boolean - false - If true, starts continous watching of location changes (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stopLocate() method. + false + If true, starts continuous watching of location changes (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stopLocate() method. setView Boolean - false - If true, automatically sets the map view to the user location with respect to detection accuracy, or to world view if geolocation failed. + false + If true, automatically sets the map view to the user location with respect to detection accuracy, or to world view if geolocation failed. maxZoom Number - Infinity + Infinity The maximum zoom for automatic view setting when using `setView` option. timeout Number - 10000 + 10000 Number of milliseconds to wait for a response from geolocation before firing a locationerror event. maximumAge Number - 0 + 0 Maximum age of detected location. If less than this amount of milliseconds passed since last geolocation response, locate will return a cached location. enableHighAccuracy Boolean - false + false Enables high accuracy, see description in the W3C spec. @@ -1150,8 +1070,8 @@ var map = L.map('map', { reset Boolean - false - If true, the map view will be completely reset (without any animations). + false + If true, the map view will be completely reset (without any animations). pan @@ -1168,7 +1088,7 @@ var map = L.map('map', { animate Boolean - - + - An equivalent of passing animate to both zoom and pan options (see below). @@ -1186,25 +1106,25 @@ var map = L.map('map', { animate Boolean - - If true, panning will always be animated if possible. If false, it will not animate panning, either resetting the map view if panning more than a screen away, or just setting a new offset for the map pane (except for `panBy` which always does the latter). + If true, panning will always be animated if possible. If false, it will not animate panning, either resetting the map view if panning more than a screen away, or just setting a new offset for the map pane (except for `panBy` which always does the latter). duration Number - 0.25 + 0.25 Duration of animated panning. easeLinearity Number - 0.25 - The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve. + 0.25 + The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve. noMoveStart Boolean - false - If true, panning won't fire movestart event on start (used internally for panning inertia). + false + If true, panning won't fire movestart event on start (used internally for panning inertia). @@ -1221,7 +1141,7 @@ var map = L.map('map', { animate Boolean - - 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. + 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. @@ -1239,25 +1159,25 @@ var map = L.map('map', { paddingTopLeft Point - [0, 0] + [0, 0] 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. paddingBottomRight Point - [0, 0] + [0, 0] The same for bottom right corner of the map. padding Point - [0, 0] + [0, 0] Equivalent of setting both top left and bottom right padding to the same value. maxZoom Number - null + null The maximum possible zoom to use. @@ -1265,7 +1185,7 @@ var map = L.map('map', {

                Properties

                -

                Map properties include interaction handlers that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging or touch zoom (see IHandler methods). Example:

                +

                Map properties include interaction handlers that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging or touch zoom (see IHandler methods). Example:

                map.doubleClickZoom.disable();
                @@ -1281,37 +1201,37 @@ var map = L.map('map', { dragging - IHandler + IHandler Map dragging handler (by both mouse and touch). touchZoom - IHandler + IHandler Touch zoom handler. doubleClickZoom - IHandler + IHandler Double click zoom handler. scrollWheelZoom - IHandler + IHandler Scroll wheel zoom handler. boxZoom - IHandler + IHandler Box (shift-drag with mouse) zoom handler. keyboard - IHandler + IHandler Keyboard navigation handler. tap - IHandler + IHandler Mobile touch hacks (quick tap and touch hold) handler. @@ -1329,51 +1249,47 @@ var map = L.map('map', {

                Map Panes

                -

                Panes are DOM elements used to control the ordering of layers on the map. You can access panes with map.getPane or map.getPanesmethods. New panes can be created with the map.createPane method.

                - -

                Every map has the following panes that differ only in zIndex.

                +

                An object literal (returned by map.getPanes) that contains different map panes that you can use to put your custom overlays in. The difference is mostly in zIndex order that such overlays get.

                - + - - - - + - - + - + + + + + - -
                PaneProperty TypeZ Index Description
                mapPane HTMLElement'auto' Pane that contains all other map panes.
                tilePane HTMLElement2 Pane for tile layers.
                overlayPaneobjectsPane HTMLElement4Pane for overlays like polylines and polygons.Pane that contains all the panes except tile pane.
                shadowPane HTMLElement5 Pane for overlay shadows (e.g. marker shadows).
                overlayPaneHTMLElementPane for overlays like polylines and polygons.
                markerPane HTMLElement6 Pane for marker icons.
                popupPane HTMLElement7 Pane for popups.
                @@ -1381,7 +1297,7 @@ var map = L.map('map', {

                Marker

                -

                Used to put markers on the map. Extends Layer.

                +

                Used to put markers on the map.

                L.marker([50.5, 30.5]).addTo(map);
                @@ -1419,71 +1335,59 @@ var map = L.map('map', { Icon class to use for rendering the marker. See Icon documentation for details on how to customize the marker icon. Set to new L.Icon.Default() by default. - interactive + clickable Boolean - true - If false, the marker will not emit mouse events and will act as a part of the underlying map. + true + If false, the marker will not emit mouse events and will act as a part of the underlying map. draggable Boolean - false + false Whether the marker is draggable with mouse/touch or not. keyboard Boolean - true + true Whether the marker can be tabbed to with a keyboard and clicked by pressing enter. title String - '' + '' Text for the browser tooltip that appear on marker hover (no tooltip by default). alt String - '' + '' Text for the alt attribute of the icon image (useful for accessibility). zIndexOffset Number - 0 - By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively). + 0 + By default, zIndex for the marker image is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively). opacity Number - 1.0 + 1.0 The opacity of the marker. riseOnHover Boolean - false - If true, the marker will get on top of others when you hover the mouse over it. + false + If true, the marker will get on top of others when you hover the mouse over it. riseOffset Number - 250 + 250 The z-index offset used for the riseOnHover feature. - - pane - String - 'markerPane' - Map pane where the markers icon will be added. - - - shadowPane - String - 'shadowPane' - Map pane where the markers shadow will be added. -

                Events

                @@ -1544,7 +1448,7 @@ var map = L.map('map', { move Event - Fired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatLng, latlng. + Fired when the marker is moved via setLatLng. New coordinate include in event arguments. add @@ -1570,14 +1474,20 @@ var map = L.map('map', {

                Methods

                -

                In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                - + + + + + + @@ -1588,7 +1498,7 @@ var map = L.map('map', { <LatLng> latlng ) - + @@ -1596,7 +1506,7 @@ var map = L.map('map', { <Icon> icon ) - + @@ -1604,23 +1514,65 @@ var map = L.map('map', { <Number> offset ) - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1630,7 +1582,7 @@ var map = L.map('map', {

                Interaction handlers

                -

                Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see IHandler methods). Example:

                +

                Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see IHandler methods). Example:

                marker.dragging.disable();
                @@ -1642,7 +1594,7 @@ var map = L.map('map', { - +
                Method Returns Description
                addTo( + <Map> map ) + thisAdds the marker to the map.
                getLatLng() LatLng thisthis Changes the marker position to the given point.
                thisthis Changes the marker icon.
                thisthis Changes the zIndex offset of the marker.
                setOpacity( <Number> opacity ) thisthis Changes the opacity of the marker.
                update() thisthis Updates the marker position, useful if coordinates of its latLng object were changed directly.
                bindPopup( + <String> html | <HTMLElement> el | <Popup> popup, + <Popup options> options? ) + thisBinds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.
                unbindPopup()thisUnbinds the popup previously bound to the marker with bindPopup.
                openPopup()thisOpens the popup previously bound by the bindPopup method.
                getPopup()PopupReturns the popup previously bound by the bindPopup method.
                closePopup()thisCloses the bound popup of the marker if it's opened.
                togglePopup()thisToggles the popup previously bound by the bindPopup method.
                setPopupContent( + <String> html | <HTMLElement> el ) + thisSets an HTML content of the popup of this marker.
                toGeoJSON() Object
                draggingIHandlerIHandler Marker dragging handler (by both mouse and touch).
                @@ -1674,11 +1626,11 @@ var map = L.map('map', { L.popup( <Popup options> options?, - <Layer> source? ) + <ILayer> source? ) - Instantiates a Popup object given an optional options object that describes its appearance and location and an optional source object that is used to tag the popup with a reference to the Layer to which it refers. + Instantiates a Popup object given an optional options object that describes its appearance and location and an optional source object that is used to tag the popup with a reference to the ILayer to which it refers. @@ -1694,121 +1646,109 @@ var map = L.map('map', { maxWidth Number - 300 + 300 Max width of the popup. minWidth Number - 50 + 50 Min width of the popup. maxHeight Number - null + null If set, creates a scrollable container of the given height inside a popup if its content exceeds it. autoPan Boolean - true - Set it to false if you don't want the map to do panning animation to fit the opened popup. + true + Set it to false if you don't want the map to do panning animation to fit the opened popup. keepInView Boolean - false - Set it to true if you want to prevent users from panning the popup off of the screen while it is open. + false + Set it to true if you want to prevent users from panning the popup off of the screen while it is open. closeButton Boolean - true + true Controls the presense of a close button in the popup. offset Point - Point(0, 6) + Point(0, 6) The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays. autoPanPaddingTopLeft Point - null + null + The margin between the popup and the top left corner of the map view after autopanning was performed. autoPanPaddingBottomRight Point - null + null +
                The margin between the popup and the bottom right corner of the map view after autopanning was performed. autoPanPadding Point - Point(5, 5) + Point(5, 5) Equivalent of setting both top left and bottom right autopan padding to the same value. zoomAnimation Boolean - true + true Whether to animate the popup on zoom. Disable it if you have problems with Flash content inside popups. closeOnClick Boolean - null - Set it to false if you want to override the default behavior of the popup closing when user clicks the map (set globally by the Map closePopupOnClick option). + null + Set it to false if you want to override the default behavior of the popup closing when user clicks the map (set globally by the Map closePopupOnClick option). className String - '' + '' A custom class name to assign to the popup. -

                Events

                - - - - - - - - - - - - - - - - - -
                EventDataDescription
                addPopupEventFired when the popup is added to the map.
                removePopupEventFired when the popup is removed from the map.
                -

                Methods

                -

                In addition to shared layer methods like addTo() and remove() you can also use the following methods:

                - + + + + + + - + @@ -1816,7 +1756,7 @@ var map = L.map('map', { <LatLng> latlng ) - + @@ -1826,11 +1766,11 @@ var map = L.map('map', { - - + + @@ -1840,7 +1780,7 @@ var map = L.map('map', { - +
                Method Returns Description
                addTo( + <Map> map ) + thisAdds the popup to the map.
                openOn( <Map> map ) thisthis Adds the popup to the map and closes the previous one. The same as map.openPopup(popup).
                thisthis Sets the geographical point where the popup will open.
                setContent( - <String|HTMLElement|Function> htmlContent ) + <String|HTMLElement> htmlContent ) thisSets the HTML content of the popup. If a function is passed the source layer will be passed to the function. The function should return a String or HTMLElement to be used in the popup.thisSets the HTML content of the popup.
                getContent()
                update()thisthis Updates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded.
                @@ -1849,7 +1789,7 @@ var map = L.map('map', {

                TileLayer

                -

                Used to load and display tile layers on the map. Extends Layer.

                +

                Used to load and display tile layers on the map, implements ILayer interface.

                Usage example

                @@ -1878,9 +1818,9 @@ var map = L.map('map', {

                A string of the following form:

                -
                'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'
                +
                'http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png'
                -

                {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates. {r} can be used to add @2x to the URL to load retina tiles.

                +

                {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates.

                You can use custom keys in the template, which will be evaluated from TileLayer options, like this:

                @@ -1898,122 +1838,116 @@ var map = L.map('map', { minZoom Number - 0 + 0 Minimum zoom number. maxZoom Number - 18 + 18 Maximum zoom number. maxNativeZoom Number - null + null Maximum zoom number the tiles source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxZoom level and auto-scaled. tileSize Number - 256 + 256 Tile size (width and height in pixels, assuming tiles are square). subdomains String or String[] - 'abc' + 'abc' Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings. errorTileUrl String - '' + '' URL to the tile image to show in place of the tile that failed to load. attribution String - '' + '' e.g. "© Mapbox" — the string used by the attribution control, describes the layer data. tms Boolean - false - If true, inverses Y axis numbering for tiles (turn this on for TMS services). + false + If true, inverses Y axis numbering for tiles (turn this on for TMS services). + + + continuousWorld + Boolean + false + If set to true, the tile coordinates won't be wrapped by world width (-180 to 180 longitude) or clamped to lie within world height (-90 to 90). Use this if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor or photo maps). noWrap Boolean - false - If set to true, the tiles just won't load outside the world width (-180 to 180 longitude) instead of repeating. + false + If set to true, the tiles just won't load outside the world width (-180 to 180 longitude) instead of repeating. zoomOffset Number - 0 + 0 The zoom number used in tile URLs will be offset with this value. zoomReverse Boolean - false - If set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom) + false + If set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom) opacity Number - 1.0 + 1.0 The opacity of the tile layer. zIndex Number - null + null The explicit zIndex of the tile layer. Not set by default. - - updateInterval - Number - 200 - Tiles will not update more then once every updateInterval. - unloadInvisibleTiles Boolean depends - If true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false. + If true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false. updateWhenIdle Boolean depends - If false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false. + If false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false. detectRetina Boolean - false - If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution. + false + If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution. reuseTiles Boolean - false - If true, all the tiles that are not visible after panning are placed in a reuse queue from which they will be fetched when new tiles become visible (as opposed to dynamically creating new ones). This will in theory keep memory usage low and eliminate the need for reserving new memory whenever a new tile is needed. + false + If true, all the tiles that are not visible after panning are placed in a reuse queue from which they will be fetched when new tiles become visible (as opposed to dynamically creating new ones). This will in theory keep memory usage low and eliminate the need for reserving new memory whenever a new tile is needed. bounds LatLngBounds - null + null When this option is set, the TileLayer only loads tiles that are in the given geographical bounds. - - - crossOrigin - Boolean - false - If true, all tiles will have their crossOrigin attribute set to ''. This is needed if you want to access tile pixel data. @@ -2052,11 +1986,6 @@ var map = L.map('map', { TileEvent Fired when a tile is removed (e.g. when you have unloadInvisibleTiles on). - - tileerror - TileEvent - Fired when there is an error loading a tile. -

                Methods

                @@ -2072,17 +2001,17 @@ var map = L.map('map', { <Map> map )
                - this + this Adds the layer to the map. bringToFront() - this + this Brings the tile layer to the top of all tile layers. bringToBack() - this + this Brings the tile layer to the bottom of all tile layers. @@ -2090,7 +2019,7 @@ var map = L.map('map', { <Number> opacity )
                - this + this Changes the opacity of the tile layer. @@ -2098,19 +2027,19 @@ var map = L.map('map', { <Number> zIndex ) - this + this Sets the zIndex of the tile layer. redraw() - this + this Causes the layer to clear all the tiles and request them again. setUrl( <String> urlTemplate ) - this + this Updates the layer's URL template and redraws it. @@ -2148,7 +2077,7 @@ var map = L.map('map', { L.tileLayer.wms( <String> baseUrl, <TileLayer.WMS options> options ) - + Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object. @@ -2168,45 +2097,39 @@ var map = L.map('map', { layers String - '' + '' (required) Comma-separated list of WMS layers to show. styles String - '' + '' Comma-separated list of WMS styles. format String - 'image/jpeg' - WMS image format (use 'image/png' for layers with transparency). + 'image/jpeg' + WMS image format (use 'image/png' for layers with transparency). transparent Boolean - false - If true, the WMS service will return images with transparency. + false + If true, the WMS service will return images with transparency. version String - '1.1.1' + '1.1.1' Version of the WMS service to use. crs - CRS - null + CRS + null Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means. - - uppercase - Boolean - false - If true, WMS request parameter keys will be uppercase. -

                Methods

                @@ -2222,15 +2145,86 @@ var map = L.map('map', { <WMS parameters> params, <Boolean> noRedraw? ) - this - Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true). + this + Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true). + + + + +

                TileLayer.Canvas

                + +

                Used to create Canvas-based tile layers where tiles get drawn on the browser side. Extends TileLayer.

                + +

                Usage example

                + +
                var canvasTiles = L.tileLayer.canvas();
                +
                +canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
                +	var ctx = canvas.getContext('2d');
                +	// draw something on the tile canvas
                +}
                + +

                Creation

                + + + + + + + + + + + + +
                FactoryDescription
                L.tileLayer.canvas( + <TileLayer options> options? ) + Instantiates a Canvas tile layer object given an options object (optionally).
                + +

                Options

                + + + + + + + + + + + + + +
                OptionTypeDefaultDescription
                asyncBooleanfalseIndicates that tiles will be drawn asynchronously. tileDrawn method should be called for each tile after drawing completion.
                + +

                Methods

                + + + + + + + + + + + + + + + +
                MethodReturnsDescription
                drawTile( + <HTMLCanvasElement> canvas, + <Point> tilePoint, + <Number> zoom ) + thisYou need to define this method after creating the instance to draw tiles; canvas is the actual canvas tile on which you can draw, tilePoint represents the tile numbers, and zoom is the current zoom.
                tileDrawn( <HTMLCanvasElement> canvas )-If async option is defined, this function should be called for each tile after drawing completion. canvas is the same canvas element, that was passed to drawTile.

                ImageOverlay

                -

                Used to load and display a single image over specific bounds of the map. Extends Layer.

                +

                Used to load and display a single image over specific bounds of the map, implements ILayer interface.

                Usage example

                @@ -2270,13 +2264,13 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);
                opacity Number - 1.0 + 1.0 The opacity of the image overlay. attribution String - '' + '' The attribution text of the image overlay. @@ -2293,7 +2287,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Map> map ) - this + this Adds the overlay to the map. @@ -2301,7 +2295,7 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <Number> opacity ) - this + this Sets the opacity of the overlay. @@ -2309,24 +2303,24 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); <String> imageUrl ) - this + this Changes the URL of the image. bringToFront() - this + this Brings the layer to the top of all overlays. bringToBack() - this + this Brings the layer to the bottom of all overlays.

                Path

                -

                An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly. Extends Layer. +

                An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly.

                Options

                @@ -2339,32 +2333,32 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); - - + + - + - + - + - + @@ -2375,55 +2369,49 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); - + - + - + - + - + - + - - - - - - - - + + - - + + - +
                stroke BooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.trueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
                color String'#3388ff''#03f' Stroke color.
                weight Number35 Stroke width in pixels.
                opacity Number10.5 Stroke opacity.
                fill Boolean dependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.Whether to fill the path with color. Set it to false to disable filling on polygons or circles.
                fillColor
                fillOpacity Number0.20.2 Fill opacity.
                fillRule String'evenodd''evenodd' A string that defines how the inside of a shape is determined.
                dashArray Stringnullnull A string that defines the stroke dash pattern. Doesn't work on canvas-powered layers (e.g. Android 2).
                lineCap String'round'null A string that defines shape to be used at the end of the stroke.
                lineJoin String'round'null A string that defines shape to be used at the corners of the stroke.
                interactiveclickable BooleantrueIf false, the vector will not emit mouse events and will act as a part of the underlying map.
                rendererRendererdependsL.SVG or L.Canvas by default depending on browser support.trueIf false, the vector will not emit mouse events and will act as a part of the underlying map.
                pointerEvents StringnullSets the pointer-events attribute on the path if SVG renderer is used.nullSets the pointer-events attribute on the path if SVG backend is used.
                className String'''' Custom class name set on an element.
                @@ -2491,29 +2479,63 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);

                Methods

                - -

                In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + @@ -2523,17 +2545,17 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); - + - + - +
                Method Returns Description
                addTo( + <Map> map ) + thisAdds the layer to the map.
                bindPopup( + <String> html | <HTMLElement> el | <Popup> popup, + <Popup options> options? ) + thisBinds a popup with a particular HTML content to a click on this path.
                bindPopup( + <Popup> popup, + <Popup options> options? ) + thisBinds a given popup object to the path.
                unbindPopup()thisUnbinds the popup previously bound to the path with bindPopup.
                openPopup( <LatLng> latlng? ) thisthis Opens the popup previously bound by the bindPopup method in the given point, or in one of the path's points if not specified.
                closePopup()thisCloses the path's bound popup if it is opened.
                setStyle( <Path options> object ) thisthis Changes the appearance of a Path based on the options in the Path options object.
                bringToFront()thisthis Brings the layer to the top of all path layers.
                bringToBack()thisthis Brings the layer to the bottom of all path layers.
                redraw()thisthis Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.
                @@ -2562,12 +2584,12 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map); CANVAS Boolean depends - True if Canvas is used for vector rendering (Android 2). You can also force this by setting global variable L_PREFER_CANVAS to true before the Leaflet include on your page — sometimes it can increase performance dramatically when rendering thousands of circle markers, but currently suffers from a bug that causes removing such layers to be extremely slow. + True if Canvas is used for vector rendering (Android 2). You can also force this by setting global variable L_PREFER_CANVAS to true before the Leaflet include on your page — sometimes it can increase performance dramatically when rendering thousands of circle markers, but currently suffers from a bug that causes removing such layers to be extremely slow. CLIP_PADDING Number - 0.5 for SVG
                0.02 for VML + 0.5 for SVG
                0.02 for VML How much to extend the clip area around the map view (relative to its size, e.g. 0.5 is half the screen in each direction). Smaller values mean that you will see clipped ends of paths while you're dragging the map, and bigger values decrease drawing performance. @@ -2579,29 +2601,11 @@ L.imageOverlay(imageUrl, imageBounds).addTo(map);

                Usage example

                // create a red polyline from an array of LatLng points
                -var latlngs = [
                -  [-122.68, 45.51],
                -  [-122.43, 37.77],
                -  [-118.2, 34.04]
                -];
                -
                 var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
                 
                 // zoom the map to the polyline
                 map.fitBounds(polyline.getBounds());
                -

                You can also pass a multi-dimensional array to represent a MultiPolyline shape:

                - -
                // create a red polyline from an array of arrays of LatLng points
                -var latlngs = [
                -  [[-122.68, 45.51],
                -   [-122.43, 37.77],
                -   [-118.2, 34.04]],
                -  [[-73.91, 40.78],
                -   [-87.62, 41.83],
                -   [-96.72, 32.76]]
                -];
                -

                Creation

                @@ -2617,7 +2621,7 @@ var latlngs = [ - +
                Instantiates a polyline object given an array of geographical points and optionally an options object. You can create a Polyline object with multiple separate lines (MultiPolyline) by passing an array of arrays of geographic points.Instantiates a polyline object given an array of geographical points and optionally an options object.
                @@ -2635,20 +2639,20 @@ var latlngs = [ smoothFactor Number - 1.0 + 1.0 How much to simplify the polyline on each zoom level. More means better performance and smoother look, and less means more accurate representation. noClip Boolean - false + false Disabled polyline clipping.

                Methods

                -

                In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                +

                You can use Path methods and additionally the following methods:

                @@ -2658,41 +2662,40 @@ var latlngs = [ - - + + - + - + - - - + + + + - - - - - @@ -2701,43 +2704,81 @@ var latlngs = [
                addLatLng( - <LatLng> latlng, - <LatLng[]> latlngs ) + <LatLng> latlng ) thisAdds a given point to the polyline. By default, adds to the first ring of the polyline in case of a multi-polyline, but can be overridden by passing a specific ring as a LatLng array (that you can earlier access with getLatLngs).thisAdds a given point to the polyline.
                setLatLngs( <LatLng[]> latlngs ) thisthis Replaces all the points in the polyline with the given array of geographical points.
                getLatLngs() LatLng[]Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.Returns an array of the points in the path.
                isEmpty()BooleanReturns true if the Polyline has no LatLng.spliceLatLngs( + <Number> index, + <Number> pointsToRemove, + <LatLng> latlng?, … ) + LatLng[]Allows adding, removing or replacing points in the polyline. Syntax is the same as in Array#splice. Returns the array of removed points (if any).
                getBounds() LatLngBounds Returns the LatLngBounds of the polyline.
                getCenter()LatLngReturns the center (centroid) of the polyline.
                toGeoJSON() Object
                + +

                MultiPolyline

                + +

                Extends FeatureGroup to allow creating multi-polylines (single layer that consists of several polylines that share styling/popup).

                + +

                Creation

                + + + + + + + + + + + + + + +
                FactoryDescription
                L.multiPolyline( + <LatLng[][]> latlngs, + <Polyline options> options? ) + Instantiates a multi-polyline object given an array of arrays of geographical points (one for each individual polyline) and optionally an options object.
                + + +

                Methods

                + +

                MultiPolylines accept all Polyline methods but +have different behavior around their coordinate contents since they can contain +multiple line features:

                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                MethodReturnsDescription
                setLatLngs( + <LatLng[][]> latlngs ) + thisReplace all lines and their paths with the given array of arrays of + geographical points.
                getLatLngs()<LatLng[][]> latlngs + Returns an array of arrays of geographical points in each line.
                openPopup()thisOpens the popup previously bound by bindPopup.
                toGeoJSON()ObjectReturns a GeoJSON representation of the multipolyline (GeoJSON MultiLineString Feature).
                + + +

                Polygon

                A class for drawing polygon overlays on a map. Extends Polyline. Use Map#addLayer to add it to the map.

                Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

                -

                Usage example

                -
                // create a red polygon from an array of LatLng points
                -var latlngs = [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]];
                -
                -var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
                -
                -// zoom the map to the polygon
                -map.fitBounds(polygon.getBounds());
                - -

                You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape:

                - -
                
                -var latlngs = [
                -  [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring
                -  [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole
                -];
                - -

                Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.

                - -
                
                -var latlngs = [
                -  [ // first polygon
                -    [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring
                -    [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole
                -  ],
                -  [ // second polygon
                -    [[-109.05, 37],[-109.03, 41],[-102.05, 41],[-102.04, 37],[-109.05, 38]]
                -  ]
                -];
                - -

                Creation

                @@ -2753,13 +2794,13 @@ var latlngs = [ - +
                Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside. You can create a a Polygon with multiple separate shapes (MultiPolygon) by passing an array of Polygon coordinates.Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside.

                Methods

                -

                In addition to Path methods like redraw() and bringToFront(), Polyline mehtods like setLatLngs() and getLatLngs(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                +

                Polygon has the same options and methods as Polyline, with the following differences:

                @@ -2775,6 +2816,69 @@ var latlngs = [
                +

                MultiPolygon

                + +

                Extends FeatureGroup to allow creating multi-polygons (single layer that consists of several polygons that share styling/popup).

                + +

                Creation

                + + + + + + + + + + + + + +
                FactoryDescription
                L.multiPolygon( + <LatLng[][]> latlngs, + <Polyline options> options? ) + Instantiates a multi-polygon object given an array of latlngs arrays (one for each individual polygon) and optionally an options object (the same as for MultiPolyline).
                + +

                Methods

                + +

                MultiPolygons accept all Polyline methods but +have different behavior around their coordinate contents since they can contain +multiple polygon features:

                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                MethodReturnsDescription
                setLatLngs( + <LatLng[][]> latlngs ) + thisReplace all polygons and their paths with the given array of arrays of + geographical points.
                getLatLngs()<LatLng[][]> latlngs + Returns an array of arrays of geographical points in each polygon.
                openPopup()thisOpens the popup previously bound by bindPopup.
                toGeoJSON()ObjectReturns a GeoJSON representation of the multipolygon (GeoJSON MultiPolygon Feature).

                Rectangle

                @@ -2811,7 +2915,7 @@ map.fitBounds(bounds);

                Methods

                -

                In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                +

                You can use Path methods and additionally the following methods:

                @@ -2824,7 +2928,7 @@ map.fitBounds(bounds);<LatLngBounds> bounds ) - +
                thisthis Redraws the rectangle with the passed bounds.
                @@ -2832,9 +2936,9 @@ map.fitBounds(bounds);

                Circle

                -

                A class for drawing circle overlays on a map. Extends CircleMarker. Use Map#addLayer to add it to the map.

                +

                A class for drawing circle overlays on a map. Extends Path. Use Map#addLayer to add it to the map.

                -
                L.circle([50.5, 30.5], 200).addTo(map);
                +
                L.circle([50.5, 30.5], 200).addTo(map);

                Creation

                @@ -2858,8 +2962,6 @@ map.fitBounds(bounds);

                Methods

                -

                In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                - @@ -2881,7 +2983,7 @@ map.fitBounds(bounds);<LatLng> latlng ) - + @@ -2889,7 +2991,7 @@ map.fitBounds(bounds);<Number> radius ) - + @@ -2903,7 +3005,7 @@ map.fitBounds(bounds);

                CircleMarker

                -

                A circle of a fixed size with radius specified in pixels. Extends Path. Use Map#addLayer to add it to the map.

                +

                A circle of a fixed size with radius specified in pixels. Extends Circle. Use Map#addLayer to add it to the map.

                Creation

                @@ -2926,8 +3028,6 @@ map.fitBounds(bounds);

                Methods

                -

                In addition to Path methods like redraw() and bringToFront(), shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                -
                Method thisthis Sets the position of a circle to a new location.
                thisthis Sets the radius of a circle. Units are in meters.
                @@ -2939,7 +3039,7 @@ map.fitBounds(bounds);<LatLng> latlng ) - + @@ -2947,7 +3047,7 @@ map.fitBounds(bounds);<Number> radius ) - + @@ -2961,7 +3061,7 @@ map.fitBounds(bounds);

                LayerGroup

                -

                Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Extends Layer.

                +

                Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.

                L.layerGroup([marker1, marker2])
                 	.addLayer(polyline)
                @@ -2975,8 +3075,8 @@ map.fitBounds(bounds);
                - @@ -2997,23 +3097,23 @@ map.fitBounds(bounds);<Map> map ) - + - + - + @@ -3021,23 +3121,23 @@ map.fitBounds(bounds);<String> id ) - + - + - + @@ -3047,7 +3147,7 @@ map.fitBounds(bounds); - + @@ -3055,7 +3155,7 @@ map.fitBounds(bounds);<Function> fn, <Object> context? ) - + @@ -3101,7 +3201,7 @@ map.fitBounds(bounds);

                Methods

                -

                In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                +

                Has all layerGroup methods and additionally:

                Method thisthis Sets the position of a circle marker to a new location.
                thisthis Sets the radius of a circle marker. Units are in pixels.
                Description
                L.LayerGroup( - <Layer[]> layers? ) + L.layerGroup( + <ILayer[]> layers? ) thisthis Adds the group of layers to the map.
                addLayer( - <Layer> layer ) + <ILayer> layer ) thisthis Adds a given layer to the group.
                removeLayer( - <Layer> layer ) + <ILayer> layer ) thisthis Removes a given layer from the group.
                thisthis Removes a given layer of the given id from the group.
                hasLayer( - <Layer> layer ) + <ILayer> layer ) BooleanReturns true if the given layer is currently added to the group.Returns true if the given layer is currently added to the group.
                getLayer( <String> id ) LayerILayer Returns the layer with the given id.
                clearLayers()thisthis Removes all the layers from the group.
                thisthis Iterates over the layers of the group, optionally specifying context of the iterator function.
                group.eachLayer(function (layer) {
                 	layer.bindPopup('Hello');
                @@ -3073,7 +3173,7 @@ map.fitBounds(bounds);

                FeatureGroup

                -

                Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Extends Layer.

                +

                Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.

                L.featureGroup([marker1, marker2, polyline])
                 	.bindPopup('Hello world!')
                @@ -3090,7 +3190,7 @@ map.fitBounds(bounds);
                L.featureGroup( - <Layer[]> layers? ) + <ILayer[]> layers? )
                @@ -3109,6 +3209,15 @@ map.fitBounds(bounds); + + + + + + @@ -3118,17 +3227,17 @@ map.fitBounds(bounds); - + - + - +
                Returns Description
                bindPopup( + <String> htmlContent, + <Popup options> options? ) + thisBinds a popup with a particular HTML content to a click on any layer from the group that has a bindPopup method.
                getBounds() LatLngBounds setStyle( <Path options> style ) thisthis Sets the given path options to each layer of the group that has a setStyle method.
                bringToFront()thisthis Brings the layer group to the top of all other layers.
                bringToBack()thisthis Brings the layer group to the bottom of all other layers.
                @@ -3193,9 +3302,10 @@ map.fitBounds(bounds);
                L.geoJson(data, {
                 	style: function (feature) {
                 		return {color: feature.properties.color};
                +	},
                +	onEachFeature: function (feature, layer) {
                +		layer.bindPopup(feature.properties.description);
                 	}
                -}).bindPopup(function (layer) {
                -	return layer.feature.properties.description;
                 }).addTo(map);

                Each feature layer created by it gets a feature property that links to the GeoJSON feature data the layer was created from (so that you can access its properties later).

                @@ -3242,7 +3352,7 @@ map.fitBounds(bounds); onEachFeature( <GeoJSON> featureData, - <Layer> layer ) + <ILayer> layer ) Function that will be called on each created feature layer. Useful for attaching events and popups to features. @@ -3250,7 +3360,7 @@ map.fitBounds(bounds); filter( <GeoJSON> featureData, - <Layer> layer ) + <ILayer> layer ) Function that will be used to decide whether to show a feature or not. @@ -3268,8 +3378,6 @@ map.fitBounds(bounds);

                Methods

                -

                In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:

                - @@ -3289,7 +3397,7 @@ map.fitBounds(bounds);<Function> style ) - + @@ -3297,7 +3405,7 @@ map.fitBounds(bounds);<Path> layer ) - +
                Method thisthis Changes styles of GeoJSON vector layers with the given style function.
                thisthis Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.
                @@ -3316,7 +3424,7 @@ map.fitBounds(bounds); <Function> pointToLayer? ) - Layer + ILayer Creates a layer from a given GeoJSON feature. @@ -3326,7 +3434,7 @@ map.fitBounds(bounds); LatLng - Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude). + Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude). coordsToLatLngs( @@ -3336,237 +3444,12 @@ map.fitBounds(bounds); Array - Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude). + Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude). -

                GridLayer

                -

                Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces TileLayer.Canvas.

                -

                GridLayer can be extended to create a tiled grid of HTML Elements like <canvas>, <img> or <div>.GridLayer will handle creating and animating these DOM elements for you.

                - -

                Synchronous usage example

                - -

                To create a custom layer, extend GridLayer and impliment the createTile() method, which will be passed a Point object with the x, y, and z (zoom level) coordinates to draw your tile.

                - -
                var CanvasLayer = L.GridLayer.extend({
                -	createTile: function(coords){
                -		// create a <canvas> element for drawing
                -		var tile = L.DomUtil.create('canvas', 'leaflet-tile');
                -
                -		// setup tile width and height according to the options
                -		var size = this.getTileSize();
                -		tile.width = size.x;
                -		tile.height = size.y;
                -
                -		// get a canvas context and draw something on it using coords.x, coords.y and coords.z
                -		var ctx = canvas.getContext('2d');
                -
                -		// return the tile so it can be rendered on screen
                -		return tile;
                -	}
                -});
                - -

                Asyncronous usage example

                - -

                Tile creation can also be asyncronous, this is useful when using a third-party drawing library. Once the tile has finished drawing it must be passed to the done() callback.

                - -
                var CanvasLayer = L.GridLayer.extend({
                -	// createTile has a 'done' parameter when on async mode
                -	createTile: function(coords, done){
                -		var error;
                -
                -		// create a <canvas> element for drawing
                -		var tile = L.DomUtil.create('canvas', 'leaflet-tile');
                -
                -		// setup tile width and height according to the options
                -		var size = this.getTileSize();
                -		tile.width = size.x;
                -		tile.height = size.y;
                -
                -		// For this example simply wait one second before tile is ready
                -		window.setTimeout(function(){
                -			// draw something and pass the tile to the done() callback
                -			done(error, tile);
                -		}, 1000);
                -
                -		// return the tile so its progress can be tracked
                -		return tile;
                -	}
                -});
                - -

                Constructor

                - - - - - - - - - - -
                FactoryDescription
                L.gridLayer(<GridLayer options> options?)Creates a new instance of GridLayer with the supplied options.
                - -

                Options

                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                OptionTypeDefault valueDescription
                maxZoomNumber'tilePane'The map pane the layer will be added to.
                tileSizeNumber or Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
                opacityNumber1Opacity of the tiles. Can be used in the createTile() function.
                unloadInvisibleTilesBooleandependsIf true, all the tiles that are not visible after panning are removed (for better performance). true by default on mobile WebKit, otherwise false.
                updateWhenIdleBooleandependsIf false, new tiles are loaded during panning, otherwise only after it (for better performance). true by default on mobile WebKit, otherwise false.
                updateIntervalNumber200Tiles will not update more then once every updateInterval.
                zIndexNumbernullThe explicit zIndex of the tile layer. Not set by default.
                boundsLatLngBoundsnullIf set tiles will only be loaded inside inside the set LatLngBounds.
                boundsLatLngBoundsnullIf set tiles will only be loaded inside inside the set LatLngBounds.
                minZoomNumber0The minimum zoom level that tiles will be loaded at. By default the entire map.
                - -

                Methods

                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                bringToFront()thisBrings the tile layer to the top of all tile layers.
                bringToBack()thisBrings the tile layer to the bottom of all tile layers.
                setOpacity( - <Number> opacity ) - thisChanges the opacity of the tile layer.
                setZIndex( - <Number> zIndex ) - thisSets the zIndex of the tile layer.
                redraw()thisCauses the layer to clear all the tiles and request them again.
                getContainer() - HTMLElementReturns the HTML element that contains the tiles for this layer.
                getTileSize() - PointNormalizes the tileSize option into a point. Used by the createTile() method.
                - -

                Events

                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                EventDataDescription
                loadingEventFired when the tile layer starts loading tiles.
                loadEventFired when the tile layer loaded all visible tiles.
                tileloadstartTileEventFired when a tile is requested and starts loading.
                tileloadTileEventFired when a tile loads.
                tileunloadTileEventFired when a tile is removed (e.g. when you have unloadInvisibleTiles on).
                tileerrorTileEventFired when there is an error loading a tile.

                LatLng

                @@ -3638,12 +3521,11 @@ map.panTo(L.latLng(50, 30)); equals( - <LatLng> otherLatlng, - <Number> maxMargin? ) + <LatLng> otherLatlng ) Boolean - Returns true if the given LatLng point is at the same position (within a small margin of error). The margin of error can be overriden by setting maxMargin to a small number. + Returns true if the given LatLng point is at the same position (within a small margin of error). toString() @@ -3657,10 +3539,40 @@ map.panTo(L.latLng(50, 30)); LatLng - Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default). + Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default). +

                Constants

                + + + + + + + + + + + + + + + + + + + + + + + + + + +
                ConstantTypeValueDescription
                DEG_TO_RADNumberMath.PI / 180A multiplier for converting degrees into radians.
                RAD_TO_DEGNumber180 / Math.PIA multiplier for converting radians into degrees.
                MAX_MARGINNumber1.0E-9Max margin of error for the equality check.
                + +

                LatLngBounds

                @@ -3717,7 +3629,7 @@ map.panTo(L.latLng(50, 30)); <LatLng|LatLngBounds> latlng ) - this + this Extends the bounds to contain the given point or bounds. @@ -3771,7 +3683,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle contains the given one. + Returns true if the rectangle contains the given one. contains( @@ -3779,7 +3691,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle contains the given point. + Returns true if the rectangle contains the given point. intersects( @@ -3787,15 +3699,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. - - - overlaps( - <LatLngBounds> otherBounds ) - - - Boolean - Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. + Returns true if the rectangle intersects the given bounds. equals( @@ -3803,12 +3707,12 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. + Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. toBBoxString() String - Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. + Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. pad( @@ -3823,7 +3727,7 @@ map.panTo(L.latLng(50, 30)); Boolean - Returns true if the bounds are properly initialized. + Returns true if the bounds are properly initialized. @@ -3854,7 +3758,7 @@ map.panBy(L.point(200, 300)); <Boolean> round? ) - Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values. + Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values. @@ -3917,23 +3821,7 @@ map.panBy(L.point(200, 300)); Point - Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. - - - scaleBy( - <Point> scale ) - - - Point - Multiply each coordinate of the current point by each coordinate of scale. In linear algebra terms, multiply the point by the scaling matrix defined by scale. - - - unscaleBy( - <Point> otherPoint ) - - - Point - Inverse of multiplyCoordinates. Divide each coordinate of the current point by each coordinate of scale. + Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. distanceTo( @@ -3958,18 +3846,13 @@ map.panBy(L.point(200, 300)); Point Returns a copy of the current point with floored coordinates (rounded down). - - ceil() - Point - Returns a copy of the current point with ceiled coordinates (rounded up). - equals( <Point> otherPoint ) Boolean - Returns true if the given point has the same coordinates. + Returns true if the given point has the same coordinates. contains( @@ -3977,7 +3860,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). + Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). toString() @@ -4074,7 +3957,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle contains the given one. + Returns true if the rectangle contains the given one. contains( @@ -4082,7 +3965,7 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle contains the given point. + Returns true if the rectangle contains the given point. intersects( @@ -4090,21 +3973,13 @@ map.panBy(L.point(200, 300)); Boolean - Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. - - - overlaps( - <Bounds> otherBounds ) - - - Boolean - Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. + Returns true if the rectangle intersects the given bounds. isValid() Boolean - Returns true if the bounds are properly initialized. + Returns true if the bounds are properly initialized. getSize() @@ -4223,7 +4098,7 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); -

                By default, it has a 'leaflet-div-icon' class and is styled as a little white square with a shadow.

                +

                By default, it has a 'leaflet-div-icon' class and is styled as a little white square with a shadow.

                Creation

                @@ -4270,7 +4145,7 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); className String - A custom class name to assign to the icon. 'leaflet-div-icon' by default. + A custom class name to assign to the icon. 'leaflet-div-icon' by default. html @@ -4279,9 +4154,125 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); + + + +

                Control

                + +

                The base class for all Leaflet controls. Implements IControl interface. You can add controls to the map like this:

                + +
                control.addTo(map);
                +// the same as
                +map.addControl(control);
                + +

                Creation

                + + + + + + + + + + + + + +
                FactoryDescription
                L.control( + <Control options> options? ) + Creates a control with the given options.
                + +

                Options

                + + + + + + + + + + + + + +
                OptionTypeDefaultDescription
                positionString'topright'The initial position of the control (one of the map corners). See control positions.
                + +

                Methods

                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                MethodReturnsDescription
                setPosition( + <String> position ) + thisSets the position of the control. See control positions.
                getPosition()StringReturns the current position of the control.
                addTo( + <Map> map ) + thisAdds the control to the map.
                removeFrom( + <Map> map ) + thisRemoves the control from the map.
                getContainer()HTMLElementReturns the HTML container of the control.
                + +

                Control Positions

                + +

                Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

                + + + + + + + + + + + + + + + + + + + + + + +
                PositionDescription
                'topleft'Top left of the map.
                'topright'Top right of the map.
                'bottomleft'Bottom left of the map.
                'bottomright'Bottom right of the map.
                + +

                Control.zoom

                -

                A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

                +

                A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

                Creation

                @@ -4311,31 +4302,31 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); - + - + - + - + - +
                position String'topleft''topleft' The position of the control (one of the map corners). See control positions.
                zoomInText String'+''+' The text set on the zoom in button.
                zoomOutText String'-''-' The text set on the zoom out button.
                zoomInTitle String'Zoom in''Zoom in' The title set on the zoom in button.
                zoomOutTitle String'Zoom out''Zoom out' The title set on the zoom out button.
                @@ -4344,7 +4335,7 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);

                Control.Attribution

                -

                The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. Extends Control.

                +

                The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. Extends Control.

                Creation

                @@ -4375,14 +4366,14 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); - + - - + +
                position String'bottomright''bottomright' The position of the control (one of the map corners). See control positions.
                prefix String'Leaflet'The HTML text shown before the attributions. Pass false to disable.'Leaflet'The HTML text shown before the attributions. Pass false to disable.
                @@ -4397,21 +4388,21 @@ L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); setPrefix( <String> prefix ) - this + this Sets the text before the attributions. addAttribution( <String> text ) - this - Adds an attribution text (e.g. 'Vector data &copy; Mapbox'). + this + Adds an attribution text (e.g. 'Vector data &copy; Mapbox'). removeAttribution( <String> text ) - this + this Removes an attribution text. @@ -4459,25 +4450,25 @@ L.control.layers(baseLayers, overlays).addTo(map); addBaseLayer( - <Layer> layer, + <ILayer> layer, <String> name ) - this + this Adds a base layer (radio button entry) with the given name to the control. addOverlay( - <Layer> layer, + <ILayer> layer, <String> name ) - this + this Adds an overlay (checkbox entry) with the given name to the control. removeLayer( - <Layer> layer ) + <ILayer> layer ) - this + this Remove the given layer from the control. @@ -4494,20 +4485,20 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'topright' + 'topright' The position of the control (one of the map corners). See control positions. collapsed Boolean - true - If true, the control will be collapsed into an icon and expanded on mouse hover or touch. + true + If true, the control will be collapsed into an icon and expanded on mouse hover or touch. autoZIndex Boolean - true - If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. + true + If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. @@ -4590,39 +4581,40 @@ L.control.layers(baseLayers, overlays).addTo(map); position String - 'bottomleft' + 'bottomleft' The position of the control (one of the map corners). See control positions. maxWidth Number - 100 + 100 Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500). metric Boolean - true + true Whether to show the metric scale line (m/km). imperial Boolean - true + true Whether to show the imperial scale line (mi/ft). updateWhenIdle Boolean - false - If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move). + false + If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move). +

                Events methods

                -

                A set of methods shared between event-powered classes (like Map and Marker). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire 'click' event).

                +

                A set of methods shared between event-powered classes (like Map). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map 'click' event).

                Example

                @@ -4645,205 +4637,532 @@ map.off('click', onClick);
                Description - on( + addEventListener( <String> type, <Function> fn, <Object> context? ) - this - Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). + this + Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). - once( + addOneTimeEventListener( <String> type, <Function> fn, <Object> context? ) - this + this The same as above except the listener will only get fired once and then removed. - on( + addEventListener( <Object> eventMap, <Object> context? ) - this + this Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - off( + removeEventListener( <String> type, <Function> fn?, <Object> context? ) - this - Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener. + this + Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to addEventListener, you must pass the same context to removeEventListener in order to remove the listener. - off( + removeEventListener( <Object> eventMap, <Object> context? ) - this - Removes a set of type/listener pairs. + this + Removes a set of type/listener pairs. - off() + removeEventListener() - this - Removes all listeners to all events on the object. + this + Removes all listeners. An alias to clearAllEventListeners when you use it without arguments. - listens( + hasEventListeners( <String> type ) Boolean - Returns true if a particular event type has any listeners attached to it. + Returns true if a particular event type has some listeners attached to it. - fire( + fireEvent( <String> type, <Object> data? ) - this + this Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. - - addEventListener( … ) - this - Alias to on. - - - addOneTimeEventListener( … ) - this - Alias to once. - - - removeEventListener( … ) - this - Alias to off. - clearAllEventListeners() - this - Alias to off(). + this + Removes all listeners to all events on the object. - hasEventListeners( … ) - this - Alias to listens. + on( … ) + this + Alias to addEventListener. - fireEvent( … ) - this - Alias to fire. + once( … ) + this + Alias to addOneTimeEventListener. + + + off( … ) + this + Alias to removeEventListener. + + + fire( … ) + this + Alias to fireEvent. -

                Layer methods

                +

                Event objects

                -A set of methods inherited from the Layer base class that all Leaflet layers use. +

                Event object is an object that you receive as an argument in a listener function when some event is fired, containing useful information about that event. For example:

                -
                var layer = L.Marker(latlng).addTo(map);
                -layer.addTo(map);
                -layer.remove();
                +
                map.on('click', function(e) {
                +	alert(e.latlng); // e is an event object (MouseEvent in this case)
                +});
                -

                Methods

                +

                Event

                - +

                The base event object. All other event objects contain these properties too.

                + +
                - - - + + + - - - + + + - - - + + + + +
                MethodReturnsDescriptionpropertytypedescription
                addTo(<Map> map)thisAdds the layer to the given map.typeStringThe event type (e.g. 'click').
                removeFrom(<Map> map)thisRemoves the layer to the given map.targetObjectThe object that fired the event.
                + +

                MouseEvent

                + + + + + + - - - + + + - + + + + + + + + + + + + + + +
                propertytypedescription
                remove()thisRemoves the layer from the map it is currently active on.latlngLatLngThe geographical point where the mouse event occurred.
                getPane(<String> name?)layerPointPointPixel coordinates of the point where the mouse event occurred relative to the map layer.
                containerPointPointPixel coordinates of the point where the mouse event occurred relative to the map сontainer.
                originalEventDOMMouseEventThe original DOM mouse event fired by the browser.
                + +

                LocationEvent

                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                propertytypedescription
                latlngLatLngDetected geographical location of the user.
                boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
                accuracyNumberAccuracy of location in meters.
                altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
                altitudeAccuracyNumberAccuracy of altitude in meters.
                headingNumberThe direction of travel in degrees counting clockwise from true North.
                speedNumberCurrent velocity in meters per second.
                timestampNumberThe time when the position was acquired.
                + +

                ErrorEvent

                + + + + + + + + + + + + + + + + + +
                propertytypedescription
                messageStringError message.
                codeNumberError code (if applicable).
                + +

                LayerEvent

                + + + + + + + + + + + + +
                propertytypedescription
                layerILayerThe layer that was added or removed.
                + +

                LayersControlEvent

                + + + + + + + + + + + + + + + + + +
                propertytypedescription
                layerILayerThe layer that was added or removed.
                nameStringThe name of the layer that was added or removed.
                + +

                TileEvent

                + + + + + + + + + - + + + + + +
                propertytypedescription
                tile HTMLElementReturns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.The tile element (image).
                urlStringThe source URL of the tile.
                -

                Popup methods

                +

                ResizeEvent

                -A set of methods inherited from the Layer base class that all Leaflet layers use. These methods provide convieniant ways of binding popups to any layer. + + + + + + + + + + + + + + + + +
                propertytypedescription
                oldSizePointThe old size before resize event.
                newSizePointThe new size after the resize event.
                -
                var layer = L.Polgon(latlngs).bindPopup('Hi There!').addTo(map);
                -layer.openPopup();
                -layer.closePopup();
                +

                GeoJSON event

                + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                propertytypedescription
                layerILayerThe layer for the GeoJSON feature that is being added to the map.
                propertiesObjectGeoJSON properties of the feature.
                geometryTypeStringGeoJSON geometry type of the feature.
                idStringGeoJSON ID of the feature (if present).
                + + + + + + + + + + + + + + +
                propertytypedescription
                popupPopupThe popup that was opened or closed.
                + +

                DragEndEvent

                + + + + + + + + + + + + +
                propertytypedescription
                distanceNumberThe distance in pixels the draggable element was moved by.
                + + + + + + +

                Class

                + +

                L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

                +

                In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

                + +
                var MyClass = L.Class.extend({
                +	initialize: function (greeter) {
                +		this.greeter = greeter;
                +		// class constructor
                +	},
                +
                +	greet: function (name) {
                +		alert(this.greeter + ', ' + name)
                +	}
                +});
                +
                +// create instance of MyClass, passing "Hello" to the constructor
                +var a = new MyClass("Hello");
                +
                +// call greet method, alerting "Hello, World"
                +a.greet("World");
                 
                -Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened. +

                The initialize method is your class's constructor function, meaning that it gets called when you do new MyClass(...).

                -

                Methods

                - - - - - - - - - - -
                featureGroup.bindPopup(function(layer){
                -	return "a unique template for this layer.";
                +
                +

                Class Factories

                + +

                You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:

                + +
                new L.Map('map'); // becomes:
                +L.map('map');
                + +

                The factories are implemented very easily, and you can do this for your own classes:

                + +
                L.map = function (id, options) {
                +	return new L.Map(id, options);
                +};
                + + +

                Inheritance

                + +

                You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

                + +
                var MyChildClass = MyClass.extend({
                +	// ... new properties and methods
                 });
                -
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                MethodReturnsDescription
                bindPopup(<String|HTMLElement|Function|Popup> content, <PopupOptions> options?)thisBinds the passed content to the layer and sets up the neccessary event listeners. If a Function is passed the function will recive a layer as the first argument and should return a String or HTMLElement.
                unbindPopup()thisRemoves the popup previously bound with bindPopup.
                openPopup(LatLng latlng?)thisOpens the bound popup at the specificed latlng or at the default popup anchor if no latlng is passed.
                closePopup()thisCloses the popup if it is open.
                togglePopup()thisOpens or closes the popup depending on its current state.
                setPopupContent(<String|HTMLElement|Popup> content, <PopupOptions> options?)thisSets the content of the popup.
                getPopup()PopupReturns the popup bound to this layer.
                + +

                This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

                + +
                var a = new MyChildClass();
                +a instanceof MyChildClass; // true
                +a instanceof MyClass; // true
                +
                + +

                You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

                + +
                var MyChildClass = MyClass.extend({
                +	initialize: function () {
                +		MyClass.prototype.initialize.call(this, "Yo");
                +	},
                +
                +	greet: function (name) {
                +		MyClass.prototype.greet.call(this, 'bro ' + name + '!');
                +	}
                +});
                +
                +var a = new MyChildClass();
                +a.greet('Jason'); // alerts "Yo, bro Jason!"
                + +

                Options

                + +

                options is a special property that unlike other objects that you pass to extend will be merged with the parent one instead of overriding it completely, which makes managing configuration of objects and default values convenient:

                + +
                var MyClass = L.Class.extend({
                +	options: {
                +		myOption1: 'foo',
                +		myOption2: 'bar'
                +	}
                +});
                +
                +var MyChildClass = MyClass.extend({
                +	options: {
                +		myOption1: 'baz',
                +		myOption3: 5
                +	}
                +});
                +
                +var a = new MyChildClass();
                +a.options.myOption1; // 'baz'
                +a.options.myOption2; // 'bar'
                +a.options.myOption3; // 5
                + +

                There's also L.Util.setOptions, a method for conveniently merging options passed to constructor with the defaults defined in the class:

                + +
                var MyClass = L.Class.extend({
                +	options: {
                +		foo: 'bar',
                +		bla: 5
                +	},
                +
                +	initialize: function (options) {
                +		L.Util.setOptions(this, options);
                +		...
                +	}
                +});
                +
                +var a = new MyClass({bla: 10});
                +a.options; // {foo: 'bar', bla: 10}
                + +

                Includes

                + +

                includes is a special class property that merges all specified objects into the class (such objects are called mixins). A good example of this is L.Mixin.Events that event-related methods like on, off and fire to the class.

                + +
                 var MyMixin = {
                +	foo: function () { ... },
                +	bar: 5
                +};
                +
                +var MyClass = L.Class.extend({
                +	includes: MyMixin
                +});
                +
                +var a = new MyClass();
                +a.foo();
                + +

                You can also do such includes in runtime with the include method:

                + +
                MyClass.include(MyMixin);
                + +

                Statics

                + +

                statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

                + +
                var MyClass = L.Class.extend({
                +	statics: {
                +		FOO: 'bar',
                +		BLA: 5
                +	}
                +});
                +
                +MyClass.FOO; // 'bar'
                + + +

                Constructor Hooks

                + +

                If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

                + +
                MyClass.addInitHook(function () {
                +	// ... do something in constructor additionally
                +	// e.g. add event listeners, set custom properties etc.
                +});
                + +

                You can also use the following shortcut when you just need to make one additional method call:

                + +
                MyClass.addInitHook('methodName', arg1, arg2, …);
                +

                Browser

                @@ -4862,77 +5181,77 @@ Popups will also be automatically opened when the layer is clicked on and closed ie Boolean - true for all Internet Explorer versions. + true for all Internet Explorer versions. ie6 Boolean - true for Internet Explorer 6. + true for Internet Explorer 6. ie7 Boolean - true for Internet Explorer 7. + true for Internet Explorer 7. webkit Boolean - true for webkit-based browsers like Chrome and Safari (including mobile versions). + true for webkit-based browsers like Chrome and Safari (including mobile versions). webkit3d Boolean - true for webkit-based browsers that support CSS 3D transformations. + true for webkit-based browsers that support CSS 3D transformations. android Boolean - true for Android mobile browser. + true for Android mobile browser. android23 Boolean - true for old Android stock browsers (2 and 3). + true for old Android stock browsers (2 and 3). mobile Boolean - true for modern mobile browsers (including iOS Safari and different Android browsers). + true for modern mobile browsers (including iOS Safari and different Android browsers). mobileWebkit Boolean - true for mobile webkit-based browsers. + true for mobile webkit-based browsers. mobileOpera Boolean - true for mobile Opera. + true for mobile Opera. touch Boolean - true for all browsers on touch devices. + true for all browsers on touch devices. msTouch Boolean - true for browsers with Microsoft touch model (e.g. IE10). + true for browsers with Microsoft touch model (e.g. IE10). retina Boolean - true for devices with Retina screens. + true for devices with Retina screens. @@ -4961,16 +5280,14 @@ Popups will also be automatically opened when the layer is clicked on and closed bind( <Function> fn, - <Object> obj, - <Any> arg1?, - <Any> arg2?, - <Any> arg3?, … ) + <Object> obj ) + Function - Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). The arguments received by the bound function will be any arguments passed when binding the function, followed by any arguments passed when invoking the bound function. Has an L.bind shortcut. Works exactly like Function.prototype.bind in modern browsers compliant with ECMAScript 5. + Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut. Not a polyfill for ES 5 bind (compare L.bind to the MDN-recommended polyfill for Function.prototype.bind). - stamp( <Object> obj ) + stamp( <Object> obj ) String Applies a unique key to the object and returns that key. Has an L.stamp shortcut. @@ -4992,20 +5309,20 @@ Popups will also be automatically opened when the layer is clicked on and closed Cancels a previous request to requestAnimFrame. - throttle( + limitExecByInterval( <Function> fn, <Number> time, <Object> context? ) Function - Returns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time (in milliseconds), but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called. + Returns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time, but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called. falseFn() Function - Returns a function which always returns false. + Always returns false. formatNum( @@ -5016,23 +5333,13 @@ Popups will also be automatically opened when the layer is clicked on and closed Number Returns the number num rounded to digits decimals. - - wrapNum( - <Number> num, - <Array> range, - <Boolean> includeMax ) - - - Number - Returns the number num modulo range in such a way so it lies within range[0] and range[1]. The returned value will be always smaller than range[1] unless includeMax is set to true. - splitWords( <String> str ) String[] - Trims and splits the string on whitespace and returns the array of parts. + Trims and splits the string on whitespace and returns the array of parts. setOptions( @@ -5049,7 +5356,7 @@ Popups will also be automatically opened when the layer is clicked on and closed String - Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'. + Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'. template( @@ -5057,7 +5364,7 @@ Popups will also be automatically opened when the layer is clicked on and closed String - Simple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument. + Simple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument. isArray( @@ -5065,7 +5372,7 @@ Popups will also be automatically opened when the layer is clicked on and closed Boolean - Returns true if the given object is an array. + Returns true if the given object is an array. trim( @@ -5156,7 +5463,7 @@ Popups will also be automatically opened when the layer is clicked on and closed

                LineUtil

                -

                Various utility functions for polyine points processing, used by Leaflet internally to make polylines lightning-fast.

                +

                Various utility functions for polyline points processing, used by Leaflet internally to make polylines lightning-fast.

                Methods

                @@ -5233,7 +5540,7 @@ Popups will also be automatically opened when the layer is clicked on and closed Point[] - Clips the polygon geometry defined by the given points by rectangular bounds. Used by Leaflet to only show polygon points that are on the screen or near, increasing performance. Note that polygon points needs different algorithm for clipping than polyline, so there's a seperate method for it. + Clips the polygon geometry defined by the given points by rectangular bounds. Used by Leaflet to only show polygon points that are on the screen or near, increasing performance. Note that polygon points needs different algorithm for clipping than polyline, so there's a separate method for it. @@ -5253,76 +5560,32 @@ Popups will also be automatically opened when the layer is clicked on and closed Description - on( - <HTMLElement> el, - <String> types, - <Function> fn, - <Object> context? ) - - - this - - Adds a listener function (fn) to a particular DOM event type of the element el. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick'). - - - on( - <HTMLElement> el, - <Object> eventMap, - <Object> context? ) - - - this - Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - - - off( - <HTMLElement> el, - <String> types, - <Function> fn, - <Object> context? ) - - - this - - Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular DOM event from the element. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener. - - - off( - <HTMLElement> el, - <Object> eventMap, - <Object> context? ) - - - this - Removes a set of type/listener pairs. - addListener( <HTMLElement> el, - <String> types, + <String> type, <Function> fn, <Object> context? ) - this - Alias to on. + this + Adds a listener fn to the element's DOM event of the specified type. this keyword inside the listener will point to context, or to the element if not specified. removeListener( <HTMLElement> el, - <String> types, - <Function> fn, - <Object> context? ) + <String> type, + <Function> fn ) - this - Alias to off. + this + Removes an event listener from the element. stopPropagation( <DOMEvent> e ) - this + this Stop the given event from propagation to parent elements. Used inside the listener functions:
                L.DomEvent.addListener(div, 'click', function (e) {
                 	L.DomEvent.stopPropagation(e);
                @@ -5334,15 +5597,16 @@ Popups will also be automatically opened when the layer is clicked on and closed
                 			<DOMEvent> e )
                 		
                 
                -		this
                -		Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions.
                +		this
                +		Prevents the default action of the event from happening (such as following a link in the href of the a element, or doing a POST request with page reload when form is submitted). Use it inside listener functions.
                + stop( <DOMEvent> e ) - this + this Does stopPropagation and preventDefault at the same time. @@ -5350,8 +5614,8 @@ Popups will also be automatically opened when the layer is clicked on and closed <HTMLElement> el )
                - this - Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events. + this + Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' and 'touchstart' events. getMousePosition( @@ -5379,7 +5643,6 @@ Popups will also be automatically opened when the layer is clicked on and closed

                Utility functions to work with the DOM tree, used by Leaflet internally.

                ->>>>>>> more layer docs

                Methods

                @@ -5405,6 +5668,14 @@ Popups will also be automatically opened when the layer is clicked on and closed + + + + + + - - - - - - - - - - @@ -5447,12 +5704,8 @@ Popups will also be automatically opened when the layer is clicked on and closed - - - - - - + + - - - - - - - - - - - - - - - - + + - - - + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - -
                String Returns the value for a certain style attribute on an element, including computed values or values set through CSS.
                getViewportOffset( + <HTMLElement> el ) + PointReturns the offset to the viewport for the requested element.
                create( <String> tagName, @@ -5416,20 +5687,6 @@ Popups will also be automatically opened when the layer is clicked on and closed Creates an element with tagName, sets the className, and optionally appends it to container element.
                remove( - <HTMLElement> el ) - -Removes el from its parent element.
                empty( - <HTMLElement> el ) - -Removes all of el's children elements from el.
                disableTextSelection() - BooleanReturns true if the element class attribute contains name.
                falseFn()FunctionAlways returns false.Returns true if the element class attribute contains name.
                addClass( @@ -5474,25 +5727,6 @@ Popups will also be automatically opened when the layer is clicked on and closed Removes name from the element's class attribute.
                getClass( - <Element> el ) - <String>Returns the element's CSS class (for HTML elements) or SVG class (for SVG elements).
                setClass( - <HTMLElement> el, - <String> name ) - -Sets the element's CSS class (for HTML elements) or SVG class (for SVG elements).
                setOpacity( <HTMLElement> el, @@ -5507,26 +5741,35 @@ Popups will also be automatically opened when the layer is clicked on and closed <String[]> props ) String or falseGoes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform.String or falseGoes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform.
                setTransform( - <HTMLElement> el, - <Point> offset, - <Number> scale? ) + getTranslateString( + <Point> point ) -Resets the 3D CSS transform of el so it is translated by offset and optionally scaled by scale. Does not have an effect if the browser doesn't support 3D CSS transforms.StringReturns a CSS transform string to move an element by the offset provided in the given point. Uses 3D translate on WebKit for hardware-accelerated transforms and 2D on other browsers.
                getScaleString( + <Number> scale, + <Point> origin ) + StringReturns a CSS transform string to scale an element (with the given scale origin).
                setPosition( <HTMLElement> el, - <Point> point ) + <Point> point, + <Boolean> disable3D? ) -Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers).Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true.
                getPosition( @@ -5536,28 +5779,6 @@ Popups will also be automatically opened when the layer is clicked on and closed Point Returns the coordinates of an element previously positioned with setPosition.
                disableImageDrag()-Prevents the user from generating dragstart DOM events, usually generated when the user drags an image. Used internally by Leaflet to override the behaviour of any click-and-drag interaction on the map. Affects drag interactions on the whole document.
                enableImageDrag()-Cancels the effects of a previous L.DomUtil.disableImageDrag.
                preventOutline( - <HTMLElement> el ) - -Makes the outline of the element el invisible. Used internally by Leaflet to prevent focusable elements from displaying an outline when the user performs a drag interaction on them.
                restoreOutline()-Cancels the effects of a previous L.DomUtil.preventOutline.

                Properties

                @@ -5572,7 +5793,7 @@ Popups will also be automatically opened when the layer is clicked on and closed TRANSITION String - Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). + Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). TRANSFORM @@ -5621,8 +5842,8 @@ fx.run(el, [300, 500], 0.5);
                <Number> easeLinearity? ) - this - Run an animation of a given element to a new position, optionally setting duration in seconds (0.25 by default) and easing linearity factor (3rd argument of the cubic bezier curve, 0.5 by default) + this + Run an animation of a given element to a new position, optionally setting duration in seconds (0.25 by default) and easing linearity factor (3rd argument of the cubic bezier curve, 0.5 by default) @@ -5707,7 +5928,7 @@ draggable.enable(); dragend - DragEndEvent + Event Fired when the dragging ends. @@ -5743,274 +5964,114 @@ draggable.enable(); START String - Name of the DOM event that initiates dragging. 'mousedown' for desktop browsers, 'touchstart' for mobile devices. + Name of the DOM event that initiates dragging. 'mousedown' for desktop browsers, 'touchstart' for mobile devices. MOVE String - Name of the DOM event for drag moving. 'mousemove' for desktop browsers, 'touchmove' for mobile devices. + Name of the DOM event for drag moving. 'mousemove' for desktop browsers, 'touchmove' for mobile devices. END String - Name of the DOM event that ends dragging. 'mouseup' for desktop browsers, 'touchend' for mobile devices. + Name of the DOM event that ends dragging. 'mouseup' for desktop browsers, 'touchend' for mobile devices. --> -

                Class

                - -

                L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

                -

                In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

                - -
                var MyClass = L.Class.extend({
                -	initialize: function (greeter) {
                -		this.greeter = greeter;
                -		// class constructor
                -	},
                -
                -	greet: function (name) {
                -		alert(this.greeter + ', ' + name)
                -	}
                -});
                -
                -// create instance of MyClass, passing "Hello" to the constructor
                -var a = new MyClass("Hello");
                -
                -// call greet method, alerting "Hello, World"
                -a.greet("World");
                -
                -

                Class Factories

                +

                IHandler

                +

                An interface implemented by interaction handlers.

                -

                You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:

                - -
                new L.Map('map'); // becomes:
                -L.map('map');
                - -

                The factories are implemented very easily, and you can do this for your own classes:

                - -
                L.map = function (id, options) {
                -	return new L.Map(id, options);
                -};
                + + + + + + + + + + + + + + + + + + + + + +
                MethodReturnsDescription
                enable()-Enables the handler.
                disable()-Disables the handler.
                enabled()BooleanReturns true if the handler is enabled.
                -

                Inheritance

                +

                ILayer

                -

                You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

                +

                Represents an object attached to a particular location (or a set of locations) on a map. Implemented by tile layers, markers, popups, image overlays, vector layers and layer groups.

                -
                var MyChildClass = MyClass.extend({
                -	// ... new properties and methods
                -});
                +

                Methods

                -

                This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

                + + + + + + + + -
                var a = new MyChildClass();
                -a instanceof MyChildClass; // true
                -a instanceof MyClass; // true
                -
                + + + + + -

                You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

                - -
                var MyChildClass = MyClass.extend({
                -	initialize: function () {
                -		MyClass.prototype.initialize.call("Yo");
                -	},
                -
                -	greet: function (name) {
                -		MyClass.prototype.greet.call(this, 'bro ' + name + '!');
                -	}
                -});
                -
                -var a = new MyChildClass();
                -a.greet('Jason'); // alerts "Yo, bro Jason!"
                - -

                Options

                - -

                options is a special property that unlike other objects that you pass to extend will be merged with the parent one instead of overriding it completely, which makes managing configuration of objects and default values convenient:

                - -
                var MyClass = L.Class.extend({
                -	options: {
                -		myOption1: 'foo',
                -		myOption2: 'bar'
                -	}
                -});
                -
                -var MyChildClass = L.Class.extend({
                -	options: {
                -		myOption1: 'baz',
                -		myOption3: 5
                -	}
                -});
                -
                -var a = new MyChildClass();
                -a.options.myOption1; // 'baz'
                -a.options.myOption2; // 'bar'
                -a.options.myOption3; // 5
                - -

                There's also L.Util.setOptions, a method for conveniently merging options passed to constructor with the defauls defines in the class:

                - -
                var MyClass = L.Class.extend({
                -	options: {
                -		foo: 'bar',
                -		bla: 5
                -	},
                -
                -	initialize: function (options) {
                -		L.Util.setOptions(this, options);
                -		...
                -	}
                -});
                -
                -var a = new MyClass({bla: 10});
                -a.options; // {foo: 'bar', bla: 10}
                - -

                Includes

                - -

                includes is a special class property that merges all specified objects into the class (such objects are called mixins). - -

                 var MyMixin = {
                -	foo: function () { ... },
                -	bar: 5
                -};
                -
                -var MyClass = L.Class.extend({
                -	includes: MyMixin
                -});
                -
                -var a = new MyClass();
                -a.foo();
                - -

                You can also do such includes in runtime with the include method:

                - -
                MyClass.include(MyMixin);
                - -

                Statics

                - -

                statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

                - -
                var MyClass = L.Class.extend({
                -	statics: {
                -		FOO: 'bar',
                -		BLA: 5
                -	}
                -});
                -
                -MyClass.FOO; // 'bar'
                - - -

                Constructor Hooks

                - -

                If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

                - -
                MyClass.addInitHook(function () {
                -	// ... do something in constructor additionally
                -	// e.g. add event listeners, set custom properties etc.
                -});
                - -

                You can also use the following shortcut when you just need to make one additional method call:

                - -
                MyClass.addInitHook('methodName', arg1, arg2, …);
                - -

                Evented

                - -

                When creating a plugin you may want your code to have access to the event methods. By extending the Evented class you can create a class which inherits event-related methods like on, off and fire

                - -
                MyEventedClass = L.Evented.extend({
                -	fire: function(){
                -		this.fire('custom', {
                -			// you can attach optional data to an event as an object
                -		});
                -	}
                -});
                -
                -var myEvents = new MyEventedClass();
                -
                -myEvents.on('custom', function(e){
                -	// e.type will  be 'custom'
                -	// anything else you passed in the
                -});
                -
                -myEvents.fire();
                - -You can still use the old-style `L.Mixin.Events` for backward compatibility. - -
                // this class will include all event methods
                -MyEventedClass = L.Class.extend({
                -	includes: L.Mixin.Events
                -});
                - -

                Layer

                - -

                The base class for all Leaflet layers that implements basic shared methods and functionality. Can be extended to create custom layers by extending L.Layer and implementing the onAdd and onRemove methods.

                + + + +
                MethodReturnsDescription
                onAdd( + <Map> map ) + -Should contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).
                onRemove( + <Map> map ) + -Should contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).

                Implementing Custom Layers

                -

                Custom layers should extend the L.Layer base class. L.Layer provides convenience methods for your layer like addTo(map), removeFrom(map) and getPane().

                -

                The most important things know about when implementing custom layers are Map viewreset event and latLngToLayerPoint method. viewreset is fired when the map needs to reposition its layers (e.g. on zoom), and latLngToLayerPoint is used to get coordinates for the layer's new position.

                Another event often used in layer implementations is moveend which fires after any movement of the map (panning, zooming, etc.).

                Another thing to note is that you'll usually need to add leaflet-zoom-hide class to the DOM elements you create for the layer so that it hides during zoom animation. Implementing zoom animation for custom layers is a complex topic and will be documented separately in future, but meanwhile you can take a look at how it's done for Leaflet layers (e.g. ImageOverlay) in the source.

                -

                Methods

                - -

                Every layer should extend from L.Layer and implement the following methods:

                - - - - - - - - - - - - - - - - - - - - - - -
                MethodReturnsDescription
                onAdd(<Map> map)thisShould contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).
                onRemove(<Map> map)thisShould contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
                getEvents()ObjectThis optional method should return an object like { viewreset: this._reset }for addEventListener. These events will be automatically added and removed from the map with your layer.
                -

                Custom Layer Example

                Here's how a custom layer implementation usually looks:

                -
                var MyCustomLayer = L.Layer.extend({
                +
                var MyCustomLayer = L.Class.extend({
                 
                 	initialize: function (latlng) {
                 		// save position of the layer or any options from the constructor
                 		this._latlng = latlng;
                 	},
                 
                -	// these events will be added and removed from the map with the layer
                -	getEvents: function(){
                -		return {
                -			viewreset: this._reset
                -		}
                -	},
                -
                 	onAdd: function (map) {
                -		// create a DOM element and put it into one of the map panes, by default the overlayPane
                +		this._map = map;
                +
                +		// create a DOM element and put it into one of the map panes
                 		this._el = L.DomUtil.create('div', 'my-custom-layer leaflet-zoom-hide');
                -		this.getPane().appendChild(this._el);
                +		map.getPanes().overlayPane.appendChild(this._el);
                 
                 		// add a viewreset event listener for updating layer's position, do the latter
                +		map.on('viewreset', this._reset, this);
                 		this._reset();
                 	},
                 
                 	onRemove: function (map) {
                 		// remove layer's DOM elements and listeners
                -		this.getPane().removeChild(this._el);
                +		map.getPanes().overlayPane.removeChild(this._el);
                +		map.off('viewreset', this._reset, this);
                 	},
                 
                 	_reset: function () {
                @@ -6020,85 +6081,14 @@ MyEventedClass = L.Class.extend({
                 	}
                 });
                 
                -var myLayer = new MyCustomLayer(latlng).addTo(map);
                +map.addLayer(new MyCustomLayer(latlng));
                 
                -

                Inherited Options

                -

                Classes extending from L.Layer will also inherit the following options:

                - - - - - - - - - - - - - -
                OptionTypeDefault valueDescription
                paneString'overlayPane'By default the layer will be added to the maps overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
                +

                IControl

                -

                Inherited Events

                - -

                Classes extending from L.Layer will also fire the following events:

                - - - - - - - - - - - - - - - - - -
                EventDataDescription
                addEventFired after the layer is added to a map.
                removeEventFired after the layer is removed from a map.
                - -

                Inherited Methods

                - -

                Classes extending from L.Layer will also inherit the following methods:

                - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                MethodReturnsDescription
                addTo(<Map> map)thisAdds the layer to the given map.
                removeFrom(<Map> map)thisRemoves the layer to the given map.
                remove()thisRemoves the layer from the map it is currently active on.
                getPane(<String> name?)HTMLElementReturns the HTMLElement representing the named pane on the map. Or if name is omitted the pane for this layer.
                - -

                Control

                - -

                Controls represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls. Can be used to create custom controls by extending L.Control and implementing the onAdd and onRemove methods.

                +

                Represents a UI element in one of the corners of the map. Implemented by zoom, attribution, scale and layers controls.

                Methods

                @@ -6162,147 +6152,16 @@ map.addControl(new MyControl());
                map.addControl(new MyControl('bar', {position: 'bottomleft'}));
                -

                Options

                - -

                Classes extending from L.Control will also inherit the following options:

                - - - - - - - - - - - - - - -
                OptionTypeDefaultDescription
                positionString'topright'The initial position of the control (one of the map corners). See control positions.
                - -

                Inherited Methods

                - -

                Classes extending from L.Control will also inherit the following methods:

                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                MethodReturnsDescription
                setPosition( - <String> position ) - thisSets the position of the control. See control positions.
                getPosition()StringReturns the current position of the control.
                addTo( - <Map> map ) - thisAdds the control to the map.
                removeFrom( - <Map> map ) - thisRemoves the control from the map.
                getContainer()HTMLElementReturns the HTML container of the control.
                - -

                Control Positions

                - -

                Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

                - - - - - - - - - - - - - - - - - - - - - - -
                PositionDescription
                'topleft'Top left of the map.
                'topright'Top right of the map.
                'bottomleft'Bottom left of the map.
                'bottomright'Bottom right of the map.
                -

                Handler

                -

                Implemented by map interaction handlers.

                - - - - - - - - - - - - - - - - - - - - - -
                MethodReturnsDescription
                enable()-Enables the handler.
                disable()-Disables the handler.
                enabled()BooleanReturns true if the handler is enabled.
                - -

                Projection

                +

                IProjection

                An object with methods for projecting geographical coordinates of the world onto a flat surface (and back). See Map projection.

                -

                Properties

                - - - - - - - - - - - - -
                PropertyTypeDescription
                boundsLatLngBoundsThe bounds where the projection is valid
                -

                Methods

                - +
                @@ -6355,13 +6214,13 @@ map.addControl(new MyControl()); -

                CRS

                +

                ICRS

                Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back (and to coordinates in other units for WMS services). See Spatial reference system.

                Methods

                -
                Method Returns
                +
                @@ -6393,14 +6252,6 @@ map.addControl(new MyControl()); - - - - - - - - - - - - - - - - - - - - - + +
                Method ReturnsPoint Projects geographical coordinates into coordinates in units accepted for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
                unproject( - <Point> point ) - LatLngGiven a projected coordinate returns the corresponding LatLng. The inverse of project.
                scale( <Number> zoom ) @@ -6410,35 +6261,18 @@ map.addControl(new MyControl()); Returns the scale used when transforming projected coordinates into pixel coordinates for a particular zoom. For example, it returns 256 * 2^zoom for Mercator-based CRS.
                getProjectedBounds( + getSize( <Number> zoom ) BoundsReturns the projection's bounds scaled and transformed for the provided zoom.
                distance( - <LatLng> latlng1, - <LatLng> latlng2 ) - NumberReturns the distance in meters between two geographic coordinates in this CRS.
                wrapLatLng( - <LatLng> latlng ) - LatLngReturns a LatLng where lat and lng has been wrapped according to the CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds.PointReturns the size of the world in pixels for a particular zoom.

                Properties

                - +
                @@ -6447,7 +6281,7 @@ map.addControl(new MyControl()); - + @@ -6461,22 +6295,7 @@ map.addControl(new MyControl()); - - - - - - - - - - - - - - - - +
                Property Type
                projectionIProjectionIProjection Projection that this CRS uses.
                code StringStandard code name of the CRS passed into WMS services (e.g. 'EPSG:3857').
                wrapLatNumber[]Latitude bounds, lower followed by upper, at which latitudes should wrap around, or null to disable wrapping
                wrapLngNumber[]Longitude bounds, lower followed by upper, at which longitudes should wrap around, or null to disable wrapping
                infiniteBooleantrue if the CRS bounds should be ignored; coordinates in an infinite CRS will not be wrappedStandard code name of the CRS passed into WMS services (e.g. 'EPSG:3857').
                @@ -6489,13 +6308,6 @@ map.addControl(new MyControl()); Projection Description - - L.CRS.Earth - - Serves as the base for CRS that are global such that they cover the earth. Can only be used as the base for - other CRS and cannot be used directly, since it does not have a code, projection or - transformation. - L.CRS.EPSG3857 @@ -6520,284 +6332,10 @@ map.addControl(new MyControl());

                If you want to use some obscure CRS not listed here, take a look at the Proj4Leaflet plugin.

                -

                Event objects

                - -

                Event object is an object that you recieve as an argument in a listener function when some event is fired, containing useful information about that event. For example:

                - -
                map.on('click', function(e) {
                -	alert(e.latlng); // e is an event object (MouseEvent in this case)
                -});
                - -

                Event

                - -

                The base event object. All other event objects contain these properties too.

                - - - - - - - - - - - - - - - - - -
                propertytypedescription
                typeStringThe event type (e.g. 'click').
                targetObjectThe object that fired the event.
                - -

                MouseEvent

                - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                propertytypedescription
                latlngLatLngThe geographical point where the mouse event occured.
                layerPointPointPixel coordinates of the point where the mouse event occured relative to the map layer.
                containerPointPointPixel coordinates of the point where the mouse event occured relative to the map сontainer.
                originalEventDOMMouseEventThe original DOM mouse event fired by the browser.
                - -

                LocationEvent

                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                propertytypedescription
                latlngLatLngDetected geographical location of the user.
                boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
                accuracyNumberAccuracy of location in meters.
                altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
                altitudeAccuracyNumberAccuracy of altitude in meters.
                headingNumberThe direction of travel in degrees counting clockwise from true North.
                speedNumberCurrent velocity in meters per second.
                timestampNumberThe time when the position was acquired.
                - -

                ErrorEvent

                - - - - - - - - - - - - - - - - - -
                propertytypedescription
                messageStringError message.
                codeNumberError code (if applicable).
                - -

                LayerEvent

                - - - - - - - - - - - - -
                propertytypedescription
                layerLayerThe layer that was added or removed.
                - -

                LayersControlEvent

                - - - - - - - - - - - - - - - - - -
                propertytypedescription
                layerLayerThe layer that was added or removed.
                nameStringThe name of the layer that was added or removed.
                - -

                TileEvent

                - - - - - - - - - - - - -
                propertytypedescription
                tileHTMLElementThe tile element (image).
                - -

                TileErrorEvent

                - - - - - - - - - - - - -
                propertytypedescription
                tileHTMLElementThe tile element (image).
                - -

                ResizeEvent

                - - - - - - - - - - - - - - - - - -
                propertytypedescription
                oldSizePointThe old size before resize event.
                newSizePointThe new size after the resize event.
                - -

                GeoJSON event

                - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                propertytypedescription
                layerLayerThe layer for the GeoJSON feature that is being added to the map.
                propertiesObjectGeoJSON properties of the feature.
                geometryTypeStringGeoJSON geometry type of the feature.
                idStringGeoJSON ID of the feature (if present).
                - - - - - - - - - - - - - - -
                propertytypedescription
                popupPopupThe popup that was opened or closed.
                - -

                DragEndEvent

                - - - - - - - - - - - - -
                propertytypedescription
                distanceNumberThe distance in pixels the draggable element was moved by.

                Global Switches

                -

                Global switches are created for rare cases and generally make Leaflet to not detect a particular browser feature even if it's there. You need to set the switch as a global variable to true before including Leaflet on the page, like this:

                +

                Global switches are created for rare cases and generally make Leaflet to not detect a particular browser feature even if it's there. You need to set the switch as a global variable to true before including Leaflet on the page, like this:

                <script>L_PREFER_CANVAS = true;</script>
                 <script src="leaflet.js"></script>