forked from Snck3rs/contao-leaflet-maps
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->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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user