Code style.

This commit is contained in:
David Molineus
2015-01-22 13:34:22 +01:00
parent 178da21895
commit 62e2b02732
9 changed files with 35 additions and 15 deletions

View File

@@ -102,7 +102,10 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
) {
if ($definition instanceof GeoJson) {
$collection = $this->loadVectorModels($model);
$definition->setOption('affectBounds', (bool) $model->affectBounds);
if ($model->affectBounds) {
$definition->setOption('affectBounds', true);
}
if ($collection) {
foreach ($collection as $item) {
@@ -120,13 +123,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
}
}
if ($model->pointToLayer) {
$definition->setPointToLayer(new Expression($model->pointToLayer));
}
if ($model->onEachFeature) {
$definition->setOnEachFeature(new Expression($model->onEachFeature));
}
$this->addCallbacks($definition, $model);
}
}
@@ -170,4 +167,23 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
{
return VectorModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
}
/**
* Add javascript callbacks.
*
* @param GeoJson $definition The definition.
* @param \Model $model The database model.
*
* @return void
*/
protected function addCallbacks(GeoJson $definition, \Model $model)
{
if ($model->pointToLayer) {
$definition->setPointToLayer(new Expression($model->pointToLayer));
}
if ($model->onEachFeature) {
$definition->setOnEachFeature(new Expression($model->onEachFeature));
}
}
}