Work on the layers implementation.

This commit is contained in:
David Molineus
2014-12-29 16:22:16 +01:00
parent 9059c74e62
commit e5d11e8ed6
5 changed files with 262 additions and 26 deletions

View 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();
}
}

View File

@@ -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);
}
}
}
}

View 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';
}