As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [leaflet]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
135 views

Query GeoServer WFS layer attributes with form

How can I set up a form in HTML to query the attributes in my GeoServer WFS layer? I assume it has something to do with the action attribute but I'm not sure how it will work. Something like <form ...
2 votes
0 answers
37 views

Unwanted different line thickness in multipolygon's shared borders

I have a multipolygon in a Leaflet map in a R Shiny app. There is always one subpolygon selected to be displayed while the other subpolygons are hidden (i.e. it's fill is transparent and the others ...
0 votes
1 answer
958 views

Load Leaflet ImageOverlay with center point instead of corners

I have an image file that I am able to overlay perfectly fine onto my Leaflet map with this code: var initLat = 38.9761; var initLon = -77.4875; var imageUrl = '/weather/nexrad/radar.png'; var ...
1 vote
0 answers
67 views

Add functionality to Leaflet Map (Search, Add on Client Select) [closed]

I've tried so many ways to do it but is there a way to do this or not? I would like to have it so that the user can search on the page (doesn't have to be a control in Leaflet) for a building with ...
3 votes
1 answer
1k views

How to add labels parallel to lines, polylines or multilines using Leaflet? [closed]

I want to add road name parallel to its line or if the line is curved, then the label should also be curved as in the image. How to add these name labels using Leaflet?
2 votes
1 answer
1k views

Tooltip for polygon disappears when hovering over a marker placed on top of that polygon in Leaflet

This seems like it should be a common enough problem but somehow I cannot find the solution anywhere. I have a layer full of polygons (polygons representing districts of a city), and a layer full of ...
1 vote
1 answer
106 views

Get the bounds of a WMS layer in Leaflet using JavaScript [duplicate]

Is there a function for calculating the bounds of a line in Leaflet maps. I have many single line layers on a leaflet map. The lines are served from GeoServer WMS. Line layer example:- var HKL = L....
0 votes
1 answer
398 views

Issues with Leaflet and WMS map BoundingBox

Our application uses Leaflet to display various kinds of maps (TMS, WMS, WMTS, XYZ etc.) as well as GeoJSON objects on the map. The problem is in how we define and use the WMS maps and layers. We're ...
0 votes
1 answer
841 views

Getting width of road segment given its end points using Leaflet?

I want to highlight a road segment on a Leaflet Map. I have the coordinates of the end point of the road segment, so could plot it as a linestring. But the problem is how can I get the width of the ...
0 votes
1 answer
48 views

Bootstrap control modals plugin changing icons in Leaflet? [closed]

I'm using Leaflet plugin L.Control.BootstrapModal (see https://github.com/gregallensworth/L.Control.BootstrapModal) to add a few layer controls on my map which toggle a modal displaying some country ...
1 vote
1 answer
65 views

Leaflet shapefile plugin doesn't show the shapefile layer

I'm trying to use the Leaflet Shapefile plugin (https://github.com/calvinmetcalf/leaflet.shapefile). A demo page also shows the plugin's output (http://calvinmetcalf.github.io/leaflet.shapefile/). I ...
2 votes
1 answer
423 views

Use self-defined Leaflet identifiers to work with jsTree checkboxes

I have some hierachic structured point-layers in a GeoJSON file using jsTree (ajax) with checkboxes to add them to the map. As I have about 20.000 points structured in 2.000 nodes representing the ...
0 votes
1 answer
52 views

Why does Leaflet layer control require null to be expanded by default

I have the following code which is used the create a Leaflet layer control and keep it open by default:- const layerControl = L.control.layers(baseLayers, null, {collapsed:false, position: '...
1 vote
1 answer
56 views

How to use getBounds() in OpenLayers 3

I am working on a project to create map using OpenLayers 3. Previously I was working with Leaflet but now I am working with OpenLayers 3. In Leaflet, I was fetching bounds using below code var bounds =...
10 votes
3 answers
40k views

How to open popup menu on right click in Leaflet

I want to open a popup menu list on right click with Leaflet map. I have tried the ContextMenu of leaflet but couldn't do it. Here is the sort of code I used. map.on('contextmenu', L.popup() ....
1 vote
1 answer
328 views

Display shapefile data - Leaflet 1.4.0

I am using Leaflet 1.4.0 and a beginner with Leaflet and JavaScript. I try to display shapefile data on my webmap with Leaflet. But it doesn't work. All the data (.shp, index.html... ) in WGS84 are ...
2 votes
2 answers
1k views

Joining CSV to KML/GeoJSON in Leaflet webmap and showing joined data in popups?

I'm trying to create a Leaflet/Mapbox webmap with line layer (GeoJSON or KML) with some IDs and data coming from the .csv (after joining through this ID) file located on the same path as the index....
1 vote
1 answer
265 views

Removing previous layer when new layer is select from drop-down menu?

I have a drop-down with some options in it, after selecting one option and button clicking I get the text and my shapefile from the GeoServer which is added to the map. So when I click on the first ...
0 votes
1 answer
188 views

Manipulating data with a Handsontable spreadsheet in a Leaflet GeoJSON Layer and rerender the map

The goal is to add a spreadsheet view to a GeoJSON Layer to comfty edit the properties directly in the spreadsheet and the location (lat/long) within the map by dragging the marker with leaflet.draw. ...
1 vote
1 answer
168 views

How to get the geometry of Vector Tiles Protobuf integrated in Leaflet

I use the Vector Grid plugin to integrate Vector Tiles (Protobuf format) in my Leaflet application. How can I access the geometry of a selected feature? I include the Vector Tiles as follows: L....
3 votes
1 answer
162 views

Polygon fill pattern not visible in screenshot taken with Leaflet simpleMapScreenshoter plugin

We are using Leaflet to display polygons with fill patterns using the leaflet-polygon.fillPattern.js plugin. Additionally, we are using the leaflet-simple-map-screenshoter.js plugin to allow users to ...
1 vote
1 answer
256 views

Leaflet Javascript: zoom to layer only on load

I have a WFS layer, updated in a loop, and I want the view to be centered on it only the first time the map is loaded; next, when the user moves the map or waits 20 secs, there is a movend function ...
1 vote
1 answer
6k views

How to detect "delete" or "edit" events in popup menu created with Leaflet-draw-toolbar plugin?

In this example you may create a polygon and then click it and popup menu shows. There is three buttons: edit, delete and pick a color. How can I detect event and determine which of it - delete or ...
2 votes
1 answer
2k views

Leaflet setView with non lat/long CRS

Is it possible to use setView when using an alternative CRS? var map = L.map('map',{crs: L.CRS.EPSG26915}).setView([4970081,477018], 13); // Returns: Uncaught TypeError: Cannot call method '...
1 vote
0 answers
71 views

Use TMS or WMTS to get vector tiles served from Geoserver in Leaflet [duplicate]

Question: Is there a reason to use a TMS over WMTS call to GeoServer to pull vector tiles? My goal is to pull vector tiles from my Geoserver to my Leaflet-based web application. Unfortunately, the ...
2 votes
1 answer
83 views

Displaying flatgeobuf file in Leaflet [closed]

I am trying to read flatgeobuf file (see https://flatgeobuf.org/examples/leaflet/) in Leaflet, but it returns blank. Here is my code: import './style.css' import 'leaflet/dist/leaflet.css' import '...
3 votes
2 answers
161 views

GeoJSON from SQL View

I am trying to select database table features within a certain distance from a leafleat generated geosjon using an sql view in geoserver. I first used a GET function and a user here suggested POST. I ...
1 vote
0 answers
215 views

Poor GeoTIFF display performance using JS plugins contrary to Leaflet for R package

I have question regarding displaying GeotTIFF using leaflet or react-leaflet. There are some packages allowing displaying tiffs, for example I had used: https://github.com/stuartmatthews/leaflet-...
0 votes
0 answers
91 views

Preloading map tiles for different zoom levels in Leaflet

Preload map tiles that are outside current map view in Leaflet talks about how to preload map tiles that aren't currently in the viewport but are at the same zoom level. But what if I wanted to ...
3 votes
1 answer
240 views

Get GeoJSON from a VectorGrid.Protobuf layer on click event

I am trying to get the GeoJSON of a VectorGrid layer on a click event. Something like this: ... var vectorTile = new L.vectorGrid.protobuf(url, options).addTo(map) vectorTile.on('click', e => { ...
0 votes
1 answer
2k views

Handling popups with overlapping layers in Leaflet

I have two polygon layers (polygons) that overlap. I've created a leaflet map using qgis2web. The issues is that, if I click on the overlapping area, the popup only shows information for the topmost ...
2 votes
1 answer
91 views

Create a toggle for users to place markers in Leaflet?

I am working on an webpage that uses Leaflet. The users can currently place a marker on the map when they click a specific area. I was wondering if there is a way to add a toggle so that the user can ...
1 vote
1 answer
837 views

Display leaflet layerswitcher on click event

I would like to click on a sidebar/menu icon, and when I do the layerswitcher Icon should appear. Right now the layerswitcher is always displayed. I know how to make it disappear with the command ...
2 votes
1 answer
130 views

Leaflet.js transfer information of a point: latitude, longitude, feature properties and variables, to a function

I'm trying to extract some information from a L.geojson feature of the map, containing points, through a newly created button inside a BindPopup feature, pointing to a function. Such function then ...
1 vote
1 answer
137 views

Customising a marker after performing a spatial search query

I'm have a geodjango app that uses leaflet for a front-end. I have integrated the search function on the front-end to be able to search a customer location in real-time, of which the code below does ...
0 votes
1 answer
63 views

Shift in Raster image in R Leaflet

I am trying to plot a raster image on a leaflet map - the raster I am using is downloaded from Environment Agency and the CRS of the raster is British National Grid (EPSG:27700). You can find the file ...
0 votes
1 answer
396 views

Make background image visible at all scales in webmap QGIS2web

I'm trying to produce a web map using the QGIS2web plug in and leaflet output, but the background image is not visible when I zoom in beyond some scale. Is there a way to control the scales a ...
0 votes
1 answer
399 views

Map data do not show up under the Leaflet magnifier

I tried to add Leaflet magnifier to my map and it is perfectly working on the base map, but it doesn't magnify or show my own data on the map. My own data is loaded as GeoJSON to map and its visible ...
2 votes
1 answer
5k views

Map is not visible at initialization using react-leaflet

I have this react component: import React, { Fragment } from 'react'; import L from 'leaflet'; import { Map, TileLayer, Marker, Popup } from 'react-leaflet'; import 'leaflet/dist/leaflet.css'; const ...
0 votes
1 answer
669 views

How to add and remove the pop-up text based on the condition by using Leaflet

I want to show and hide the popup text based on the condition given below. .component.ts var insidecirclespace1 = (lat, long) => { for (var i = 0; i < this.sensors.length; i++) { ...
1 vote
1 answer
324 views

Cannot set zoom past 23 in Leaflet

How can I set the zoom to 23 or more? When I try to set the zoom higher the map image disappears. I am able to zoom in past 23 once the map is activated in a browser, but I can't set the zoom past 23 ...
1 vote
2 answers
178 views

Offset of markers and polygon depending on zoom level in Leaflet

I have run into a problem with a suspicious offset what comes to self created polygon using Leaflet. I am creating a website using NodeJS (and Pug for rendering the HTML itself). Using Leaflet, I ...
0 votes
1 answer
1k views

Leaflet Map moves to opened popups when zooming in (React-leaflet)

i wanted to open the popup Markers when the MapZoom is at a certain value ,i got the mapZoom using the map.getZoom() on the zoomend Event , a state is set for the MapZoom when the user scrolls ...
2 votes
1 answer
107 views

Specify tilelayer position on Leaflet

I have 2 raster images (.png), 2 maps that are geographically next to each other (east part and west part of a city). These images are part of a bigger set, and cannot be merged (or my PC dies). These ...
1 vote
0 answers
242 views

Where to set CRS property in react-leaflet?

I am changing my reference system in my Leaflet app. I am using the react-leaflet library since I am building it with React. import { MapContainer, TileLayer, ImageOverlay, useMap } from 'react-...
1 vote
0 answers
61 views

ImageOverlay bounds in Leaflet from GDAL processed image

I am displaying an image to Leaflet. The image is a result of a process from a backend I am also building. I cannot get the right bounds for the image. I return the bounds from the function gdal.Info. ...
1 vote
1 answer
330 views

mapfish.print.InvalidValueException: url has an invalid value

I have the config yaml set us below: - !image maxwidth: 120 maxheight: 40 align: left url: "file:\\C:\Program Files (...
2 votes
1 answer
1k views

Adding a popup to features in a leaflet.vectorgrid layer

I am loading a tile set from MapTiler to my leaflet map. I have no trouble styling each feature in the tile set. I can set each feature to the appropriate color. I would like to also add a popup to ...
1 vote
1 answer
175 views

refreshClusters on esri.Cluster.featureLayer

I am trying to 'refresh' a cluster layer which is created by L.esri.Cluster.featureLayer and a feature url. I have tried to remove and re-add the layer (with no succees). But the refreshClusters is ...
4 votes
1 answer
76 views

Crossing lines when displaying multilinestring from GeoJSON in Leaflet

I'm stuck with something simple. I'm trying to draw a multilinestring from a GeoJSON file in a Leaflet map. I've taken the GeoJSON data from an application (built with OpenLayers + GeoServer), which ...

1 2
3
4 5
82