Error: Bounds are not valid (React-Leaflet)
See original GitHub issueI’m trying to integrate this library with React-Leaflet in the following way.
var provider = new EsriProvider();
class Search extends MapControl {
createLeafletElement() {
return GeoSearchControl({
provider: provider,
style: 'bar',
showMarker: true,
showPopup: false,
autoClose: true,
retainZoomLevel: false,
animateZoom: true,
keepResult: false,
searchLabel: 'search'
});
}
}
return (
<Map
className="map-surface"
center={[39, -104]}
zoom={5}
minZoom={2}
ref="map"
worldCopyJump={true}
zoomControl={false}
>
{ this.props.children }
<ZoomControl
position="topright"
zoomInTitle="Zoom in"
zoomOutTitle="Zoom out"
/>
<ScaleControl
className="scale"
/>
<Search />
<TileLayer
attribution="&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors"
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
</Map>
);
And I’m getting the next error:
leaflet-src.js:2548 Uncaught (in promise) Error: Bounds are not valid.
at NewClass.fitBounds (leaflet-src.js:2548)
at NewClass.centerMap (leafletControl.js:406)
at NewClass.showResult (leafletControl.js:340)
at NewClass.<anonymous> (leafletControl.js:323)
at eval (eval at processIncludes (runtime.js:36), <anonymous>:3:4725)
I’m doing something wrong or is a bug in the library?
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
React Leaflet Bound not working as expected - Stack Overflow
The error Cannot read properties of undefined (reading 'lat') is because you are passing an empty array of markers to <Rectangle> .
Read more >L.geoJson() - Error: Bounds are not valid - GIS Stack Exchange
I am iterating through an array of zipcodes and passing each to Mapbox Geocoding API. With every iteration, on success, I pass to...
Read more >View bounds - React Leaflet
Click a rectangle to fit the map to its bounds. ... const [bounds, setBounds] = useState(outerBounds). const map = useMap(). const innerHandlers =...
Read more >Fit a map's bounds to contents of a FeatureGroup in React ...
... Fit a map's bounds to contents of a FeatureGroup in React-Leaflet-Reactjs. ... in react native · Marker click event on react native...
Read more >leaflet-geosearch - npm
With retainZoomLevel on true , the map is only panned. animateZoom controls whether or not the pan/zoom moment is being animated. autoClose ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did not get the exact same error as you, but I was able to get the plugin working with leaflet-react v2 by wrapping my custom component with the
withLeaflet()
component (see Creating custom components).Don’t forget to add the leaflet-geosearch CSS too.
I was having this same problem, also with react leaflet. I used as @hancocb mentioned, but still not working. I figured out, that if I change the property:
retainZoomLevel
to true it works. For those who still getting this problem, change to somenthing like:Maybe we are going to receive a fix for this?