CodeforAustralia / school-finder

:eyes: Find schools by location
https://education.nsw.gov.au/school-finder
GNU General Public License v3.0
17 stars 7 forks source link

Map acting jumpy (panning in response to interaction with map marker / infowindows) #301

Closed Lilith-Palmer closed 7 years ago

Lilith-Palmer commented 7 years ago

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.

techieshark commented 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.

image

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:

image

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.

techieshark commented 7 years ago

For comparison, here's mapbox:

map image showing very small gap between info window and screen

techieshark commented 7 years ago

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.

Lilith-Palmer commented 7 years ago

I had a feeling this would be annoying

techieshark commented 7 years ago

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):

image

Lilith-Palmer commented 7 years ago

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.

Lilith-Palmer commented 7 years ago

Hm actually it's not stable - the navigation back to schools is slow (and nice) only sometimes. Not sure what the pattern is.

techieshark commented 7 years ago

@Lilith-Palmer yeah I think #298 is a pretty different issue; wouldn't expect this would have any impact on it

Lilith-Palmer commented 7 years ago

@techieshark it does seem to be better for the frame issue

Lilith-Palmer commented 7 years ago

frame issue Although.... maybe not. i think jumping at the bottom is a lesser issue than not reacting at all.

Lilith-Palmer commented 7 years ago

Disable for now - we can explore properly at a later point. Seeing how users interact with/react to the different options would be helpful.