GeoTIFF / georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of raster on your Leaflet Map
https://geotiff.github.io/georaster-layer-for-leaflet-example/
Apache License 2.0
297 stars 58 forks source link

Trying to import georaster-layer-for-leaflet makes my software crash #100

Open revitalpresman opened 2 years ago

revitalpresman commented 2 years ago

I'm trying to use "georaster-layer-for-leaflet" in my react application, I'm importing this way:

import { GeoRasterLayer } from "georaster-layer-for-leaflet";

and my program is crashing and I get this error: "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory".

Screenshots image

can you please make a manual on how to use this package in react?

jksaunders commented 2 years ago

I had a similar issue starting out with this package today where the tab freezes and crashes, but got it working after downgrading to georaster-layer-for-leaflet@3.5.0! Give that a try and hopefully we can help identify an issue introduced since 3.5.0.

My usage looks like this:

``` import React, { useEffect } from 'react'; import parseGeoraster from 'georaster'; import GeoRasterLayer, { GeoRaster } from 'georaster-layer-for-leaflet'; import { useMap } from 'react-leaflet'; export default ({ url }: { url: string }) => { const map = useMap(); const layerRef = React.useRef(null); useEffect(() => { parseGeoraster(url).then((georaster: GeoRaster) => { const layer = new GeoRasterLayer({ attribution: 'Planet', georaster, }); layerRef.current = layer; map.addLayer(layer); }); return () => { if (layerRef.current) { map.removeLayer(layerRef.current); } }; }, [map]); return null; }; ```
revitalpresman commented 2 years ago

Thank you for the answer, unfortunately this versions of georaster-layer-for-leaflet also does the same error.

pcpatfire commented 2 years ago

Same problem.

DanielJDufour commented 2 years ago

Hey, all. Thanks so much for commenting. It really helps me prioritize tickets and it seems like this is a big problem! I'll prioritize fixing this.

DanielJDufour commented 2 years ago

Hi, all. I'm not sure what the issue but if I had to guess some possibilies:

Open to other ideas!