Check options before assigning them.

This commit is contained in:
David Molineus
2016-10-06 11:38:52 +02:00
parent 016d0f1435
commit 48a6a3a360

View File

@@ -14,6 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper;
use Netzmacht\Contao\Leaflet\Filter\Filter; use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Model\ControlModel; use Netzmacht\Contao\Leaflet\Model\ControlModel;
use Netzmacht\Contao\Leaflet\Model\MapModel; use Netzmacht\Contao\Leaflet\Model\MapModel;
use Netzmacht\JavascriptBuilder\Type\Expression;
use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\Control; use Netzmacht\LeafletPHP\Definition\Control;
use Netzmacht\LeafletPHP\Definition\Layer; use Netzmacht\LeafletPHP\Definition\Layer;
@@ -98,7 +99,11 @@ class MapMapper extends AbstractMapper
protected function buildCustomOptions(Map $map, MapModel $model) protected function buildCustomOptions(Map $map, MapModel $model)
{ {
if ($model->options) { if ($model->options) {
$map->setOptions(json_decode($model->options, true)); $options = json_decode($model->options, true);
if (is_array($options)) {
$map->setOptions($options);
}
} }
$map->setOption('dynamicLoad', (bool) $model->dynamicLoad); $map->setOption('dynamicLoad', (bool) $model->dynamicLoad);