georaster-layer-for-leaflet icon indicating copy to clipboard operation
georaster-layer-for-leaflet copied to clipboard

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

Open revitalpresman opened this issue 3 years ago • 5 comments

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?

revitalpresman avatar Jun 06 '22 08:06 revitalpresman

I had a similar issue starting out with this package today where the tab freezes and crashes, but got it working after downgrading to [email protected]! 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;
};

jksaunders avatar Jun 07 '22 19:06 jksaunders

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

revitalpresman avatar Jun 08 '22 10:06 revitalpresman

Same problem.

pcpatfire avatar Jun 16 '22 15:06 pcpatfire

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 avatar Jun 16 '22 16:06 DanielJDufour

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

  • the raster has one band and the new statistical calculations are causing an issue, in which case add a pixelValuesToColorFn would fix that
  • something changed with the way how geotiff.js unpacks raster tile values

Open to other ideas!

DanielJDufour avatar Jul 09 '22 21:07 DanielJDufour