• Resolved svenatkins

    (@svenatkins)


    Hi Daniel
    I’m trying to do something like the following:

    umMap.on("zoomend", () => { marker.openPopup(); });

    But I get the message: Uncaught ReferenceError: marker is not defined
    Can you tell how to access the marker on the map?

    Greetings,
    Sven

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author 100plugins

    (@100plugins)

    Hi @svenatkins,

    The “zoomend” fires after any zoom event (see here). It doesn’t contain any info on markers.

    If you want to access all the available markers you could do this by:

    oumMap.eachLayer((layer) => {
      //do something with layer (=marker)
    })

    Best Regards,
    Daniel

    Thread Starter svenatkins

    (@svenatkins)

    Hi Daniel,
    I want to open the Popup of the marker after I flyto to a marker.
    The flyto event is triggerd by a slider.

    swiper.on('slideChangeTransitionStart', function () {
    	const lng = document.querySelector('.swiper-slide-active').getAttribute('data-longitude');
    	const lat = document.querySelector('.swiper-slide-active').getAttribute('data-latitude');
    	oumMap.flyTo([lat,lng], 18);
    });

    I don’t understand how to connect the end of the flyto with the layer.

    Hallo Daniel,
    ich m?chte das Popup des Markers ?ffnen nachdem ich zu ihm geflogen bin.
    Das “fliegen” lass ich von einem Slider starten der die Ziel Koordinaten mitgibt.
    Leider versteh ich nicht wie ich die Layer Funktion mit der flyto Funktion verknüpfen kann.
    Kannst du mir noch einen Tipp in die richtige Richtung geben?

    Danke und Grü?e.

    Plugin Author 100plugins

    (@100plugins)

    Hey @svenatkins,

    Let’s stick to english so that most people could read along (thanks for the german translation though).

    Unfortunately this will not work like you want it to. If you just zoom-in on some coordinates on the map there is no relation to the markers that may (or may not) exist on this specific point.

    You need to address the markers directly with a post_id (POPUP_MARKER_ID):

    oumMap.eachLayer(function(layer){
      if(layer.options.post_id && layer.options.post_id == POPUP_MARKER_ID){
        if(!layer._icon) {
          oumMap.fitBounds(layer.__parent._bounds);
        }else{
          oumMap.setView(layer.getLatLng(), 9);
        }
        layer.openPopup();
      }
    });

    So don’t use the oum.flyTo in your code. Instead use the snippet from above with the correct post_id (POPUP_MARKER_ID).

    Best Regards,
    Daniel

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘It is possible to access the Markers?’ is closed to new replies.