amrfaissal / googlemaps-services Goto Github PK
View Code? Open in Web Editor NEW📍Ruby client library for Google Maps API Web Services
Home Page: https://amrfaissal.github.io/googlemaps-services/
License: MIT License
📍Ruby client library for Google Maps API Web Services
Home Page: https://amrfaissal.github.io/googlemaps-services/
License: MIT License
Hello, I'm using this nice library to query the Google geocoding API, and I just went over the query limit of 2500 requests/day. Immediately, in the middle of my script, I started getting errors such as this:
undefined method `+' for nil:NilClass
googlemaps-services-1.4.7/lib/googlemaps/services/client.rb:170:in `rescue in request'
googlemaps-services-1.4.7/lib/googlemaps/services/client.rb:150:in `request'
googlemaps-services-1.4.7/lib/googlemaps/services/geocoding.rb:60:in `query'
This is generated when responses such as the following are received:
status: 200 OK
body:
{
"error_message": "You have exceeded your daily request quota for this API.",
"results": [],
"status": "OVER_QUERY_LIMIT"
}
I assume it's related to retry_counter
being nil
(declared as a param with a default value of nil
in lib/googlemaps/services/client.rb:102
and incremented in the rescue
block at line 170 in the same file.
Do you think retry_counter
should have a default value of 0
instead?
Thanks for your library, HTH
Hi,
Does it support Asset Tracking api ?
If yes then how to use ?
Thanks.
First of all thanks for making an awesome gem. It was so simple to get it working.
My code was working fine, but recently i started getting a frozen string error.
This is calling the distance matrix api. Implemented as a concern on a model called 'Address':
The error is thrown when calling the query:
Address.distance.query(origins: origin, destinations: dest, mode: 'driving', units: units)
Full concern code is this:
require 'googlemaps/services/client'
require 'googlemaps/services/distancematrix'
module Mappable
extend ActiveSupport::Concern
include GoogleMaps::Services
# https://maps.googleapis.com/maps/api/distancematrix/json?&key=
included do
client = GoogleClient.new(key: Rails.application.secrets.google_api_key, response_format: :json)
self.distance = DistanceMatrix.new(client) # creates a class instance variable (so this will be a singleton)
end
module ClassMethods
attr_accessor :distance
end
def distance_to(destination, units)
dest = []
origin = []
dest << {lat:"#{destination.latitude}", lng:"#{destination.longitude}"}
origin << {lat:"#{self.latitude}", lng:"#{self.longitude}"}
result = Address.distance.query(origins: origin, destinations: dest, mode: 'driving', units: units)
puts 'result is ****', result
return result['rows'][0]['elements'][0]['distance']
end
end
The default client read_timeout is 1 second and this might be too aggressive. I tried the demo and immediately got HTTP::TimeoutError: Read timed out after 1 seconds
. Setting read_timeout: 5
in GoogleClient.new
solved my issues. What do you think about increasing the default read_timeout to 5 seconds?
Thanks very much for this project!
Would it be possible to bump up this dependency? It's conflicting with another gem's dependency :(
https://developers.google.com/places/web-service/autocomplete
By providing a sessionToken it's possible to bundle together many requests to the autocomplete api, drastically reducing the billed requests.
I'll provide a pull request soon.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.