IITC-CE / Leaflet.Canvas-Markers

Leaflet plugin for displaying icons on canvas instead of DOM
MIT License
2 stars 4 forks source link

Issue with installing/Using #16

Open henrikmaa opened 3 years ago

henrikmaa commented 3 years ago

I am having problems with rbush is not defined

steps i did:

  1. npm install https://github.com/IITC-CE/Leaflet.Canvas-Markers.git
  2. require('leaflet-canvas-marker'); also tried import 'leaflet-canvas-marker'

Now i get error: rbush is not defined

Also tried to install rbush in my project. Am I using this wrong?

Used this code to test

   // Adds a layer
    let ciLayer = L.canvasIconLayer({}).addTo(map);

      // Marker definition
    let marker =  L.marker([58.5578, 29.0087]);

      // Adding marker to layer
    ciLayer.addMarker(marker);

I also deleted node_modules and package-lock and npm install again to make sure...

johnd0e commented 3 years ago

After npm install have you got dist/leaflet.canvas-markers.js file (14436 b size)?

johnd0e commented 3 years ago

Also please note that original 'build system' is rather dumb and the only tested way to use it - is following original guide literally: https://github.com/IITC-CE/Leaflet.Canvas-Markers#installation-and-basic-usage.

I'm not the author of that code, and in my project I use main source file directly https://github.com/IITC-CE/Leaflet.Canvas-Markers/blob/master/src/plugin/leaflet.canvas-markers.js (after including rbush 2.0.2).

I see that you prefer to install the plugin with require. I cannot tell if that should work. So if that is not working - you can try to fix webpack.config.js or Leaflet.Canvas-Markers/src/_full.js

https://github.com/IITC-CE/Leaflet.Canvas-Markers/blob/affa3f5c1c5b8aee979fa79532a1223dcb3f7e34/src/_full.js#L1-L5

P.S. Feel free to open PR if you will be able to solve your issue.