forked from Snck3rs/contao-leaflet-maps
Implement as dynamic setting of the map bounds.
This commit is contained in:
@@ -63,6 +63,7 @@ class MapMapper extends AbstractMapper
|
||||
$this->buildCustomOptions($map, $model);
|
||||
$this->buildControls($map, $model, $builder, $bounds);
|
||||
$this->buildLayers($map, $model, $builder, $bounds);
|
||||
$this->buildBoundsCalculation($map, $model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,4 +151,23 @@ class MapMapper extends AbstractMapper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build map bounds calculations.
|
||||
*
|
||||
* @param Map $map The map being built.
|
||||
* @param MapModel $model The map model.
|
||||
*/
|
||||
private function buildBoundsCalculation(Map $map, MapModel $model)
|
||||
{
|
||||
$adjustBounds = deserialize($model->adjustBounds, true);
|
||||
|
||||
if (in_array('deferred', $adjustBounds)) {
|
||||
$map->setOption('adjustBounds', true);
|
||||
}
|
||||
|
||||
if (in_array('load', $adjustBounds)) {
|
||||
$map->calculateFeatureBounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user