Support pointToLayer and onEachFeature customization.

This commit is contained in:
David Molineus
2015-01-09 16:10:17 +01:00
parent 717b02e615
commit 150e3706ed
5 changed files with 54 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
use Netzmacht\LeafletPHP\Plugins\Ajax\GeoJsonAjax;
use PhpSpec\Exception\Exception;
class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
{
@@ -73,7 +74,9 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
}
if ($definition instanceof GeoJson) {
$definition->setPointToLayer(new Expression('ContaoLeaflet.pointToLayer.bind(ContaoLeaflet)'));
if ($model->pointToLayer) {
$definition->setPointToLayer(new Expression($model->pointToLayer));
}
}
}

View File

@@ -74,8 +74,13 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
}
if ($definition instanceof GeoJson) {
$definition->setOnEachFeature(new Expression('ContaoLeaflet.onEachFeature.bind(ContaoLeaflet)'));
$definition->setPointToLayer(new Expression('ContaoLeaflet.pointToLayer.bind(ContaoLeaflet)'));
if ($model->pointToLayer) {
$definition->setPointToLayer(new Expression($model->pointToLayer));
}
if ($model->onEachFeature) {
$definition->setOnEachFeature(new Expression($model->onEachFeature));
}
}
}