Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was debating with one of my collegues on OpenLayers v/s Leaflet. I made a point that OpenLayers is much better API if we wish to build a project, where you need direct connectivity to the Geoserver and PostGIS.

Then I found Open Data Kit, which looks pretty new but has the features of connectivity with the Geoserver and PostGIS.

So my project details are as follows,

  1. Use the map interface to fetch Feature Info
  2. Create a customized tool that takes the lat/lon from user as to where he/she clicks on the map and then fetches the Climate Data from the raster (which is handled by a py script on the server)
  3. Allows user to upload excel, which is sent to the py script, which returns a GeoJSON, which creates Vector Features on the map
  4. Allow user to create vector polygons, which will fetch the Features it intersects from the WFS Layer.
  5. Fetches Layer from the PostGIS Datastore on GeoServer and displays the layers on the map.

So now I am confused on which is better and why using OpenLayers over Leaflet makes more sense or not?

share|improve this question
Depends on the project. – CaptDragon Sep 20 '12 at 16:55
a. Improve your question by giving more details on the project. b. You are talking about direct connection to the database (postgis) for the users, are you sure? – Pablo Sep 20 '12 at 17:06
sorry about that, updated my project details – Sam007 Sep 20 '12 at 17:30
up vote 52 down vote accepted

I have used both OpenLayers and Leaflet in my apps. There has been so much discussion on this topic in this forum and others on planet-internet. They usually fall into 2 camps - features and flexibility of OpenLayers versus simplicity of Leaflet. I would not be surprised if someone spawns an "OpenLeaf" initiative soon marrying the best of both worlds!

I found Leaflet very simple to use, a petite 64K size, compared to over 700K Openlayers, and in very few steps you can create apps that have the freshness and eye-candy of today's web and mobile GIS apps. Your stack - GeoServer, PostGIS etc., is a standard stack, so OpenLayers or Leaflet could easily be incorporated.

Having said that, I would still go with OpenLayers for the following reasons

1) There is just a TON of material around OpenLayers. It is a lot more mature than Leaflet.

2) Check out the comparison on commits and users

3) OpenLayers, GeoServer, PostGIS stack is so proven in the FOSS world that you are going on a path that is solid.

4) OpenLayers has tad bit more features on Map Controls

5) While its a bit more work to create transitions and visual-effects, it can be done in OpenLayers.


share|improve this answer
Also what about mobile devices? Which is better suited? – Sam007 Oct 2 '12 at 15:35
Yes. I am currently building mobile apps using OpenLayers and SenchaTouch. There are plenty of mobile map apps running on Openlayers. Here are some examples – Ramesh Elaiyavalli Oct 2 '12 at 17:31
Thanks for the example will look into it – Sam007 Oct 3 '12 at 4:53

Leaflet all the way. I feel like Leaflet is the next step on the evolution of the open source tile based browser clients. Ka-Map -> OpenLayers -> Leaflet.

Leaflet is simple to use and does exactly what it says on the tin. OpenLayers has become bloated by trying to to be all things to all people, Leaflet does the 20% of things that are required 80% of the time.

share|improve this answer
So it's not just "Leaflet all the way", it's "Leaflet if you don't need any of all those features missing in it". I agree that Leaflet is much simpler to use, but if you need to do something not that common you have to go with OL. – Juan Aug 14 '15 at 17:44

I've just gone through this decision for my new mobile project and the clear winner is OpenLayers. Leaflet, as of this writing, was rather sluggish on mobile. The transitions for pan/zoom did not feel smooth and it was disorienting at times. Short of going native, I tried OpenLayers and the experience is much better. Still not as good as native, but definitely usable and a real option.

share|improve this answer
Interesting. I would have expected Leaflet to be lighter and smoother on a mobile device. Thanks for sharing this experience. – LarsH Sep 10 '14 at 23:29
@Christian Fritz - was your experience with OL3 or OL2? – sfletche Sep 11 '14 at 20:04
@sfletche the comparison was between OL3 and leaflet 0.7.3 – Christian Fritz Sep 11 '14 at 23:02

I'd say check the API documentation for both. For me it seems that OpenLayers offers an extensive bunch of features, however the development/debugging time is longer.

Leaflet is sexier and much more easy going rather than the OL, however if you want to do a lot with your map, I think someday you might need a feature which is not implemented in Leaflet yet!

I really recommend to take a look at APIs! OpenLayers & Leaflet

Also you might need to consider that current stable release for Leaflet is 0.5.1 but it's 2.12 for OpenLayers.

P.S. If I want to develop a mobile application, I think I might go for Leaflet.

share|improve this answer

This question had the second rank on Google when I searched for

OpenLayers versus Leaflet

so I thought I'd mention that there is a basic tutorial that compares the APIs of both OpenLayers 3 and Leaflet by having you build the same thing in both of them. It is written by Astun Technology and the tutorial tasks are:

  • Basic map with OSM tiles
  • OS-GB Map with Ordnance Survey tiles
  • GeoJSON layer with markers
    • Info for GeoJSON layer
  • WMS layer
    • Info for WMS layer

Here's the link:

share|improve this answer
scrolling by spacebar is broken btw – bugmenot123 Jul 20 '15 at 11:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.