UNPKG

7.79 kBMarkdownView Raw
1# Leaflet FAQ
2
3This is a collection of answers to the most frequently asked questions about Leaflet.
4
5 1. [Data Providers](#data-providers)
6 2. [Commercial Use and Licensing](#commercial-use-and-licensing)
7 3. [Features](#features)
8 4. [Performance](#performance)
9 5. [Misc](#misc)
10
11## Data Providers
12
13#### The map is wrong in my neighborhood, could you fix it?
14
15Nope, but you can.
16The map you see on Leaflet examples is based on [OpenStreetMap](http://openstreetmap.org),
17a free editable map of the world.
18Signing up and editing the map there is easy,
19and the changes will be reflected on the map in a few minutes.
20
21#### What map tiles can I use with Leaflet? Is it limited to OpenStreetMap?
22
23Leaflet is provider-agnostic, meaning you can use any map provider as long as you conform to its terms of use.
24You can roll your own tiles as well.
25[OpenStreetMap](http://openstreetmap.org) is the most popular data source among different tile providers,
26but there are providers that use other sources.
27
28Check out [this example](http://leaflet-extras.github.io/leaflet-providers/preview/)
29with over seventy different layers to choose from.
30Popular commercial options, free up to a particular number of requests, include
31[MapBox](http://mapbox.com),
32[Bing Maps](http://www.microsoft.com/maps/choose-your-bing-maps-API.aspx) (using a [plugin](https://github.com/shramov/leaflet-plugins)),
33[Esri ArcGIS](http://www.esri.com/software/arcgis/arcgisonline/maps/maps-and-map-layers) ([official plugin](https://github.com/Esri/esri-leaflet)),
34[MapQuest](https://developer.mapquest.com/products) ([official plugins](https://developer.mapquest.com/documentation/leaflet-plugins))
35and [Nokia Here](http://developer.here.com/web-experiences).
36
37Always be sure to **read the terms of use** of a chosen tile provider, **know its limitations**, and **attribute it properly** in your app.
38
39#### I'm looking for satellite imagery to use with my Leaflet map, any options?
40
41[MapBox](http://mapbox.com),
42[Bing Maps](http://www.microsoft.com/maps/choose-your-bing-maps-API.aspx),
43[ArcGIS](http://www.esri.com/software/arcgis/arcgisonline/maps/maps-and-map-layers)
44and [MapQuest Open](http://developer.mapquest.com/web/products/open/map) provide satellite imagery among others.
45
46#### I want to use Google Maps API tiles with Leaflet, can I do that?
47
48The problem with Google is that its [Terms of Use](https://developers.google.com/maps/terms) forbid any means of tile access other than through the Google Maps API.
49
50You can add the Google Maps API as a Leaflet layer with a [plugin](https://github.com/shramov/leaflet-plugins). 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.
51
52#### I want to roll my own OSM tile server for Leaflet, where do I start?
53
54Check out [this excellent guide](http://switch2osm.org/serving-tiles/).
55
56#### I want to create tiles from my own data for use with Leaflet, what are the options?
57
58There's a number of services that allow you to do this easily,
59notably [MapBox](https://www.mapbox.com/), [CartoDB](http://cartodb.com/) and [GIS Cloud](http://www.giscloud.com/).
60If you want to make tiles on your own, probably the easiest way is using [TileMill](https://www.mapbox.com/tilemill/).
61TileMill can export your map as a single [.mbtiles](https://www.mapbox.com/developers/mbtiles/) file, which can be copied to a webserver and accessed by Leaflet with [a small PHP script](https://github.com/infostreams/mbtiles-php).
62Alternatively, you can [extract](https://github.com/mapbox/mbutil) the tiled images from the .mbtiles database and place them directly on your webserver with absolutely no server-side dependencies.
63
64## Commercial Use and Licensing
65
66#### I have an app that gets lots of hits a day, and I want to switch from Google/Bing/whatever to Leaflet. Is there a fee for using it?
67
68Leaflet, unlike Google Maps and other all-in-one solutions, is just a JavaScript library.
69It's free to use, but doesn't provide map imagery on its own —
70you have to choose a tile service to combine with it.
71
72There are [plenty of options](#what-map-tiles-can-i-use-with-leaflet-is-it-limited-to-openstreetmap) for a tile service,
73each with their own terms of use, prices (some of them free), features, limitations, etc.
74Choice is yours.
75
76#### I'm building a commercial app that I plan to sell. Can I use Leaflet in it?
77
78You're welcome, as the code is published under the very permissive [2-clause BSD License](https://github.com/Leaflet/Leaflet/blob/master/LICENSE).
79Just make sure to attribute the use of the library somewhere in the app UI or the distribution
80(e.g. keep the Leaflet link on the map, or mention the use on the About page or a Readme file, etc.) and you'll be fine.
81
82That only applies to the code though.
83Make sure you conform to the terms of use of the tile images provider(s) that you choose as well.
84
85
86## Features
87
88#### What's the best way to put the data I have on a Leaflet map?
89
90Check out [this awesome cheatsheet](https://github.com/tmcw/mapmakers-cheatsheet).
91
92#### Why is there still no feature X in Leaflet?
93
94First of all, did you check out the [Leaflet plugins page](http://leafletjs.com/plugins.html)?
95It lists about a hundred plugins doing all kinds of crazy stuff,
96and there's a high possibility that it has what you're looking for.
97
98Generally, we do our best to keep the Leaflet core small, lightweight and simple,
99focusing on _quality_ instead of _quantity_, and leaving all the rest to plugin authors.
100
101Check out [this video](http://www.youtube.com/watch?v=_P2SaCPbJ4w) of a talk by the Leaflet creator for more background on the story and philosophy behind Leaflet.
102Another essential read is [Advocating Simplicity in Open Source](http://blog.universalmind.com/advocating-simplicity-in-open-source/) by the same guy.
103
104
105## Performance
106
107#### I have thousands of markers on my map. How do I make it faster and more usable?
108
109Check out the [Leaflet.markercluster](https://github.com/Leaflet/Leaflet.markercluster) plugin. It's amazing.
110
111#### I have vector data with many thousands of points on my map. Any performance tips?
112
113Leaflet generally does a pretty good job of handling heavy vector data
114with its real-time clipping and simplification algorithms,
115but browser technology still has its limits.
116Try [switching from SVG to Canvas as the default rendering back-end](http://leafletjs.com/reference.html#global),
117it may help considerably (depends on the app and the data).
118
119If you still have too much data to render, you'll have to use some help of a server-side service
120like [MapBox](https://www.mapbox.com/),
121[CartoDB](http://cartodb.com/)
122and [GIS Cloud](http://www.giscloud.com/)
123(they all work great with Leaflet).
124What they do under the hood is serving rendered data as image tiles,
125along with additional data to enable interactivity like hovering shapes
126(e.g. done using [UTFGrid](https://www.mapbox.com/developers/utfgrid/) —
127Leaflet [has a nice plugin](https://github.com/danzel/Leaflet.utfgrid) for it).
128
129
130## Misc
131
132#### I downloaded the Leaflet source but didn't find `leaflet.js` there. Why is that?
133
134You can download the built versions using links from the [download page](http://leafletjs.com/download.html).
135It even includes the latest build of the development version (`master` branch),
136updated automatically on each commit to the repo.
137
138We removed the built versions from the repository because it's a chore to build and commit them manually on each change,
139and it often complicates merging branches and managing contributions.
140
141There's a common complaint that Leaflet can't be used with [Bower](http://bower.io/) because of that, but we'll resolve the issue soon.