Google directions API limit results by bus company - google-maps

I am using Google directions API to get bus journeys. I would like to have results limited to a given bus company. I was not able to find anything in the API doc that would allow me to so. Is there any workaround / non public API that is able to accomplish it ?

As of now there's no property that would allow your Directions Request to limit to a single bus company / transit agency.
You can choose to display only certain transit agencies by checking the response of your Directions Request and manually filtering by agencies.name for example. Here's the documentation.
But there is still a chance for routes to be missing certain steps if you manually filtered out a bus ride from a different transit agency, and the route requires you to walk/go to a different bus stop that is also not being handled by your target agency. So be careful with that.

Related

Can you get an ideal route of multiple destinations using a single API call?

I'm trying to see if there's a way in a single API call to find the ideal route, order not mattering, between X destinations.
For example, the program has 3 destinations, Jeff's house, Amy's house, and Valerie's house. Don't really care the order we go in, but we'd like to visit each house with the least amount of driving.
Right now, I have it set up such that we try every ordering of destinations, and settle on the one with the fastest time. But having so many API calls seems inefficient, but I can't see a way in the API to do what I want. Is what I want presently possible in the google maps API?
You can use Waypoints in Directions API web service which returns a route that includes pass throughs or stopovers at intermediate locations.
By default, the Directions service calculates a route through the
provided waypoints in their given order. Optionally, you may pass
optimize:true as the first argument within the waypoints parameter to
allow the Directions service to optimize the provided route by
rearranging the waypoints in a more efficient order.
Sample request:
https://maps.googleapis.com/maps/api/directions/json?
origin=Adelaide,SA&destination=Adelaide,SA
&waypoints=optimize:true|Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+Vale,SA
&key=YOUR_API_KEY
Note that requests using waypoint optimization are billed at a higher rate.
If you will be using client-side Maps JavaScript Directions Service. Refer to this documentation and example.
Hope this helps!

Understanding Requests from Google Places API for Web w Place Autocomplete

We are considering using Google Places API for a new web application project and I believe we are vastly underestimating the number of requests we would use.
We would be using place search, Maps JavaScript API map load to grab Place IDs from Google as well as Place Autocomplete to help users find the defined location. So my questions are:
Would the Autocomplete be considered a request on every keystroke?
Would if also be a request when we select the suggestion (Places API)
and update to Map?
I have seen that with the premium Plan autocompletes use 0.1 Maps API Credit, while JavaScript API map load is 1 and Places API is 2 credits. Trying to understand how to count before the 150k limit and after
As mentioned in the comment of your question, Google is making some drastic changes to their collective maps API usage rates. Starting June 11th, the new pricing will go into effect.
Would the Autocomplete be considered a request on every keystroke?
As of now, places autocomplete is counted on every keystroke. Starting June 11th, you have the option to switch to session-based billing. They have different pricing rates which can be see in the pricing sheet link. Depending on your application, you'll want to use the option that minimizes API calls. I think if your use case is one time selecting of location by your users then you're better off with billing by keystroke.
Would if also be a request when we select the suggestion (Places API)
and update to Map?
Selecting a suggestion from Places API would not incur an API request (requesting the suggestions does), but updating a google map using the Map API would use an API request.
The 150k daily limit is going away in favor of the new billing rates, so I would suggest you look into that now. There are some free unlimited services still offered, like the Google Maps Embed API. Loading a map using the Embed API is not counted towards any billing (as of now).

What if I have no results to display on a map after calling Google Distance Matrix API

I would like to develop a service, using Google Distance Matrix API, where a user can enter their current location and a map will be displayed showing how many other users from their group have addresses in the same general area. For privacy reasons, I do not want to show any other details (location, name, address etc.) of those other users just the number of people.
In order to ascertain this information I was intending to make a call to the API and displaying under the map of their area a message like "There are 5 other people within a 3 minute drive of your address".
Can anybody tell me whether this meets the API limitation:
The Google Maps Distance Matrix API may only be used in conjunction with displaying results on a Google map. It is prohibited to use Google Maps Distance Matrix API data without displaying a Google map
If my requirements of the API are not acceptable, could anybody suggest another publicly available API that I could use in its place?
Thanks!
Yournavigation Api gives you distance from given points.
Try this request example.
You can find their usage policy here.
They said that there are no limitations on usage, except those regarding overload:
The routing API is open and freely available for everyone under the condition that you don't overload the server. Overloading the server in this context means: more then 1 request per second for sustained periods of time. Bursting multiple requests for short time-periods is not a problem though

Google Geo coding service for getting only geocodes

We have a pharmacy search application. We are trying to get the the input address from
user and find pharmacies around that address in a user specified raduis.
We are planning to geo code the address entered by user from a third party service.
After getting the geocodes we will search for pharmacies in our DB around that address and
display the results. With each result there will be a link which will open a new tab/window of maps.google.com displaying the location.
If we use the google geocoding API service to get geocodes will they charge for it ? I am not showing the map on my UI. Is that ok or violating the google terms ? Is the 2500 requests/day applicable for this scenario as well ? I am seeing that MapQuest is a service which will return only geocodes.
Thanks,
Avinash.
Double check with Google's Terms of Service, but generally they begin denying your API requests after you reach your limit. If you are a repeat offender, they may permanently prevent your IP from using their API. The limit is on the calls that you make to the Geocoding API and is unrelated to whether you display a map using their maps api. The following includes strategies for how to work within these limits: https://developers.google.com/maps/articles/geocodestrat
MapQuest just released their Open Geocoding Web Service, which is built using data provided by the OpenStreetMap community, and (currently) does not have a limit on the number of geocoding requests that can be made.

How does Google Geocoding API usage limits apply to [Sales]force.com?

The following are the usage limits as specified by Google on their Developer Guide pages:
Google Maps JavaScript API v3 => For-profit web sites are permitted to generate up to 25,000 map loads per day
Google Geocoding API => subject to a query limit of 2,500 geolocation requests per day
Google Maps API for Business => may perform up to 100,000 requests per day
Am trying to evaluate using any one of the above for use with Visualforce on Salesforce.com (SFDC) platform [*]
I understand for a public website the requests are per IP. Now for SFDC, there could be many different Organizations on a particular server (say, NA1). So, two different companies using SFDC and Google Maps API could have an URL at https://na1.salesforce.com/something_here and their requests should be counted separately.
Will it be so? What will happen in case of each API?
[*]SFDC is a SaaS cloud for the purpose of our discussion. All users login through the same page but they could be logged into different "orgs"/"organizations" but their URLs might look similar
It's important to differentiate between the server-side and client-side limits here. The server-side geocoding api would have have the 2500 limit enforced across the shared Salesforce instance based on how many machines the requests come from (I assume NA1 isn't 1 huge server). Multiple organization using the free geocoding API would all share the same server-side geocoding limit. I've actually run into the same limits using Google's own App Engine platform, where a bunch of applications share the same outbound IP address.
For any sort of guaranteed performance you'll need to send the queries from your own server or go the Maps for Business route which lets you authenticate your queries to get those higher limits.
Client-side geocoding via the JavaScript API doesn't have these server-limits, so if users do any sort of action to trigger a geocode or two using the JS API is the best route.
You can already create your own "bucket" to track your 25K map loads per day by signing up for an API Key.
This question on SO addresses the geocoding API specifically being run from a visualforce page directly, Salesforce: Google maps query status 620 G_GEO_TOO_MANY_QUERIES and it does seem to mean that without a key the limits are shared. I would suspect that unless you plan on giving the app away that you are working on, you will pretty much be forced to pick up an upgraded API key. One thing you may want to look at to work around this is hosting the maps portion in another location, and iframing it into Salesforce.