toutpt / angular-leaflet-light

angular <leaflet> directive that is just leaflet
http://toutpt.github.io/angular-leaflet-light/
14 stars 4 forks source link

map promise would be nice #6

Closed elasticrash closed 6 years ago

elasticrash commented 7 years ago

This is ideal for some of my projects, but I do have a small complain. Except if I am blind, I didn't see any way to call map before being initialized (which is a major drawback for random anync operations). When I say before I mean of course through a promise. So I had to create a Service that looks like this

...
        var _map = $q.defer();
        var _private = {
            getMap: function () {
                return _map.promise;
            }
        };
        return {
            getMap: function () {
                return _private.getMap();
            },
            setMap: function (map) {
                _map.resolve(map);
            }
}
...

the map is set inside the on-map-initialized function

model.customise = function (map) {
            mapService.setMap(map);
        };

and It is used like this

ServiceName.getMap().then(function (map) {
});

If I find a bit of spare time I might end up doing a pull request

jmfrancois commented 6 years ago

no news from you so I close the issue. Don't hesitate to contribute.