#10294·Leaflet

Controls added twice on extends Map

Author: savage13Created Jul 6, 2026Updated Jul 22, 2026
Labelsbugneeds triage

Checklist

  • I've looked at the documentation to make sure the behavior isn't documented and expected.
  • I'm sure this is an issue with Leaflet, not with my app or other dependencies (Angular, Cordova, React, etc.).
  • I've searched through the current issues to make sure this hasn't been reported yet.
  • I agree to follow the Code of Conduct that this project adheres to.

Steps to reproduce

Controls are added twice (Attribution and Zoom) on class NewMap extends Map {}

Using Leaflet 2.0.0-alpha.1

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="leaflet/leaflet.css"/>
    <style> #map { height: 100vh; } body { margin: 0; padding: 0}</style>
  </head>
  <body>
    <div id="map"></div>
    <script type="module">
      // Using 2.0.0-alpha.1
      import { Map } from './leaflet/leaflet.js';
      class NewMap extends Map { }
      new NewMap('map')
    </script>
  </body>
</html>

Results in

Looks like Class::callInitHooks() from Class initialize() calls initHooks for all prototypes of the Map and the new Class that extends Map. Resulting in the the controls being added twice.

Not sure if one should not extend Map. Apologies if this is already a known bug or already documented.

Do the Controls need to check it they have been added to the map? Does the Map need to know if that Control has been added or if that hook has already been called?

Expected behavior

Controls (Zoom and Attribution) should only be added once

Current behavior

Controls (Zoom and Attribution) are added twice

Minimal example reproducing the issue

No response

Environment

  • Leaflet version: Leaflet 2.0.0-alpha.1
  • Browser (with version): Firefox 152.0.4
  • OS/Platform (with version): Mac 15.5