Add markers and vectors as feature to the layer.

This commit is contained in:
David Molineus
2015-01-18 23:19:52 +01:00
parent 05d3ddb870
commit d4c70f1f11
2 changed files with 9 additions and 5 deletions

View File

@@ -67,7 +67,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
if ($model->deferred) { if ($model->deferred) {
if ($model->pointToLayer) { if ($model->pointToLayer) {
$layer = new GeoJson($this->getElementId($model, $elementId) . '_1'); $layer = new GeoJson($this->getElementId($model, $elementId));
$layer->setPointToLayer(new Expression($model->pointToLayer)); $layer->setPointToLayer(new Expression($model->pointToLayer));
return array($this->getElementId($model, $elementId), RequestUrl::create($model->id), array(), $layer); return array($this->getElementId($model, $elementId), RequestUrl::create($model->id), array(), $layer);
@@ -93,7 +93,11 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
if ($collection) { if ($collection) {
foreach ($collection as $item) { foreach ($collection as $item) {
$definition->addLayer($mapper->handle($item)); $marker = $mapper->handle($item);
if ($marker instanceof Marker) {
$definition->addData($marker->toGeoJsonFeature(), true);
}
} }
} }

View File

@@ -80,7 +80,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
} }
if (!empty($options)) { if (!empty($options)) {
$layer = new GeoJson($this->getElementId($model, $elementId) . '_1'); $layer = new GeoJson($this->getElementId($model, $elementId));
$layer->setOptions($options); $layer->setOptions($options);
return array($this->getElementId($model, $elementId), RequestUrl::create($model->id), array(), $layer); return array($this->getElementId($model, $elementId), RequestUrl::create($model->id), array(), $layer);
@@ -108,8 +108,8 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
foreach ($collection as $item) { foreach ($collection as $item) {
$vector = $mapper->handle($item); $vector = $mapper->handle($item);
if ($vector instanceof Layer) { if ($vector instanceof ConvertsToGeoJsonFeature) {
$definition->addLayer($vector); $definition->addData($vector->toGeoJsonFeature(), true);
} }
} }
} }