Skip to main content

All Questions

45 votes
9 answers
50k views

leaflet map shows up grey

I'm starting leaflet.js with the quickstart but my map shows as grey... is there something I'm missing? script.js: var leafletMap = L.map('leafletMap').setView([51.505, -0.09], 13); L.tileLayer('...
Connor Leech's user avatar
  • 18.6k
29 votes
6 answers
27k views

How to identify Leaflet's Marker during a `popupopen` event?

when a marker is clicked, I need to execute some code that finds the id corresponding to the marker being clicked , retrieves data from backend API, then adds the newly retrieved data to the content ...
Nyxynyx's user avatar
  • 62.9k
24 votes
2 answers
22k views

How to add markers bulk in leaflet?

I have an array with ~30k elements and I need to create map with markers for each of them. I use markerclusters and trying to optimize adding moment. for (var i = 0; i < myItems.length; i++) { ...
Egor Sazanovich's user avatar
4 votes
1 answer
5k views

Global map tiles disappear past zoom level 19

I use OpenStreetMap with Leaflet.js. I have a map with an indoor picture on it. The problem is when I zoom in, streets disapears. Do you know anything that can solve this plz? Tricks or tips! EDIT: ...
Orelsanpls's user avatar
  • 23.3k
55 votes
1 answer
48k views

Get address from co-ordinates using OpenStreetMap [closed]

I'm looking for a solution which gives an address based on co-ordinates (Latitude & Longitude) which I got from html5 geolocation api. I'm using OpenStreetMap.
vishal's user avatar
  • 695
14 votes
2 answers
38k views

How to add only one marker in leaflet map

I am adding marker on map on user click. Problem is that I want only one marker but now whenever I click on map new marker is added. I am trying to remove it but nothing happens: var marker; map....
1110's user avatar
  • 7,247
11 votes
1 answer
11k views

Show only United States when using Leaflet.js and OSM

I'm using leaflet.js and OSM tiles to create a map, but I'd only like the continental United States to be viewable, not the entire world. Is that possible? I'm loading the map like this: var map = L....
frajk's user avatar
  • 863
5 votes
2 answers
9k views

How to add two geoJSON feature collections in to two layer groups

I have two geoJSON feature collections that I need to add to the map, and I also want them to be toggled on and off via the layer visibility controllers as shown in http://leafletjs.com/examples/...
thusithak's user avatar
  • 129
5 votes
1 answer
4k views

OpenStreetMap often sends Gateway Timeout error

I am using a leaflet map in program with the following code: <style> <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-...
LBes's user avatar
  • 3,426
5 votes
1 answer
2k views

How to use leaflet slider along with markercluster in Javascript?

i am making a map that uses a slider to show or hide markers, and i want to add clustering functionality, each one alone works perfectly, but i want the slider to show the markers, and in case of ...
jaafar Nasrallah's user avatar
1 vote
4 answers
1k views

Color certain grid tiles based on coordinates

I would like to color certain grid tiles based on their coordinates. I created the following grid: <!DOCTYPE html> <html> <head> <title>Color Tiles</title> &...
Carol.Kar's user avatar
  • 5,175
-1 votes
3 answers
8k views

reverse entries in (multi-dimensional) array in javascript

I'm using leafletjs to display some polygons on an openstretmap. I have an external data ressource which gives me the coordinates for the polygons. Unfortunately this array has the wrong order for ...
lornz's user avatar
  • 306
9 votes
2 answers
10k views

Showing an offline OSM map file. Suggestion: an MB Tiles file with Js.library

When online access to the internet is not possible, I would like the (offline) HTML5 app show an OSM map via an OSM file. Can you give an example of how I can show in an offline Html5 app OSM tiles ...
tm1701's user avatar
  • 7,323
8 votes
2 answers
21k views

Leaflet custom marker icon scale to zoom

I use Leaflet to draw an OpenStreetMap and attach it with a custom icon marker var mymap = L.map('mapid').setView([x, y], 13); L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?...
necroface's user avatar
  • 3,445
8 votes
4 answers
11k views

Render 2500 geoJSON polygons onto a leaflet map

I've been searching but cannot seem to find a solution. I have a GeoJSON file which is 170mb in size. It contains about 2500 polygons. Somehow I need to render it to a leaflet map. Evidently at that ...
user1641165's user avatar

15 30 50 per page