Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Leaflet, WebGL & the Future of Web Mapping

Leaflet, WebGL & the Future of Web Mapping

Used by thousands of developers for online interactive maps, Leaflet may be the most popular FOSS4G library ever created. But with exciting new trends like WebGL and client-side vector maps, and new mapping libraries providing functionality similar to Leaflet, some people believe that its days are numbered.

But is Leaflet really going away anytime soon? Can it live in harmony with cutting-edge technologies? How will the web mapping landscape look in the near future? And what are the next big challenges? A talk by the creator and maintainer of Leaflet and core developer of Mapbox GL JS.

Vladimir Agafonkin

March 12, 2015
Tweet

More Decks by Vladimir Agafonkin

Other Decks in Technology

Transcript

  1. Leaflet, WebGL
    and the future of
    web mapping
    Vladimir Agafonkin
    11.03.15

    View Slide

  2. View Slide

  3. Vladimir Agafonkin

    View Slide

  4. by far the most used
    open source map library

    View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. creating a web map in 2008

    View Slide

  17. born against
    all odds

    View Slide

  18. no way you could do that

    View Slide

  19. You’re wasting time

    View Slide

  20. build an OPENLAYERS wrapper

    View Slide

  21. born as a protest
    against bloat, clutter
    and complexity

    View Slide

  22. top priorities:
    simplicity
    performance

    View Slide

  23. feature need
    complexity
    simplify

    View Slide

  24. 1.0

    View Slide

  25. View Slide

  26. View Slide

  27. View Slide

  28. 0.7
    1.0-dev
    WTF
    yay!

    View Slide

  29. View Slide

  30. Leaflet 1.0 trap,
    episode 1 of many:
    flyover animations

    View Slide

  31. View Slide

  32. arbitrary
    animation curve
    fractional zoom

    View Slide

  33. fractional zoom:
    map.setZoom(12.67)

    View Slide

  34. arbitrary
    animation curve
    multi-zoom pyramid
    tile loading

    View Slide

  35. View Slide

  36. fractional zoom
    rewrite half of
    Leaflet code

    View Slide

  37. code refactoring

    View Slide

  38. CSS transitions:
    very fast,
    impossible to control
    precisely, still buggy

    View Slide

  39. frame by frame
    animations:
    full control,
    much slower

    View Slide

  40. significantly degrade Leaflet
    performance,
    or introduce confusing
    limitations, fragility and
    complexity by having two
    animation systems?

    View Slide

  41. sometimes
    browsers
    break

    View Slide

  42. View Slide

  43. sorry guys

    View Slide

  44. oh and did I
    mention
    Android?

    View Slide

  45. tweaking leaflet animations

    View Slide

  46. my map broke
    in IE7!!!

    View Slide

  47. tough problems,
    hard choices,
    uncertainty,
    constant stream of
    issues and support
    requests,
    lots of work

    View Slide

  48. feeling anxiety
    and guilt
    and pressure

    View Slide

  49. View Slide

  50. open
    source
    burnout

    View Slide

  51. vlad adds a feature to leaflet

    View Slide

  52. it’s a trap!

    View Slide

  53. Vlad
    retreats
    to his
    happy
    place

    View Slide

  54. RBush

    View Slide

  55. • rbush
    • earcut
    • simpleheat
    • simplify-js
    • geojson-vt
    • pbf
    • geobuf
    • suncalc
    • dead-simple-grid
    • bullshit.js

    View Slide

  56. war in ukraine

    View Slide

  57. father of
    twin girls

    View Slide

  58. View Slide

  59. View Slide

  60. 0.7.3 — 1.0

    View Slide

  61. sharing the joy of
    successful refactoring

    View Slide

  62. animations
    & usability

    View Slide

  63. flyover animations

    View Slide

  64. much better
    tile loading
    (smoother, less flickering)

    View Slide

  65. much better
    panning inertia

    View Slide

  66. smoother zoom
    on iOS Safari

    View Slide

  67. popup fade out
    animation

    View Slide

  68. accessibility
    improvements

    View Slide

  69. vectors 2.0

    View Slide

  70. Use SVG & Canvas
    on the same map

    View Slide

  71. put vectors in
    custom panes

    View Slide

  72. huge SVG layers
    performance boost:
    adding ~3x faster,
    takes ~2.5 less memory

    View Slide

  73. huge Canvas layers
    performance boost:
    partial redraws,
    faster mouse events

    View Slide

  74. Canvas layers
    now retina-enabled

    View Slide

  75. solved all problems with
    MultiPolygon & MultiPolyline:
    no longer inherited from
    FeatureGroup

    View Slide

  76. Polyline & Polygon
    Centroids

    View Slide

  77. TileLayer

    View Slide

  78. TileLayer split into
    GridLayer & TileLayer

    View Slide

  79. GridLayer is the new
    TileLayer.Canvas

    View Slide

  80. Projections

    View Slide

  81. No hardcoded
    projection hacks,
    all centralized in CRS

    View Slide

  82. CRS defines everything:
    how tiles wrap,
    what are the bounds,
    distance measure, etc.

    View Slide

  83. Proj4Leaflet FTW

    View Slide

  84. Layers

    View Slide

  85. all layers now inherited
    from Layer class
    less code, more consistency,
    good for plugins

    View Slide

  86. Custom Pane
    Management

    View Slide

  87. ImageOverlay events

    View Slide

  88. other performance
    improvements

    View Slide

  89. much faster
    Layer construction
    (delegated DOM events and
    other optimizations)

    View Slide

  90. huge FeatureGroup
    performance boost
    due to better event
    propagation mechanism

    View Slide

  91. much better memory
    footprint for DOM &
    Leaflet events

    View Slide

  92. LatLng construction
    8x faster

    View Slide

  93. obj.off(event, listener)
    2x faster

    View Slide

  94. more stable:
    less freezes
    and race conditions

    View Slide

  95. …and many other
    bugfixes and
    improvements

    View Slide

  96. best of all?
    it got smaller!

    View Slide

  97. Uncompressed: 212.80 KB (-2910 bytes)
    Compressed: 120.17 KB (-2482 bytes)
    Gzipped: 32.79 KB (+18 bytes)
    master vs stable

    View Slide

  98. state of 1.0

    View Slide

  99. View Slide

  100. 1.0 beta

    View Slide

  101. VLAD TRIES TO FINISH 1.0

    View Slide

  102. Leaflet’s neat,
    but Vlad, wouldn’t it be
    awesome to have
    rotation? ^___^

    View Slide

  103. View Slide

  104. Mapbox GL

    View Slide

  105. View Slide

  106. View Slide

  107. View Slide

  108. View Slide

  109. View Slide

  110. View Slide

  111. drawing a line
    in WebGL

    View Slide

  112. View Slide

  113. View Slide

  114. View Slide

  115. drawing a line
    in WebGL
    is a hard problem

    View Slide

  116. drawing a polygon
    in WebGL

    View Slide

  117. github.com/mapbox/earcut

    View Slide

  118. drawing a polygon
    in WebGL
    is a very hard problem

    View Slide

  119. drawing text
    in WebGL

    View Slide

  120. View Slide

  121. View Slide

  122. placing labels
    in Mapbox GL

    View Slide

  123. View Slide

  124. View Slide

  125. View Slide

  126. holy
    f***ing
    sh*t

    View Slide

  127. displaying GeoJSON
    in Mapbox GL

    View Slide

  128. View Slide

  129. github.com/mapbox/geojson-vt

    View Slide

  130. vlad tries to borrow
    Mapbox GL feature for leaflet

    View Slide

  131. Vlad,
    how about adding a
    WebGL renderer to
    Leaflet? ^___^

    View Slide

  132. View Slide

  133. meant to be
    simple

    View Slide

  134. Leaflet will remain the
    go-to mapping library:
    dead simple,
    easy to use,
    works on all platforms, 

    tons of plugins,
    huge community,
    everyone knows it

    View Slide

  135. meant to be very complex,
    and push the boundaries
    of what’s possible
    Mapbox GL

    View Slide

  136. opposite sides
    of spectrum

    View Slide

  137. excited to be
    pushing both

    View Slide

  138. View Slide