All Questions
58
questions
88
votes
18
answers
78k
views
How to fix error "Failed to compile : ./node_modules/@react-leaflet/core/esm/path.js 10:41 Module parse failed: Unexpected token (10:41)"
I am trying to create a react-typescript app along with leaflet. I used the command,
npm install leaflet react-leaflet @types/react @types/leaflet --save to install the dependencies.
But when I start ...
23
votes
3
answers
17k
views
How do you call fitBounds() when using leaflet-react?
I cannot figure out how to call fitBounds() on the Leaflet map.
If I was just using vanilla leaflet, this solution would work perfectly: Zoom to fit all markers in Mapbox or Leaflet
Unfortunately, I ...
57
votes
7
answers
99k
views
Leaflet: Map container not found
I have the below react class which fetches the geolocation through the browser.
I am mapping a leaflet map. I want to geolocation to be an input to the setView, for such that the map "zooms" into the ...
3
votes
2
answers
6k
views
Is there a way to use leaflet.heat in react?
I am trying to use leaflet.heat in reactJS. I have already made leaflet library to work with react hooks but unfortunately I can't use leaflet.heat in react. I import the module like:
import "../...
3
votes
2
answers
4k
views
React leaflet and react-leaflet-draw
I'm trying to implement the draw functions on leaflet map. I've created a new app with only react-leaflet installed, using npx create-react-app and the following packages installed:
npm install react ...
3
votes
1
answer
5k
views
Leaflet _ ReactJS - Where to find the invalidateSize property?
I have tried to find it in:
this.mapRef.current.leafletElement
this.mapRef.current.getLeafletElement()
invalidating this.mapRef.current.getLeafletElement().invalidateSize
this.mapRef.current....
91
votes
19
answers
85k
views
react-leaflet map not correctly displayed
I'm trying to use react-leaflet to display a map. I use the code from this fiddle which is working, but on my computer I have this output
Here is my code :
DeviceMap.js
import React from 'react'
...
15
votes
4
answers
11k
views
Leaflet React get map instance in functional component
I want to have a button outside the map that changes the view to another coordinates.
Is there any way to get mapContainer instance to call their functions? Or how can I implement that function?
I ...
8
votes
1
answer
5k
views
Using leaflet.offline with React?
I'm developing a React app, and I'm trying to implement a Leaflet-map with support for offline download of the map tiles. For this I thought of using leaflet.offline (https://github.com/allartk/...
6
votes
1
answer
10k
views
How to use Leaflet Routing Machine with React-Leaflet 3?
The old way of doing things in react-leaflet 2.8.0 was to use MapLayer and withLeaflet.
But now in react-leaflet:
MapLayer and withLeaflet are deprecated as of version 3.
I'm trying to grasp the ...
5
votes
2
answers
11k
views
Missing Leaflet Map Tiles when using react-leaflet
I am using the simple example from leaflet-react in a barebones create-react-app app.
Problem: The map tiles do render, but there is always 1-2 rows of map tiles that do not render (grayed out). ...
5
votes
3
answers
8k
views
react-leaflet create a custom components
I would like to create a custom component with react-leaflet that shows the actual position (x,y) of the mouse, but I don't know how to create it. I found react-leaflet-control but it seems that it is ...
3
votes
1
answer
1k
views
React leaflet side-by-side
I wanted to show two tile layers side by side, like the plugin side-by-side for leaflet (https://github.com/digidem/leaflet-side-by-side).
However, I am not sure how to do this with react. Is there ...
3
votes
2
answers
9k
views
Remove Zoom control from map in react-leaflet
I am building a react-leaflet application, and I am trying to separate the zoom control from the map itself. The same question in a vanilla Leaflet context was asked here: Placing controls outside ...
2
votes
1
answer
9k
views
How to fly to a location in react-leaflet
So I'm really new to react and leaflet but all I want to do is basically have the user enter some input, and after they press enter, trigger an event which then flies to the coordinates generated from ...