Closed Lilith-Palmer closed 7 years ago
Yeah, I'm seeing this too - for example, this is about as close as a marker can be to the left side of the screen; if the marker is even 10px to the left and you hover over it, the map pans before opening the infowindow despite having plenty of room to display the infowindow.
I think behavior with markers near the top might be OK in terms the amount of space google maps tries to provide between the top of the infowindow and the top of the screen:
Getting the left margin between the infowindow and the side of the screen in the first example to match the top margin in the second example would be a start.
For comparison, here's mapbox:
I'm not finding an easy way to deal with this in google maps; our best option may be to disable the auto-pan functionality.
There is no option in the InfoWindowOptions object specification to control the auto pan margin (but we could set disableAutoPan: true
).
This jsfiddle shows the behavior we want (via a autopanMargin
option), but I found that in this comment on js-info-bubble which is a retired and unmaintained library, not part of google maps. It'd be more work to switch to that library, and we'd have no guarantee that it wouldn't break in a future release of google maps.
I'll push a branch with autopan disabled so we can try that.
I had a feeling this would be annoying
If we really needed to get this working, we could create our own auto-pan functionality and attach that to the mouseover
event for the map marker.
I also thought maybe if we set the maxWidth
for the marker, google maps might minimize the margin but no (here's with a zero width infowindow):
Disabling autopan works surprisingly well for icons close to the frame. It also seems to have slowed the autopan when you navigate away from schools altogether, which is quite nice.
Hm actually it's not stable - the navigation back to schools is slow (and nice) only sometimes. Not sure what the pattern is.
@Lilith-Palmer yeah I think #298 is a pretty different issue; wouldn't expect this would have any impact on it
@techieshark it does seem to be better for the frame issue
Although.... maybe not. i think jumping at the bottom is a lesser issue than not reacting at all.
Disable for now - we can explore properly at a later point. Seeing how users interact with/react to the different options would be helpful.
If an icon is close to the map frame border, and the user hovers over it, the map shifts so the icon is more centred. this is happening even when the location/name is clear and does not require more space.