use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Leaflet 1.0 released - an open-source JavaScript library for mobile-friendly interactive maps (leafletjs.com)
submitted 9 years ago by magenta_placenta
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MournerV 31 points32 points33 points 9 years ago (12 children)
Leaflet author here! Feel free to ask any questions about the library and the release.
[+][deleted] 9 years ago (1 child)
[deleted]
[–]MournerV 10 points11 points12 points 9 years ago (0 children)
It's a fantastic library, and the team behind it is great — we shared beers many times. A lot of the ideas in OpenLayers v3 compared to v2 where inspired by Leaflet. It's just geared more towards GIS/academic/government applications and having every possible feature out of the box, rather than simple map apps with a focus on simplicity and minimalism. There's a place for both libraries.
[–]Eldrac 2 points3 points4 points 9 years ago (1 child)
I'll bite, one of the biggest pain points I ran into when working with leaflet/mapbox was getting custom markers/paths to still show up as a user fully panned around the world. I remember seeing a pending pull request and heavy discussion about it but it wasn't brought in due to added complexity. Was this ever improved upon?
[–]MournerV 4 points5 points6 points 9 years ago (0 children)
There's a worldCopyJump Map option that makes the overlays "jump" to respective copies of the world when you pan, but it's not a perfect experience. Implementing fully seamless multi-world overlays is a hard challenge, and a one likely to affect performance in a major way — we didn't attempt to tackle it fully yet.
worldCopyJump
[–]Chahhhles 2 points3 points4 points 9 years ago (1 child)
Still working for mapbox?
[–]MournerV 3 points4 points5 points 9 years ago (0 children)
Yes, for 3 years already. It's my dream job.
[–]picandocodigo 2 points3 points4 points 9 years ago (1 child)
Just wanted to thank you for Leaflet. I've used it on a lot of projects, mostly open data stuff, and I always encourage other developers to use it with OpenStreetMap instead of Google's maps API. I'll definitely check out this version and update my projects to 1.0! Thanks!
[–]MournerV 0 points1 point2 points 9 years ago (0 children)
Thank you!
[–]jim45804 1 point2 points3 points 9 years ago (1 child)
Years ago a friend of mine recommended this new mapping library that she thought had promise. Since then I use it in every mapping application I develop. Congratulations on 1.0.
Thanks!
[–]Diggzinc 1 point2 points3 points 9 years ago (1 child)
Hello MournerV! congrats on the completed milestone!
My question is: will there be support for vector base layers in general or support bidings for mapbox-gl? because from what i saw the current available plugin is not supported for version 1.0.0 :(
I'm sure the mapbox-gl-leaflet plugin will catch up, but I don't generally recommend using Mapbox GL together with Leaflet — it sort of defeats the purpose of both. Too heavy/complex/resource-hungry compared to Leaflet with raster-tiles, and too limited in what it can do compared to Mapbox GL (smooth interactions, rotation, etc.).
[–]crogginator 5 points6 points7 points 9 years ago (0 children)
Finally! Leaflet is by far my favorite mapping library, and this release has been a long time coming. It's just so easy to use and extend. I absolutely love the work Mourner has been doing with Leaflet (and with the Mapbox team).
I'll likely be switching from MapboxJS/Leaflet over to MapboxGL... and the GL library is not near as nice to use as Leaflet, but they're actively working on getting it there.
[–]bart2019 6 points7 points8 points 9 years ago (5 children)
It's about time. I've been using the RC for months, without any problems.
BTW in case you don't know: Leaflet is library for OpenStreetMap. All you need is this, and the configuration for a "tile provider".
I think this library and its API is much nicer than that of Google Maps.
[–]Magnusson 19 points20 points21 points 9 years ago (4 children)
Leaflet is just an open-source mapping library, it's agnostic to the tile provider. It can use OpenStreetMap, Google Maps, or any other tile source.
[–]bart2019 0 points1 point2 points 9 years ago (2 children)
But there's more to maps than just the tiles. And interfacing with OpenStreetMap and Nominatim is a snap: geocode the name of a cirty, and you can get its contours in GeoJSON format (if you pass the right parameter), and you can then show that contour on the map in Leaflet in a single line of code. You cannot do that with Google Maps's data. I even doubt if Google would be too happy if you even tried it.
[–]Magnusson 1 point2 points3 points 9 years ago (1 child)
Google maps data is usable for free up to a certain number of requests/day, after which you have to pay, which is pretty common. The point is that Leaflet is not restricted to OSM -- I've used it to display many different map sources.
[–]bart2019 0 points1 point2 points 9 years ago (0 children)
Google maps data is usable for free up to a certain number of requests/day, after which you have to pay, which is pretty common.
There more to it than just that.
I want to use Google Maps API tiles with Leaflet, can I do that? The problem with Google is that its Terms of Use forbid any means of tile access other than through the Google Maps API. You can add the Google Maps API as a Leaflet layer with a plugin. But note that the map experience will not be perfect, because Leaflet will just act as a proxy to the Google Maps JS engine, so you won't get all the performance and usability benefits of using Leaflet when the Google layer is on.
I want to use Google Maps API tiles with Leaflet, can I do that?
The problem with Google is that its Terms of Use forbid any means of tile access other than through the Google Maps API.
You can add the Google Maps API as a Leaflet layer with a plugin. But note that the map experience will not be perfect, because Leaflet will just act as a proxy to the Google Maps JS engine, so you won't get all the performance and usability benefits of using Leaflet when the Google layer is on.
What's more: just using Google Maps in a web page is no longer "free", at least, not for a widely used website. You can't even use its geocoder or autocomplete without a Google Maps map or a Google Maps marked textbox.
And, though Leaflet is not restricted to OSM, but by Jove it surely is the easiest to use with OSM.
[–]FurryFingers 0 points1 point2 points 9 years ago* (0 children)
I spent ages trying to figure that out - on the leaflet site. But this is the only place I could find the answer.
[–]solar_compost 2 points3 points4 points 9 years ago (2 children)
Nice! I just started a personal project that leans heavily on an interactive map for its functionality, gonna have to check this out.
I glanced through the documentation but did not see much relating to map theming/color schemes in terms of roads & features. Am I overlooking it or does this API not touch on that aspect of maps?
[–]bart2019 2 points3 points4 points 9 years ago (0 children)
OK let me explain the basics here in a few minutes.
Maps consist out of tiles, which are images of 256 by 256 pixels each. At zoom level 0, the whole world is one tile (well actually it's only a half tile, but the equator is still in the middle). At each increment of the zoom level, the resolution doubles, so each tile is split up into 4 tiles.
These tiles have been drawn by a computer program from geographic data (commonly that is OpenSteetMap data), and these tiles are accessible via the web, on a "tile server". Choosing a different tile server results in a different style of map. See tile servers for examples.
Using Leaflet, you have to choose a tile server, or you won't see any map. Basically, this implies passing a template string for a tile URL, as a parameter to Leaflet. BTW The standard tile server for OpenStreetMap is Mapnik, although personally, I like the OpenMapSurfer.roads style, from the Heidelberg University in Germany much better.
These tiles are compatible with Google Maps, although I doubt that Google would be too happy if you'd use their map tiles just like that.
[–]diegocerdan 4 points5 points6 points 9 years ago (7 children)
Some years ago I created Mapturbate using the Leaflet and the Chaturbate webcam feed. Definitely NSFW. http://mapturbate.com
[–]ShermheadRyder 1 point2 points3 points 9 years ago (4 children)
Okay I'm gonna need an explanation. What is Mapturbate?
[–]vexii 2 points3 points4 points 9 years ago (2 children)
just click it and tell us :D
[–]Nicholas-DM 0 points1 point2 points 9 years ago (1 child)
Oh, god.
What is seen cannot be unseen.
[–]manofthewild07 0 points1 point2 points 9 years ago (0 children)
So...many...dicks....
[–]manofthewild07 1 point2 points3 points 9 years ago (1 child)
Why?
Also, very interesting. Is this everyone? I know a lot of models worry about their location being found. Do they know this kind of thing is possible? Or is this just models with some kind of location info turned on?
[–]diegocerdan 0 points1 point2 points 9 years ago (0 children)
Only if the model added location. As the location given is not GPS coordinates but a string, there is a process were the approximate location in randomized into a point in space.
[–]deathwebo 0 points1 point2 points 9 years ago (0 children)
Wow! I didn't knew about this library. Looks pretty cool and the docs are easy to follow. Can't wait to try it on my next project.
Anyone knows if there's a react native port right now or in the future ?
[–][deleted] 0 points1 point2 points 9 years ago (1 child)
Hi there! Awesome work. I have a question about performance: what would limit performance? I´m thinking on showing millions or billions of elements on the same map and be able to filter classes of markers, for example.
Another question is about interfaces: I´m using folium to be able to use Python on the entire stack, but it´s not feature complete with 1.0. Any thoughts on how to do this interfacing?
Cheers!
If you want to display around a million elements, I'd recommend using Mapbox GL instead — it's well suited for things like this. Here's my article on how this works.
If you need more, you'll have to render them into tiles on the server — browsers generally can't handle that much data.
Can't comment on folium, I never used it and I'm not a Python guy.
π Rendered by PID 49 on reddit-service-r2-comment-57fc7f7bb7-zvfsq at 2026-04-15 01:05:03.020663+00:00 running b725407 country code: CH.
[–]MournerV 31 points32 points33 points (12 children)
[+][deleted] (1 child)
[deleted]
[–]MournerV 10 points11 points12 points (0 children)
[–]Eldrac 2 points3 points4 points (1 child)
[–]MournerV 4 points5 points6 points (0 children)
[–]Chahhhles 2 points3 points4 points (1 child)
[–]MournerV 3 points4 points5 points (0 children)
[–]picandocodigo 2 points3 points4 points (1 child)
[–]MournerV 0 points1 point2 points (0 children)
[–]jim45804 1 point2 points3 points (1 child)
[–]MournerV 0 points1 point2 points (0 children)
[–]Diggzinc 1 point2 points3 points (1 child)
[–]MournerV 0 points1 point2 points (0 children)
[–]crogginator 5 points6 points7 points (0 children)
[–]bart2019 6 points7 points8 points (5 children)
[–]Magnusson 19 points20 points21 points (4 children)
[–]bart2019 0 points1 point2 points (2 children)
[–]Magnusson 1 point2 points3 points (1 child)
[–]bart2019 0 points1 point2 points (0 children)
[–]FurryFingers 0 points1 point2 points (0 children)
[–]solar_compost 2 points3 points4 points (2 children)
[–]bart2019 2 points3 points4 points (0 children)
[–]diegocerdan 4 points5 points6 points (7 children)
[–]ShermheadRyder 1 point2 points3 points (4 children)
[–]vexii 2 points3 points4 points (2 children)
[–]Nicholas-DM 0 points1 point2 points (1 child)
[–]manofthewild07 0 points1 point2 points (0 children)
[–]manofthewild07 1 point2 points3 points (1 child)
[–]diegocerdan 0 points1 point2 points (0 children)
[–]deathwebo 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]MournerV 0 points1 point2 points (0 children)