bluehalo / ngx-leaflet

Core Leaflet package for Angular.io
MIT License
774 stars 127 forks source link

how to custom/remove prefix in tileLayer attribution? #117

Closed sgrillon14 closed 6 years ago

sgrillon14 commented 6 years ago
LAYER_OCM = {
    id: 'opencyclemap',
    name: 'Open Cycle Map',
    enabled: true,
    layer: tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', {
        maxZoom: 18,
        attribution: 'Open Cycle Map'
    })
};

Official docs:

http://leafletjs.com/reference-1.0.0.html#map-attributioncontrol

2018-01-02_162848

2018-01-02_163406

reblace commented 6 years ago

The ngx-leaflet plugin doesn't affect this. You should look at Leaflet itself for this. But, I wouldn't be surprised if they don't allow you to get rid of it.

alexgoldstone commented 6 years ago

This is what I do:

ngOnInit() {
    this.options = {
        layers: [
            tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                maxZoom: 18,
                attribution:
                    'My attribution <a href="http://test.com" target="_blank">My Link</a>'
            })
        ],
        zoom: 5,
        center: latLng(46.879966, -121.726909),
        attributionControl: false
    };
}

onMapReady(map: Map) {
    this.map = map;
    this.map.addControl(
        control.attribution({
            position: 'bottomright',
            prefix: ''
        })
    );
}
sgrillon14 commented 6 years ago

This solution ready, thanks @alexgoldstone

  (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: ''
        })
    );
  }

2018-01-03_204117

orange-beans commented 5 years ago

Put the following code: document.getElementsByClassName( 'leaflet-control-attribution' )[0].style.fontSize = '0px';

antoine4ucsd commented 1 year ago

hello , any suggestion to do the same in R environment? thank you