Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change coordinate reference system (CRS) dynamically #401

Closed
muenchdo opened this issue Jun 27, 2014 · 3 comments
Closed

Change coordinate reference system (CRS) dynamically #401

muenchdo opened this issue Jun 27, 2014 · 3 comments

Comments

@muenchdo
Copy link

Is it possible to change the coordinate reference system (CRS) dynamically?

I have managed to initialize the map with different CRS by passing a Leaflet CRS object (e.g. L.CRS.EPSG3857) into defaults, but when I change this object the change is not reflected on the map.

There is a fiddle which does this with regular Leaflet.js, where this also requires to redraw the layer. I thought I could maybe do this by setting the baselayers object to {} and then adding my baselayers back in, but that also doesn't work.

Would be great if someone could help out!

@boxfish
Copy link

boxfish commented Aug 14, 2014

You can use the leafletData service to do it:

angular.module('myApp')
  .controller('MainCtrl', ['leafletData', function (leafletData) {
    function _changeMapCRS(map, crs) {
      map.options.crs = crs;
      map._initialTopLeftPoint = map._getNewTopLeftPoint(map.getCenter());
    }
    leafletData.getMap().then(function(map) {
      _changeMapCRS(map, L.CRS.EPSG3857);
    });  
}]);

@nmccready
Copy link
Contributor

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

@tombatossals
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants