I'm totally novice for Rest Api, so i'm looking for example code. I've a set of geographical coordinates taken from a database and I need to find best route among these. I'm using Bing Maps, let say I have an idea how to code the Rest request, my problem is how parse and manage the JSON response to draw the route on the map in a asp.net page.
Assuming you're using the Bing V8 HTML control, the directions module will handle making the REST request and displaying the result for you - there's no need to parse the REST response directly yourself. See https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/directionscreatedrivingroute
If you're using one of the other controls, similar modules are available.
I've found this JSON, is a step to step guide to request and consume JSON response.
Related
I need to get the coordinates of all route points through the CURL - in the HERE API documentation, I did not click on how to do it. Tell me what you need to create a request or give a link to the HERE documentation
With HERE Routing v8 API, you can get the route shape by specifying return=polyline in the query parameters, as shown in this guide.
Keep in mind however, that this returns a so-called "flexible polyline", which is an encoded representation of the route shape coordinates. It looks like this:
"polyline": "BGwynmkDu39wZvBtFAA3InfAAvHrdAAvHvbAAoGzF0FnGoGvHsOvRAA8L3NAAkSnVAAoGjIsEzFAAgFvHkDrJAAwHrJoVvb0ezoBAAjInVAA3N_iBAAzJ_Z"
You can use a decoder to get the coordinates. Here is a JS implementation of the decoder. The heremaps/flexible-polyline contains implementations in several other languages.
I am working on a school project in R where I am attempting to map where the most popular youtube videos are posted around the world. I am able to get the data for the 50 most popular videos, but am having trouble understanding how to use pageToken.
The current get request I am using is with the following:
https://www.googleapis.com/youtube/v3/videospart=snippet%2CrecordingDetails&chart=mostPopular&maxResults=50&key={api_key}
Is it possible to retrieve more than 50 results using "pageToken" (I am unfamiliar with how this works).
Any help would be appreciated thanks!
Videos: list
pageToken string The pageToken parameter identifies a specific
page in the result set that should be returned. In an API response,
the nextPageToken and prevPageToken properties identify other pages
that could be retrieved.
Note: This parameter is supported for use in conjunction with the
myRating parameter, but it is not supported for use in conjunction
with the id parameter.
So when you get the results from the first request you should have an option called page token if you send that to the next request
&pageToken=api_pageToken
it should give you the next bunch of rows.
Note: I am not an R programmer so I cant help with the code for a loop over the results to find out if there are page tokens or not.
I am having issue with Google Maps API:
When I am requesting following url it returns results
https://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens
But using waypoints=optimize:true returns no data
https://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&waypoints=optimize:true
I can't understand the reason. Please some one help.
I have checked the doc they said to put waypoints between, but what if origin and destination is dynamic and I don't know the waypoints.
I believe you don't get any results, because you don't actually pass any waypoints. This is the example request provided in the Docs:
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
Try adding some waypoints by appending it to your request and separating them by using the pipe character |.
Is it possible to limit the search area for Google Places in an http request? The website mentions bounds are possible (using SW and NE lat and long for the corners) for the javascript method but I would like to stick to the http request because I know nothing about javascript. Any help would be really appreciated because I am struggling with this. Thank you!
So, your http request should be something similar to this:
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
There are a required set of parameters, including the radius parameter (unless rankby=distance is set) that need to be used with the places api. The radius parameter is what you are looking for, the maximum allowed value is 50,000. The units are in meters, so the maximum distance would be 50km.
An example http api call would look something like this:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AddYourOwnKeyHere
This will output the requested places of type 'food' within a 500m radius of a point in Sydney, Australia, containing the word 'harbour' in their name. The data will be returned in the Json format. You may be working with XML data instead of Json, if that's the case then just replace json with xml in the http request.
More information on using the Places API can be found Here.
When we use maps.google.com, there's a way to 'Send' the current directions searched via email. One could also copy-paste a unique URL - even shorten it.
Is there a way to get this through the JavaScript API (v3)?
You could generate the directions and store it in the database - after that you can generate a link to recall the route, and shorten it with the Google URL Shortener API
The API doesn't do this, because if you have start and end locations in order to get directions, it's quite easy to construct a url yourself:
http://maps.google.com/?q=from:A to:B (encoded if necessary)
If you want to use your map to show the route, then you will need to implement your own system of querystring parameters and handle those in your map page.