Skip to content

Markers not disappearing when removed as child components. #220

@ir-fuel

Description

@ir-fuel

this is the code I use:

  return (
    <Pane name="addressesPane" className="addressesPane">
      <MarkerClusterGroup
        key={Date.now()}
        chunkedLoading={true}
        elementsPlacementStrategy="original-locations"
        pane="housesPane"
        showCoverageOnHover={false}
        disableClusteringAtZoom={18}
        spiderLegPolylineOptions={{
          opacity: 0
        }}
      >
        {houseMarkers}
        {flatMarkers}
      </MarkerClusterGroup>
    </Pane>
  )

marker code looks like this:

    return <Marker
      key={address.id}
      position={[coords[1], coords[0]]}
      icon={L.divIcon({
        html: '<div class="w-4 h-4 rounded-full bg-green-500" style="width: 20px;height: 20px"></div>',
        className: ''
      })}
    >
    </Marker>

The markers show up correctly and get clustered. However if somewhere later the houseMarkers and flatMarkers are empty arrays, I see the component being called, but the markers stay on screen (I put logs right before the return of the component containing this code).

The only solution is to add key={Date.now} in MarkerClusterGroup.

this is happening in 5.0.0-rc.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions