forked from Snck3rs/contao-leaflet-maps
Change multi polyline and multi polygone to work with leaflet v1.
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|||||||
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\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\MultiPolygon;
|
use Netzmacht\LeafletPHP\Definition\Vector\Polygon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MultiPolygonMapper maps the multi polygon database model to its definition.
|
* Class MultiPolygonMapper maps the multi polygon database model to its definition.
|
||||||
@@ -28,7 +28,7 @@ class MultiPolygonMapper extends MultiPolylineMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\MultiPolygon';
|
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polygon';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
@@ -49,7 +49,7 @@ class MultiPolygonMapper extends MultiPolylineMapper
|
|||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $filter);
|
||||||
|
|
||||||
if ($definition instanceof MultiPolygon) {
|
if ($definition instanceof Polygon) {
|
||||||
$this->createLatLngs($definition, $model);
|
$this->createLatLngs($definition, $model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|||||||
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\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\MultiPolyline;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MultiPolylineMapper maps the databse model it the multi polyline definition.
|
* Class MultiPolylineMapper maps the databse model it the multi polyline definition.
|
||||||
@@ -29,7 +29,7 @@ class MultiPolylineMapper extends AbstractVectorMapper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\MultiPolyline';
|
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polyline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer type.
|
* Layer type.
|
||||||
@@ -50,7 +50,7 @@ class MultiPolylineMapper extends AbstractVectorMapper
|
|||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $filter);
|
||||||
|
|
||||||
if ($definition instanceof MultiPolyline) {
|
if ($definition instanceof Polyline) {
|
||||||
$this->createLatLngs($definition, $model);
|
$this->createLatLngs($definition, $model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,24 +58,22 @@ class MultiPolylineMapper extends AbstractVectorMapper
|
|||||||
/**
|
/**
|
||||||
* Create lat lngs for the definition.
|
* Create lat lngs for the definition.
|
||||||
*
|
*
|
||||||
* @param MultiPolyline $definition The multi polyline.
|
* @param Polyline $definition The multi polyline.
|
||||||
* @param \Model $model The definition model.
|
* @param \Model $model The definition model.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function createLatLngs(MultiPolyline $definition, \Model $model)
|
protected function createLatLngs(Polyline $definition, \Model $model)
|
||||||
{
|
{
|
||||||
$latLngs = array();
|
foreach (deserialize($model->multiData, true) as $ring => $data) {
|
||||||
|
$latLngs = array_map(
|
||||||
foreach (deserialize($model->multiData, true) as $data) {
|
|
||||||
$latLngs[] = array_map(
|
|
||||||
function ($row) {
|
function ($row) {
|
||||||
return LatLng::fromString($row);
|
return LatLng::fromString($row);
|
||||||
},
|
},
|
||||||
explode("\n", $data)
|
explode("\n", $data)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
$definition->setLatLngs($latLngs);
|
$definition->addLatLngs($latLngs, $ring);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user