mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-30 03:54:10 +01:00
Use assets manager in the marker cluster layer mapper.
This commit is contained in:
@@ -93,7 +93,11 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLa
|
|||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper';
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper';
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper';
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
|
||||||
|
return new \Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper(
|
||||||
|
$GLOBALS['container'][\Netzmacht\Contao\Toolkit\DependencyInjection\Services::ASSETS_MANAGER]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Control mappers.
|
// Control mappers.
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper';
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\View\Assets\AssetsManager;
|
||||||
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
|
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
@@ -42,6 +43,25 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected static $type = 'markercluster';
|
protected static $type = 'markercluster';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assets manager.
|
||||||
|
*
|
||||||
|
* @var AssetsManager
|
||||||
|
*/
|
||||||
|
private $assetsManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MarkerClusterLayerMapper constructor.
|
||||||
|
*
|
||||||
|
* @param AssetsManager $assetsManager Assets manager.
|
||||||
|
*/
|
||||||
|
public function __construct(AssetsManager $assetsManager)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->assetsManager = $assetsManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -61,7 +81,6 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* @SuppressWarnings(PHPMD.Superglobals)
|
|
||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
@@ -83,7 +102,7 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$model->disableDefaultStyle) {
|
if (!$model->disableDefaultStyle) {
|
||||||
$GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css||static';
|
$this->assetsManager->addStylesheet('assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = LayerModel::findBy(
|
$collection = LayerModel::findBy(
|
||||||
|
|||||||
Reference in New Issue
Block a user