Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
onclick on image passing dynamic parameters

I'm creating a contextmenu in leaflet that is dynamically created according to the region of the map that was clicked (basically it displays the features next to the click). The menu is created using popup.

Question: I need to call a function passing "value" object as parameter when user clicks on image

My Code:


            proximos = queryFeatures(e.latlng, 1)

            var contentHtml = ''
            var tipo_icon = ''

            proximos.forEach(function (value, index) {

                contentHtml = contentHtml + "<div class='container_menu'><div class='item_contextmenu_img'>"
                
                  **// call function with parameters on click this img:**

                contentHtml = contentHtml + "<img id=dst_" + index + " src={% static 'icons/icon_add_map.svg'%} class='add_icon' width='15' height='15'></div>"

                if (value.tipo == 'DMSCoord') {
                    tipo_icon = "{% static 'icons/icon-gps-location.svg'%}"
                }
                else if (value.tipo == 'airport') {
                    tipo_icon = "{% static 'icons/userpoint_Airport.svg'%}"
                } else if (value.tipo == 'waypoint') {
                    tipo_icon = "{% static 'icons/userpoint_waypoint.svg'%}"
                } else if (value.tipo == 'VOR') {
                    tipo_icon = "{% static 'icons/VOR.png'%}"
                }

                contentHtml = contentHtml + "<div class='item_contextmenu_img'><img src=" + tipo_icon + " width='15' height='15'></div>"

                contentHtml = contentHtml + "<div class='item_contextmenu_txt'>" + value.txtname + "</div></div>"

            })

            var popup = L.popup()
                .setLatLng(e.latlng)
                .setContent(contentHtml)
                .openOn(map);
        });
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda