Monday, 22 November 2021

Leaflet - get the most up-to-date image from the webcam thumbnail

I would like to have the webcam thumbnail on the map. I used the standard onEachFeature function with defining the popupContent variable where I placed the attribute. One of the elements in my GeoJSON file looks like this:

  "type": "Feature", "properties": { "id": 1, "Location": "Sumburg Head", "Provider": 
  "Shetland Webcams", "Stream": 1, "Refresh": null, "AzimuthI": 300, "AzimuthII": 360, 
  "Nightmode": 1, "AllSky": 0, "Available": 1, "Rotation": "except overnight", "Country": 
  "United Kingdom", "Importance": null, "Link": "https://www.shetlandwebcams.com/cliff-cam-3/"  
  }, "geometry": { "type": "Point", "coordinates": [ -1.274802004043399, 59.854703404497755 ] 
 } 
  } },
  { "type": "Feature", "properties": { "id": 2, "Location": "Soteag Cliff", "Provider": 
 "Shetland Webcams", "Stream": 1, "Refresh": null, "AzimuthI": 60, "AzimuthII": 120, 
 "Nightmode": 1, "AllSky": 0, "Available": 1, "Rotation": "except overnight", "Country": 
 "United Kingdom", "Importance": null, "Link" : "https://www.foto-webcam.eu/webcam/hochmuth/" 
 }, "geometry": { "type": "Point", "coordinates": [ -1.27255592832451, 59.856353055941931 ] } 
  }

and the major JS code:

  onEachFeature: function (pointFeature, layer) {
   var popupContent = "<p><h2 class='webcam_location'>" +
   pointFeature.properties.Location + "</h2></p>" + 
   "<h4 class='webcam_provider'>" + pointFeature.properties.Provider + "</h4>" +
   "<iframe src=" + pointFeature.properties.Link + "'&output=embed'height='200' width='300' 
    title='camera thumbnail'></iframe>"
  layer.bindPopup(popupContent);
 }

where I have picked up the hint from the link below:

Overcoming "Display forbidden by X-Frame-Options"

but the effect is still like you can see below:

enter image description here

I think the issue is similar to this one:

Get most recent frame from webcam

Is there any way to make the image webcam thumbnail valid? based on the most-recent webcam activity?

UPDATE:

I found a similar hint here:

Overcoming "Display forbidden by X-Frame-Options"

and consequently added the '&output=embed' to my link in the section, but regrettably, it doesn't work either.



from Leaflet - get the most up-to-date image from the webcam thumbnail

No comments:

Post a Comment