mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-28 19:13:55 +01:00
Fix handling of inactive layers.
This commit is contained in:
@@ -47,7 +47,7 @@ class LayersControlMapper extends AbstractControlMapper
|
||||
$arguments[2] = array();
|
||||
|
||||
/** @var ControlModel $model */
|
||||
$collection = $model->findLayers();
|
||||
$collection = $model->findActiveLayers();
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $layer) {
|
||||
|
||||
@@ -127,7 +127,7 @@ class MapMapper extends AbstractMapper
|
||||
*/
|
||||
private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
|
||||
{
|
||||
$collection = $model->findLayers();
|
||||
$collection = $model->findActiveLayers();
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $layer) {
|
||||
|
||||
@@ -27,4 +27,17 @@ class ControlModel extends AbstractActiveModel
|
||||
|
||||
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Model\Collection
|
||||
*/
|
||||
public function findActiveLayers()
|
||||
{
|
||||
$query = 'SELECT l.*, c.mode as controlMode FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_control_layer c ON l.id = c.lid WHERE c.cid=? AND l.active=1';
|
||||
$result = \Database::getInstance()
|
||||
->prepare($query)
|
||||
->execute($this->id);
|
||||
|
||||
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,17 @@ class MapModel extends \Model
|
||||
|
||||
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Model\Collection
|
||||
*/
|
||||
public function findActiveLayers()
|
||||
{
|
||||
$query = 'SELECT l.* FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_map_layer m ON l.id = m.lid WHERE m.mid=? AND l.active=1';
|
||||
$result = \Database::getInstance()
|
||||
->prepare($query)
|
||||
->execute($this->id);
|
||||
|
||||
return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user