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 as renderer in options;
    • โœ‚ Removed MultiPolyline and MultiPolygon classes since multiple rings are now handled by Polyline and Polygon classes respectively. Layers with multiple rings now perform much better (since each is now physically a single path object instead of being a FeatureGroup 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 and Polygon getCenter for getting centroids.
    • Respectively, improved Polyline and Polygon popup positioning when calling openPopup.
    • ๐Ÿ‘Œ Improved Polyline/Polygon getBounds to be cached (so it works much faster).
    • ๐Ÿ”„ Changed Circle to inherit from CircleMarker and not the other way.
    • ๐Ÿ›  Fixed GeoJSON resetStyle to work properly in case style option wasn't set.
    • ๐Ÿ›  Fixed a bug where map fired moveend when updating Canvas layers.
    • โœ‚ Removed Polyline and Polygon spliceLatLngs method (just use setLatLngs 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 added Map 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 and remove events to all layers.
    • โž• Added remove method to layers and controls (marker.remove() is now equivalent to map.removeLayer(marker)).
    • ๐Ÿ‘Œ Improved performance of adding and removing layers.
    • โž• Added pane option to all layers that can be changed (e.g. you can set pane: '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 in onAdd/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 and close events in favor of add and remove for consistency.
    • ๐Ÿšš Moved all layer-related logic in Map.js to Layer.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 to interactive (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 new GridLayer class (which TileLayer now inherits, extending it with logic specific to tile servers).
    • โœ‚ Removed TileLayer.Canvas in favor of the much more flexible and powerful GridLayer.
    • ๐Ÿ‘Œ Improved tile wrapping and bounding logic in TileLayer to work transparently and completely depent on the CRS used; removed the need for TileLayer hacks when using custom projections.
    • โž• Added non-square tiles support (by @IvanSanchez). #3573 #3570
    • โœ‚ Removed url property in tileload and tileloadstart events (get it through tile.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 and wrapLng properties which define whether the world wraps on a given axis and in what range. Set as [-180, 180] for EPSG:3857, EPSG:4326, EPSG:3395 by default.
    • โž• Added CRS and Map 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 for CRS.Simple.
    • โž• Added CRS getProjectedBounds and Map getPixelWorldBounds methods that returns world bounds in projected coordinates depending on zoom (derived from Projection bounds) (by @perliedman).
    • โž• Added CRS unproject method that converts coordinates in CRS-dependent units into LatLng 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 to viewreset 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 correspondingly GeoJSON) 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 require context 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 and getScaleString methods.
    • โœ‚ Removed DomUtil documentIsLtr method.
    • Removed LatLng RAD_TO_DEG, DEG_TO_RAD and MAX_MARGIN constants.
    • ๐Ÿ“‡ Renamed Util.limitExecByInterval to Util.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 old includes: 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 to TileLayer 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 native Function bind on modern browsers and prepend real arguments to bound ones.
    • โž• Added LatLng equals second argument maxMargin.
    • โž• Added DomUtil setClass and getClass methods.
    • ๐Ÿ‘Œ Improved Marker move event to include oldLatlng (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 and toBack methods.
    • โž• Added Evented listens as a shortcut to hasEventListeners.
    • โž• Added optional support for center-oriented scroll for L.map option touchZoom (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 and setMaxZoom methods (by @nathancahill). #3383 #3380
    • โž• Added originalEvent to Map and Marker drag and move event data (by @yohanboniface). #3264
    • โž• Added Popup autoClose option (by @jfirebaugh). #3018 #2716 #1853
    • โž• Added Control.Zoom enable and disable 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 (now false 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 or flyTo animation.
    • โž• Added Map maxBoundsViscosity option that controls how much the map resits dragging out of max bounds (set to 1 for a hard limit) (by @IvanSanchez). #2224 #3510 #1673
    • โž• Added Bounds and LatLngBounds 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 and popupclose events when manually creating a popup object and passing it to bindPopup. #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 returning this (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 a MultiPolygon 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 when maxNativeZoom = 0. #3004
    • ๐Ÿ›  Fixed FeatureGroup setStyle not affecting ImageOverlay 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 a Control.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 accept altitude 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 in Map options and then set center (by @AndriiHeonia). #2849 #1871
    • ๐Ÿ›  Fixed a race condition with TileLayer setUrl where loading 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 return NaN on equal locations. #2705
    • ๐Ÿ›  Fixed a bug where TileLayer maxNativeZoom didn't work properly with bounds 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