mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 19:43:50 +01:00
Add markers and vectors as feature to the layer.
This commit is contained in:
@@ -67,7 +67,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
if ($model->deferred) {
|
||||
|
||||
if ($model->pointToLayer) {
|
||||
$layer = new GeoJson($this->getElementId($model, $elementId) . '_1');
|
||||
$layer = new GeoJson($this->getElementId($model, $elementId));
|
||||
$layer->setPointToLayer(new Expression($model->pointToLayer));
|
||||
|
||||
return array($this->getElementId($model, $elementId), RequestUrl::create($model->id), array(), $layer);
|
||||
@@ -93,7 +93,11 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $item) {
|
||||
$definition->addLayer($mapper->handle($item));
|
||||
$marker = $mapper->handle($item);
|
||||
|
||||
if ($marker instanceof Marker) {
|
||||
$definition->addData($marker->toGeoJsonFeature(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
$layer = new GeoJson($this->getElementId($model, $elementId) . '_1');
|
||||
$layer = new GeoJson($this->getElementId($model, $elementId));
|
||||
$layer->setOptions($options);
|
||||
|
||||
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) {
|
||||
$vector = $mapper->handle($item);
|
||||
|
||||
if ($vector instanceof Layer) {
|
||||
$definition->addLayer($vector);
|
||||
if ($vector instanceof ConvertsToGeoJsonFeature) {
|
||||
$definition->addData($vector->toGeoJsonFeature(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user