mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-02 04:53:56 +01:00
Do not limit to marker and vector model.
This commit is contained in:
@@ -14,8 +14,6 @@ namespace Netzmacht\Contao\Leaflet\Subscriber;
|
|||||||
use Netzmacht\Contao\Leaflet\Dca\Vector;
|
use Netzmacht\Contao\Leaflet\Dca\Vector;
|
||||||
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
|
||||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
|
||||||
use Netzmacht\LeafletPHP\Definition\GeoJson\Feature;
|
use Netzmacht\LeafletPHP\Definition\GeoJson\Feature;
|
||||||
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
||||||
@@ -38,8 +36,7 @@ class GeoJsonSubscriber implements EventSubscriberInterface
|
|||||||
return array(
|
return array(
|
||||||
ConvertToGeoJsonEvent::NAME => array(
|
ConvertToGeoJsonEvent::NAME => array(
|
||||||
array('addPopup'),
|
array('addPopup'),
|
||||||
array('enrichMarker'),
|
array('enrichObjects'),
|
||||||
array('enrichVector'),
|
|
||||||
array('enrichCircle'),
|
array('enrichCircle'),
|
||||||
array('setModelData')
|
array('setModelData')
|
||||||
)
|
)
|
||||||
@@ -70,38 +67,20 @@ class GeoJsonSubscriber implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enrich marker with feature data and bounds information.
|
* Enrich map object with feature data and bounds information.
|
||||||
*
|
*
|
||||||
* @param ConvertToGeoJsonEvent $event The subscribed event.
|
* @param ConvertToGeoJsonEvent $event The subscribed event.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function enrichMarker(ConvertToGeoJsonEvent $event)
|
public function enrichObjects(ConvertToGeoJsonEvent $event)
|
||||||
{
|
{
|
||||||
$feature = $event->getGeoJson();
|
$feature = $event->getGeoJson();
|
||||||
$definition = $event->getDefinition();
|
$definition = $event->getDefinition();
|
||||||
$model = $event->getModel();
|
$model = $event->getModel();
|
||||||
|
|
||||||
if ($definition instanceof Marker && $model instanceof MarkerModel && $feature instanceof Feature) {
|
if (($definition instanceof Marker || $definition instanceof Vector)
|
||||||
$this->setDataProperty($model, $feature);
|
&& $model instanceof \Model && $feature instanceof Feature) {
|
||||||
$this->setBoundsInformation($model, $feature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enrich vector with feature data and bounds information.
|
|
||||||
*
|
|
||||||
* @param ConvertToGeoJsonEvent $event The subscribed event.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function enrichVector(ConvertToGeoJsonEvent $event)
|
|
||||||
{
|
|
||||||
$feature = $event->getGeoJson();
|
|
||||||
$definition = $event->getDefinition();
|
|
||||||
$model = $event->getModel();
|
|
||||||
|
|
||||||
if ($definition instanceof Vector && $model instanceof VectorModel && $feature instanceof Feature) {
|
|
||||||
$this->setDataProperty($model, $feature);
|
$this->setDataProperty($model, $feature);
|
||||||
$this->setBoundsInformation($model, $feature);
|
$this->setBoundsInformation($model, $feature);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user