View image on popup
See original GitHub issueI’ve been trying to add an image to a folium marker popup using the following command:
html = '<img src="image.png" style="width:400px;height:300px;">'
folium.Marker(location=(lat, lon), popup=folium.Popup(folium.element.IFrame(html=html, width=420, height=320), max_width=2000)).add_to(map)
Each time I open the saved “map.html” file in the browser and click on the marker, however, the popup shows an empty white rectangle without the image.
I even tried serving the file using “python3 -m http.server 8080” and navigating to the address “127.0.0.1:8080/map.html”, but I still see just the empty white rectangle.
Note that the file “image.png” is in the same directory as the “map.html” file.
Could you please let me know what I might be doing wrong? I’ve now been stuck with this for a few hours.
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
How to show an image in a pop-up window
Replace Open popup with the link text you'd like to use. ... You can add as many links as you like, make sure...
Read more >How To Create Modal Images - W3Schools
Modal Image A modal is a dialog box/popup window that is displayed on top of the current page. This example use most of...
Read more >HTML - JS How to open an image in an image popup by ...
Show activity on this post. A very simple way to popup a image when click on click here text. Save this answer. Show...
Read more >Click on the image to view full size in a popup ... - InsideTheDiv
To view an image in full size in a popup modal first we need to create a modal using HTML and CSS javascript...
Read more >How to Show Images on Click using HTML ? - GeeksforGeeks
We have to set “display: none” for the image. After that, when the user clicks on the button, we will call a JavaScript...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That ( plus the .decode() ) did the trick! Thank you very much.
@ocefpaf Sure. Here is a simplified version of my code (apologies if this is not ideal sscce format - I tried). Simplified in that I have replaced the part at the start with arbitrary inputs where in the full version lat/lon/etc are read from photo exif data. Same applies to values of width/height/res in the lower section for now. To run this you will just need three .jpg’s saved in the current directory.
For me, this generates the html map with 3 points in the correct position, but clicking them shows a white rectangle with a broken link (and also causes the map to pan away from the points).
EDIT: So it was just the specified width/height parameters which was causing the panning when clicking on the point (popup was too big for screen). Reducing these solves that. But I still haven’t solved the broken link.