Tenía un vector en mi mapa con una imagen, pero necesitaba usar gif en lugar de una imagen estática, así que o.layer.vector por ol.Overlay , muestra mi gif pero no puedo agregarlo a mi layerSwitcher porque overlay no tiene propiedad de title , también con vector podría mostrar información usando forEachFeaturePixel pero ahora no puedo. ¿Hay alguna forma de agregar mi overlay a layerSwitcher y mostrar información al hacer clic en ella?
Esto es lo que tenía:
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); }); }Esta es mi nueva superposición:
lastPoint = new ol.Overlay({ position: ol.proj.fromLonLat(lastCoordinates, map.getView().getProjection()), positioning: 'center-center', element: document.getElementById('new-gif'), stopEvent: false });¿O hay alguna forma mejor de usar un gif en lugar de una imagen?