Leaflet v1.0-beta1 Release Notes
Release Date: 2015-07-14 // almost 9 years ago-
๐ The first beta of the huge, long-awaited Leaflet 1.0 release.
โฌ๏ธ This version contains a lot of beneficial but potentially breaking changes (especially if you're a plugin author), so please read through the changes carefully if your code breaks after upgrading.
Vectors API improvements
๐ Leaflet vector layers rendering got a major rewrite, making it possible to switch between rendering backends (Canvas, SVG) dynamically (and even use both for different layers at the same time), have more than one physical pane for vector layers, significantly improving performance, adding Canvas retina support, getting rid of ugly hacks and generally making the code much cleaner. Main PR #2290.
- โ Added
Renderer
layer (inherited by SVG/Canvas implementations) that handles renderer bounds and zoom animation. - โ Added
SVG
&Canvas
classes that now contain all renderer-specific code for vector layers and can be added as layers to the map. - All vector layer classes (
Path
,Polyline
, etc.) now don't contain any renderer-specific code and instead can be passed a renderer layer to use asrenderer
in options; - โ Removed
MultiPolyline
andMultiPolygon
classes since multiple rings are now handled byPolyline
andPolygon
classes respectively. Layers with multiple rings now perform much better (since each is now physically a single path object instead of being aFeatureGroup
of layers). - ๐ Dramatically improved performance of interactive Canvas layers. Mouse events work much faster (due to improved hit detection algorithms), and layers get updated many times faster (with partial redraws instead of redrawing the whole Canvas).
- ๐ Dramatically improved performance of interactive SVG layers (e.g. creating a big GeoJSON layer and adding to a map got 3x faster while taking 2.5x less memory). #2240 #2315
- โ Added retina support for Canvas layers.
- ๐ Improved default vector layer styles.
- โ Added
Polyline
andPolygon
getCenter
for getting centroids. - Respectively, improved
Polyline
andPolygon
popup positioning when callingopenPopup
. - ๐ Improved
Polyline
/Polygon
getBounds
to be cached (so it works much faster). - ๐ Changed
Circle
to inherit fromCircleMarker
and not the other way. - ๐ Fixed
GeoJSON
resetStyle
to work properly in casestyle
option wasn't set. - ๐ Fixed a bug where map fired
moveend
when updating Canvas layers. - โ Removed
Polyline
andPolygon
spliceLatLngs
method (just usesetLatLngs
instead). - ๐ Changed
Polygon
getLatLngs
to always return an array of rings (nested array) (by @yohanboniface). #2618 #3386 Leaflet/Leaflet#3279 #2648 - โ Added the ability to specify a custom pane for vector layers (making it possible to easily do stacks like vectors-tiles-vectors with proper z-index order) (by @Jakobud). #3266 #2786
- โ Added vector layers
fillRule
option (by @bullgare). #2834 - Removed
L_PREFER_CANVAS
global switch and addedMap
preferCanvas
option instead (by @yohanboniface). #3623
Layers API improvements
๐จ All Leaflet layers (including markers, popups, tile and vector layers) have been refactored to have a common parent,
Layer
class, that shares the basic logic of adding and removing. The leads to the following changes (main PR #2266):- โ Added
Layer
class which all layers added to a map should inherit from. - โ Added
add
andremove
events to all layers. - โ Added
remove
method to layers and controls (marker.remove()
is now equivalent tomap.removeLayer(marker)
). - ๐ Improved performance of adding and removing layers.
- โ Added
pane
option to all layers that can be changed (e.g. you can setpane: 'overlayPane'
to a tile layer). - โ Added
map
createPane
method for custom panes. #1742 - ๐ Simplified map panes — removed
objectsPane
, all panes are on the same level now. - โ Added
shadowPane
option to markers as well. - โ Added
getEvents
method to all layers that returns an{event: listener, ...}
hash; layers now manage its listeners automatically without having to do this inonAdd
/onRemove
. - โ Added
togglePopup
,setPopupContent
,getPopup
,isPopupOpen
methods to all layers. #2279 #2292 - ๐ Improved performance of adding/removing layers with layers control present (instead of listening to any layer add/remove, the control only listens to layers added in configuration).
- ๐ Fixed
FeatureGroup
getBounds
to work correctly when containing circle markers. - โ Removed
Map
tilelayersload
event. - โ Removed
Popup
open
andclose
events in favor ofadd
andremove
for consistency. - ๐ Moved all layer-related logic in
Map.js
toLayer.js
. - ๐ Improved
FeatureGroup
bindPopup
to accept a function for generating popup content, significantly improving memory footprint when adding popups to a huge number of layers (by @patrickarlt). #3109 #3059 - โ Added
ImageOverlay
interactivity (mouse events, etc.) (by @snkashis). #3009 #1727 - โ Added
ImageOverlay
getBounds
(by @brunob). #2848 - ๐ Renamed
clickable
option tointeractive
(by @AndriiHeonia). #2838 #2499 - ๐ Changed the default z-index of panes to be bigger, leaving more room for customization (by @patrickarlt). #3591
- ๐ Improved DOM event bubbling mechanism for layers (by @yohanboniface). Leaflet/Leaflet#3307 #3450 #3307
- โ Added
nonBubblingEvents
option to layers (by @yohanboniface). #3605 #3307 #3604
In addition, layer events implementation was rewritten to use event delegation, significantly improving add/remove performance and memory footprint. #3032 #46
TileLayer & Projections API improvements
๐จ TileLayer code and everything projections-related has undergone a major refactoring, documented in PR #2247. It includes the following changes (in addition to much cleaner and simpler code):
TileLayer API improvements
These changes make implementing custom grid-like layers for Leaflet much easier.
- ๐ Moved most of the
TileLayer
logic into the newGridLayer
class (whichTileLayer
now inherits, extending it with logic specific to tile servers). - โ Removed
TileLayer.Canvas
in favor of the much more flexible and powerfulGridLayer
. - ๐ Improved tile wrapping and bounding logic in
TileLayer
to work transparently and completely depent on the CRS used; removed the need forTileLayer
hacks when using custom projections. - โ Added non-square tiles support (by @IvanSanchez). #3573 #3570
- โ Removed
url
property intileload
andtileloadstart
events (get it throughtile.src
).
Projections API improvements
๐ These changes were targeted at removing any hardcoded projection-specific logic accross Leaflet classes, making it transparent and driven by the chosen CRS. They make using Leaflet with custom projections (including flat maps) much easier, and remove the need for ugly hacks in the Proj4Leaflet plugin.
- โ Added
CRS.Earth
which serves as a base for all Earth-based CRS (EPSG3857
etc.). #2345 - โ Added
Projection
bounds
property that defines bounds for different projections (Mercator
, etc.) in projected coordinates (by @perliedman). - โ Added
CRS
wrapLat
andwrapLng
properties which define whether the world wraps on a given axis and in what range. Set as[-180, 180]
forEPSG:3857
,EPSG:4326
,EPSG:3395
by default. - โ Added
CRS
andMap
wrapLatLng
(the latter depends on the chosen CRS). - โ Added
CRS
infinite
property that disables boundaries (the world can go on infinitely in any direction), default forCRS.Simple
. - โ Added
CRS
getProjectedBounds
andMap
getPixelWorldBounds
methods that returns world bounds in projected coordinates depending on zoom (derived fromProjection
bounds
) (by @perliedman). - โ Added
CRS
unproject
method that converts coordinates in CRS-dependent units intoLatLng
coordinates (by @sowelie). - โ Added
Map
distance(latlng1, latlng2)
method that takes CRS into account and works with flat projections. #2345 #1442 - ๐ Improved
Circle
to be approximated with an ellipse in Earth-based projections. #2345 - ๐ Fixed
EPSG:4326
to have correct tile pyramid (2x1 tiles at root). - ๐ Fixed
Projection.SphericalMercator
to project to meter units (by @calvinmetcalf). - ๐ Fixed
Map
worldCopyJump
option to work for other projections. - ๐ Fixed
Circle
to work with flat projections. #2345 #1465 - ๐ Fixed scale control precision in non-EPSG:3857 projections. #2345
- ๐ Fixed
ImageOverlay
not working properly in some non-standard projections. #3011
Animations improvements and fractional zoom
Animation code in Leaflet had undergone a major rewrite (main PR: #2382), bringing improvements such as:
- Multi-level tile buffering for more seamless zooming experience with less flickering
- Optimal path animation (
map.flyTo
) for zooming to a particular place in a curve (simultaneously zooming and panning) - ๐ Fractional zoom support — now you can do things like
map.setZoom(12.45)
and it just works. - Layers now rely on
zoom
event in addition toviewreset
for frame-by-frame zoom animations. #3278
UX improvements
- ๐ Improved panning inertia behavior so that there are no tearing during animation when panning around quickly. #2360
- ๐ Improved inertial scrolling to have a nicer, more natural feel (by @RickMohr). Leaflet/Leaflet#3063 #3063 #3062 #2987
- โ Added popup fade out animation.
- ๐ Improved keyboard support to ignore keystrokes with modifier keys (Ctrl, Alt, Meta) to not interfere with OS shortcuts.
- Made popup to close when pressing Escape (by @snkashis). #951 #3000
- ๐ Improved keyboard zoom to zoom by 3 levels if shift key is pressed (by @yohanboniface). #3024
- ๐ Improved layers control to become scrollable when there are too many layers (by @rowanwins). #3571 #3167
๐ Misc. performance improvements
- ๐ Significantly improved
LatLng
creation performance (8x). - ๐ Improved performance of layer objects construction.
- ๐ Significantly improved
FeatureGroup
(and correspondinglyGeoJSON
) layer adding and events performance (about 10x) by implementing a much better event propagation mechanism. #2311 - ๐ Improved Leaflet events and DOM events memory footprint.
- ๐ Improved
Evented
off
performance by about 2 times.
Other breaking API changes
- ๐ Changed
DomUtil
off
to requirecontext
attribute if you remove a listener that was previously added with a particular context. - โ Removed
DomUtil.getViewportOffset
method as it is no longer necessary. - โ Removed
DomUtil
getTranslateString
andgetScaleString
methods. - โ Removed
DomUtil
documentIsLtr
method. - Removed
LatLng
RAD_TO_DEG
,DEG_TO_RAD
andMAX_MARGIN
constants. - ๐ Renamed
Util.limitExecByInterval
toUtil.throttle
.
Other API improvements
- โ Added
Evented
class that now many Leaflet classes inherit from (instead of mixing in events methods in each class), while keeping the oldincludes: L.Mixin.Events
syntax available. #2310 - ๐ Improved
Class
options
to be prototypically inherited instead of copied over in children classes, which leads to more efficient memory use, faster object construction times and ability to change parent options that get propagated to all children automatically (by @jfirebaugh). #2300 #2294 - โ Added
{r}
variable toTileLayer
url
for adding"@2x"
prefix on Retina-enabled devices (by @urbaniak). #2296 - โ Added
Point
ceil
method (by @perliedman). - โ Added
Util.wrapNum
method for wrapping a number to lie in a certain range. - ๐ Improved
L.bind
to use nativeFunction
bind
on modern browsers and prepend real arguments to bound ones. - โ Added
LatLng
equals
second argumentmaxMargin
. - โ Added
DomUtil
setClass
andgetClass
methods. - ๐ Improved
Marker
move
event to includeoldLatlng
(by @danzel). #2412 - โ Added
Marker
mousemove
event (by @bullgare). #2798 - ๐ Improved
DomEvent
on
/off
to accept space-separated events and object literals ({type: fn}
). - โ Added
DomUtil
toFront
andtoBack
methods. - โ Added
Evented
listens
as a shortcut tohasEventListeners
. - โ Added optional support for center-oriented scroll for
L.map
optiontouchZoom
(by @mtmail). #2527 - โ Added
getElement
method to all layers that returns an associated DOM element. - โ Added
LatLng
clone
method (by @yohanboniface). #3390 - โ Added
Map
setMinZoom
andsetMaxZoom
methods (by @nathancahill). #3383 #3380 - โ Added
originalEvent
toMap
andMarker
drag
andmove
event data (by @yohanboniface). #3264 - โ Added
Popup
autoClose
option (by @jfirebaugh). #3018 #2716 #1853 - โ Added
Control.Zoom
enable
anddisable
methods. #3172 - โ Added an argument to
L.PolyUtil.clipPolygon
that controls rounding (by @aparshin). #2926 #2917 - โ Added
Map
wheelDebounceTime
option (by @AndriiHeonia). #2836 #2501 - โ Added
TileLayer.WMS
uppercase
option (nowfalse
by default) (by @kdeloach). #2831 #1751 - โ Added
ImageOverlay
alt
option (by @francis-liberty). #2767 #2564 - ๐ Improved
L.Util.extend
performance (by @fab1an). #2746 - โ Added
Map
stop
method for stopping panning orflyTo
animation. - โ Added
Map
maxBoundsViscosity
option that controls how much the map resits dragging out of max bounds (set to1
for a hard limit) (by @IvanSanchez). #2224 #3510 #1673 - โ Added
Bounds
andLatLngBounds
overlaps
method (by @IvanSanchez). #2981 #3508 - โ Added
ImageOverlay
crossOrigin
option (by @patrickarlt). #3594 #2621
๐ Bugfixes
- ๐ Fixed
DomUtil
on
to make it possible to add the same listener to the same element for multiple contexts. - ๐ Fixed a bug that thowed an error when attempting to reinitialize the map on unload (by @gamb). #2410
- ๐ Fixed excessively blurry non-retina tiles on retina iOS devices.
- ๐ Fixed a bug with popup close button in IE7/8. #2351
- ๐ Fixed
ImageOverlay
mercator distortion on lower zoom levels. - ๐ Fixed a bug where layers didn't fire
popupopen
andpopupclose
events when manually creating a popup object and passing it tobindPopup
. #2354 - ๐ Fixed box-zoom overlay appearing under markers. #1813
- ๐ Fixed
Map
panInsideBounds
to accept array-form bounds (by @RLRR). #3489 - ๐ Fixed marker draggable state to persist when removing and adding back to the map (by @IvanSanchez). #3488
- ๐ Fixed inertia not working when parallel to axis (by @rikvanmechelen). #3432
- ๐ Fixed images and SVG inside popups having max-width property overridden (by @yohanboniface). #3452
- ๐ Fixed cursors when dragging is disabled (by @juliensoret). #3219 #3233
- ๐ Fixed
LatLng
wrap
to not drop altitude (by @IvanSanchez). #3420 - ๐ Fixed Firefox for Android not being detected as mobile (by @IvanSanchez). #3419
- ๐ Fixed an infinite loop when calling
setMaxBounds
several times in a row (by @IvanSanchez). #3410 #3320 - ๐ Fixed a WTF
Map
locate
bug that could cause some unexpected effects (by @sindre). Leaflet/Leaflet#3404 - ๐ Fixed broken zoom in Project Spartan browsers (by @mitchless). #3379
- ๐ Fixed broken
Polygon
getCenter
when all points in the same pixel (by @yohanboniface). #3372 - ๐ Fixed broken
Polyline
getCenter
when the line is very small (by @yohanboniface). #3371 - ๐ Fixed keyboard zoom out not working on
azerty
keyboards. #3362 - ๐ Fixed a bug where tabbing to an offscreen marker broke control positioning (by @IvanSanchez). #3340 #3333
- ๐ Fixed
Map
panBy
not always returningthis
(by @Trufi). #3303 - ๐ Fixed a bug where pushing a zoom control with a keyboard would switch focus to the map (by @Jakobud). #3275 #3159
- ๐ Fixed more race conditions leading to map freeze. #3270 #3268 #2693 #2478
- ๐ Fixed iOS race condition when doing a very small pan. #2519
- ๐ Fixed
Polygon
toGeoJSON
exporting aMultiPolygon
in some cases (by @yohanboniface). #2977 - ๐ Fixed
TileLayer.WMS
passing all options as WMS params. #2972 - ๐ Fixed a race condition that made
map.fitBounds(map.getBounds())
zoom out sometimes. #2957 - ๐ Fixed a bug where a draggable marker stopped being draggable after
setIcon
(by @jeffsmale90). #2578 - ๐ Fixed some IE11 touch performance and stability issues (by @danzel). #3007 #2820
- ๐ Fixed a race condition with
TileLayer
whenmaxNativeZoom = 0
. #3004 - ๐ Fixed
FeatureGroup
setStyle
not affectingImageOverlay
opacity
(by @opie). #3008 #2246 - ๐ Fixed class init hooks not being called for parent classes (by @jfirebaugh). #2545
- ๐ Fixed a bug when adding a control that's already added or removing a control that's not present (by @jfirebaugh). #3020 #2877
- ๐ Fixed buggy inertia on low zoom levels when
Map
worldCopyJump
option is enabled (by @flemenach). #3038 #2624 - ๐ Fixed a bug where
getMaxZoom
sometimes returned wrong result inside aControl.Layers
baselayerchange
event (by @CloudNiner). #3048 #2318 - ๐ Fixed a bug where during zooming one map, dragging was disabled on all other maps on the page (by @kdeloach). #3050 #2539
- ๐ Fixed a
Map
getSize
race condition where it could return a wrong result (by @kshepard). #3052 #3031 - ๐ Fixed
L.latLng
factory to acceptaltitude
as a third argument too (by @lonelyelk). #3070. - ๐ Fixed
L.latLng
factory to not throw error on empty array input (by @lonelyelk). #3080 #3079 - ๐ Fixed popups to have a default color (by @snkashis). #3115 #3112 #333
- ๐ Fixed
Map
locate
not to mutate the given options object (by @tmcw). #3173 - ๐ Fixed Canvas polylines not to render if stroke is set to 0 (by @optical). #3203
- Prevented a Joomla bug that could lead to vector layers disappearing (by @SniperSister). #2886 #2881 Leaflet/Leaflet#2881
- ๐ Fixed IE Metro touch events passing through objects on top of a Leaflet map (by @nikgavalas). #2954
- ๐ Fixed a bug where vector layers wouldn't display on websites with SVG max-width set to 100% (by @SniperSister). #2886 #2881
- ๐ Fixed
Marker
setIcon
to not reset popup anchor offset (by @bullgare). #2872 - ๐ Fixed a case where you provide
zoom
inMap
options and then set center (by @AndriiHeonia). #2849 #1871 - ๐ Fixed a race condition with
TileLayer
setUrl
whereloading
event didn't fire properly (by @bennlich). #2802 #2675 #2827 - ๐ Fixed a bug where a tile layer was not cleaned up properly after zooming past its max zoom (by @francis-liberty). #2764 #1905
- ๐ Fixed a memory leak with
Marker
setIcon
(by @jfgodoy). #2811 - ๐ Fixed
LatLng
distanceTo
to not returnNaN
on equal locations. #2705 - ๐ Fixed a bug where
TileLayer
maxNativeZoom
didn't work properly withbounds
option set (by @mlegenhausen). #2725 #2704 - ๐ Fixed a bug where tiles touching the edge of the bounds from outside where loaded (by @IvanSanchez). #2981 #3508
- ๐ Fixed a memory leak in
map.remove()
(by @IvanSanchez). #3514 #2718 - ๐ Fixed a bug where layers control collapsed when hovering over a disabled radio button (by @rowanwins). #3564 #2771 Leaflet#2771
- ๐ Fixed GeoJSON not accepting null geometry (by @pglotov). #3585
- ๐ Fixed occasional popup 1px horizontal offset (by @patrickarlt). #3587 #3526 #3586 #3525
- ๐ Fixed some inconsistencies in mouse events for Canvas vector layers (by @wpf500). #3590 #3568 #3618
- ๐ Fixed scale control for non-earth CRS (by @cmulders). #3614
Misc improvements
- ๐ Improved the build system (
jake build
) to report gzipped library size. - โ Added version name and commit number to Leaflet builds. #2276
- โ Added Leaflet logo in vector format as
src/images/logo.svg
. - โ Added reference to Leaflet CSS in
package.json
(by @bclinkinbeard). #2432 - ๐ Switched from JSHint to ESLint for checking code style and made the checks more strict. #3176
- โ Added a plugin guide section on module loaders and publishing plugins (by @patrickarlt). #2955 Leaflet/Leaflet#2955
- ๐ Fixed the build system to work in non-git Leaflet folder (by @cschwarz). #2758
- โ Added