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.

[leafletMapDefaults] Setting {trackResize: false} does not work #62

Open
@nmccready

Description

@nmccready

From @adgoncal on May 22, 2015 16:11

I noticed that if I set {trackResize: false} on map defaults, map.options.trackResize is still true and the resize event is still triggered.

Example:

angular.module('SomeModule', []);
angular.module('SomeModule').controller('SomeController', someController);

function someController($scope, leafletData) {
    angular.extend($scope, {
        defaults: {
            trackResize: false
        },
        center: {
            lat: 0,
            lng: 0,
            zoom: 1
        },
        layers: {
            baselayers: { ... }
        }
    });

    leafletData.getMap('mapID').then(function(map) {
        console.log(map.options.trackResize);
    });
}

Looking at the source code, it is clear that only a subset of the possible options are actually used on leafletMapDefaults.setDefaults. Wouldn't it be better to use angular.extend on the defaults that angular-leaflet-directive creates and the options that the user passes to the defaults object?

Something like this:

// ...
setDefaults: function (userDefaults, scopeId) {
    var newDefaults = _getDefaults();

    // Extend the defaults with userDefaults
    newDefaults = angular.extend({}, newDefaults, userDefaults);

    var mapId = obtainEffectiveMapId(defaults, scopeId);
    defaults[mapId] = newDefaults;
    return newDefaults;
}
// ...

Copied from original issue: tombatossals/angular-leaflet-directive#772

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions