Orange-OpenSource / Orange-OpenSource/IOT-Map-Component

`L.MarkerClusterGroup is not a constructor`

Open
#32 0 comments 0 reactions 1 assignee View on GitHub

@MewenLeHo is already working on this.

Since Feb 23, 2022.

bug
Dominant language
TypeScript
Stars
24
Forks
8
PR merge metrics
No merged PRs in 30d

Description

We have implemented a switch between the manual and automatic clustering. So this is our first test for using automatic clustering in our hybrid Angular JS / Angular project.

In development mode (an equivalent of ng serve), we don't have any problems.

In production mode, the compilation is OK but when we display the map in automatic clustering, we can see the following error:

L.MarkerClusterGroup is not a constructor

This is linked to the content of the private initLayer function:

} else { // clusterables marker
      layer = L.markerClusterGroup({
        maxClusterRadius: this.config.map.clusterRadius,
        showCoverageOnHover: false,
        iconCreateFunction: this.getClusterIcon.bind(this)
      })

This is probably a problem of typings as we had in https://github.com/Orange-OpenSource/IOT-Map-Component/issues/18.

We found a way of making it work that wasn't needed before. In our index.ts, we now have to add:

// Leaflet
import 'leaflet';
import 'leaflet.markercluster';

I haven't dug into the problem more than that, but it would be nice not having to do that which is a bit tricky to find.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.