You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon toying around with ggmap, I realized in some instances the zoom level that is calculated is erroneous so that the returned map does not cover the complete range of latitude and longitude when it is provided as a bounding box. This was tested on Google Maps with "hybrid" maps but the behavior should be identical for all map providers.
The blame is tu put here, where the max should rather be min:
Replicable exemple (you'll need your own Google API key)
# Global variables, API key...
MAP_PROVIDER <- "google"
GOOGLE_API_KEY <- ""
if (MAP_PROVIDER == "google") {
register_google(key = GOOGLE_API_KEY)
}
# Example failing
gps_range <- c("left" = 46.00803,
"bottom" = -19.62127,
"right" = 46.11314,
"top" = -19.35588)
# Get and plot map
plot_map <- get_map(location = gps_range,
source = MAP_PROVIDER,
maptype = MAP_TYPE)
With that example, zoomlon is calculated at 11 and zoomlat at 13. The map that is fetched at a max of these two (13) has coordinates ranging latitude -19.540 through -19.440, and longitude 46.000 through 46.125. The latitude does not cover the expected extent.
Changing the max to min solves the issue.
Thanks for considering this !
The text was updated successfully, but these errors were encountered:
Hi,
Upon toying around with ggmap, I realized in some instances the zoom level that is calculated is erroneous so that the returned map does not cover the complete range of latitude and longitude when it is provided as a bounding box. This was tested on Google Maps with "hybrid" maps but the behavior should be identical for all map providers.
The blame is tu put here, where the
max
should rather bemin
:ggmap/R/get_map.R
Line 189 in 4cdb1fb
Replicable exemple (you'll need your own Google API key)
With that example,
zoomlon
is calculated at 11 andzoomlat
at 13. The map that is fetched at a max of these two (13) has coordinates ranging latitude -19.540 through -19.440, and longitude 46.000 through 46.125. The latitude does not cover the expected extent.Changing the max to min solves the issue.
Thanks for considering this !
The text was updated successfully, but these errors were encountered: