Hot answers tagged

3 votes
Accepted

Drag Scale on Leaflet?

Yes , it's actually quite simple. Get the container of the scale control with the .getContainer() method and then make it draggable: var controlScale = L.control.scale({'position':'bottomleft', '...
user avatar
  • 16.7k
2 votes

Implement plot purchases on fictional map

Here's a workflow using QGIS and some data from the Leaflet examples. Before you start, read the Leaflet tutorial about L.CRS.Simple. I mean it. Stop what you're doing, and read it. Lauch QGIS. Read ...
user avatar
  • 9,285
2 votes

Turn Leaflet Layers On or Off Based on Zoom Levels

What you have to do is to save created layer object to some global variable which you can then use in maps zoomend event processing function to add or remove layer from the map. Relevant part of the ...
user avatar
  • 16.7k
1 vote

Strange 404 error when loading Leaflet map

The img tags you write in your HTML document on line 289 "<img src='"+ feature.properties.Bildlink +"'width='300'</img>" +"<br>"+"<br>"+ ...
user avatar
  • 3,508
1 vote

Detecting Leaflet layer type (react-Leaflet)?

Since I'm not familiar with React, answer will be for vanilla Leaflet JS. Since Leaflet layers have no property that can be used to detect layer type, one possible solution is, when creating layer, to ...
user avatar
  • 16.7k
1 vote

Change popup content with JavaScript

Define your show_hide() function on global level and then call it with text parameter you want to replace current text with. Code could then look something like this: function show_hide(element, txt) ...
user avatar
  • 16.7k
1 vote
Accepted

Count Features using WFST-Leaflet

L.WFST layer fires load event when all features are loaded, so you just have to catch the event and get number of layers from event object (assuming all features are points): wfstPoint.on('load', ...
user avatar
  • 16.7k
1 vote
Accepted

Read geo-spatial data in R via Leaflet

Here's a sample sp-class points data frame in a projected coordinate system like your data is: > ps class : SpatialPointsDataFrame features : 4 extent : 1, 4, 1, 4 (xmin, xmax, ...
user avatar
  • 51.1k
1 vote
Accepted

Leaflet geoJSON - function within setStyle()

Since style_new function returns style object, it must not be embedded in the object specifiers {} when you call it, so code should look like this: this.map_layer.eachLayer(function (layer: any) { ...
user avatar
  • 16.7k
1 vote

Drag Scale on Leaflet?

I just applied your solution for the scale "Leaflet.GraphicScale" , it's also valid var graphicScale = L.control.graphicScale({position: 'bottomleft', doubleLine:true, fill:true}).addTo(map);...
user avatar
  • 135
1 vote

Leaflet geoJSON tooltip coordinates

You can control position of the tooltip only for map tooltips (see https://leafletjs.com/reference.html#map-methods-for-layers-and-controls). So if your desired tooltip coordinates would be latlng, ...
user avatar
  • 16.7k
1 vote
Accepted

How to overlay BLM map in leafletjs?

If you look at the Leaflet docs for tile layers at https://leafletjs.com/reference.html#tilelayer, you'll see that syntax for specifying tile parameters z, y and x looks something like this: 'https://{...
user avatar
  • 16.7k
1 vote
Accepted

Displaying pop ups for overlapping polygons in the same layer in Leaflet?

On way to do it is to use your click processing function zoomToFeature and there with the help of turf.js library function turf.booleanPointInPolygon check which features contain clicked point ...
user avatar
  • 16.7k
1 vote

gdal2tiles.py generates wrong tiles / MapTiler the right ones

This question is a bit old, but there's now an "official" solution to this problem. Since GDAL version 3.1, gdal2tiles.py now includes a --xyz option. (For a full list of options see this ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible