mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-02 21:14:15 +01:00
Implement boundsMode fit.
This commit is contained in:
@@ -302,6 +302,30 @@ class Layer
|
||||
->execute($dataContainer->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bounds modes supported by the layer.
|
||||
*
|
||||
* @param \DataContainer $dataContainer The data container.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBoundsModes($dataContainer)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
if ($dataContainer->activeRecord && !empty($this->layers[$dataContainer->activeRecord->type]['boundsMode'])) {
|
||||
foreach ($this->layers[$dataContainer->activeRecord->type]['boundsMode'] as $mode => $enabled) {
|
||||
if ($enabled === true) {
|
||||
$options[] = $mode;
|
||||
} elseif ($enabled === 'deferred' && $dataContainer->activeRecord->deferred) {
|
||||
$options[] = $mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a button.
|
||||
*
|
||||
|
||||
@@ -51,4 +51,37 @@ class Marker
|
||||
|
||||
return $builder->getOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the coordinates.
|
||||
*
|
||||
* @param string $value The raw data.
|
||||
* @param \DataContainer $dataContainer The data container driver.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveCoordinates($value, $dataContainer)
|
||||
{
|
||||
$combined = array(
|
||||
'latitude' => null,
|
||||
'longitude' => null,
|
||||
'altitude' => null
|
||||
);
|
||||
|
||||
$values = trimsplit(',', $value);
|
||||
$keys = array_keys($combined);
|
||||
|
||||
if (count($values) >= 2 && count($values) <= 3) {
|
||||
for ($i = 0; $i < count($values); $i++) {
|
||||
$combined[$keys[$i]] = $values[$i];
|
||||
}
|
||||
}
|
||||
|
||||
\Database::getInstance()
|
||||
->prepare('UPDATE tl_leaflet_marker %s WHERE id=?')
|
||||
->set($combined)
|
||||
->execute($dataContainer->id);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user