Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [leaflet]

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

84
votes
8answers
58k 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 ...
59
votes
7answers
12k 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 ...
44
votes
5answers
84k 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 ...
40
votes
13answers
31k 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 ...
32
votes
6answers
23k 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 ...
31
votes
5answers
88k 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)...
27
votes
1answer
21k 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 ...
26
votes
2answers
35k views

Adding/Removing Leaflet GeoJSON layers

I'm 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 don't actually want them all to show at once). I ...
25
votes
5answers
10k 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 ...
24
votes
2answers
29k 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 ...
21
votes
4answers
60k 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 ...
19
votes
2answers
48k 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 ...
19
votes
6answers
18k 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
3answers
47k 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?
19
votes
1answer
31k 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 ...
18
votes
1answer
31k views

How to 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 ...
17
votes
5answers
10k 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 ...
17
votes
6answers
13k 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
17
votes
2answers
10k 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...
17
votes
2answers
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 ...
17
votes
3answers
9k 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 ...
16
votes
3answers
16k 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.
16
votes
1answer
35k 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 ...
15
votes
1answer
59k 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("...
15
votes
4answers
19k 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,...
15
votes
7answers
3k 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-...
15
votes
4answers
29k 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 ...
15
votes
3answers
19k 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 ...
15
votes
2answers
10k 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 ...
15
votes
3answers
17k 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?
14
votes
1answer
4k 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 ...
14
votes
1answer
2k 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 ...
14
votes
4answers
7k views

Open source alternatives to Google's StreetView engine?

I am looking to create an open source javascript app using either Leaflet or OpenLayers. Is there any way to implement panoramic views (similar to Google's StreetView) into either of these, or any ...
13
votes
2answers
14k 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 ...
13
votes
2answers
34k 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 ...
13
votes
1answer
10k 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 ...
13
votes
3answers
10k 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....
13
votes
2answers
4k 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 ...
13
votes
1answer
3k views

Generating Heatmap from PostGIS

I have GIS data in a PostGIS data base and would like to generate a density map and display them on a Leaflet/Google Maps. Question: What is the recommended/typical method for doing so, without ...
13
votes
5answers
3k views

How to use Leaflet to efficiently show parts of a massive dataset?

I keep seeing non-GIS web developers running into this problem, and I'm not sure what the solution is. There is some dataset of thousands of items. We want to show a map to the user, with the visible ...
13
votes
2answers
5k views

Examples of leaflet interactive mapping applications [closed]

I would like to develop a simple mapping application. One where users can digitize lines, polygons and points and attribute the features. The attributes will then be stored in a database for later ...
12
votes
3answers
12k views

How to get Leaflet interactivity from Geoserver WMS?

I have geoserver serving shapefiles as a WMS into Leaflet. I'd like to add interativity that shows a popup with WMS attributes in the Leaflet map when the user hovers over or clicks on a WMS feature. ...
12
votes
0answers
885 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 ...
11
votes
1answer
6k views

Placing controls outside map container with Leaflet?

Can someone tell me how I can place controls outside of the map content with Leaflet? In this case, I just want to place the layer switch control outside the map object.
11
votes
1answer
13k 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?
10
votes
5answers
1k views

Calculating correct longitude when it's over |180|?

I'm trying to develop a "formula" to correct the lat-lng values. I'm using vue-leaflet but when you pan outside the "first" world you get big numbers. Over +180 or under -180. For example: when I ...
10
votes
2answers
14k 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 ...
10
votes
2answers
12k views

How to add Geoserver WFS to Leaflet JS Application

I have a PostGIS database and have successfully consumed a table into GeoServer and published a WFS. Are there REST endpoints available for these WFS' akin to ESRI's feature services? How are ...
10
votes
1answer
33k 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 ...
10
votes
2answers
19k 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 ...