/**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     if (!$definition instanceof Attribution) {
         return;
     }
     if ($model->disableDefault && $parent instanceof Map) {
         $parent->setAttributionControl(false);
     }
     $attributions = deserialize($model->attributions, true);
     foreach ($attributions as $attribution) {
         $definition->addAttribution($attribution);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     if (!$definition instanceof LayerGroup) {
         return;
     }
     $collection = LayerModel::findBy(array('pid=?', 'active=1'), array($model->id), array('order' => 'sorting'));
     if ($collection) {
         foreach ($collection as $layerModel) {
             $layer = $mapper->handle($layerModel);
             if ($layer instanceof Layer) {
                 $definition->addLayer($layer);
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     if (!$definition instanceof OverpassLayer) {
         return;
     }
     $amenityIconsMap = $this->buildAmenityIconsMap($model);
     $definition->setOption('amenityIcons', $amenityIconsMap);
     if ($model->pointToLayer) {
         $definition->setPointToLayer(new Expression($model->pointToLayer));
     }
     if ($model->onEachFeature) {
         $definition->setOnEachFeature(new Expression($model->onEachFeature));
     }
     if ($model->overpassPopup) {
         $definition->setOption('overpassPopup', new Expression($model->overpassPopup));
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     if ($definition instanceof GeoJson) {
         $collection = $this->loadVectorModels($model);
         if ($model->boundsMode) {
             $definition->setOption('boundsMode', $model->boundsMode);
         }
         if ($collection) {
             foreach ($collection as $item) {
                 $vector = $mapper->handle($item);
                 $feature = $mapper->convertToGeoJsonFeature($vector, $item);
                 if ($feature) {
                     $definition->addData($feature, true);
                 }
             }
         }
         $this->addCallbacks($definition, $model);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     if ($definition instanceof GeoJson) {
         if ($model->boundsMode) {
             $definition->setOption('boundsMode', $model->boundsMode);
         }
         $collection = $this->loadMarkerModels($model);
         if ($collection) {
             foreach ($collection as $item) {
                 $marker = $mapper->handle($item);
                 $point = $mapper->convertToGeoJsonFeature($marker, $item);
                 if ($point) {
                     $definition->addData($point, true);
                 }
             }
         }
         if ($model->pointToLayer) {
             $definition->setPointToLayer(new Expression($model->pointToLayer));
         }
     }
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function setReference(Definition $definition, EncodeReferenceEvent $event)
 {
     if ($definition instanceof AbstractIcon) {
         $event->setReference('icons.' . $definition->getId());
     }
 }
 /**
  * Convert a definition to a geo json feature.
  *
  * @param Definition $definition The leaflet definition object.
  * @param mixed      $model      The corresponding definition model.
  *
  * @return GeoJsonFeature
  * @throws \RuntimeException If a definition type is not supported.
  */
 public function convertToGeoJsonFeature(Definition $definition, $model)
 {
     if ($definition instanceof GeoJsonFeature) {
         $feature = $definition;
     } elseif ($definition instanceof ConvertsToGeoJsonFeature) {
         $feature = $definition->toGeoJsonFeature();
     } else {
         throw new \RuntimeException(sprintf('Definition of class "%s" could not be converted to a geo json feature.', get_class($definition)));
     }
     $event = new ConvertToGeoJsonEvent($definition, $feature, $model);
     $this->eventDispatcher->dispatch($event::NAME, $event);
     return $feature;
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function setReference(Definition $definition, EncodeReferenceEvent $event)
 {
     if ($definition instanceof Control) {
         $event->setReference('controls.' . $definition->getId());
     }
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function setReference(Definition $definition, EncodeReferenceEvent $event)
 {
     if ($definition instanceof Vector) {
         $event->setReference('layers.vector_' . $definition->getId());
     }
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function setReference(Definition $definition, EncodeReferenceEvent $event)
 {
     if ($definition instanceof LayerGroup) {
         $event->setReference('layers.' . $definition->getId());
     }
 }