download a static map from the Microsoft map tile server

Share:

Description

Query the Google server for a static map tile, defined primarily by its

center and zoom. Many additional arguments allow the user to customize

the map tile.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
GetBingMap(center = c(lat = 42, lon = -76), mapArea = c(45.219, 


    -122.325, 47.61, -122.107), size = c(640, 640), destfile, 


    zoom = 12, markers, path = "", maptype = c("Road", "Aerial ", 


        "AerialWithLabels")[1], format = c("png", "gif", "jpg", 


        "jpg-baseline", "png8", "png32")[1], extraURL = "", RETURNIMAGE = TRUE, 


    GRAYSCALE = FALSE, NEWMAP = TRUE, SCALE = 1, apiKey = NULL, 


    verbose = 0)

Arguments

center

optional center (lat first,lon second )

mapArea

A rectangular area specified as a bounding box (ll,ur). Required when a center point or set of route points are not specified

size

desired size of the map tile image. defaults to maximum size returned by the Gogle server, which is 640x640 pixels

destfile

File to load the map image from or save to, depending on NEWMAP.

zoom

Google maps zoom level.

markers

(optional) defines one or more markers to attach to the image at specified locations. This parameter takes a string of marker definitions separated by the pipe character (|)

path

(optional) defines a single path of two or more connected points to overlay on the image at specified locations. This parameter takes a string of point definitions separated by the pipe character (|)

maptype

defines the type of map to construct. See https://msdn.microsoft.com/en-us/library/ff701724.aspx

format

(optional) defines the format of the resulting image. By default, the Static Maps API creates GIF images. There are several possible formats including GIF, JPEG and PNG types. Which format you use depends on how you intend to present the image. JPEG typically provides greater compression, while GIF and PNG provide greater detail. This version supports only PNG.

extraURL

custom URL suffix

RETURNIMAGE

return image yes/no default: TRUE

GRAYSCALE

Boolean toggle; if TRUE the colored map tile is rendered into a black & white image, see RGB2GRAY

NEWMAP

if TRUE, query the Google server and save to destfile, if FALSE load from destfile.

SCALE

use the API's scale parameter to return higher-resolution map images. The scale value is multiplied with the size to determine the actual output size of the image in pixels, without changing the coverage area of the map

apiKey

optional API key (allows for higher rate of downloads)

verbose

level of verbosity

Value

map structure or URL used to download the tile.

Note

Note that size is in order (lon, lat)

Author(s)

Markus Loecher

See Also

GetMap.bbox

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
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
if (0){


  #for bing maps you will need your own API key, 


  #sign up at https://msdn.microsoft.com/en-us/library/ff428642.aspx


  apiKey = scan("C:/Users/loecherm/Dropbox/stuff/bingAPIkey.txt",what="")


  map1=GetBingMap(center=c(47.619048,-122.35384),zoom=15,apiKey=apiKey, 


                  verbose=1, destfile="Seattle.png") 


  PlotOnStaticMap(map1)


  m="&pp=47.620495,-122.34931;21;AA&pp=47.619385,-122.351485;;AB&pp=47.616295,-122.3556;22"


  map2=GetBingMap(center=c(47.619048,-122.35384),zoom=15,markers=m,apiKey=apiKey, 


                  verbose=1, destfile="Seattle2.png")


  


  PlotOnStaticMap(map2,lat=c(47.620495,47.619385,47.616295),


                  lon=c(-122.34931,-122.351485,-122.3556))


  	


  m="&pp=49.28273,-123.12074;22&pp=44.05207,-123.08675;22"


  


  map3= GetBingMap(center=c(47.677006,-122.125526),zoom=6,markers=m,apiKey=apiKey,


                   verbose=1, destfile="Seattle2.png")


  #plotmap(map=map3)


  m=cbind.data.frame(lat=c(49.28273,44.05207),lon=c(-123.12074,-123.08675),col=c(3:4))


  PlotOnStaticMap(map3, lat =m$lat,lon=m$lon,col=m$col,pch=19)


  


  #overlay traffic:


  #Get a map with Road imagery and traffic flow based on a query.


  #This example gets a map with road imagery based on a query result Bellevue, Washington. 


  #Traffic flow is also included on the map.


  


  #http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/Bellevue%20Washington


  #?mapLayer=TrafficFlow&key=BingMapsKey


  #note that we are using the extraURL argument to pass any extra parameters:


  map4 = GetBingMap(center="Bellevue%20Washington", zoom=12, extraURL="&mapLayer=TrafficFlow", 


                    apiKey=apiKey,verbose=1, destfile="BellevueTraffic.png")


  PlotOnStaticMap(map4)


  


  #Get a map with Road imagery that displays a route.


  #This example gets a map with road imagery that displays a driving 


  #route between the cities of Seattle and Redmond in Washington State. 


  


  #note that we are using the extraURL argument to pass any extra parameters:


  #http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes


  #?wp.0=Seattle,WA;64;1&wp.1=Redmond,WA;66;2&key=BingMapsKey 


  map5 = GetBingMap(center="Bellevue%20Washington", zoom=8, 


                    extraURL="&Routes?wp.0=Seattle,WA;64;1&wp.1=Redmond,WA;66;2", 


                  apiKey=apiKey,verbose=1, destfile="Seattle2Redmond.png")


  PlotOnStaticMap(map5)


}

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.