Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Using a computed map id causes some misnamed events #235

@ezk84

Description

@ezk84

This happens with a computed id, for example:

    <leaflet id="{{:: mapId }}" center="center"></leaflet>

After this, map events will be named leafletDirectiveMap.{{:: mapId }}.<event name>. Note that marker events are not affected by this, they will be named correctly, e.g.: leafletDirectiveMarker.the-map.popupopen.

Check this plunkr for an MCVE.

I checked the code out and can trace this to one line in src/services/events/leafletMapEvents.js:

    var _addEvents =  function(map, mapEvents, contextName, scope, logic){
        leafletIterators.each(mapEvents, function(eventName) {
            var context = {};
            context[contextName] = eventName;
            map.on(eventName, _genDispatchMapEvent(scope, eventName, logic, map._container.id || ''), context); // <<< right here!
        });
    };

At the stage that this function is being called (linking of the main leaflet directive) the map._container.id still hasn't been updated by angular, but luckily the mapId has already been saved for us in scope.mapId by the link function earlier. So this should be a one line change (plus tests, of course).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions