Questions tagged [leaflet]

An Open-Source JavaScript Library for Mobile-Friendly Interactive Maps

Filter by
Sorted by
Tagged with
113 votes
8 answers
90k views

Choosing OpenLayers or Leaflet? [closed]

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 ...
user avatar
  • 4,275
68 votes
7 answers
149k views

Loading external GeoJSON file into Leaflet map?

I would like to load a geoJSON (polygon) file into my leaflet map. I have seen examples where geoJSON is embedded into the javascript code but I can't find any examples showing how it is done with an ...
user avatar
  • 1,201
60 votes
7 answers
13k views

Creating Vector Polygons with rendering performance like GISCloud?

I have been looking for a solid solution which would allow me to create a web map and overlay vector polygons without taking forever to load such data with the goal of allowing me to make each polygon ...
user avatar
49 votes
14 answers
43k views

Converting ArcGIS Server JSON to GeoJSON?

I'm creating a web map using Leaflet, and I want to be able to grab feature layers from our ArcServer. I have successfully been able to retrieve a feature class as JSON, but Esri's JSON objects don't ...
user avatar
  • 7,215
48 votes
5 answers
148k views

Showing popup on mouse-over, not on click using Leaflet?

Is it possible in Leaflet that popup opens on mouse-over, not on click? This is working for just one marker at a time, but I need it for a bigger number of markers: marker.on('mouseover', function(e)...
user avatar
  • 4,944
42 votes
6 answers
34k views

Visualizing large datasets with Leaflet

When using Leaflet to visualize a large dataset (GeoJSON with 10,000 point features), not surprisingly the browser crashes or hangs. A sub-sample of 1000 features from the same dataset works ...
user avatar
  • 521
34 votes
1 answer
36k views

What is the default projection in Leaflet?

I've read an API documentation for Leaflet on its site, but I can't realize: what is a default projection to view maps? It was written about spherical and elliptical Mercator and Equirectangular - so ...
user avatar
  • 441
32 votes
4 answers
55k views

Disable panning/dragging on leaflet map for div within map

Does anyone know how to suppress panning when you click and drag over top of a div box embedded within the map itself? For example here, when you click and drag over top of the legend, the map ...
user avatar
32 votes
3 answers
49k views

Adding/Removing GeoJSON layers using Leaflet

I am trying to show different GeoJSON layers at different zoom layers using the Leaflet API. I can load and display all three layers at once (though I do not actually want them all to show at once). ...
user avatar
  • 1,132
32 votes
0 answers
3k views

Leaflet v1 plugin: layer control for ungrouped, grouped, and nested-grouped layers

I need a Leaflet plugin which extends L.Control.Layers. I have the following requirements: works with Leaflet 1.x handles ungrouped layers alongside grouped ones handles nested layer groups does not ...
user avatar
  • 5,562
31 votes
4 answers
32k views

Disable leaflet interaction temporary

How can I temporary disable zoming/draging the Mapview in Leaflet.js Tried so many ways but without any luck. It's important to make it temporary and I also need the option to enable again.
user avatar
  • 493
30 votes
3 answers
79k views

setStyle() function for GeoJSON features - Leaflet

Ok, since I already asked a very long question about this, but since it didn't get any new replies for a while, and not to get confused in details, I will keep this one simple the best way I can. If ...
user avatar
29 votes
4 answers
95k views

How to add text-only labels on Leaflet map with no icon

I'm looking for a way to show text on Leaflet map using markers or anything else without showing any icon. I want to show text only and be able to style and rotate it... Any suggestion?
user avatar
28 votes
5 answers
101k views

Drawing polyline in Leaflet?

This is my coding I used in Leaflet: var pointA = new L.LatLng(28.635308, 77.22496); var pointB = new L.LatLng(28.984461, 77.70641); var pointList = [pointA, pointB]; var ...
user avatar
  • 4,944
27 votes
6 answers
24k views

GeoJSON too bulky - what to do?

I am using leaflet.js to allow web users to select a region. Valid regions are US states, Canadian providences, and world countries (except for US and Canada). I constructed a shapefile myself using ...
user avatar
27 votes
3 answers
39k views

Click Events with Leaflet and geoJSON

How do I attach a click event to a geoJSON that then executes an Ajax function when clicked. I looked into onEachFeature but that executes when the geoJSON is loaded, not when clicked, thus executing ...
user avatar
25 votes
4 answers
38k views

Leaflet mouse wheel zoom only after click on map

I'm working with the Leaflet JavaScript Library and attached a (working) map to my HTML Document. It is in the middle of the page, and when I'm scrolling down with my mouse wheel and arrive at the map,...
user avatar
  • 455
24 votes
1 answer
50k views

Change marker icon on click using leaflet

I have a map with many (>100) markers on it. I would like to make it so that clicking on these changes the icon to a highlighted version. I've created two custom icons, one regular, and one ...
user avatar
24 votes
5 answers
15k views

Database for offline slippy map tiles

I currently have an offline HTML5 map application (built on Leaflet & KendoUI with custom additions) that has an app manifest and works fine on multiple platforms. However, I am hesitant to use ...
user avatar
  • 1,367
23 votes
2 answers
85k views

Leaflet: How do you use removeLayer?

This is driving me mad. See the Leaflet tutorial for adding a layer control to your map: L.Icon.Default.imagePath = "Scripts/images"; var mapUrl = 'http://{s}.tile.openstreetmap.se/hydda/full/{z}/...
user avatar
  • 448
23 votes
2 answers
44k views

Add/Remove legend with Leaflet layers control?

I have two overlays http://02d0c8c.netsolhost.com/dev/lcb_census_layers3.html that can be turned on and off with a Layer Control. I’d like the legend for each layer to turn on/off along with the ...
user avatar
  • 231
22 votes
2 answers
97k views

Getting Lat, Long of clicked location using Leaflet API?

I am using OSM with Leaflet API. Now I want to get the lat and long of a clicked location. I meant something similar to this. ex: http://openlayers.org/dev/examples/click.html map.events.register("...
user avatar
22 votes
4 answers
43k views

Custom Leaflet Controls

I have gotton some help in creating a custom control for leaflet, but I am still having trouble upgrading to the CSS styles used by the latest versions of Leaflet. Basically, all I need is a icon in ...
user avatar
  • 1,367
22 votes
4 answers
79k views

Triggering click event on Leaflet map?

Is it possible to make a click event occur at a particular lat/lon on a leaflet map? I would like to make a popup appear that is associated with a point at a particular location. I have tried ...
user avatar
  • 15.9k
21 votes
1 answer
17k views

Zoom further in than level 19 with leaflet javascript API?

We're using the leaflet JavaScript API with a tile layer which supports zoom level up to 19. I'd like users to be able to zoom further even if the tiles blur as they have to place markers to a high ...
user avatar
  • 383
20 votes
1 answer
62k views

How to change Leaflet Map panes layering order (z-index)?

Leaflet maintains that the Map panes elements contain all layers added to the map. The difference between many of the Map panes is strictly the z-index order of layering. I would like to use a ...
user avatar
19 votes
6 answers
21k views

How to Create Animated Cluster Markers in OpenLayers/Leaflet?

I want to use Leaflet due to the smooth transitions which Openlayers seems like they can't match. I specifically require the ability to cluster markers with custom styled marker groups. The best ...
user avatar
19 votes
3 answers
24k views

Does Leaflet JS API provide a Geocoding service?

I am considering replacement of Google Maps with Open Street Maps and the Leaflet JS API. Does the Leaflet JS API provide a Geocoding service?
user avatar
  • 293
18 votes
1 answer
35k views

How to check if a leaflet layer is already added on the map?

I built a simple map app where I have a layer on top of a map. In Leaflet, how can I check if the layer is already present?
user avatar
  • 2,514
18 votes
2 answers
14k views

What is the most common way of displaying geodata from Postgis on Leaflet?

For example, in my database I've some points with geographic coordinates. I want to display them on Leaflet JS layer. Which instruments should I use? Maybe there is some API...
user avatar
18 votes
3 answers
12k views

Leaflet: how to draw curved lines?

So, I'm trying to draw curved lines in my application which is based on a Leaflet map. As far as I know Leaflet does not support drawing curved lines at the moment, so my question is really more ...
user avatar
  • 550
18 votes
4 answers
41k views

Changing popup position on Leaflet marker?

I want open a popup on bottom of my marker icon in Leaflet. my code: var mymap = L.map('mapid').setView([51.505, -0.09], 13); L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?...
user avatar
  • 661
17 votes
4 answers
44k views

How to update a popup content from its marker?

I created a popup with Leaflet doing so: marker.bindPopup(content).openPopup(); How can I update the content value afterwards? I suppose to do it from the marker, something like this: marker....
user avatar
  • 283
17 votes
7 answers
21k views

How do you convert OSM XML to geojson?

I want to take the XML output of a Xapi query and display it using leaflet or polymaps. How can I do that? Is there an easy way to convert XML to geojson
user avatar
17 votes
3 answers
8k views

Leaflet rendering TileMill tiles in the wrong order

I'm stumped, and quite a lot of searching has turned up nothing helpful. I'm on the first step of what will ultimately be a map with three raster layers and three layers of markers (with controls to ...
user avatar
  • 185
17 votes
2 answers
15k views

Leaflet: Container coordinates vs Layer coordinates?

What is the difference between map container coordinates and layer coordinates? From what I gathered, the map container coordinates are always relative to the map viewport, and while layer ...
user avatar
17 votes
2 answers
3k views

Understanding web mapping tools [duplicate]

Before I start, this is going to be a general question but with specific cases. I've been trying to understand GIS tools and applications to achieve the following: Build my own basemap Publish the ...
user avatar
  • 639
16 votes
4 answers
55k views

Dynamically set zoom level based on a bounding box

I have a leaflet map whose size depends on the size of the browser window. I would like the zoom level to be dynamically chosen so that it is as zoomed in as possible while showing the entirety of the ...
user avatar
16 votes
7 answers
5k views

Comparing two maps with nice web interface?

Is it possible in Leaflet or OpenLayers to compare two maps with a bar to slide between the two? Examples include: http://www.esri.com/services/disaster-response/hurricanes/hurricane-sandy-the-...
user avatar
16 votes
1 answer
3k views

How to copy the color styling to a color column in a layer's attribute table?

I have a polygon layer in QGIS that I have applied a random color style to each polygon. Under Layer Properties -> Style I selected a Categorized style and then generated a random color ramp. I added ...
user avatar
16 votes
1 answer
17k views

How do I get the bounds of a layerGroup in Leaflet?

I have added multiple geoJSON layers to my map by first adding them to a LayerGroup and then adding the layerGroup to the map. Now I want to call fitBounds on the map with the combined bounds of all ...
user avatar
  • 1,167
16 votes
1 answer
80k views

Adding a search box to a Leaflet.js example

Consider the example in the following link for Folium: US Employment visualization per county. The result looks like what you see below:     I would like to add a search box to it to be ...
user avatar
16 votes
6 answers
41k views

3D perspective on maps in Leaflet, CartoDB?

Are there any JS library out there that would render normal, flat maps (like Leaflet) into a perspective map like this one, on the web: Also, anyone seen anything that could turn CartoDB data into 3D ...
user avatar
  • 735
16 votes
3 answers
20k views

Color-code a Leaflet polyline based on additional values, e.g. altitude, speed,

I'd like to draw a GPX-track on a Leaflet map. The polyline shouldn't have only one color, but I'd like to show certain values like altitude, speed, heart-rate, temperature, cadence, slope color-coded....
user avatar
  • 330
16 votes
2 answers
6k views

How can I make a polyline wrap around the world?

I am using leaflet maps to create a representation of a round-the-world challenge. I would like to add a polyline which heads east from tokyo and then appears west of south america on the map - but ...
user avatar
15 votes
2 answers
71k views

Leaflet: How to add a marker to, or remove it from, a Leaflet map?

On Leaflet, I am drawing a marker everytime the user click on the map like this: function getClickedLanLon(e) { var lat, lon, zoom; lat = e.latlng.lat; lon = e.latlng....
user avatar
  • 253
15 votes
2 answers
28k views

How to calculate the bounding box of a geojson object using python or javascript?

I have django app with leaflet on the frontend and I need to calculate the bbox of a geojson object so that I can pass the coordinates to map.fitBounds() I have tried some libs as well as trying the ...
user avatar
  • 1,167
15 votes
2 answers
37k views

Using Leaflet Js, is it possible to know the onclick location of a Marker (ignore anchor point)?

I have a marker object that is of a specific height and width, and although it is pointing a single coordinate, the visual representation of the marker spans many pixels. When I click on the visual ...
user avatar
15 votes
2 answers
42k views

Free tile provider for Leaflet

I'm using Leaflet for the maps of my website. So far I was using maps of Mapbox (they're cool), but they obviously charge for them for website with 100,000+ maps per month. I'm trying to find a ...
user avatar
  • 331
15 votes
3 answers
48k views

Is it possible to convert regular JSON to GeoJSON?

I have JSON data I've exported from Openpaths.cc which contains lat and lon values. However, the data is not in GeoJSON format so can't be read by OGR2OGR. Could anyone point me in the right direction ...
user avatar
  • 1,705

1
2 3 4 5
77