gvisMap: Google Maps with R

Description Usage Arguments Value Note Author(s) References See Also Examples

Description

The gvisMap function reads a data.frame and creates text output referring to the Google Visualisation API, which can be included into a web page, or as a stand-alone page.

The maps are the well known Google Maps.

Usage

1
2
gvisMap(data, locationvar='', tipvar='',
           options = list(), chartid)

Arguments

data

a data.frame. The data has to have at least two columns with location name (locationvar) and the variable to display the text in the tip icon (tipvar).

locationvar

column name of data with the geo locations to be analysed. The locations can be provide in two formats:

Format 1

'latitude:longitude'. See the example below.

Format 2

The first column should be a string that contains an address. This address should be as complete as you can make it.

tipvar

column name of data with the string text displayed over the tip icon.

options

list of configuration options for Google Map.

gvis.editor

a character label for an on-page button which opens an in-page dialog box that enables users to edit, change and customise the chart. By default no value is given and therefore no button is displayed.

Further possible components are, taken from https://google-developers.appspot.com/chart/interactive/docs/gallery/map.html#Configuration_Options:

enableScrollWheel

boolean. Default FALSE. If set to TRUE, enables zooming in and out using the mouse scroll wheel.

showTip

boolean. Default FALSE. If set to TRUE, shows the location description as a tool-tip when the mouse is positioned above a point marker.

showLine

boolean. Default FALSE. If set to TRUE, shows a Google Maps polyline through all the points.

lineColor

string default color. If showLine is TRUE, defines the line color. For example: '#800000'.

lineWidth

number. Default 10. If showLine is true, defines the line width (in pixels).

mapType

string. Default: 'hybrid'. The type of map to show. Possible values are 'normal', 'terrain', 'satellite' or 'hybrid'.

useMapTypeControl

boolean. Default FALSE. Show a map type selector that enables the viewer to switch between [map, satellite, hybrid, terrain]. When useMapTypeControl is FALSE (default) no selector is presented and the type is determined by the mapType option.

zoomLevel

number/ Default automatic. An integer indicating the initial zoom level of the map, where 0 is completely zoomed out (whole world) and 19 is the maximum zoom level. (See "Zoom Levels" in the Google Maps API.)

chartid

character. If missing (default) a random chart id will be generated based on chart type and tempfile

Value

gvisMap returns list of class "gvis" and "list".

An object of class "gvis" is a list containing at least the following components:

type

Google visualisation type, here 'Map'

chartid

character id of the chart object. Unique chart ids are required to place several charts on the same page.

html

a list with the building blocks for a page

header

a character string of a html page header: <html>...<body>,

chart

a named character vector of the chart's building blocks:

jsHeader

Opening <script> tag and reference to Google's JavaScript library.

jsData

JavaScript function defining the input data as a JSON object.

jsDrawChart

JavaScript function combing the data with the visualisation API and user options.

jsDisplayChart

JavaScript function calling the handler to display the chart.

jsFooter

End tag </script>.

jsChart

Call of the jsDisplayChart function.

divChart

<div> container to embed the chart into the page.

caption

character string of a standard caption, including data name and chart id.

footer

character string of a html page footer: </body>...</html>, including the used R and googleVis version and link to Google's Terms of Use.

Note

The Lat-Long pairs option loads maps much faster, especially with large data. We recommend that you use this option for large data sets. Please visit Google Maps API to find out how to transform your addresses to lat-long points. The map can display a maximum of 400 entries; if your data holds more than 400 rows, only the first 400 will be shown.

Author(s)

Markus Gesmann markus.gesmann@gmail.com,

Diego de Castillo decastillo@gmail.com

References

Google Map API: https://google-developers.appspot.com/chart/interactive/docs/gallery/map.html

Follow the link for Google's data policy.

See Also

See also print.gvis, plot.gvis for printing and plotting methods, gvisGeoMap and gvisIntensityMap for an alternative to gvisMap.

Further the packages:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Please note that by default the googleVis plot command
## will open a browser window and requires Internet
## connection to display the visualisation.
  
## Example with latitude and longitude information
## Plot Hurricane Andrew (1992) storm path:

data(Andrew)

M1 <- gvisMap(Andrew, "LatLong" , "Tip",
              options=list(showTip=TRUE, showLine=TRUE, enableScrollWheel=TRUE,
                           mapType='hybrid', useMapTypeControl=TRUE,
                           width=800,height=400))

plot(M1) 


## Example with address, here UK post-code and some html code in tooltip

df <- data.frame(Postcode=c("EC3M 7HA", "EC2P 2EJ"),
                 Tip=c("<a href='http://www.lloyds.com'>Lloyd's</a>", 
                 "<a href='http://www.guildhall.cityoflondon.gov.uk/'>Guildhall</a>"))
 
M2 <- gvisMap(df, "Postcode", "Tip",
              options=list(showTip=TRUE, mapType='normal',
              enableScrollWheel=TRUE))
 
plot(M2)

jburos/GoogleVis documentation built on May 18, 2019, 9:19 p.m.