title: Multiple marker selection within a box in leaflet
body: <p>I need to select multiple markers in a map. Something like this: <a href="https://stackoverflow.com/questions/7976196/box-rectangle-draw-selection-in-google-maps">Box/Rectangle Draw Selection in Google Maps</a> but with Leaflet and OSM.</p>
  
  <p>I think it could be done by modifying the zoom box that appears when you shift click and drag in an OSM map, but I don't know how to do it.</p>
  
  <p>Edit:
  I rewrote the _onMouseUp function, as <a href="https://stackoverflow.com/users/996302/l-sanna">L. Sanna</a> suggested and ended up with something like this:</p>
  
  <pre><code>_onMouseUp: function (e) {
  
      this._finish();
  
      var map = this._map,
      layerPoint = map.mouseEventToLayerPoint(e);
  
      if (this._startLayerPoint.equals(layerPoint)) { return; }
  
      var bounds = new L.LatLngBounds(
      map.layerPointToLatLng(this._startLayerPoint),
      map.layerPointToLatLng(layerPoint));
  
      var t=0;
      var selected = new Array();
  
      for (var i = 0; i &lt; addressPoints.length; i++) {
          var a = addressPoints[i];
          pt = new L.LatLng(a[0], a[1]);
  
          if (bounds.contains(pt) == true) {
              selected[t] = a[2];
              t++;
          }
      }
  
      alert(selected.join('\n'))
  },
  </code></pre>