Improve handling of bounds calculation. Layers have to whitelist, vectors/markers can set themselves to ignore.

This commit is contained in:
David Molineus
2015-01-21 18:21:28 +01:00
parent 5d1ccb1d54
commit b3eb4c8e61
12 changed files with 130 additions and 93 deletions

View File

@@ -80,6 +80,10 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
$options['onEachFeature'] = new Expression($model->onEachFeature);
}
if ($model->affectBounds) {
$options['affectBounds'] = (bool) $model->affectBounds;
}
if (!empty($options)) {
$layer = new GeoJson($this->getElementId($model, $elementId));
$layer->setOptions($options);
@@ -105,6 +109,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
) {
if ($definition instanceof GeoJson) {
$collection = $this->loadVectorModels($model);
$definition->setOption('affectBounds', (bool) $model->affectBounds);
if ($collection) {
foreach ($collection as $item) {
@@ -114,7 +119,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
$feature = $vector->toGeoJsonFeature();
if ($feature instanceof Feature) {
$feature->setProperty('affectBounds', (bool) $item->affectBounds);
$feature->setProperty('ignoreForBounds', (bool) $item->ignoreForBounds);
}
$definition->addData($feature, true);
@@ -150,7 +155,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
if ($vector instanceof GeoJsonFeature) {
if ($vector instanceof Feature) {
$vector->setProperty('affectBounds', (bool) $item->affectBounds);
$vector->setProperty('ignoreForBounds', (bool) $item->ignoreForBounds);
}
$feature->addFeature($vector);