Questions tagged [leaflet]
An Open-Source JavaScript Library for Mobile-Friendly Interactive Maps
4,032
questions
117
votes
8
answers
94k
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 ...
71
votes
7
answers
159k
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 ...
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 ...
49
votes
14
answers
45k
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 ...
48
votes
5
answers
158k
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)...
35
votes
1
answer
39k
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 ...
34
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 ...
33
votes
4
answers
61k
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 ...
33
votes
3
answers
50k
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). ...
32
votes
6
answers
26k
views
GeoJSON too bulky
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 ...
31
votes
4
answers
36k
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.
31
votes
3
answers
84k
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 ...
30
votes
4
answers
104k
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?
30
votes
5
answers
112k
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 ...
29
votes
3
answers
43k
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 ...
26
votes
4
answers
41k
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,...
26
votes
1
answer
52k
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 ...
25
votes
2
answers
106k
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("...
24
votes
2
answers
45k
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 ...
24
votes
5
answers
15k
views
Database for offline slippy map tiles [closed]
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 ...
23
votes
2
answers
95k
views
Using removeLayer of Leaflet
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}/{x}/{y}.png';
var ...
23
votes
4
answers
90k
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 ...
23
votes
1
answer
18k
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 ...
22
votes
4
answers
46k
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 ...
20
votes
7
answers
23k
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
20
votes
1
answer
68k
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 ...
19
votes
5
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 ...
19
votes
2
answers
15k
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...
19
votes
3
answers
26k
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?
18
votes
3
answers
9k
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 ...
18
votes
1
answer
39k
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?
18
votes
1
answer
20k
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 ...
18
votes
3
answers
13k
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 ...
18
votes
4
answers
47k
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?...
17
votes
5
answers
47k
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....
17
votes
3
answers
82k
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....
17
votes
3
answers
47k
views
Displaying properties of GeoJSON in popup on Leaflet?
This is my simple GeoJSON with Leaflet map. I want to display properties as popup but I don't know why it is empty.
Can you tell me my mistake?
<html>
<head>
<title>A Leaflet map!...
17
votes
2
answers
39k
views
Loading vector tile layer in Leaflet map?
I need to load a vector tile layer in a Leaflet map.
The vector tile is the vector tile layer about Mapillary sequences (look at https://a.mapillary.com/#vector-tiles ...), and the tile URL pattern ...
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 ...
17
votes
1
answer
87k
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 ...
17
votes
6
answers
44k
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 ...
16
votes
5
answers
59k
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 ...
16
votes
2
answers
49k
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 ...
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-...
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 ...
16
votes
2
answers
7k
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 ...
15
votes
6
answers
55k
views
How to remove attribution in Leaflet?
I want to remove the "Leaflet.com" that appears on the right bottom of the screen
here. How can I do that?
15
votes
2
answers
30k
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 ...
15
votes
2
answers
44k
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 ...
15
votes
2
answers
23k
views
leaflet geojson coordinate problem
I just started to play with leflet/geojson a little. But my coordinates are not rendered properly and I have no clue what is going on.
My coordinates are: 52.23943, 4.97599. They work correct with ...