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

Dynamic cluster icons with v-for #34

Open
Chris-McQuiggan opened this issue Jan 31, 2020 · 0 comments
Open

Dynamic cluster icons with v-for #34

Chris-McQuiggan opened this issue Jan 31, 2020 · 0 comments

Comments

@Chris-McQuiggan
Copy link

Hi, having a problem with how custom cluster icons are showing.
For the most part it works perfectly as expected except that when stopping displaying a cluster group that has no pins/data, the last cluster group added takes on the icon properties of the one removed. The files are removed by altering the fileList variable.

A very condensed code snippet bellow:

<template>
  <l-map ...>
	  <div v-for="(fileNumber, index) in fileList"
		  <Vue2LeafletMarkerCluster :options="options(fileNumber)">
			  <l-marker ...>
			  </l-marker>
		  </Vue2LeafletMarkerCluster>
	  </div>
  </l-map>
</template>


<script>
  options(index) {
        console.log(index);
        return {
          iconCreateFunction: function(cluster) {
            var childCount = cluster.getChildCount();

            var c= " marker-cluster-";
            if (childCount < 10) {
              c += "small";
            } else if (childCount < 100) {
              c += "medium";
            } else {
              c += "large";
            }
            console.log(index);
            return new L.DivIcon({
              html: `<div><span>${childCount}</span></div>`,
              className: `marker-cluster ${c} marker-cluster-index-${index}`,
              iconSize: new L.Point(40, 40)
            });
          }
        };
      },
</script>

The first console log always outputs the correct value however, when the bug occurs, the second outputs the value of the empty file.

Steps to recreate:

  1. have one file with geodata in and one without
  2. load the file without the data
  3. load the file with data
  4. unload the file without data
  5. OBSERVE cluster has the icon properties of the unloaded data (class of the remaining data has been overwritten with that of the empty data file)
@Chris-McQuiggan Chris-McQuiggan changed the title dynamic cluster icons with v-for Dynamic cluster icons with v-for Jan 31, 2020
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

1 participant