# NOT RUN {
## Example 1
## quickMap code
## as example of third-party use of functions
quickMap <- function(lat, lon, show.data = FALSE, ...){
#get map
map <- getRGMapArg(lat, lon, ...)
#scale axis for map projection
map.axis.comps <- axis.components.loaMap(map)
map.axis <- function(components, ...)
axis.default(components = map.axis.comps, ...)
#scale data for map projection
temp <- LatLon2MercaptorXY(lat, lon)
lat <- temp$newY
lon <- temp$newX
#plot data on map
xyplot(lat~lon,
xlim = map$xlim, ylim = map$ylim,
aspect = map$aspect,
axis = map.axis,
panel = function(...){
panel.loaGBMapPlotRaster(map)
if(show.data)
panel.xyplot(...)
}, ...)
}
## Example 2
## Off-line GoogleMap examples
# Use a subsample of lat.lon.meuse
temp <- lat.lon.meuse[sample(1:155, 15),]
RgoogleMapsPlot(zinc~latitude*longitude, col.regions=c("grey", "darkred"),
data=temp, map=roadmap.meuse)
RgoogleMapsPlot(zinc~latitude*longitude, col.regions=c("grey", "darkred"),
panel=panel.binPlot,
data=temp, map=roadmap.meuse)
RgoogleMapsPlot(cadmium*50+copper*10+lead*2+zinc~latitude*longitude,
col.regions=c("grey", "darkred"),
key.z.main="Concentrations", panel.zcases = TRUE,
data=temp, map=roadmap.meuse)
RgoogleMapsPlot(cadmium*50+copper*10+lead*2+zinc~latitude*longitude,
col.regions=c("grey", "darkred"), panel=panel.zcasePiePlot,
data=temp, map=roadmap.meuse)
# Note 1:
# Here, the map argument is supplied so example works off-line.
# If not supplied and R is on-line, the MapPlots will get map
# from either Google or OpenStreetMap API. Repeat any of above
# without map argument when on-line. For example:
# }
# NOT RUN {
RgoogleMapsPlot(zinc~latitude*longitude, col.regions=c("grey", "darkred"),
data=lat.lon.meuse)
# }
# NOT RUN {
# (The map will appear slightly different because non-default
# size and maptype settings were used to make roadmap.meuse. See
# ?roadmap.meuse for details.)
# Note 2:
# To make a map for use with panel.loaBGMapPlotRaster or panel.loaBGMapPlotRaster
# without plotting use makeRGMapArg() or makeRGMapArg().
# To recover a map from a previously plotted loa MapPloy use loaMapArg().
# }
Run the code above in your browser using DataLab