Ongoing development.

This commit is contained in:
David Molineus
2014-12-29 12:17:40 +01:00
parent d289b67196
commit 633be6a2bc
32 changed files with 2057 additions and 23 deletions

7
module/assets/.htaccess Normal file
View File

@@ -0,0 +1,7 @@
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,23 @@
L.Contao = L.Class.extend( {
includes: L.Mixin.Events,
maps: {},
addMap: function (id, map) {
this.maps[id] = map;
this.fire('mapadded', { id: id, map: map});
return this;
},
getMap: function (id) {
if (typeof (this.map[id]) === 'undefined') {
return null;
}
return this.map[id]
}
});
window.ContaoLeaflet = new L.Contao();

View File

@@ -0,0 +1,8 @@
<?php
TemplateLoader::addFiles(
array(
'ce_leaflet_map' => 'system/modules/leaflet/templates',
'be_leaflet_geocode' => 'system/modules/leaflet/templates',
)
);

View File

@@ -1,5 +1,76 @@
<?php
/*
* Backend module.
*/
$GLOBALS['BE_MOD']['content']['leaflet'] = array(
'tables' => array('tl_leaflet_map')
'tables' => array('tl_leaflet_map'),
'icon' => 'system/modules/leaflet/assets/img/leaflet.png',
);
/*
* Content elements.
*/
$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\LeafletMapElement';
/*
* Models.
*/
$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel';
/*
* Leaflet mappers.
*
* Mappers do the translations between the database models and the leaflet definition.
*/
$GLOBALS['LEAFLET_MAPPERS'] = array();
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper';
/*
* Leaflet encoders.
*
* The encoders transforms the definitions into javascript. The encoders has to be an implementation of the
* EventDispatcherInterface of the event dispatcher.
*
* You can define the encoders using the syntax of the cca event dispatcher implementation.
*
* @see https://github.com/contao-community-alliance/event-dispatcher#event-subscriber-per-configuration
*/
$GLOBALS['LEAFLET_ENCODERS'] = array();
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Javascript\Subscriber\EncoderSubscriber';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\MapEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\ControlEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\GroupEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\RasterEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\VectorEncoder';
$GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber';
/*
* Leaflet assets.
*
* The leaflet definition are aware of the required javascript libraries. Register the assets so that they are
* loaded automatically.
*
* Each entry is an array of 2 values. The first is the resource. The second is a type. Supported types are:
* - url: An valid url.
* - file: An file path relative to the Contao Root.
* - source: Inline css/javascript.
*/
$GLOBALS['LEAFLET_ASSETS']['contao'] = array(
'javascript' => array(
array()
)
);
$GLOBALS['LEAFLET_ASSETS']['leaflet'] = array(
'css' => array(
array('http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css', 'url')
),
'javascript' => array(
array('http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js?3', 'url')
)
);

View File

@@ -0,0 +1,5 @@
<?php
return array(
'Netzmacht\Contao\Leaflet\Subscriber\BootSubscriber'
);

View File

@@ -0,0 +1,72 @@
<?php
use Netzmacht\Contao\Leaflet\Boot;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\MapService;
use Netzmacht\Javascript\Builder;
use Netzmacht\Javascript\Encoder;
use Netzmacht\LeafletPHP\Leaflet;
use Symfony\Component\EventDispatcher\EventDispatcher;
/** @var \Pimple $container */
global $container;
/*
* Leaflet map service is a simply api entry to to get the leaflet map from the database.
*/
$container['leaflet.map.service'] = $container->share(function ($container) {
return new MapService(
$container['leaflet.definition.mapper'],
$container['leaflet.definition.builder'],
$container['event-dispatcher']
);
});
/*
* The leaflet boot.
*/
$container['leaflet.boot'] = $container->share(function ($container) {
return new Boot($container['event-dispatcher']);
});
/*
* The definition mapper.
*/
$container['leaflet.definition.mapper'] = $container->share(function ($container) {
/** @var Boot $boot */
$boot = $container['leaflet.boot'];
$mapper = new DefinitionMapper($container['event-dispatcher']);
return $boot->initializeDefinitionMapper($mapper);
});
/*
* The local event dispatcher is used for the leaflet javascript encoding system.
*/
$container['leaflet.definition.builder.event-dispatcher'] = $container->share(function ($container) {
/** @var Boot $boot */
$boot = $container['leaflet.boot'];
$dispatcher = new EventDispatcher();
return $boot->initializeEventDispatcher($dispatcher);
});
/*
* The leaflet builder transforms the definition to javascript.
*/
$container['leaflet.definition.builder'] = $container->share(function($container) {
/** @var Boot $boot */
$boot = $container['leaflet.boot'];
$dispatcher = $container['leaflet.definition.builder.event-dispatcher'];
$encoder = new Encoder($dispatcher);
$builder = new Builder($encoder, $dispatcher);
$leaflet = new Leaflet($builder);
return $boot->initializeLeafletBuilder($leaflet);
});

22
module/dca/tl_content.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
$GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = array(
'type' => array('type', 'headline'),
'leaflet' => array('leaflet_map'),
'templates' => array(':hide', 'customTpl'),
'protected' => array(':hide', 'protected'),
'expert' => array(':hide', 'guests', 'cssID', 'space'),
'invisible' => array(':hide', 'invisible', 'start', 'start')
);
$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'],
'inputType' => 'select',
'exclude' => true,
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Content', 'getMaps'),
'eval' => array(
'tl_class' => 'w50',
'chosen' => true,
),
'sql' => "int(10) unsigned NOT NULL default '0'"
);

View File

@@ -5,7 +5,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
'config' => array(
'dataContainer' => 'Table',
'enableVersioning' => true,
'ctable' => array('tl_leaflet'),
// 'ctable' => array('tl_leaflet'),
'sql' => array
(
'keys' => array
@@ -70,33 +70,34 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
'metapalettes' => array(
'default' => array(
'name' => array('title', 'alias'),
'zoom' => array('center', 'zoom', 'adjustExtraZoom'),
'controls' => array('zoomControl', 'attributionControl', 'controls'),
'operation' => array(
'title' => array('title', 'alias'),
'zoom' => array('center', 'zoom', 'adjustZoomExtra'),
'controls' => array('zoomControl', 'controls'),
'interaction' => array(
'dragging',
'touchZoom',
'scrollWheelZoom',
'doubleClickZoom',
'boxZoom',
'tap',
'adjustKeyboard'
'keyboard'
),
'behaviour' => array(
'behaviour' => array(
'trackResize',
'popupOnClick',
'closeOnClick',
'bounceAtZoomLimits'
),
'experts' => array(
'cache',
'options'
'experts' => array(
'options',
'detachLibraries',
'cache'
)
),
),
'metasubpalettes' => array(
'adjustKeyboard' => array('keyboard', 'keyboardPanOffset', 'keyboardZoomOffset'),
'adjustExtraZoom' => array('minZoom', 'maxZoom'),
'keyboard' => array('keyboardPanOffset', 'keyboardZoomOffset'),
'adjustZoomExtra' => array('minZoom', 'maxZoom'),
),
'fields' => array
@@ -114,7 +115,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['title'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory' => true, 'maxlength' => 255),
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'alias' => array
@@ -122,9 +123,82 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory' => true, 'maxlength' => 255),
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'center' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['center'],
'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"
),
'zoom' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Leaflet', 'getZoomLevels'),
'default' => '',
'eval' => array(
'maxlength' => 4,
'rgxp' => 'digit',
'tl_class' => 'w50',
'includeBlankOption' => true,
'nullIfEmpty' => true
),
'sql' => "int(4) NULL"
),
'adjustZoomExtra' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50 m12', 'submitOnChange' => true),
'sql' => "char(1) NOT NULL default ''"
),
'minZoom' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Leaflet', 'getZoomLevels'),
'eval' => array(
'maxlength' => 4,
'rgxp' => 'digit',
'tl_class' => 'w50',
'includeBlankOption' => true,
'nullIfEmpty' => true
),
'sql' => "int(4) NULL"
),
'maxZoom' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Leaflet', 'getZoomLevels'),
'eval' => array(
'maxlength' => 4,
'rgxp' => 'digit',
'tl_class' => 'w50',
'includeBlankOption' => true,
'nullIfEmpty' => true
),
'sql' => "int(4) NULL"
),
'dragging' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'],
@@ -147,18 +221,22 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['scrollWheelZoom'],
'exclude' => true,
'inputType' => 'checkbox',
'inputType' => 'select',
'options' => array('1', '', 'center'),
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'],
'default' => true,
'eval' => array('tl_class' => 'w50'),
'eval' => array('tl_class' => 'w50', 'helpwizard' => true,),
'sql' => "char(1) NOT NULL default ''"
),
'doubleClickZoom' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['doubleClickZoom'],
'exclude' => true,
'inputType' => 'checkbox',
'inputType' => 'select',
'options' => array('1', '', 'center'),
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'],
'default' => true,
'eval' => array('tl_class' => 'w50'),
'eval' => array('tl_class' => 'w50', 'helpwizard' => true,),
'sql' => "char(1) NOT NULL default ''"
),
'boxZoom' => array
@@ -179,14 +257,95 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
'eval' => array('tl_class' => 'w50'),
'sql' => "char(1) NOT NULL default ''"
),
'adjustKeyboard' => array
'trackResize' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustKeyboard'],
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['trackResize'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50'),
'sql' => "char(1) NOT NULL default '1'"
),
'bounceAtZoomLimits' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50'),
'sql' => "char(1) NOT NULL default '1'"
),
'closeOnClick' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['closeOnClick'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50'),
'sql' => "char(1) NOT NULL default '1'"
),
'keyboard' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboard'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50', 'submitOnChange' => true),
'sql' => "char(1) NOT NULL default ''"
),
'keyboardPanOffset' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardPanOffset'],
'exclude' => true,
'inputType' => 'text',
'default' => 80,
'eval' => array('mandatory' => true, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'clr w50'),
'sql' => "int(4) NOT NULL default '80'"
),
'keyboardZoomOffset' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardZoomOffset'],
'exclude' => true,
'inputType' => 'text',
'default' => 1,
'eval' => array('mandatory' => true, 'maxlength' => 4, 'rgxp' => 'digit', 'tl_class' => 'w50'),
'sql' => "int(4) NOT NULL default '1'"
),
'zoomControl' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50'),
'sql' => "char(1) NOT NULL default '1'"
),
'options' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['options'],
'exclude' => true,
'inputType' => 'textarea',
'default' => true,
'eval' => array('tl_class' => 'clr lng', 'allowHtml'=>true, 'style' => 'min-height: 40px;'),
'sql' => "char(1) NOT NULL default ''"
),
'detachLibraries' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['detachLibraries'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => false,
'eval' => array('tl_class' => 'w50'),
'sql' => "char(1) NOT NULL default ''"
),
'cache' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['cache'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => false,
'eval' => array('tl_class' => 'w50', 'submitOnChange' => true),
'sql' => "char(1) NOT NULL default '0'"
),
),
);

View File

@@ -0,0 +1,4 @@
<?php
$GLOBALS['TL_LANG']['MOD']['leaflet'][0] = 'Leaflet maps';
$GLOBALS['TL_LANG']['MOD']['leaflet'][1] = 'Manage Leaflet maps';

View File

@@ -0,0 +1,49 @@
<?php
$GLOBALS['TL_LANG']['tl_leaflet_map']['title_legend'] = 'Title';
$GLOBALS['TL_LANG']['tl_leaflet_map']['interaction_legend'] = 'Interaction controls';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom_legend'] = 'Center and zoom';
$GLOBALS['TL_LANG']['tl_leaflet_map']['title'][0] = 'Title';
$GLOBALS['TL_LANG']['tl_leaflet_map']['title'][1] = 'Title of the map.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'][0] = 'Alias';
$GLOBALS['TL_LANG']['tl_leaflet_map']['alias'][1] = 'Alias of the map.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['center'][0] = 'Center';
$GLOBALS['TL_LANG']['tl_leaflet_map']['center'][1] = 'Initial geographical center of the map. Comma separated coordinates.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'][0] = 'Dragging';
$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'][1] = 'Whether the map be draggable with mouse/touch or not.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['touchZoom'][0] = 'Touch zoom';
$GLOBALS['TL_LANG']['tl_leaflet_map']['touchZoom'][1] = 'Whether the map can be zoomed by touch-dragging with two fingers.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['scrollWheelZoom'][0] = 'Scroll wheel zoom';
$GLOBALS['TL_LANG']['tl_leaflet_map']['scrollWheelZoom'][1] = 'Whether the map can be zoomed by using the mouse wheel.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['doubleClickZoom'][0] = 'Double click zoom';
$GLOBALS['TL_LANG']['tl_leaflet_map']['doubleClickZoom'][1] = 'Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom'][0] = 'Box zoom';
$GLOBALS['TL_LANG']['tl_leaflet_map']['boxZoom'][1] = 'Whether the map can be zoomed to a rectangular area specified by dragging the mouse while pressing shift.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['tap'][0] = 'Instant taps';
$GLOBALS['TL_LANG']['tl_leaflet_map']['tap'][1] = 'Enables mobile hacks for supporting instant taps.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['trackResize'][0] = 'Track window resize';
$GLOBALS['TL_LANG']['tl_leaflet_map']['trackResize'][1] = 'Whether the map automatically handles browser window resize to update itself.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['closeOnClick'][0] = 'Close popup on click';
$GLOBALS['TL_LANG']['tl_leaflet_map']['closeOnClick'][1] = 'Disable if you don\'t want popups to close when user clicks the map';
$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboard'][0] = 'Keyboard navigation';
$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboard'][1] = 'Makes the map focusable and allows users to navigate the map with keyboard arrows and +/- keys';
$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardPanOffset'][0] = 'Keyboard pan offset';
$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardPanOffset'][1] = 'Amount of pixels to pan when pressing an arrow key.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardZoomOffset'][0] = 'Keyboard zoom offset';
$GLOBALS['TL_LANG']['tl_leaflet_map']['keyboardZoomOffset'][1] = 'Number of zoom levels to change when pressing + or - key.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'][0] = 'Zoom level';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoom'][1] = 'Initial map zoom.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'][0] = 'Minimum zoom level';
$GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'][1] = 'Minimum zoom level of the map. Overrides any minZoom set on map layers.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'][0] = 'Maximum zoom level';
$GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'][1] = 'Maximum zoom level of the map. This overrides any maxZoom set on map layers.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'][0] = 'Add default zoom control';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'][1] = 'Whether the zoom control is added to the map by default.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0] = 'Disable';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][1] = 'Disable zoom function.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][0] = 'Enable';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][1] = 'Enable zoom function.';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][0] = 'Center';
$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][1] = 'If passed \'center\', it will zoom to the center of the view regardless of where the mouse was.';

View File

@@ -0,0 +1,58 @@
<?php $GLOBALS['TL_CSS'][] = 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css'; ?>
<?php $GLOBALS['TL_CSS'][] = 'system/modules/leaflet/assets/leaflet/control-geocoder/Control.Geocoder.css'; ?>
<?php $GLOBALS['TL_JAVASCRIPT'][] = 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js'; ?>
<?php $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/leaflet/assets/leaflet/control-geocoder/Control.Geocoder.js'; ?>
<div id="map_<?php echo $this->field; ?>" style="margin-top: 5px; width: 670px; height: 300px"></div>
<script>
var map = L.map('map_<?php echo $this->field; ?>').setView([0, 0], 2);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var geocoder = L.Control.geocoder({
collapsed: false,
placeholder: 'Suchen'
}).addTo(map);
geocoder.markGeocode = function(result) {
var container = document.createElement('div');
var link = document.createElement('button');
var element = $('<?php echo $this->field; ?>');
link.set('style', 'margin-left: 10px;');
link.appendText('übernehmen');
link.addEvent('click', function(e) {
e.stop();
element.set('value', result.center.lat + ',' + result.center.lng);
});
container.appendHTML(result.html || result.name);
container.appendChild(link);
if (this._geocodeMarker) {
map.removeLayer(this._geocodeMarker);
}
map.fitBounds(result.bbox, { padding: [0, 70]});
map.panTo(result.center);
this._geocodeMarker = new L.Marker(result.center)
.bindPopup(container, {
keepInView: true,
autoPanPaddingTopLeft: [0, 70]
})
.addTo(map)
.openPopup();
return this;
};
<?php if ($this->marker): ?>
geocoder._geocodeMarker = L.marker(<?php echo $this->marker; ?>).addTo(map);
map.setZoom(16);
map.panTo(<?php echo $this->marker; ?>);
<?php endif; ?>
</script>

View File

@@ -0,0 +1,6 @@
<div id="<?php echo $this->mapId; ?>" style="width: 100%; height: 400px;"></div>
<script>
<?php echo $this->map; ?>
</script>