Giter Club home page Giter Club logo

googleway's Introduction

googleway

CRAN_Status_Badge downloads CRAN RStudio mirror downloads Github Stars Build Status Coverage Status

Homepage: http://symbolixau.github.io/googleway/

Provides a mechanism to access various Google Maps APIs, including plotting a Google Map from R and overlaying it with shapes and markers, and retrieving data from the places, directions, roads, distances, geocoding, elevation and timezone APIs.

Google Maps

v2.7

see News for a full list of changes and additions

See the vignette for instructions and examples.

v2.7.0001+ (dev)

Installation

## install release version from CRAN
install.packages("googleway")

## To install the development version you currently need v0.7.1002 of googlePolylines
devtools::install_github("SymbolixAU/googlePolylines")

## then you can install googleway
devtools::install_github("SymbolixAU/googleway")



googleway's People

Contributors

avsdev-cw avatar dcooley avatar tdeenes avatar techisdead avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googleway's Issues

Remove requirement for key?

Given the API doesn't actually require you to have a key; do we want to make it optional, but say that it is recommended to do so?

Not finding all places

Hi, I'm new to github, so please tell if I'm not using this session in the right way.

I'm using googleway to find nearby places based on a lat/long (first I'll need gas_stations, then general places). I made some tests, and it is not finding all locations, I'll give an example:


  • The place "Posto 100 %", located in: -6.362805, -39.306283.

To check if it was in google as a real place, I went to Places API developers page and got the 'Place ID', which is: ChIJHRauPxYeowcRfVIL9Cd29zM

  • First validation:

I checked the ID on the googleway function to get some info, which was all correct, including the 'gas_station' tag:

local_info <- google_place_details(place_id = 'ChIJHRauPxYeowcRfVIL9Cd29zM',
                                                        key = chave)
structure(local_info)
  • Second validation:

Then, I made some tests, trying to find this gas station based on its location within a radius (I tried with 50, 100, 1000 and 5000):

gas_stations <- google_places(place_type = 'gas_station',
                                                  location = c(-6.362805, -39.306283),
                                                  radius=1000,
                                                  key = chave)
structure(gas_stations)

Which returned some Gas Stations, but not this one.
I also tried using keywords and a search_string, but it was also unsuccessful.


Do you know why it is not finding this one? Also many other specific establishments?I'm using for Brazil only, is this a problem?

Thanks very much for this awesome package, and I hope you can understand my english.


EDIT: I've tested with a link provided by developers page, and it is returning this gas station I gave as an example. The inputs where exactly the same (location, radius and type):
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-6.362805,%20-39.306283&radius=500&types=gas_station&key=YOUR_KEY

allow data.frames to store location/address

If the location/address information is all the same type (e.g., all lat/lon pairs, or all string address), allow a data.frame to be passed into the functions.

For waypoints, allow three columns, the third to identify 'stopover' or 'via'. In google the default is 'stopover'.

Map updates

Updates planed for future releases

simplify results

use 'simplify' in stead of 'output_format' . Simplify will be coerced into a list using jsonlite::fromJSON()

Plot a google map

  • base map object
  • default location
  • shows in Rstudio Viewer pane
  • work with shiny
    • in browser
    • in Rstudio
  • pass data into map object
  • set view - either bounding all markers, or user defined
  • plot markers
    • using data passed in through R
    • specify which columns contain marker data
    • use separate add_marker( ) function
  • plot routes
  • custom map style
  • add/remove 'layers' from the map dynamically
  • update_heatmap (rather than clear and re-draw)
  • traffic layer
  • map search box widget
    • clear search
  • polylines
  • polygons
    • need to handle complex polygons, such as those with holes in
  • data.table inputs
  • single row inputs - when trying to read lat.length, for example
  • update map bounds on all layer updates
  • markers on streetview
  • cluster markers
  • using a column of data that has the name of a parameter, as another parameter gets overwritten as NA (e.g., using a column called 'title' as a marker 'info_window' - this fails the column_check)
  • layer ids
  • mouseover events for all layers
  • polyline encoder
  • map style options
  • mouse_over doesn't return the shape to its starting 'alpha' value
  • mouse_over_group - faded alpha value should be the minimum of the user-defined alpha, or the 'default' faded value
  • 'title' for markers isn't working
  • onClick events for shapes / markers so the data can be used in R
  • heatmapLayer - change the 'outer' colour / hue based on the first user input colour
  • marker info_window at top of marker and doesn't get removed when another is loaded (i.e., the functionality before I tried to be clever and consolidate the code)
  • roads API
  • rectangles
  • layer z-index
  • return bounds from polygons on click (https://developers.google.com/maps/documentation/javascript/reference?csw=1#PolygonOptions)

google_elevation limits

as per StackOverflow

Sample polylines:

pl1 <- "q{|aHknlv@n@Mt@IxAGb@B\\Eb@AZGRG^W`AyAPQF?NHDJFZBz@FVNPn@D`@C|@DjACv@@h@Dh@Ll@Zj@^\\`@fAx@j@r@d@n@\\ZJPNd@NbANzAFhANb@JNLHD?PKHMRGPSr@UPMXGDGJELMFCPAbBWROpAm@h@YZe@dAaC@Of@aAb@a@t@iALg@LWNQROf@IjAJnFbAv@Dr@Aj@BpBx@fFdCd@HlAHd@Pp@b@|@d@~@j@n@R~@n@\\NTCXBNEZCZKbB]rAKpDK~BO\\?NCd@?`DMz@SLO`@URCR@XLRRRVHd@NXNP\\RXf@JHXN\\Xn@ZD@Z?\\NvArA~BxA"
pl2 <- "uipaHmmcv@iBoFm@{AKQy@}B}AoDyA_CASEMGKKI]y@i@y@EOi@q@kAw@KEMAu@M]?[@WDkAZiB~@]H_@PUF]TUL_@XkAn@}CzAyAx@e@P_@JSNGROPa@Fu@[UOc@IOAu@_@WIUMIIWGu@]YEk@SoBiAc@_@gAeAg@{@]mAMq@YmBA]Oq@YuBKYUg@UQa@QiAOI@QIm@EiA[w@BSFYZ_@h@]t@o@bAOb@}@zAWn@_@jAGf@SbAKbAKXSpAS`@ICa@FSHICQ@gAHq@KSAa@I[CQ@k@KOGMKYg@aBkEs@u@k@g@_@a@{@o@W]IAYQYAsDIODc@LW\\GRKn@Ch@WtAO`BCzAIj@Wh@SRc@NS@a@KaAg@kCgAm@]iBo@w@_@UQc@S}@Ww@e@MCa@Sm@Sk@WYI{@g@IIMAMIIIm@QuBaAIGu@_@SQiAqA_AmASSYIUEqAKQBm@Im@Qe@i@k@UQBSCe@NO?[FKFYBSH_ADa@GQIw@OOSKF[b@M@gAl@i@b@{@b@OLwAj@KLWRI@yBvAuAd@m@F_@@qAEk@Kc@Oi@_@_@e@oAeBc@u@SSi@]i@We@Im@Q}@k@w@_@i@a@w@a@SQ[Qy@OeCSUGg@WSOa@e@W]MK_@i@CMMWIEMWa@m@[QEIICK@QHUTe@n@ELKFa@l@u@t@WNYLYXO?IBGHc@Tc@Ja@@{@Q{@]s@a@kBq@YOcAYs@IU?_@NU@GAu@^a@LSPg@X]^YJc@h@]PKHI@w@n@]h@AXEJMTCZc@|AS`@OVg@j@_Av@{@bA"

it's possible to send in the polylines directly : https://developers.google.com/maps/documentation/elevation/intro

Shiny polyline colours

Polylines in Chrome and Rstudio viewer can handle 6 or 8 character hex colours, shiny only seems to be able to handle 6

#FFFFFFFF
vs
#FFFFFF

Need to investigate

Add the option to optimize waypoints

The API offers the option to optimize the waypoints in order to get the best/shortest path via (optimize:true) Link.
It comes in handy especially if you have a lot of unordered waypoints and don't have the possibility to order them beforehand.

Cheers

Precision of coordinates

Currently I'm working on some visualisations on the workings of intersections (traffic lights). The default precision of jsonlite::toJSON of 4 digits is too low for that. For other inner city related projecs the default precision is too low as well (e.g. building contours, locating GPS equipped objects, etc.).

Please add a parameter 'digits' to the add_polylines function (and friends / similar functions) that is passed to the digits parameter of the toJSON function (default value = 4). This approach gives fine control of the number of digits used for each time a function is used. A global "options" variable for 'digits' is another solution, but gives less (or at least counterintuitive) control.

Perhaps another solution is even better and perhaps I have missed something that enables higher precision allready. I couldn't find a global paramter for jsonlite (only stetting through 'digits' directly in the toJSON function).

To check the solution, I 'hacked' a copy of googleway and replaced the toJSON function with one of my own with a higher default and that did the trick for me.

googleway:Google_places - problems with page_token

Hi. I'm using google_places of googleway package.
I am triying to loop to the next pages using the page_token;
I put as input the df_temp$next_page_token.
The first two loops work.
The third return dataframe$next_page_token = NULL
Is it a problem with the interface?
Thanks

Add other API calls

  • Distance √√
  • Elevation √√
  • Geocoding √√
  • Reverse Geocoding
  • Timezones √√

Add "icon" argument to add_markers

There is an icon argument in the Google Maps APIs for adding a custom image to be used for the marker instead of the default. This would be super useful and (I think) not too hard to implement.

Google_distance() Time outs

My team are currently building a tool that uses your googleway R code.
We LOVE IT! so thanks for putting it together.
We've hit a bit of a snag however.
There seems to be some issue with timeouts.
We are attempting to get drive time on 140k records for our exercise.
We've successfully got results on approx 20k records but it has timed out twice.
The first time we didn't check the run time, but the 2nd time it ran for ~2 hours and then timed out.
I wonder if you know if there's a setting we can tweak to avoid the time out so that our job runs to completion and could help us doctor the code a little to allow this to occur?

Package updates

  • allow place_id values for origin / destination
  • default to 'now' if traffic_mode is used without departure_time
  • datasets available for examples and vignettes
  • polyline encoder
  • helper functions for parsing results with jqr
  • allow data.frames passed into google_distance

use proxy for google_distance

Hi, thank you for the wonderful R package.
Since I am using the company network, I need to use the proxy to receive the data.
Usually I can set the proxy for library httr or Rcurl, (ggmap uses GET function from httr so I could use proxy for that), I saw that googleway imports curl library so I tried everything I could but I still cannot make it.. Could you let me know how can I set the proxy to use the google_distance function without problem? Thank you

for google_distance I have a following error
Error in readLines(con) : Couldn't connect to server

and for google_direction I have a following error
Error in open.connection(con, "rb") : Couldn't connect to server

multiple lat/lon colulmn in data.frame

if there are both of lat & latidue (and lon and longitude) columns, currently the first is used. Should this be explicitly stated, or as an option to the user through an error?

google_distance waypoints for driving

Currently waypoints are only available for transit, walking or bicycling modes. Are there any plans to make waypoints available for driving mode so the user can calculate the time taken between origin. destination and waypoints in between?

Safely access connection and control for errors

I notice there's no error control around curl::curl(map_url); this would not be too hard to do safely, either with tryCatch() or purrr::safely(). I'd guess that would be feedback you received from CRAN anyway.

Some processing on the returned data would be useful too; I received a few empty returns with

result$status
#> [1] "ZERO_RESULTS"

Checking the status_code for success would be useful, returning a helpful message otherwise. When deployed within a shiny app, errors don't always float to the top the way one might hope.

google_directions(); Valid names for waypoints list

In google_directions(), while it is already noted that lists with elements named via will be processed as non-stopping waypoints, it took hunting through the source code to realise that they need to be named "" (explicitly empty character) to be used otherwise. You have fatal testing for this in-place, but it's not documented.

Given that you explicitly write the via: prefix anyway, I'd like to suggest adding stop to the list of valid names in your package, which can then be left out from the actual API call.

Error executing google_distance

When I run the following function I get a message that there was an error. When I check the URL this works.

 google_distance(origins = list(c("Melbourne Airport, Australia"),
+                                c("MCG, Melbourne, Australia"),
+                                c(-37.81659, 144.9841)),
+                 destinations = c("Portsea, Melbourne, Australia"),
+                 key = key,
+                 simplify = FALSE)
NULL
Warning message:
In value[[3L]](cond) :
  There was an error downloading results. Please manually check the following URL is valid by entering it into a browswer. If valid, please file a bug report citing this URL (note: your API key has been removed, so you will need to add that back in) 

https://maps.googleapis.com/maps/api/distancematrix/json?&origins=Melbourne+Airport,+Australia|MCG,+Melbourne,+Australia|-37.81659,144.9841&destinations=Portsea,+Melbourne,+Australia&departure_time=1502273016&alternatives=false&units=metric&mode=driving&key=
> 

Cannot decode overview_polyline

I try to decode the overview polyline from this request and got cannot be decoded error:
"https://maps.googleapis.com/maps/api/directions/json?origin=place_id:ChIJg0QqCUx-bIcRTdSPo8yl9XA&destination=39.763262,-105.143201&mode=driving&units=imperial&departure_time=1482433621&traffic_model=pessimistic&avoid=highway&key=[KEY]"

aweqF~~v_SgVGAoM@iFaT@oEAoAA}@?oBzBqHpI}@bawf@MTe@p@{HJkBlC]v@kAlAgGnHmInKwEtGeA|Aq@pAWn@k@jBy@tDeBhIq@D]jAm@lB_@|@_A~AmAdBw@|@oAbAsA|@kBt@kBn@aHbCcFlBcHjDqCvA_HrDaAb@yBnA_ECiBfBs@x@{@nAiAlBkDFmAlBw@dA{ClDsHhIiDzDSVuA|B{AbCiBbCcEdEmAdAmBrAiDrBoChAeCx@yGjBkCr@yEbAaAL_APs@Ju@@}A@sACoAIcAOcB_@cA[{By@{BaAiCw@}Ds@s@EeAIsCCwA?mFHE?i@FgBZqA@gAh@YNUNuBfBwCD_BBcBbBqBbBwAv@_Bf@eARcALyABoBI{A[cD_A_D}@wBq@aEyAmAc@c@SiBgAaAq@eEcEaB{BsB{CwA{Bs@gAwNyT_FwHuHwMkAqBeBsCaBoBmAkAcBwA}B{AkBoA_@_@aC}A_Aq@q@k@_AcAmAsBe@aAiAiDk@aB]wAaDwKa@yA[cAOe@BG?M?ICMuAwEk@oAy@uA]i@qAwAMQCIQO_DeC}CeBgBw@mBm@oA]aB[eC[sCSwCCaMEk@GiAWm@IoDoBw@Ym@G_ABm@TMJg@^y@fASl@Ib@EPCZC@cf@DzF@A@@@xbcCQfC[rBsAtHo@|DaAxGGd@?j@wAfHeAbGWzBIDFhBRxCf@HHdCChBs@hQQdGEMGlMEfXUvDa@tDq@bHGhAKbE?hBHbFPFb@HjAlNZdDNdCB~BExBEfBSIChF?rM?jUGbCIh@Q~Aa@hB{@~BmBjF[pAObAStBCzCB~@@pd^B|@hCnAxCt@vBRt@XbBLtAFdBBnM@fb@?bB[~TIdCGbA]rCk@zCYfA{@fC{@rBo@jA_B|B{BpCyAxBe@|@i@bBe@rBQfBElBBlBLpB@rdpc|Qb@pCvAKb@~CpBfNbBzKz@~FXnCDt@JzBDpBHlP@bd@AfJObE}@fOUFCrE@td@Fll@F|FPnFZfFb@pEz@vGn@pDp@~CnJt^pHrXrAFdAjD@daf@AnAjBt@bApAlAx@h@^T~At@pA@`ARvALlDDhDCnXEff@O

It can be decoded with [https://developers.google.com/maps/documentation/utilities/polylineutility](polyline utility tool).

Keyless entry

I'm planning on using googleway to add some route-estimating functionality to ubeR (see datawookie/ubeR#1) but of course not everyone has a Google Maps API key.

Thus:

  1. Is it possible to use the service without an API key (presumably with some limitations) and if so, can this be an option in googleway functions?
  2. Otherwise, what do you think of creating a hardcoded googleway API key (limited access, read-only, dedicated account) with a request to not abuse it? I'm sure I've seen this in a package somewhere, but can't recall where.
  3. That API key could be specific to either googleway or ubeR, I just thought I'd run it by you first.

Alternatively, I'll just have it fail if the user doesn't have a valid key. That's not too harsh given that they need to be able to get an Uber API key anyway.

google places

implement a function for Google Places API

  • text search
  • location search
  • radar search
  • page token
  • open now

issue in working under proxy

I am facing issues in calling the package under proxy:
Error in open.connection(con, "rb") : Couldn't resolve host name

I tried to call:

library(httr)
set_config(
  use_proxy(url="myproxy", port=80,
            username="myusername",password="mypass")
)

then call

mykeyKey='mykey'
library(googleway)

df <- google_geocode(address = "Via G. Pogliani 6 Paderno Dugnano",
                     key = mykeyKey,
                     simplify = TRUE)

without results...

Is it possible to find a workaround?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.