mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 11:33:46 +01:00
Work on the layers implementation.
This commit is contained in:
28
src/Netzmacht/Contao/Leaflet/Dca/Layer.php
Normal file
28
src/Netzmacht/Contao/Leaflet/Dca/Layer.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2014 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Dca;
|
||||
|
||||
|
||||
class Layer
|
||||
{
|
||||
public function getVariants($dataContainer)
|
||||
{
|
||||
if ($dataContainer->activeRecord
|
||||
&& $dataContainer->activeRecord->tile_provider
|
||||
&& !empty($GLOBALS['LEAFLET_TILE_PROVIDERS'][$dataContainer->activeRecord->tile_provider]['variants'])
|
||||
) {
|
||||
return $GLOBALS['LEAFLET_TILE_PROVIDERS'][$dataContainer->activeRecord->tile_provider]['variants'];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,11 @@
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Map;
|
||||
use Netzmacht\LeafletPHP\Plugins\LeafletProviders\Provider;
|
||||
|
||||
class MapMapper extends AbstractMapper
|
||||
{
|
||||
@@ -102,5 +104,15 @@ class MapMapper extends AbstractMapper
|
||||
*/
|
||||
private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper)
|
||||
{
|
||||
$ids = deserialize($model->layers, true);
|
||||
$collection = LayerModel::findMultipleByIds($ids);
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $layer) {
|
||||
/** @var Provider $layer */
|
||||
$layer = $mapper->handle($layer);
|
||||
$map->addLayer($layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
src/Netzmacht/Contao/Leaflet/Model/LayerModel.php
Normal file
19
src/Netzmacht/Contao/Leaflet/Model/LayerModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2014 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Model;
|
||||
|
||||
|
||||
class LayerModel extends \Model
|
||||
{
|
||||
protected static $strTable = 'tl_leaflet_layer';
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user