0

I'm using ngx-leaflet v4.0.0 and Angular v6.1.10.

I have a map with several basemaps and a few custom overlays. I'm using the LayersControl from ngx-leaflet.

How can a user easily zoom to the bounds of a specific overlay layer? I know I can do it like this:

zoomToHome() {
  this.map.flyToBounds(this.homeLayer.getBounds());
  this.map.fitBounds(this.homeLayer.getBounds());
}

This is the click function of my custom button. And when adding my layers I save one as my home layer.

I would prefer to have a button in the layer control in front of each layer, when clicked the map goes to its bounds.

Can this be done with the current layers control or should I submit a feature request with Asymmetrik?

Paul Meems
  • 3,002
  • 4
  • 35
  • 66

1 Answers1

0

To add this, you'd likely need to find or author a plugin for Leaflet that would implement this functionality to the layers control.

AFAIK, this is not built in to Leaflet currently and ngx-leaflet only intends to expose Leaflet to Angular.io, not implement custom functionality to Leaflet.

reblace
  • 4,115
  • 16
  • 16