Skip to content

Error connecting controller on map_controller.js when using leaflet #2925

Open
@michelcourtade

Description

@michelcourtade

Hi,

I have an issue since (I think) I upgraded my ux-map bundle to 2.22 via composer update symfony/* but I also rebuilt my docker images on my sf roject. I'm running sf 7.3.1 now (7.2 before)
I don't manage to display a Marker anymore on a map. The map is here but the markers don't display due to this error. If I try to display polygons, it works but I have to remove the code for the markers.
I have this error showing on my browser console, just after "symfony--ux-leaflet-map--map #initialize" :

Error connecting controller

TypeError: Cannot read properties of null (reading 'createIcon')
    at NewClass._initIcon (leaflet-src.js:7893:1)
    at NewClass.onAdd (leaflet-src.js:7800:1)
    at NewClass._layerAdd (leaflet-src.js:6897:1)
    at NewClass.whenReady (leaflet-src.js:4590:1)
    at NewClass.addLayer (leaflet-src.js:6955:1)
    at NewClass.addTo (leaflet-src.js:6835:1)
    at extended.doCreateMarker (map_controller.js:151:104)
    at extended.createMarker (map_controller.js:73:1)
    at map_controller.js:25:1
    at Array.forEach (<anonymous>)

{identifier: 'symfony--ux-leaflet-map--map', controller: extended, element: div.leaflet-container.leaflet-touch.leaflet-fade-anim.leaflet-grab.leaflet-touch-drag.leaflet-touch…}

Here is the code on my symfony controller :

$map = (new Map('default'))
            ->center(new Point(44.84581135142777, -0.5735346335130781))
            ->zoom(6)
            ->options(
                (new LeafletOptions())
                    ->tileLayer(new TileLayer(
                        url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
                        attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
                       options: ['maxZoom' => 19]
                    ))
            );
// $pager is a query builder result from doctrine repository
        foreach ($pager as $site) {
            $map->
            addMarker(new Marker(
                position: new Point($site->getLat(), $site->getLong()),
                title: $site->getName(),
                infoWindow: new InfoWindow(
                    content: '<p>' . $site->getName() . '<br />' . $site->getCustomer()->getName() . '</p>',
                )
            ));
        }

I tried to use symfony/ux-icon in order to define an Icon and pass it to the marker but it doesn't work either ...

I don't know what I'm missing.
Anyone help please ?

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions