I want to remove the "Leaflet.com"
that appears on the right bottom of the screen
here. How can I do that?
7 Answers
The Leaflet way: L.map('map', {attributionControl: false, etc...})
A simple $('.leaflet-control-attribution').hide()
or non jQuery document.getElementsByClassName( 'leaflet-control-attribution' )[0].style.display = 'none';
.
Vladimir himself says it's OK to remove it: https://groups.google.com/d/msg/leaflet-js/fA6M7fbchOs/JTNVhqdc7JcJ, but it seems like you should leave it or acknowledge Leaflet in some way.
-
Thank you for your answer. Your solution worked for me!! Commented Jul 11, 2020 at 13:07
-
5Thanks for sharing Vladimirs comment! Here is a way to only remove the
Leaflet
prefix:map.attributionControl.setPrefix(false)
leafletjs.com/reference.html#control-attribution-prefix– CoderPiCommented Jan 30, 2022 at 16:56
This is perfectly explained in the Leaflet API reference for attribution control.
If you just wanna remove "Leaflet" prefix then :
map.attributionControl.setPrefix('YOUR_ATTRIBUTION')
Where map
is an object returned by L.map(...)
call.
-
I like the attribution coupled with my tileLayer (I use OpenStreetMap), so I call
map.attributionControl.setPrefix()
with empty args to remove the Leaflet attribution– kevlenedCommented Aug 13, 2020 at 16:47
If you use leaflet on Angular you can disable it at this way:
this.map = new Map('mapId', {attributionControl: false});
tutorial here
(leafletMapReady)="onMapReady($event);"
[leafletOptions]="options"
import { Layer, tileLayer, Map, control } from 'leaflet';
...
options: any = {};
constructor() {
this.options['attributionControl'] = false;
}
...
onMapReady(map: Map) {
map.addControl(
control.attribution({
position: 'bottomright',
prefix: ''
})
);
}
If you use leaflet on TMS WEB Core (Delphi Programming), then you can use the following procedure:
procedure LeafletMapsAttribution(Map: TWebLeafletMaps; Enabled: Boolean);
var
Attribution: TJSHTMLElement;
DisplayStyle: String;
begin
Attribution := TJSHTMLElement(Map.ElementHandle.getElementsByClassName('leaflet-control-attribution')[0]);
if Enabled then DisplayStyle := 'block' else DisplayStyle := 'none';
Attribution.style.setProperty('display', DisplayStyle);
end;
To use this function, you simply pass your TWebLeafletMaps
component as the first param and the Enabled
status on the second param.
So to hide the attribution do LeafletMapsAttribution(Map, False)
and to show the attribution do LeafletMapsAttribution(Map, True)
.