It used to be that precipitationProbability was in units of percentage points. For example, if there were a 50% chance of rain, the API would return 50.
Recently, the units seem to have changed to hundredths of percentage points. For example, I'm seeing numbers ranging from 200-3800. Is this intended, or is this a bug? If it's intended, will the API documentation be updated to reflect this? Here are the docs I'm referencing:
https://developer.here.com/documentation/destination-weather/dev_guide/topics/resource-type-weather-items.html
We have reviewed this resource retrieves weather reports. Severe weather alerts be requested by setting the product parameter to alerts, and setting the name parameter to the required location in the request URL.
Link : https://developer.here.com/documentation/examples/rest/auto_weather
It worked perfectly fine for us , please check the attached screenshot.
Also, “metric parameter”. If set to false, the response contains imperial units (feet, inch, Fahrenheit, miles).
Default: true
Please check the following link to review the same(use API key).
https://weather.ls.hereapi.com/weather/1.0/report.json?name=berlin&product=forecast_hourly&oneobservation=true&metric=false&apikey=&jsonpCallback=jsonp_callback_53724
Related
Below url is used for fetching analytics data related to firebase dynamic links:
https://firebasedynamiclinks.googleapis.com/v1/SHORT_DYNAMIC_LINK/linkStats?durationDays=DURATION
(Please note that the above url is an API that needs authentication/token. You can't open it in a browser. Also, SHORT_DYNAMIC_LINK and DURATION are just placeholders not actual parameter values.
The reason I have added a link is because my question is about the value of the placeholder - DURATION present in the link)
DURATION tells how many days(going backwards) worth data needs to be fetched.
My requirement is to fetch data from the start(when the dynamic link was created). So, what value should I set for durationDays to achieve that?
As a workaround I can set a big number(like 1000 days) but wanted to know a proper way.
Based on what I tried, the parameter durationDays must be present in the url, otherwise the request would return 400 INVALID ARGUMENT. Even setting DURATION values to 0 or -1 return a similar error.
Firebase Analytics API Doc: https://firebase.google.com/docs/reference/dynamic-links/analytics
https://reverse.geocoder.cit.api.here.com/6.2/multi-reversegeocode.json?app_id=MYID&app_code=MYCODE&gen=8&mode=retrieveAddress
Get Parameters
app_id=MYID
app_code=MYCODE
gen=8
mode=retrieveAddress
Headers
Content-Type=*
Cache-Control=no-cache
Post Body
prox=44.97750,-93.26899,50
prox=44.93909,-93.28083,50
Returns a 500 error with the response body being
{"type":"SystemError"}
This error doesn't provide me with any useful information as to what is wrong. Is there something wrong with my request or is this on Here's side?
here is a link to the API description that should help you with a successful post request: https://developer.here.com/rest-apis/documentation/geocoder/topics/request-first-multi-reverse-geocode.html
Looks like your post body doesn't include an "id". But you need that as otherwise you will not be able input to results, which is important when you don't limit maxresults to "1" and you are very likely get multiple results per input coordinate back.
I also recommend to set gen=9 and increase the radius from 50 to at least 250 meters. Because when your input point is further away than 50 meters from a road you can easily get back an area level fallback. Results are ranked by distance to input coordinate anyway, so a larger radius doesn't hurt at all.
id=0001&prox=44.97750,-93.26899,250
id=002&prox=44.93909,-93.28083,250
I am calling the Google Analytics API (w/ e-commerce) to get a simple set of data:
Dimensions
ga:medium
ga:transactionId
Metrics
ga:transactionsThis should in theory give me 0 or 1, since the data is broken down by transactionId
What I'm assuming I will get is something like:
['organic','transaction_1000001','1']
['organic','transaction_1020001','1']
['organic','transaction_1000501','1']
['organic','transaction_1001001','1']
...
['email', 'transaction_1001001','1']
...
But instead, I don't get the ga:transactionId dimension. I only get results grouped by ga:medium:
['organic','1238']
['email','151']
...
I don't really care about the metric, it could be anything. What I need want is to get the medium with the transactionId.
So, is there a way to get a result set grouped by ga:medium and ga:transactionId? Why is the ga:transactionId dimension ignored?
I solved this issue. Hopefully this answer helps anyone facing this problem.
I was using the NodeJS api bindings. Turns out, the dimensions (and metrics) properties need to be strings. I was using an array.
The dimensions value needs to be specified like this:
ga:medium,ga:transactionId
So a simple dimensions.join(',') fixed it.
I have the following script which is being used in a spreadsheet to calculate the driving distance between two cities or a city and a zip code of another city. It is being run for approximately 25 locations simultaneously. To better explain, I have cell B3 in which I enter a new city every time. The script is then used in cells adjacent to my 25 plant locations to calculate the distance from each of my plants to the variable city.
It uses google sheets built in mapping api and works on 80% of the calculations but returns "TypeError: Can Not Read Property "legs" from undefined. (line 16). The plants that it fails on vary with every new city so its not like it is for certain locations. It is almost like the api times out before it completes some of them. I split it into two separate scripts with a varied name and that worked for a day but then 20% fail again.
To make things slightly more odd, I have another script that sorts the plants based on closest distance to the variable address. When you sort the plants, even the ones with errors go to their correct location based on distance. So it is like the distance script is obtaining the correct disance but displaying the error anyways.
Clear as mud? Would love any input I could get on how to correct the issue or an alternate mapping api that could solve my problems.
function distancecalcone(origin,destination) {
var directions = Maps.newDirectionFinder()
//Set the Method of Transporation. The available "modes" are WALKING, DRIVING, BICYCLING, TRANSIT.
.setMode(Maps.DirectionFinder.Mode.DRIVING)
//Set the Orgin
.setOrigin(origin)
//Set the Destination
.setDestination(destination)
//Retrieve the Distance
.getDirections();
return directions.routes[0].legs[0].distance.value/1609.34;
}
Have you tried using a try-catch block around directions.routes[0].legs[0].distance.value ?
try{
return directions.routes[0].legs[0].distance.value/1609.34;
}
catch (e){
console.log("error",e)
}
or you could try something like this
alert(directions);
alert(directions.routes[0]);
alert(directions.routes[0].legs[0]);
alert(directions.routes[0].legs[0].distance);
alert(directions.routes[0].legs[0].distance.value);
and so on...to find out which one comes up as undefined the first. That might help you to debug the issue.
Enable Direction Api
1)Go to "google cloud platform"
2)go to "Api and services"
3)search for "direction api" and enable it
The directions service is subject to a quota and a rate limit. Check the return status before parsing the result.
For lots of distances (or at least more than 10), look at the DistanceMatrix.
I'm able to run the script from the Script editor, but not from spreadsheet. The error is "unable to read property legs" when the function is called from spreadsheet. But the property is in place when called from Script editor and contain correct values.
You probably need to use WEB API and have API KEY:
Google Apps Script - How to get driving distance from Maps for two points in spreadsheet
I am trying to get the travel time with traffic between 2 sets of lat/long coordinates. I can call the Google Distance Matrix API, but I am only getting travel time without traffic. The API notes which I have read say to use a parameter called departure_time. Here is the excerpt:
departure_time specifies the desired time of departure as seconds since midnight, January 1, 1970 UTC. The departure time may be specified by Maps for Business customers for to specify the departure_time to receive trip duration considering current traffic conditions. The departure_time must be set to within a few minutes of the current time.
I found this website to give me that time: epochconverter
However I am still getting the same travel time every time. Here is a sample request, the departure_time parameter would need to be updated (not that it matters).
https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&departure_time=1408046331&origins=37.407585,-122.145287&destinations=37.482890,-122.150235
15 minutes is always returned.
Using "maps dot google dot com" a travel time of 19 mins is returned when traffic is taken into account.
If anyone can help me get the travel time with traffic from the Distance Matrix API, that would be greatly appreciated.
No need for business license, just need an API key from project on https://console.developers.google.com/ with Google distance Matrix enabled.
For results as on google map use traffic_model with values pessimistic,optimistic and do keep in mind "The departure_time must be set to within a few minutes of the current time" without that it will always return 15 minutes.
That feature appears to only be available to Maps for Business customers, according to the docs.
Even with business licence you can only query departure_time 5 minutes from now if you're using traveling mode is driving
https://developers.google.com/maps/documentation/distancematrix/
According to the google docs "departure_time" can only be used if "mode"(travel mode) is set to "Driving"(which is the default travelMode) and an Api KEY is included in your request.
There is also an optional parameter "trafficModel".
Here is an example url with proper parameters.
https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=40.6655101,-73.89188969999998&destinations=40.598566%2C-73.7527626&mode=driving&departure_time=now&traffic_model=optimistic&key=YOUR_API_KEY
To use distance matrix api as javascript code use it as mentioned in this doc.
https://developers.google.com/maps/documentation/javascript/distancematrix
**Imp:**There are many limitations with this API. Most of the features are available only for premium users.Read the above doc carefully.
Please try with below code.
var origin = new google.maps.LatLng(detectedLatitude,detectedLongitude);
var destination = new google.maps.LatLng(latitudeVal,langtitudeVal);
var service = new google.maps.DistanceMatrixService();var date = new Date();
date.setDate(date.getDate() + 1);
var DrivingOptions = {
departureTime: date,
trafficModel: 'pessimistic'
};
service.getDistanceMatrix(
{
origins: [origin],
destinations: [destination],
travelMode: 'DRIVING',
drivingOptions : DrivingOptions,
unitSystem: google.maps.UnitSystem.METRIC,
durationInTraffic: true,
avoidHighways: false,
avoidTolls: false
}, response_data);function response_data(responseDis, status) {
if (status !== google.maps.DistanceMatrixStatus.OK || status != "OK"){
console.log('Error:', status);
// OR
alert(status);
}else{
alert(responseDis.rows[0].elements[0].distance.text);
}});
Please refer this document click here
This API can solve your problem - https://distancematrix.ai/dev
It takes into consideration the traffic conditions, road constructions, and other restrictions when calculating travel time. And if you were using Google's API before for you will be easy, because you don't need to rewrite code.
Regarding the departure time, you will find the following in the documentation:
"departure_time — a desired time of the departure. You can specify the time as an integer in seconds since midnight, January 1, 1970, UTC. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second). If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). The departure_time must be set to the current time or some time in the future. It cannot be in the past. Results for a given request may vary over time due to the changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency."
Follow these recommendations, and you won't have this problem. Besides, you can easily contact the developers and ask any questions concerning your situation.
Disclaimer: I work at a company that creates this API.
If you are using golang client, set DepartureTime to "now" in the input parameter DirectionsRequest of the Directions func.