mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 03:24:37 +01:00
Work on vectors integration.
This commit is contained in:
@@ -102,9 +102,30 @@ L.Contao = L.Class.extend( {
|
||||
* @returns {L.Marker}|{*}
|
||||
*/
|
||||
pointToLayer: function(feature, latlng) {
|
||||
var marker = L.marker(latlng, feature.properties.options);
|
||||
var type = 'marker';
|
||||
var marker = null;
|
||||
|
||||
if (feature.properties) {
|
||||
if (feature.properties.type) {
|
||||
type = feature.properties.type;
|
||||
}
|
||||
|
||||
// constructor arguments given, use them.
|
||||
if (feature.properties.arguments) {
|
||||
marker = L[type].apply(L[type], feature.properties.arguments);
|
||||
L.Util.setOptions(marker, feature.properties.options);
|
||||
}
|
||||
}
|
||||
|
||||
if (marker === null) {
|
||||
marker = L[type](latlng, feature.properties.options);
|
||||
}
|
||||
|
||||
if (feature.properties) {
|
||||
if (feature.properties.radius) {
|
||||
marker.setRadius(feature.properties.radius);
|
||||
}
|
||||
|
||||
if (feature.properties.icon) {
|
||||
var icon = this.getIcon(feature.properties.icon);
|
||||
|
||||
@@ -116,11 +137,21 @@ L.Contao = L.Class.extend( {
|
||||
this.bindPopupFromFeature(marker, feature);
|
||||
}
|
||||
|
||||
this.fire('marker:created', { marker: marker, feature: feature, latlng: latlng });
|
||||
this.fire('point:added', { marker: marker, feature: feature, latlng: latlng, type: type });
|
||||
|
||||
return marker;
|
||||
},
|
||||
|
||||
onEachFeature: function (feature, layer) {
|
||||
if (feature.properties) {
|
||||
L.Util.setOptions(layer, feature.properties.options);
|
||||
|
||||
this.bindPopupFromFeature(layer, feature);
|
||||
|
||||
this.fire('feature:added', { feature: feature, layer: layer});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind popup from feature definitions.
|
||||
*
|
||||
|
||||
@@ -30,6 +30,7 @@ $GLOBALS['TL_MODELS']['tl_leaflet_icon'] = 'Netzmacht\Contao\Leaflet\Model\Ic
|
||||
$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel';
|
||||
$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel';
|
||||
$GLOBALS['TL_MODELS']['tl_leaflet_marker'] = 'Netzmacht\Contao\Leaflet\Model\MarkerModel';
|
||||
$GLOBALS['TL_MODELS']['tl_leaflet_vector'] = 'Netzmacht\Contao\Leaflet\Model\VectorModel';
|
||||
|
||||
|
||||
/*
|
||||
@@ -42,12 +43,19 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ZoomControlMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ScaleControlMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LayersControlMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\AttributionControlMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper';
|
||||
|
||||
/*
|
||||
* Leaflet encoders.
|
||||
@@ -106,14 +114,34 @@ $GLOBALS['LEAFLET_LAYERS'] = array
|
||||
*
|
||||
* Supported leaflet control types. Register your type for the database driven definition here.
|
||||
*/
|
||||
$GLOBALS['LEAFLET_CONTROLS'] = array();
|
||||
$GLOBALS['LEAFLET_CONTROLS'][] = 'zoom';
|
||||
$GLOBALS['LEAFLET_CONTROLS'][] = 'layers';
|
||||
$GLOBALS['LEAFLET_CONTROLS'][] = 'scale';
|
||||
$GLOBALS['LEAFLET_CONTROLS'][] = 'attribution';
|
||||
$GLOBALS['LEAFLET_CONTROLS'] = array('zoom', 'layers', 'scale', 'attribution');
|
||||
|
||||
|
||||
/*
|
||||
* Leaflet icons.
|
||||
*
|
||||
* Supported leaflet icon types. Register you type for the database driven definition here.
|
||||
*/
|
||||
$GLOBALS['LEAFLET_ICONS'] = array('image', 'div');
|
||||
|
||||
|
||||
/*
|
||||
* Leaflet vectors.
|
||||
*
|
||||
* Supported leaflet vector types. Register you type for the database driven definition here.
|
||||
*/
|
||||
$GLOBALS['LEAFLET_VECTORS'] = array
|
||||
(
|
||||
'polyline',
|
||||
'polygon',
|
||||
'multiPolyline',
|
||||
'multiPolygon',
|
||||
'rectangle',
|
||||
'circle',
|
||||
'circleMarker'
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Leaflet tile layer providers.
|
||||
*/
|
||||
|
||||
@@ -129,7 +129,10 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array
|
||||
),
|
||||
'group extends default' => array(
|
||||
'+title' => array('groupType'),
|
||||
) ,
|
||||
),
|
||||
'vectors extends default' => array(
|
||||
'+active' => array('deferred'),
|
||||
),
|
||||
),
|
||||
|
||||
'metasubselectpalettes' => array(
|
||||
@@ -263,8 +266,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['deferred'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'eval' => array('tl_class' => 'w50', 'submitOnChange' => false),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
'default' => true,
|
||||
'eval' => array('tl_class' => 'w50', 'submitOnChange' => false, 'isBoolean' => true),
|
||||
'sql' => "char(1) NOT NULL default '1'"
|
||||
),
|
||||
'groupType' => array
|
||||
(
|
||||
|
||||
@@ -0,0 +1,393 @@
|
||||
<?php
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
||||
(
|
||||
'config' => array(
|
||||
'dataContainer' => 'Table',
|
||||
'enableVersioning' => true,
|
||||
'ptable' => 'tl_leaflet_layer',
|
||||
'sql' => array
|
||||
(
|
||||
'keys' => array
|
||||
(
|
||||
'id' => 'primary'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
'list' => array
|
||||
(
|
||||
'sorting' => array
|
||||
(
|
||||
'mode' => 4,
|
||||
'fields' => array('sorting'),
|
||||
'flag' => 1,
|
||||
'headerFields' => array('title', 'type'),
|
||||
'child_record_callback' => array('Netzmacht\Contao\Leaflet\Dca\Vector', 'generateRow'),
|
||||
),
|
||||
'label' => array
|
||||
(
|
||||
'fields' => array('title'),
|
||||
'format' => '%s',
|
||||
),
|
||||
'global_operations' => array
|
||||
(
|
||||
'all' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
||||
'href' => 'act=select',
|
||||
'class' => 'header_edit_all',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"'
|
||||
),
|
||||
),
|
||||
'operations' => array
|
||||
(
|
||||
'edit' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['edit'],
|
||||
'href' => 'act=edit',
|
||||
'icon' => 'edit.gif'
|
||||
),
|
||||
'copy' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['copy'],
|
||||
'href' => 'act=copy',
|
||||
'icon' => 'copy.gif'
|
||||
),
|
||||
'delete' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['delete'],
|
||||
'href' => 'act=delete',
|
||||
'icon' => 'delete.gif',
|
||||
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
|
||||
),
|
||||
'cut' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['cut'],
|
||||
'href' => 'act=paste&mode=cut',
|
||||
'icon' => 'cut.gif',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset()"',
|
||||
),
|
||||
'toggle' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['toggle'],
|
||||
'icon' => 'visible.gif',
|
||||
'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
|
||||
'button_callback' => \Netzmacht\Contao\DevTools\Dca::createToggleIconCallback(
|
||||
'tl_leaflet_vector',
|
||||
'active'
|
||||
)
|
||||
),
|
||||
'show' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['show'],
|
||||
'href' => 'act=show',
|
||||
'icon' => 'show.gif'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
'palettes' => array(
|
||||
'__selector__' => array('type')
|
||||
),
|
||||
|
||||
'metapalettes' => array(
|
||||
'default' => array(
|
||||
'title' => array('title', 'alias', 'type'),
|
||||
'data' => array(),
|
||||
'style' => array(
|
||||
':hide',
|
||||
'stroke',
|
||||
'color',
|
||||
'weight',
|
||||
'opacity',
|
||||
'dashArray',
|
||||
'fill',
|
||||
'lineCap',
|
||||
'lineJoin',
|
||||
),
|
||||
'popup' => array(':hide','addPopup'),
|
||||
'config' => array(':hide', 'clickable', 'className'),
|
||||
'active' => array('active')
|
||||
),
|
||||
|
||||
'polyline extends default' => array(
|
||||
'+config' => array('smoothFactor', 'noClip'),
|
||||
'data' => array('data')
|
||||
),
|
||||
|
||||
'multiPolyline extends polyline' => array(
|
||||
'data' => array('multiData')
|
||||
),
|
||||
|
||||
'polygon extends polyline' => array(),
|
||||
|
||||
'multiPolygon extends multiPolyline' => array(
|
||||
),
|
||||
|
||||
'rectangle extends polygon' => array(),
|
||||
|
||||
'circle extends default' => array(
|
||||
'+data' => array('coordinates', 'radius'),
|
||||
),
|
||||
|
||||
'circleMarker extends circle' => array(),
|
||||
),
|
||||
'metasubpalettes' => array(
|
||||
'addPopup' => array('popupContent'),
|
||||
'fill' => array('fillColor', 'fillOpacity',)
|
||||
),
|
||||
|
||||
'fields' => array
|
||||
(
|
||||
'id' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL auto_increment"
|
||||
),
|
||||
'tstamp' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL default '0'"
|
||||
),
|
||||
'pid' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL default '0'"
|
||||
),
|
||||
'sorting' => array
|
||||
(
|
||||
'sql' => "int(10) unsigned NOT NULL default '0'"
|
||||
),
|
||||
'title' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['title'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'alias' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['alias'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'type' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['type'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'eval' => array(
|
||||
'mandatory' => true,
|
||||
'tl_class' => 'w50',
|
||||
'includeBlankOption' => true,
|
||||
'submitOnChange' => true,
|
||||
'chosen' => true,
|
||||
),
|
||||
'options' => &$GLOBALS['LEAFLET_VECTORS'],
|
||||
'reference' => &$GLOBALS['TL_LANG']['leaflet_layer'],
|
||||
'sql' => "varchar(32) NOT NULL default ''"
|
||||
),
|
||||
'active' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['active'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'eval' => array('tl_class' => 'w50'),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
),
|
||||
'addPopup' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['addPopup'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'eval' => array('tl_class' => 'w50', 'submitOnChange' => true),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
),
|
||||
'popupContent' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popupContent'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => true, 'rte' => 'tinyMCE', 'helpwizard' => true, 'tl_class' => 'clr'),
|
||||
'explanation' => 'insertTags',
|
||||
'sql' => "mediumtext NULL"
|
||||
),
|
||||
'stroke' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['stroke'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'default' => true,
|
||||
'eval' => array('tl_class' => 'w50 m12'),
|
||||
'sql' => "char(1) NOT NULL default '1'"
|
||||
),
|
||||
'color' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['color'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'wizard' => array(
|
||||
\Netzmacht\Contao\DevTools\Dca::createColorPickerCallback(),
|
||||
),
|
||||
'eval' => array(
|
||||
'tl_class' => 'w50 wizard',
|
||||
'maxlength' => 7,
|
||||
'decodeEntities' => true
|
||||
),
|
||||
'sql' => "varchar(8) NOT NULL default ''"
|
||||
),
|
||||
'weight' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['weight'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'default' => 5,
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'clr w50'),
|
||||
'sql' => "int(4) NOT NULL default '5'"
|
||||
),
|
||||
'opacity' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['opacity'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'default' => '0.5',
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(4) NOT NULL default '0.5'"
|
||||
),
|
||||
'fill' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['fill'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
),
|
||||
'fillColor' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['fillColor'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'wizard' => array(
|
||||
\Netzmacht\Contao\DevTools\Dca::createColorPickerCallback(),
|
||||
),
|
||||
'eval' => array(
|
||||
'tl_class' => 'clr w50 wizard',
|
||||
'maxlength' => 7,
|
||||
'decodeEntities' => true
|
||||
),
|
||||
'sql' => "varchar(8) NOT NULL default ''"
|
||||
),
|
||||
'fillOpacity' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['weight'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'default' => '0.2',
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(4) NOT NULL default '0.2'"
|
||||
),
|
||||
'dashArray' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['dashArray'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 32, 'tl_class' => 'w50 clr'),
|
||||
'sql' => "varchar(32) NOT NULL default ''"
|
||||
),
|
||||
'lineCap' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['lineCap'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'options' => array('butt', 'round', 'square', 'inherit'),
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['lineCaps'],
|
||||
'eval' => array('mandatory' => false, 'tl_class' => 'w50 clr', 'includeBlankOption' => true, 'helpwizard'),
|
||||
'sql' => "varchar(8) NOT NULL default ''"
|
||||
),
|
||||
'lineJoin' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['lineJoin'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'options' => array('miter', 'round', 'bevel', 'inherit'),
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['lineJoins'],
|
||||
'eval' => array('mandatory' => false, 'tl_class' => 'w50', 'includeBlankOption' => true, 'helpwizard'),
|
||||
'sql' => "varchar(8) NOT NULL default ''"
|
||||
),
|
||||
'clickable' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['clickable'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'checkbox',
|
||||
'default' => true,
|
||||
'eval' => array('tl_class' => 'm12 w50'),
|
||||
'sql' => "char(1) NOT NULL default ''"
|
||||
),
|
||||
'className' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['className'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 64, 'tl_class' => 'w50'),
|
||||
'sql' => "varchar(64) NOT NULL default ''"
|
||||
),
|
||||
'coordinates' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['coordinates'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'save_callback' => array(
|
||||
array('Netzmacht\Contao\Leaflet\Dca\Leaflet', 'validateCoordinate')
|
||||
),
|
||||
'wizard' => array(
|
||||
array('Netzmacht\Contao\Leaflet\Dca\Leaflet', 'getGeocoder')
|
||||
),
|
||||
'eval' => array(
|
||||
'maxlength' => 255,
|
||||
'tl_class' => 'long clr',
|
||||
'nullIfEmpty' => true,
|
||||
),
|
||||
'sql' => "varchar(255) NULL"
|
||||
),
|
||||
'radius' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['radius'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'default' => 5,
|
||||
'eval' => array('mandatory' => false, 'maxlength' => 10, 'rgxp' => 'digit', 'tl_class' => 'clr w50'),
|
||||
'sql' => "int(10) NOT NULL default '5'"
|
||||
),
|
||||
'data' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['data'],
|
||||
'inputType' => 'textarea',
|
||||
'search' => false,
|
||||
'eval' => array('mandatory' => true, 'alwaysSave' => true),
|
||||
'sql' => "longblob NULL"
|
||||
),
|
||||
'multiData' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['multiData'],
|
||||
'inputType' => 'multiColumnWizard',
|
||||
'search' => false,
|
||||
'eval' => array(
|
||||
'mandatory' => true,
|
||||
'alwaysSave' => true,
|
||||
'flatArray' => true,
|
||||
'columnFields' => array
|
||||
(
|
||||
'data' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['data'],
|
||||
'inputType' => 'textarea',
|
||||
'search' => false,
|
||||
'eval' => array('alwaysSave' => true, 'style' => 'width:600px'),
|
||||
)
|
||||
)
|
||||
),
|
||||
'sql' => "longblob NULL"
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
21
src/Netzmacht/Contao/Leaflet/Dca/Vector.php
Normal file
21
src/Netzmacht/Contao/Leaflet/Dca/Vector.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Dca;
|
||||
|
||||
|
||||
class Vector
|
||||
{
|
||||
public function generateRow($row)
|
||||
{
|
||||
return sprintf('%s <span class="tl_gray">[%s]</span>', $row['title'], $row['type']);
|
||||
}
|
||||
}
|
||||
122
src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php
Normal file
122
src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
||||
use Netzmacht\Contao\Leaflet\Request\RequestUrl;
|
||||
use Netzmacht\Javascript\Type\Value\Reference;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection;
|
||||
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
||||
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
use Netzmacht\LeafletPHP\Plugins\Ajax\GeoJsonAjax;
|
||||
|
||||
class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
{
|
||||
/**
|
||||
* Class of the definition being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Group\GeoJson';
|
||||
|
||||
/**
|
||||
* Layer type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'vectors';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createInstance(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
|
||||
{
|
||||
if ($model->deferred) {
|
||||
$reflector = new \ReflectionClass('Netzmacht\LeafletPHP\Plugins\Ajax\GeoJsonAjax');
|
||||
$instance = $reflector->newInstanceArgs($this->buildConstructArguments($model, $mapper, $bounds));
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
return parent::createInstance($model, $mapper, $bounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $mapper,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
if ($definition instanceof GeoJsonAjax) {
|
||||
$definition->setUrl(RequestUrl::create($model->id));
|
||||
} elseif ($definition instanceof LayerGroup) {
|
||||
$collection = $this->loadVectorModels($model);
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $item) {
|
||||
$definition->addLayer($mapper->handle($item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($definition instanceof GeoJson) {
|
||||
$definition->setOnEachFeature(new Reference('ContaoLeaflet.onEachFeature', 'ContaoLeaflet'));
|
||||
$definition->setPointToLayer(new Reference('ContaoLeaflet.pointToLayer', 'ContaoLeaflet'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Model $model
|
||||
* @param DefinitionMapper $mapper
|
||||
* @param LatLngBounds $bounds
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handleGeoJson(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
|
||||
{
|
||||
$feature = new FeatureCollection();
|
||||
$collection = $this->loadVectorModels($model);
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $item) {
|
||||
$feature->addFeature($mapper->handle($item)->toGeoJson());
|
||||
}
|
||||
}
|
||||
|
||||
return $feature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Model $model
|
||||
*
|
||||
* @return \Model\Collection|null
|
||||
*/
|
||||
protected function loadVectorModels(\Model $model)
|
||||
{
|
||||
$collection = VectorModel::findBy(
|
||||
array('active=1', 'pid=?'),
|
||||
array($model->id),
|
||||
array('order' => 'sorting')
|
||||
);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
use Netzmacht\LeafletPHP\Definition\Vector\Path;
|
||||
|
||||
class AbstractVectorMapper extends AbstractTypeMapper
|
||||
{
|
||||
/**
|
||||
* Class of the model being build.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\VectorModel';
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this
|
||||
->addOptions('stroke', 'weight', 'opacity', 'clickable', 'className')
|
||||
->addConditionalOption('color')
|
||||
->addConditionalOption('lineCap')
|
||||
->addConditionalOption('lineJoin')
|
||||
->addConditionalOption('dashArray')
|
||||
->addConditionalOptions('fill', array('fill', 'fillColor', 'fillOpacity'))
|
||||
;
|
||||
}
|
||||
|
||||
protected function doBuild(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof Path) {
|
||||
if ($model->addPopup) {
|
||||
$definition->bindPopup($model->popupContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php
Normal file
56
src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLng;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
use Netzmacht\LeafletPHP\Definition\Vector\Circle;
|
||||
|
||||
class CircleMapper extends AbstractVectorMapper
|
||||
{
|
||||
/**
|
||||
* Class of the definition being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Circle';
|
||||
|
||||
/**
|
||||
* Layer type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'circle';
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->addOption('radius');
|
||||
}
|
||||
|
||||
protected function doBuild(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof Circle) {
|
||||
$definition->setLatLng(LatLng::fromString($model->coordinates));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLng;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
use Netzmacht\LeafletPHP\Definition\Vector\Circle;
|
||||
|
||||
class CircleMarkerMapper extends CircleMapper
|
||||
{
|
||||
/**
|
||||
* Class of the definition being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\CircleMarker';
|
||||
|
||||
/**
|
||||
* Layer type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'circleMarker';
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLng;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
use Netzmacht\LeafletPHP\Definition\Vector\MultiPolygon;
|
||||
|
||||
class MultiPolygonMapper extends MultiPolylineMapper
|
||||
{
|
||||
/**
|
||||
* Class of the definition being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\MultiPolygon';
|
||||
|
||||
/**
|
||||
* Layer type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'multiPolygon';
|
||||
|
||||
protected function doBuild(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof MultiPolygon) {
|
||||
$latLngs = array();
|
||||
|
||||
foreach (deserialize($model->multiData, true) as $data) {
|
||||
$latLngs[] = array_map(
|
||||
function ($row) {
|
||||
return LatLng::fromString($row);
|
||||
},
|
||||
explode("\n", $data)
|
||||
);
|
||||
}
|
||||
|
||||
$definition->setLatLngs($latLngs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLng;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
use Netzmacht\LeafletPHP\Definition\Vector\MultiPolyline;
|
||||
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
||||
|
||||
class MultiPolylineMapper extends AbstractVectorMapper
|
||||
{
|
||||
/**
|
||||
* Class of the definition being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\MultiPolyline';
|
||||
|
||||
/**
|
||||
* Layer type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'multiPolyline';
|
||||
|
||||
|
||||
protected function doBuild(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof MultiPolyline) {
|
||||
$latLngs = array();
|
||||
|
||||
foreach (deserialize($model->multiData, true) as $data) {
|
||||
$latLngs[] = array_map(
|
||||
function ($row) {
|
||||
return LatLng::fromString($row);
|
||||
},
|
||||
explode("\n", $data)
|
||||
);
|
||||
}
|
||||
|
||||
$definition->setLatLngs($latLngs);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php
Normal file
29
src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||
|
||||
class PolygonMapper extends PolylineMapper
|
||||
{
|
||||
/**
|
||||
* Class of the definition being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polygon';
|
||||
|
||||
/**
|
||||
* Layer type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'polygon';
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLng;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
||||
|
||||
class PolylineMapper extends AbstractVectorMapper
|
||||
{
|
||||
/**
|
||||
* Class of the definition being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Polyline';
|
||||
|
||||
/**
|
||||
* Layer type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'polyline';
|
||||
|
||||
|
||||
protected function doBuild(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof Polyline) {
|
||||
array_map(
|
||||
function ($row) use ($definition) {
|
||||
$definition->addLatLng(LatLng::fromString($row));
|
||||
},
|
||||
explode("\n", $model->data)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
src/Netzmacht/Contao/Leaflet/Model/VectorModel.php
Normal file
23
src/Netzmacht/Contao/Leaflet/Model/VectorModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package dev
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2015 netzmacht creative David Molineus
|
||||
* @license LGPL 3.0
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Model;
|
||||
|
||||
|
||||
class VectorModel extends \Model
|
||||
{
|
||||
/**
|
||||
* Model table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $strTable = 'tl_leaflet_vector';
|
||||
}
|
||||
Reference in New Issue
Block a user