Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular CLI installation #158

Open
Battozxz opened this issue Nov 16, 2017 · 12 comments
Open

Angular CLI installation #158

Battozxz opened this issue Nov 16, 2017 · 12 comments

Comments

@Battozxz
Copy link

Hi, i looking for a way to install this library en my project with angular cli but when i try to import the dependencies like this:

import { PruneCluster, PruneClusterForLeaflet } from 'prunepluster'

in my component... i got the following error:

WEBPACK IMPORT MODULE _3_prunecluster _default PruneCluster is not a constructor

Any help?

@sylvaincaillot
Copy link

sylvaincaillot commented Nov 23, 2017

Hi,
I have exactly the same issue but with a Vuejs project

  import L from 'leaflet'
  import Vue2Leaflet from 'vue2-leaflet'
  import { PruneCluster, PruneClusterForLeaflet } from 'prunecluster'

export default {
...
methods: {
      setClusters (data) {
        var markerLayer = new PruneClusterForLeaflet()
        for (var i = 0; i < data.length; i++) {
          var marker = new PruneCluster.Marker(data[i].s[2], data[i].s[3])
          markerLayer.RegisterMarker(marker)
        }        
        map.addLayer(markerLayer)
        markerLayer.ProcessView()
      }
}
...
}

and got a
TypeError: __WEBPACK_IMPORTED_MODULE_10_prunecluster__.PruneClusterForLeaflet is not a constructor

i have also tried #115 but get the following error in that case:
no-webpack-loader-syntax Unexpected '!' in 'exports-loader?PruneCluster,PruneClusterForLeaflet!prunecluster/dist/PruneCluster.js'. Do not use import syntax to configure webpack loaders

I am a bit frustated as I need to migrate my old pruneCluster project to VueJS now

Thank you for your help

Sylvain

@sylvaincaillot
Copy link

Hi,
This is how i did overcome my issues above.

Following recommendation from facebook/create-react-app#1015

I have added the following line to prevent the eslint error:

/* eslint import/no-webpack-loader-syntax: off */
import { PruneCluster, PruneClusterForLeaflet } from 'exports-loader?PruneCluster,PruneClusterForLeaflet!prunecluster/dist/PruneCluster.js'
import 'prunecluster/dist/LeafletStyleSheet.css'

It's a bit dirty but it works in my case.

Cheers
S.

@Treasureworth
Copy link

Hi,
How I wish this also can work for angular.

Any idea to go about this?

@hansbrito
Copy link

hansbrito commented Feb 15, 2019

Hey Guys! I'm having the same issue. Has anyone managed to solve it?

I'm trying to use in Angular 7 Project.

@TheVoxell
Copy link

in package.json
"prunecluster": "2.1.0",

in angular.json

in "styles": [
"./node_modules/prunecluster/dist/LeafletStyleSheet.css",

"scripts": [
"./node_modules/prunecluster/dist/PruneCluster.js",

Then use it in your map component

@hansbrito
Copy link

hansbrito commented Feb 18, 2019

Hi! Thanks for your reply!
After installing @types/leaflet and follow your instructions, I got this error:

image

Leaflet types don't have any exported member ILayer:
image

@Jonibigoud
Copy link

Jonibigoud commented Dec 23, 2019

@hansbrito , did you manage to make it work? If anybody has a clear explanation of how i could add PruneCLuster to an angular-cli project.

@hansbrito
Copy link

Yes, i`ve changed in PruneCluster Library:
image

image

image

Everytime I install a new library i need to replace entire folder.

It isn't a solution, only a workaround.

@Jonibigoud
Copy link

Thanks @hansbrito, but you just inserted .js and .css files like @TheVoxell suggested?
Could you tell me how you call pruneCluster and pruneCLusterForLeaflet Constructors in your components ?

@hansbrito
Copy link

angular.json
import Styles:
"node_modules/prunecluster/dist/LeafletStyleSheet.css",
and scripts:
"node_modules/prunecluster/dist/PruneCluster.js",

image

inside my Component:
image

declare this variables:
image

on ngInit:
image

on onMapReady:
image

Now you can use like documentation says, adding markers ....

const _marker = new PruneCluster.Marker(packet.lat, packet.lng);
this.pruneCluster.RegisterMarker(_marker);

@Jonibigoud
Copy link

Thank you for your precious help, i really appreciate

@hrsh25
Copy link

hrsh25 commented Sep 1, 2020

Try:
import { PruneCluster, PruneClusterForLeaflet } from "exports-loader?exports[]=PruneCluster&exports[]=PruneClusterForLeaflet!@sintef/prune-cluster/dist/PruneCluster.js"

There is actually a syntax error in the import statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants