@@ -13,6 +13,11 @@ export var FeatureLayer = L.FeatureGroup.extend({
1313 2. for static templated feature: null
1414 3. for non-templated feature: layer- (with no src) or mapml file (with src)
1515 */
16+ // options.extent: when you use a FeatureLayer, you can either get it to calculate the
17+ // .layerBounds dynamically (the default), based on adds/removes of features from the layer/
18+ // or you can construct it with a bounds (via options.extent),
19+ // which will then remain static for the lifetime of the layer
20+
1621 L . setOptions ( this , options ) ;
1722 if ( this . options . static ) {
1823 this . _container = L . DomUtil . create (
@@ -53,7 +58,7 @@ export var FeatureLayer = L.FeatureGroup.extend({
5358 this . addData ( mapml , native . cs , native . zoom ) ;
5459 } else if ( ! mapml ) {
5560 this . isVisible = false ;
56- this . layerBounds = null ;
61+ this . layerBounds = this . options . extent ? this . options . extent : null ;
5762 this . zoomBounds = this . options . zoomBounds ;
5863 }
5964 } ,
@@ -273,14 +278,16 @@ export var FeatureLayer = L.FeatureGroup.extend({
273278 }
274279
275280 let layer = this . geometryToLayer ( mapml , options , nativeCS , + zoom , title ) ;
276- let ext = mapml . extent ,
277- xmin = ext . topLeft . pcrs . horizontal ,
278- ymin = ext . bottomRight . pcrs . vertical ,
279- xmax = ext . bottomRight . pcrs . horizontal ,
280- ymax = ext . topLeft . pcrs . vertical ,
281- bnd = L . bounds ( L . point ( xmin , ymin ) , L . point ( xmax , ymax ) ) ;
281+ if ( ! this . options . extent ) {
282+ let ext = mapml . extent ,
283+ xmin = ext . topLeft . pcrs . horizontal ,
284+ ymin = ext . bottomRight . pcrs . vertical ,
285+ xmax = ext . bottomRight . pcrs . horizontal ,
286+ ymax = ext . topLeft . pcrs . vertical ,
287+ bnd = L . bounds ( L . point ( xmin , ymin ) , L . point ( xmax , ymax ) ) ;
282288
283- this . layerBounds = this . layerBounds ? this . layerBounds . extend ( bnd ) : bnd ;
289+ this . layerBounds = this . layerBounds ? this . layerBounds . extend ( bnd ) : bnd ;
290+ }
284291 if ( layer ) {
285292 // if the layer is being used as a query handler output, it will have
286293 // a color option set. Otherwise, copy classes from the feature
0 commit comments