I have a map created as a views block (Leaflet API, via IPGV&M) and I am showing some text and images in the popups (that get relatively big).
As shown in the attached pair of screen shots, the first time a marker is clicked the map does not move and if the popup is big it is cropped to the map frame (problematic behaviour).
The second (and any subsequent) time the same marker is clicked the opening of the popup causes the map to move down so as to show the top of the popup (correct bahaviour).
The above problem happens in Chrome, Firefox and Opera while in IE11 the map moves correctly from the first time.
Any ideas how could that be corrected?

Files: 
CommentFileSizeAuthor
#6 view-002.jpg756.61 KBarx-e
#6 view-001.jpg139.01 KBarx-e
ipgeoloc-leaflet-popup-01.jpg314.9 KBarx-e

Comments

arx-e created an issue. See original summary.

arx-e’s picture

I have found this post in stackoverflow.com that i think is related to the issue.
When the images are loaded in browser cache the popups autopan seems to work correctly.
There is a solution proposed in this answer but I lack the understanding of how it could be implemented here.

Unfortunately, if the image is not loaded yet in browser cache, the popup will open right away with default size, and adjust its size but not its position once the image is fully loaded and displayed. As a result, the popup is shifted and its arrow is misplaced compared to the marker it is bound to.

A simple workaround is to listen to the image "load" event and to re-open the popup at that moment:

popupContent = document.createElement("img");
popupContent.onload = function () {
layer.openPopup();
};
popupContent.src = "path/to/image";
layer.bindPopup(popupContent, {
maxWidth: "auto"
});

Any ideas that could help?

arx-e’s picture

Title: Big popups do not cause the map to move the first time they are opened » Size of images in leaflet popups not taken into account when is calculated for the first time
arx-e’s picture

Title: Size of images in leaflet popups not taken into account when is calculated for the first time » Size of images in leaflet popups not taken into account when autopan is calculated for the first time
glompos21’s picture

I want to do the same thing as you did on the popup
Can you please provide more information on how to do it?

arx-e’s picture

FileSize
139.01 KB
756.61 KB

@glompos21 You can include in the popup the fields you want by enabling one of the following two options in the view's format settings (Format: Map (Leaflet API, via IPGV&M) | Settings):

"Display non-excluded fields in a pop-up balloon above the marker, when clicked."
"Display non-excluded fields in a pop-up balloon above the marker, when hovered."

Have a look at the two additional settings screenshots I am uploading (view-001.jpg and view-002.jpg).

arx-e’s picture

Anybody any idea on how this issue could be solved?
Or where and who else could I ask for help?

In the meantime I have changed the order so that the images go to the top of the balloon and the text fields closer to the marker so that the text has more chances to remain visible but still this is not a solution.