Learn R Programming

plotGoogleMaps (version 1.3)

plotGoogleMaps: Create a plot of spatial data on Google Maps

Description

Plot htm output with Google Maps API and a plot of spatial data as a combination of users' data and Google Maps layers. Ready to use as local htm file or into your own website.

Usage

plotGoogleMaps(SP, 
              filename = '',
              zcol = 1,
              add = FALSE, 
              previousMap = NULL,
              colPalette = NULL,
              strokeColor = '#FFAA00',
              strokeOpacity = 1, 
              strokeWeight = 1,
              geodesic = TRUE, 
              clickable = TRUE,
              draggableMarker = FALSE,
              iconMarker='',
              flat = TRUE, 
              visible = TRUE, 
              zIndex = 'null',
              map.width = '80%',
              map.height = '100%',
              layerName = '', 
              control.width = '20%', 
              control.height = '100%', 
              zoom = 15, 
              fitBounds = TRUE,
              mapTypeId = 'HYBRID', 
              disableDoubleClickZoom = FALSE, 
              draggable = TRUE, 
              keyboardShortcuts = TRUE, 
              mapTypeControlOptions = 'DEFAULT',
              navigationControl = TRUE,
              navigationControlOptions = 'DEFAULT', 
              scaleControlOptions = 'STANDARD',
              noClear = FALSE,
              scrollwheel = TRUE, 
              streetViewControl = FALSE)

Arguments

Value

This function returns a list with HTML, JavaScript, Google Maps API key and else what is necessary for the final web map. The second output is htm file ready to use.

See Also

bubbleGoogleMaps, ellipseGoogleMaps, segmentGoogleMaps

Examples

Run this code
# Data preparation
# Point data
data(meuse)
coordinates(meuse)<-~x+y
proj4string(meuse) <- CRS('+init=epsg:28992')
# Line data
data(meuse.grid)
coordinates(meuse.grid)<-c('x','y')
meuse.grid<-as(meuse.grid,'SpatialPixelsDataFrame')
im<-as.image.SpatialGridDataFrame(meuse.grid['dist'])
cl<-ContourLines2SLDF(contourLines(im))
proj4string(cl) <- CRS('+init=epsg:28992')

# Create web map of Point data
m<-plotGoogleMaps(meuse,filename='myMap.htm') # open the myMap, see in working directory

# Combine point and line data
mapMeusePoints<- plotGoogleMaps(meuse,add=TRUE,mapTypeId='TERRAIN')
mapMeuseCl<- plotGoogleMaps(cl,previousMap=mapMeusePoints,filename='myMap2.htm')
# see results in your working directory

Run the code above in your browser using DataLab