angular-leaflet-directive icon indicating copy to clipboard operation
angular-leaflet-directive copied to clipboard

bounds is not set after initial map load

Open jasadams opened this issue 12 years ago • 4 comments

I know the way bounds and center was reworked recently. One side effect of this improvement is that after the inital load of my map, the bounds are not set. It is not until I pan or zoom the map that the bounds are set. I did a little initial investigation and it seems that the listener for the "boundsChanged" event in the bounds directive is not set up in time for the initial broadcast of this event when the center is set in the center directive. The listener is inside a Map.whenReady promise and the map is not ready when the initial center is set.

jasadams avatar Mar 25 '14 13:03 jasadams

If I move the code that sets up the listener to just after the getMap promise it seems to work ok. I thought this may be safe because we shouldn't get a boundsChanged event until the map and the centerController are ready anyway. However, I am not familiar enough with the code to know the potential downsides to this. I have applied this patch in my fork and am using it in my project until there is a more permanent fix in this project.

jasadams avatar Mar 25 '14 13:03 jasadams

I am actually having this same issue, to fix it inside my Ionic application I check for missing bounds on map moveEnd and re-set it.

            var trueBounds = map.getBounds();
            var trueNE = trueBounds.getNorthEast();
            var trueSW = trueBounds.getSouthWest();

            $scope.map.bounds = {
                northEast: {
                    lat: trueNE.lat,
                    lng: trueNE.lng
                },
                southWest: {
                    lat: trueSW.lat,
                    lng: trueSW.lng
                }
            };

iamjoeysox avatar Jul 09 '15 20:07 iamjoeysox

This issue was moved to angular-ui/ui-leaflet#16

nmccready avatar Oct 29 '15 16:10 nmccready

I'm going to rework&redesign angular-leaflet-directive to be compatible with Leaflet v1.0. It will mantain almost all its functionality, and will be compatible with the current features of the directive, but I must start from a fresh point, so I'm going to close this issue. If you think it must be worked with the new version, please reopen it.

tombatossals avatar Nov 04 '15 07:11 tombatossals