yafred / leaflet-responsive-popup

This plugin overrides L.Popup to remove the need to move the map to be able to see the content of the popup.
https://yafred.github.io/leaflet-responsive-popup/
BSD 2-Clause "Simplified" License
90 stars 20 forks source link

Need help - Leaflet opening on center #17

Closed rivartnik closed 3 years ago

rivartnik commented 3 years ago

I am creating dynamic popups based on the response from DB, and I implemented a leaflet-responsive-popup which works fine when opening on edges (left, right, top), however, it does not function correctly on the bottom edge, and if for example opening on the middle of the screen. Here is image of bottom: https://postimg.cc/75xzR4RN

If I open in the middle the popup is opened but OVER the icon not on top. Sorry for the black dots on the image but I need to hide that data. LINK: https://postimg.cc/zySjLpsx

However, if I now leave the popup open and scroll then the popup gets positioned correctly?

https://postimg.cc/Z9s63QVx

Any idea why would be much appreciated?

    this.map = L.mapquest.map('map', {
      center: [25.73, 30.3],
      layers: [L.mapquest.tileLayer('map')],
      zoom: 2.5,
      minZoom: 3,
      maxZoom: 16,
      closePopupOnClick: false,
      doubleClickZoom: false,
      zoomControl: false
    });
    this.redIcon = L.divIcon({
      className: 'icn',
      iconSize: 20,
      iconAnchor: [10, 20],
       popupAnchor: [0, 0],
      html: '<div class="map-pin map-pin--with-icon map-pin--red"><span class="material-icons">close</span></div><div class="map-pin-pulse"></div>',
    });
    var popup = L.responsivePopup({
      hasTip: true,
      autoPan: true,
    }).setContent(
      fl => {
        const popupEl: NgElement & WithProperties<MyPopupComponent> = document.createElement('popup-element') as any;
        popupEl.object = object;
        popupEl.map = this.map;
        popupEl.takeFn = () => this.statusAndCount();
        popupEl.addEventListener('closed', () => document.body.removeChild(popupEl));
       /* document.body.appendChild(popupEl); */
         return popupEl;
      }
    );

    let tempMarker = L.marker([object.LATITUDE, object.LONGITUDE], {
      icon: tempIcon,
      draggable: false,
      zIndexOffset: object.Z_INDEX
    }).addTo(this.map).bindPopup(
      popup
      , {
        maxWidth: 800,
        minWidth: 700,
      })

    return tempMarker;
rivartnik commented 3 years ago

After much debugging, I found a problem.

The issue was that I needed to add min-height to my popup since the min-height property does not exist on leaflet popup. Will leave the post in case someone found it useful.