ggmap
ggmap copied to clipboard
Wrong computation of zoom level (when location is bbox and zoom is 'auto')
Long story short
Briefly, this line https://github.com/dkahle/ggmap/blob/master/R/get_map.R#L178, should read
zoom <- min(zoomlon, zoomlat)
instead of
zoom <- max(zoomlon, zoomlat)
Problem
I'm plotting trips on Google Maps as base map. Trips' bboxes are sometimes 'squares' and sometimes 'rectangles'. When they are 'squares' most of the time, zoomlon = zoomlat and the whole trip is plotted. But when they are 'rectangles', sometimes zoomlon != zoomlat. For the trip to be fully plotted, and not cropped, the min zoom needs to be taken, not the max zoom.
I took that part of code that computes the zoom, changed the line to min(zoomlon, zoomlat)
and fed the computed zoom to get_map()
and that solved my issue.