Hacker News new | past | comments | ask | show | jobs | submit login
Leaflet – A JavaScript library for mobile-friendly interactive maps (leafletjs.com)
216 points by simon04 on Jan 15, 2018 | hide | past | favorite | 36 comments



Great news, Leaflet is the standard for open source web maps. This release looks to have a lot of nice quality of life improvements.

I've been a little worried about Leaflet's future vs. Mapbox GL JS. That's also an excellent open source map library, but is based entirely on new technology (vector maps and GL) and favors using Mapbox's paid services. I think Leaflet has a long life ahead for folks who want something simpler, something that can easily composite raster data from many sources.


I switched a project over from Leaflet to Mapbox GL JS for the better-integrated vector tile support and better mobile rendering performance. Raster tiles still have value, but I wouldn't call vector tiles "new"; they're mature enough that they should start phasing raster tiles out, especially for projects that need a wide range of zoom levels, tight bandwidth requirements, or a lot of flexible, overlapping, and/or dynamic layers.

Thanks to tools like Maputnik, tippecanoe, and TileServer GL, I also had no problems using Mapbox GL and vector tiles without once touching a Mapbox service.

I still use Leaflet for most raster and simple vector maps simply because it is light and modular enough that I can get what I want, but the open source tools are there to reap the good stuff from Mapbox GL while avoiding the proprietary bits of Mapbox.


I'd love to see a writeup of using Mapbox GL without Mapbox services. I know it's possible in theory but it seems fairly awkward. Particularly interested if there are any map services you can easily use, free or paid, rather than standing up a vector tile server of your own.


Not awkward at all: https://openmaptiles.org/


I would actually not be worried at all. As you have mentioned, Leaflet is ideal for people who look for something simple which they can further expand. Mapbox is more for people ready to pay for a robust set of APIs and SDKs which can be nicely combined together. From my experience, I think both of them are doing an excellent job.


Mapbox is built on top of Leaflet [1], so I don't think its success would be a bad thing for Leaflet itself.

[1] https://blog.mapbox.com/mapbox-%EF%B8%8F-leaflet-d60b1be9661...


MapboxJS was, but MapboxGLJS is new tech.

It was however also made by the creator of Leaflet, who works for Mapbox.


Someone made a nice wrapper for react I've been using with good success.

https://github.com/PaulLeCam/react-leaflet


Didn't have a good experience with this kind of React wrappers, I used a Leaflet wrapper for a few years.

They always lack behind and try to force the React lifecycle and composition onto the library. Often this leads to leaking abstractions, which get uglier and uglier with time. Updating is also not a charm.

I stopped using them and simply build one component as facade, then use props as interfaces to the lib while letting the lib do its thing the way it wants behind that component.


Not to discount your experience, which is pretty consistent with my own, but what you've just described is writing your own wrapper component.

I think there's something to be said for doing it yourself, particularly when the available options make you have to care about their internals anyway. But perhaps some of that effort might be put towards making a better open-source wrapper.


I've worked a little bit with libraries like this (react-mapbox-gl) and I think the point GP is making is more like this:

    <3P.Wrapper>
      <3P.Foo>
        <3P.Bar
          subcomponent={props}
        />
      </3P.Foo>
      { someCondition ?
        <3P.Quux
          onCrunch={doQuack}{
        />
      }
    </3P.Wrapper>
where mounting and unmounting those child components interacts with the wrapped API. Contrast that with

    <3P.BasicWrapper
      useFoo
      useBar
      useQuux={someCondition}
      onQuuxCrunch={doQuack}
    />
which is less suitable for generic use, but easy enough to write (and modify later) that you probably don't need a highly-generic wrapper.


There is a difference between creating one component as entry to the lib and using React for the whole state management.


I've had the same experience. Especially if you get into using more and more niche packages (plugins for Leaflet), it can get ugly pretty fast.


And if you need many customizations


Folium is a nice python wrapper for Leaflet: https://github.com/python-visualization/folium


Folium is amazing. It makes it relatively easy to make a map like this one: http://fernandoi.cl/mapascomunales/primarias/primarias.html


Do you have any supplementary materials, such as a tutorial or git repo to go along with it? I've been using the d3.geo cli for something similar.


I do not have any specific recommendations, aside from this guide to start: https://blog.dominodatalab.com/creating-interactive-crime-ma...


I was curious why Leaflet, which has been around a while, popped up today. Looks like it's because 1.3.0 is out, but as far as I can tell it's a bugfix release. The most exciting new feature (to me, at least) is iterating over layers in a LayerGroup with eachLayer, which is neat but hardly groundbreaking.

Am I missing something? I love Leaflet, but I thought it was already one of the standards for maps on the web.


One of the most efficient, snappy, and lightweight frameworks for 2D maps with overlays and simple vector drawing capabilities. Clear and simple API. Keep doing great job!


Really great library, I had to use Bing Maps v8 API and it was not the best mapping library, the documentation is not very impressive, and it's just not as feature heavy as I'd hoped and the features get confusing really quickly.

We wound up using Leaflet to handle everything else but the imagery is all from Bing Maps instead. I've run into edge cases I've had to figure out with Leaflet, but at least the JS ecosystem is big enough to where you can always find generic solutions that work with the existing mapping library.


Is http://openlayers.org/ the jQuery of web mapping now ?


leaflet and open layers have different use-cases.

This is a massive oversimplification, but roughly, one way of thinking of it is that leaflet is more suited to consumer-facing web maps and openlayers is more appropriate for heavy gis workloads; e.g. a web app for visualising business locations worldwide vs a web app for manipulating SHP data and EPSG projections.

That's not to say Leaflet can't be used for the latter -- e.g. in combination with some other tools like turf -- but OL is being developed with this kind of stuff on mind.


openlayers has more functionality built-in. in leaflet, things like editing geo-features are in plugins.


OpenLayers vs. Leaflet is a bit like Rails vs. Sinatra: one is a lot bigger and heavier, but you'll probably end up reimplementing 1/4 to 3/4 of its features if you go with the other.

Plenty of cases where either choice is the right one, IMO.


I use Leaflet for 90% of my mapping projects. But once in a while a complex requirement comes along and only OpenLayers has the power to solve it. Rotating a map was a recent one.


We recently launched a project that relies heavily on leaflet for generating custom, interactive maps from CMS data and once we got the hang of it it was such a breeze to work with. Really enjoyed it and got the wheels spinning on other pet projects that could utilize it.


Fun fact: LibreOffice Online uses Leaflet for tile rendering.


It made me think of that as well. I saw a demo on a local open source event (T-DOSE in Eindhoven, Netherlands) a few years ago and thought it was a horrible mistake. I still can't believe why they thought this was a good idea, other than a good tech demo (like playing Doom on an oscilloscope or something -- abusing something completely but it technically works).


It's also used in GTA video game for the map browsing.


Can you share more information on that?


When I was still in school I used Leaflet for a product and I remember being really impressed by it then. This must have been around 2013. I scripted huge AutoCAD exports with AutoLISP and sliced them up with ImageMagick to make custom zoomable maps of schools and hospitals. They would be annotated with BIM data and used for utility inspections. I'm glad to see it's still alive and kicking!


Leaflet has been a pleasure to work with. I recently used it to build animated wildfire maps, such as this one of the Thomas Fire in California. https://firetracker.scpr.org/thomas-fire-santa-barbara-2017


One more vote for Leaflet. Just started using it for one of my side projects (my long term get rich plan) and it’s super easy to create custom maps exactly how you want them. There are also many plugins allowing you to further enhance the functionality. Now, if only I could find some extra spare time to work on it...


great library. been using it in some GIS projects I am involved in. glad to see development continues.


I love Leaflet. We are currently using it for some applications at my work. It's super simple and easy to extend




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: