Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
How to display information using Overlay in Openlayers?

I had a vector in my map with an image but ned to use gif instead static image so i exchanged o.layer.vector for ol.Overlay, it displays my gif but I can't get any way to add it to my layerSwitcher because overlay doesn't have title property, also with vector i could display some information using forEachFeaturePixel but now i cant. Is there any way to add my overlay to layerSwitcher and display information clicking on it?

This is what i had:

lastPoint = new ol.layer.Vector({
            source: new ol.source.Vector({
                features: [new ol.Feature(
                    new ol.geom.Point(
                        ol.proj.fromLonLat(lastCoordinates, map.getView().getProjection())
                    )
                )]
            }),
            visible: true,
            title: "Evento sísmico",
            style: new ol.style.Style({
                image: new ol.style.Icon({
                    anchor: [0.5, 0.5],
                    size: [30, 28],
                    offset: [0.2, 0.2],
                    scale: 1,
                    src: "assets/img/red-point.png"
                }),
            }),
        })
addEarthqPoint = (e, map, clickedCoordinate, date, time, depth, magnitude, overlayLayerEarthq) => {
    map.forEachFeatureAtPixel(e.pixel, () => {
        overlayLayerEarthq.setPosition(clickedCoordinate);
        overlayTitleEarthq.innerHTML = "Detalle de evento: "
        overlayFeatureDate.innerHTML = "Fecha: " + date;
        overlayFeatureTime.innerHTML = "Hora (UTC-5): " + time;
        overlayFeatureDepth.innerHTML = "Profundidad: " + depth + " km";
        overlayFeatureMagnitude.innerHTML = "Magnitud: M " + magnitude;
    }, {
        layerFilter: (layerCandidate) => {
            return layerCandidate.get("title") === "Evento sísmico";
        }
    });
}
mapClicked = (overlayLayer, overlayLayerEarthq) => {
    map.on("click", function (e) {
        const clickedCoordinate = e.coordinate;

        overlayLayer.setPosition(undefined);
        overlayLayerEarthq.setPosition(undefined);

        /* using preview values to use into function */
        addEarthqPoint(e, map, clickedCoordinate, lastDate, lastTime, lastDepth, lastMagnitude, overlayLayerEarthq);
    });
}

This is my new Overlay:

    lastPoint = new ol.Overlay({
        position: ol.proj.fromLonLat(lastCoordinates, map.getView().getProjection()),
        positioning: 'center-center',
        element: document.getElementById('new-gif'),
        stopEvent: false
    });

Or is there any better way to use a gif instead an image?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda