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

Add Shortcut to zoom to bounding box of _layerGroup #5

Open
nsubordin81 opened this issue May 11, 2015 · 0 comments
Open

Add Shortcut to zoom to bounding box of _layerGroup #5

nsubordin81 opened this issue May 11, 2015 · 0 comments

Comments

@nsubordin81
Copy link

It would be nice to have a flag or some other type of configurable option that you could pass in when instantiating the leaflet object that would listen for a crossfilter filter event or append to the redraw event and it would fit the bounds of the internally managed map to the layer group. The easiest way for me to add this in my own code was to just always do it in the redraw method of my local dc.leaflet.js, but it is not an elegant solution:

  _chart._doRedraw = function () {
//doRedraw function body. . . 
  if (_chart.cluster() && addList.length > 0) {
      _layerGroup.addLayers(addList);
    }
  //this is where the redraw function usually ends

  //create a featureGroup from the layers in the layer group so we can call .getBounds()
    var _boundFeatures = L.featureGroup(_layerGroup.getLayers());
  //the usual method for fitting the bounding box around the markers
    _chart.map().fitBounds(_boundFeatures.getBounds());
  }; //end doRedraw()
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

1 participant