dkahle / dkahle/ggmap

Wrong computation of zoom level (when location is bbox and zoom is 'auto')

Open
#93 1 comment 2 reactions 0 assignees View on GitHub
bug
Dominant language
R
Stars
778
Forks
234
PR merge metrics
No merged PRs in 30d

Description

### 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in R/get_map.R at line 178, where the automatic zoom is computed for a bounding-box location. Check the behavior with rectangular and square bounding boxes, then verify that the full rectangle remains visible when zoom is set to auto. Done means the zoom calculation no longer crops rectangular trips.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.