ERROR TypeError: this.Getaddress is not a function

Getaddress function was working fine for over a year but after doing npm update and updating some packages is not working.

 drawMap(): void {
    let map ='map');
    Leaflet.tileLayer('https://{s}{z}/{x}/{y}.png', {

    map.locate({ setView: true });

    function onLocationError(e) {

    map.on('locationerror', onLocationError);
    map.on('dragend', function (MouseEvent) {

      this.Getaddress(map.getCenter()).then(data => {
        let content = data;


    Getaddress(latlng) {
        let url = '' + + '&lon=' + this.LatLng.lng + '&zoom=18&addressdetails=1';
        return new Promise(resolve =>
            .map(res => res.json())
            .subscribe(data => {

There are a lot of problems here, but probably the most urgent and relevant is that you are losing execution context. Never type the word “function” inside the body of one. Use fat arrow functions instead.

1 Like

I am not professional coder but interesting it.What I learned is by try and error.

Anyway, I am so thankful for your guide. :rose::hibiscus: