1`MaxZoom` <-structure(function#computes the maximum zoom level which will contain the given lat/lon range 2### computes the maximum zoom level which will contain the given lat/lon range 3( 4 latrange, ##<< range of latitude values 5 lonrange, ##<< range of longitude values 6 size = c(640,640) ##<< desired size of the map tile image. defaults to maximum size returned by the Gogle server, which is 640x640 pixels 7){ 8 SinPhi = sin(latrange * pi /180); 9 normX = lonrange / 180; 10 normY = (0.5 * log(abs((1 + SinPhi) / (1 -SinPhi) )) ) / pi; 11 12 MaxZoom.lon <- floor(1 + log2(abs(size[1]/256/diff(normX)))); 13 MaxZoom.lat <- floor(1 + log2(abs(size[2]/256/diff(normY)))); 14 15 return(min(c(MaxZoom.lat=MaxZoom.lat,MaxZoom.lon=MaxZoom.lon))) 16### zoom level 17 }) 18 19