https://github.com/cran/RgoogleMaps
Tip revision: fdac28afd3b48a5385b27dc8f03b9c5fd56e7d93 authored by Markus Loecher on 24 August 2012, 00:00:00 UTC
version 1.2.0.2
version 1.2.0.2
Tip revision: fdac28a
MaxZoom.R
`MaxZoom` <-structure(function#computes the maximum zoom level which will contain the given lat/lon range
### computes the maximum zoom level which will contain the given lat/lon range
(
latrange, ##<< range of latitude values
lonrange, ##<< range of longitude values
size = c(640,640) ##<< desired size of the map tile image. defaults to maximum size returned by the Gogle server, which is 640x640 pixels
){
SinPhi = sin(latrange * pi /180);
normX = lonrange / 180;
normY = (0.5 * log(abs((1 + SinPhi) / (1 -SinPhi) )) ) / pi;
MaxZoom.lon <- floor(1 + log2(abs(size[1]/256/diff(normX))));
MaxZoom.lat <- floor(1 + log2(abs(size[2]/256/diff(normY))));
return(min(c(MaxZoom.lat=MaxZoom.lat,MaxZoom.lon=MaxZoom.lon)))
### zoom level
})