forked from Snck3rs/contao-leaflet-maps
Add attribution adding to the javascript class.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
L.Contao = L.Class.extend( {
|
L.Contao = L.Class.extend( {
|
||||||
includes: L.Mixin.Events,
|
includes: L.Mixin.Events,
|
||||||
|
|
||||||
|
attribution: ' | <a href="http://contao-leaflet.netzmacht.de/" title="Leaflet extension for Contao CMS">netzmacht <em>creative</em></a>',
|
||||||
/**
|
/**
|
||||||
* The map registry.
|
* The map registry.
|
||||||
*/
|
*/
|
||||||
@@ -38,6 +39,8 @@ L.Contao = L.Class.extend( {
|
|||||||
* @returns {L.Contao}
|
* @returns {L.Contao}
|
||||||
*/
|
*/
|
||||||
addMap: function (id, map) {
|
addMap: function (id, map) {
|
||||||
|
map.map.attributionControl.setPrefix(map.map.attributionControl.options.prefix + this.attribution);
|
||||||
|
|
||||||
this.maps[id] = map;
|
this.maps[id] = map;
|
||||||
|
|
||||||
this.fire('map:added', { id: id, map: map});
|
this.fire('map:added', { id: id, map: map});
|
||||||
|
|||||||
@@ -30,32 +30,11 @@ class EncoderSubscriber implements EventSubscriberInterface
|
|||||||
return array(
|
return array(
|
||||||
BuildEvent::NAME => array(
|
BuildEvent::NAME => array(
|
||||||
array('startWrapper', 1000),
|
array('startWrapper', 1000),
|
||||||
array('addAttribution'),
|
|
||||||
array('endWrapper', -1000)
|
array('endWrapper', -1000)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add contao-leaflet attribution.
|
|
||||||
*
|
|
||||||
* @param BuildEvent $event
|
|
||||||
*/
|
|
||||||
public function addAttribution(BuildEvent $event)
|
|
||||||
{
|
|
||||||
$object = $event->getObject();
|
|
||||||
|
|
||||||
if ($object instanceof Map) {
|
|
||||||
$attribution = <<<HTML
|
|
||||||
map.map.attributionControl.setPrefix(
|
|
||||||
'<a href="http://www.leafletjs.com" title="A JS library for interactive maps">Leaflet</a> | ' +
|
|
||||||
'<a href="http://www.netzmacht.de/contao-leaflet" title="Leaflet extension for Contao CMS">netzmacht <em>creative</em></a>'
|
|
||||||
);
|
|
||||||
HTML;
|
|
||||||
$event->getOutput()->addLine($attribution);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the wrapper.
|
* Start the wrapper.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user