Skip to content

TypeError: undefined is not an object (evaluating 'projection.fromLatLngToDivPixel') #910

Open

Description

@LeLunZ

When calling clearMarkers/addMarkers relatively early after the map is initialised, a error is thrown.
It seems even though the map is initialised, markerclusterer doesn't have a valid projection.


Environment details

Markerclusterer: 2.5.3

Steps to reproduce

  1. create a markerclusterer object.
  2. register mapInitialized Callback (in the callback call .clearMarkers or addMarkers)
  3. error is thrown when callback is called

Stack trace

latLngBoundsToPixelBounds — index.esm.js:233
extendBoundsToPaddedViewport — index.esm.js:194
getPaddedViewport — index.esm.js:202
calculate — index.esm.js:567
render — index.esm.js:872
clearMarkers — index.esm.js:862

Following these steps will guarantee the quickest resolution possible.

Thanks!

Activity

  1. added
    triage meI really want to be triaged.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Aug 14, 2024
  2. odingrey commented on Dec 15, 2025

    @odingrey

    This seems like an issue on render. It is guarding with map.getProjection() but then sending this.getProjection() to the algorithm. Meaning the parent overlay hasn't yet been given the projection.

  3. rtcpw commented on Dec 19, 2025

    @rtcpw

    What kind of workaround can we use in the meantime?

  4. odingrey commented on Dec 19, 2025

    @odingrey

    I blocked my render() on clusterer.getProjection().

    You just have to remember to set noDraw to true when you add markers. Oh and if it fails you might not render, so make sure you try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions