Questions tagged [leaflet]

Leaflet is an open-source JavaScript library for mobile-friendly, cross-browser, interactive maps. For the R leaflet package, please use the r-leaflet tag.

Leaflet is an open-source JavaScript library for displaying interactive maps. It can be extended with the use of plugins and has an extensive well-documented API.

Leaflet is designed with simplicity, performance and usability in mind. It works efficiently across all major desktop and mobile platforms out of the box, taking advantage of HTML5 and CSS 3 on modern browsers while still being accessible on older ones. It can be extended with many plugins, has a beautiful, easy to use and well-documented API and a simple, readable source code that is a joy to contribute to.


Browser Support

On Desktop

  • Chrome
  • Firefox
  • Safari 5+
  • Opera 12+
  • Internet Explorer 7–11

On Mobile

There are now two packages for using Leaflet from within the R language for data analysis and visualization. You can also use Leaflet from within R using the Leaflet package at Leaflet for R. Additionally, you can read the documentation on another package r-leaflet at http://cran.r-project.org/web/packages/leafletR/leafletR.pdf.


Online resources

13879 questions
22
votes
2 answers

Leaflet : Firing an event when bounds change

I am using leaflet to develop a new application. You can have an idea of the app here. I would like to fire an event whenever the bounds of the map change. I looked at the doc but couldn't find anything related to that. I have found the getBounds()…
jlengrand
  • 12,152
  • 14
  • 57
  • 87
22
votes
4 answers

Multiple markers on the exact same position on a Leaflet map

We use leafletJS to show maps with round about 100 markers. Some of these markers are located on exact the same position. Marker2 is above Marker1 so Marker1 isn't visible. Is there a way to rotate Markers in a way that you can see there are more…
Thomas1703
  • 1,152
  • 5
  • 16
  • 33
22
votes
2 answers

is there a way to resize marker icons depending on zoom level in leaflet?

I'm making a project for the school and I need to resize the marker icons depending on zoom level in a leaflet map, Is there an easy way to accomplish this? Any tutorial on the web? Thanks in advance for the help!!!
user2533531
22
votes
4 answers

geojson circles, supported or not?

When I look up the specs of GeoJson I see that circles are supported: http://geopriv.dreamhosters.com/geojson/geojson-spec.html#circleExample When I try out the code in geojsonlint (http://geojsonlint.com/) however, it gives me an error. Input: {…
cantdutchthis
  • 31,949
  • 17
  • 74
  • 114
22
votes
1 answer

How can I change the default loading tile color in LeafletJS?

By default, when leafletJS is loading a map, the background tiles are all grey. I'd like to change that color to be black (or any other arbitrary color). How can I go about doing this?
thisissami
  • 15,445
  • 16
  • 47
  • 74
22
votes
5 answers

How to use Google Maps API in leaflet-cloudmade

Is there any way to integrate Google Maps with leaflet-cloudmade? I mean, I don't want to use the original cloudmade map, but I want to use Google Maps instead. I want to show a map of Alaska (not many roads there). If I use a cloudmade map, it…
goFrendiAsgard
  • 4,016
  • 8
  • 38
  • 64
21
votes
7 answers

Why is my `client-only` component in nuxt complaining that `window is not defined`?

I have Vue SPA that I'm trying to migrate to nuxt. I am using vue2leaflet in a component that I enclosed in tags but still getting an error from nuxt saying that window is not defined. I know I could use nuxt-leaflet or create a plugin…
yam
  • 1,383
  • 3
  • 15
  • 34
21
votes
3 answers

How do you call fitBounds() when using leaflet-react?

I cannot figure out how to call fitBounds() on the Leaflet map. If I was just using vanilla leaflet, this solution would work perfectly: Zoom to fit all markers in Mapbox or Leaflet Unfortunately, I am using react-leaflet. Here is the solution if I…
Dox
  • 571
  • 1
  • 5
  • 15
21
votes
1 answer

R leaflet zoomControl option

I'm building a map tool in R using leaflet, and I would like to restrict the zoom to a certain area, but the setMaxBounds function doesn't seem to have any effect. library(dplyr) library(leaflet) library(tigris) ohio_map <- leaflet(counties('OH',…
Brian Stamper
  • 2,143
  • 1
  • 18
  • 41
21
votes
4 answers

Data-toggle tab does not download Leaflet map

I am using tabs to display clear content, but one of them stopped downloading well since it is in the data-toggle tab. It is a Leaflet map. Here is the code : Navbar code :
21
votes
1 answer

Achieving animated zoom with d3 and Leaflet

Using d3 to plot SVG artefacts on top of a Leaflet map is a simple way to get a solid map controller combined with the strength of d3. There are numerous examples and guides as how to achieve this and the two main approaches seem to be: Appending a…
averas
  • 545
  • 1
  • 6
  • 15
21
votes
3 answers

Leaflet: Update GeoJson filter?

I would like to populate a GeoJson layer with data and then dynamically filter what features to show. I have gotten the filter function to work but I do not know how to change the filter and then refresh the layer. Is there any way I can update the…
dani
  • 4,880
  • 8
  • 55
  • 95
21
votes
5 answers

Layer Ordering in leaflet.js

How can I force a new layer added to the map in Leaflet to be the first over the basemap? I could not find a method to easily change the order of the layers, which is a very basic GIS feature. Am I missing something?
user1249791
  • 1,241
  • 4
  • 14
  • 33
21
votes
3 answers

how to add text for display on map to a geojson object in leaflet

So I have a geojson layer in leaflet, and I can add geojson objects to this layer for display on the resulting map. Now I'd like to add a text label to display near the object. This example shows use of a custom L.control() object to display…
monkut
  • 42,176
  • 24
  • 124
  • 155
21
votes
2 answers

Definition of a Leaflet layer

What exactly does a layer represent in the Leaflet Mapping Library? Conceptually, to me a layer would represent a single tier of some type of feature or object; for example all image tiles representing the base level map would be represented on a…
oli
  • 3,541
  • 1
  • 27
  • 34