The lab5ab package provides a RC class named address
to use geocoding and reverse geocoding from Google API.
In order to create an object of address class, you need to give either an character address or a numeric vector of latitude or longitude.
library(devtools) install_github("brbatv/lab5",force=TRUE) library(lab5ab) address_or_coordinates<-"Paris"
```r
my_address<-address$new(address_or_coordinates)
The constructor will recognize what is the type of the argument (address or coordinates) and tell you if you give wrong inputs. ### Add special filters You can give optional parameters to the constructor, and theses are the ones available in the google API documention. For extra reference, please see <https://developers.google.com/maps/documentation/geocoding/intro#RegionCodes> and <https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering> A example of use can be found below : ```r my_address<-address$new("Toledo",region="ES") my_address<-address$new("Santa Cruz",components="country:ES")
In order to change the API key, you'll need to open utilities.R and change the key inside the add_api_key_to_url
function. By default the key of the creator is used.
Address class has 3 fields : $Coordinates
, $Components
and $Formatted_Address
$Coordinates
gives back a named numeric vector of the most precise result found by Google.
$Formatted_Address
gives back a character of all possible results found by Google.
$Components
gives back a more detailed data frame on the location of the most precise result found by Google.
```r
my_address<-address$new("33 av des champs elysees Paris") my_address$Formatted_Address my_address$Components my_address$Coordinates
### Search by coordinates ```r #Search by coordinates my_address<-address$new(c(58.39784,15.57601)) my_address$Formatted_Address my_address$Components my_address$Coordinates
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.