Google Places API bounds in http request - google-maps-api-3

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.

Related

HERE API - Need to get the coordinates of all route waypoints

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.

Speed limit for multiple locations using HERE API

I need to know the speed limit for some coordinates from the vehicle's trip.
If I do POST request like:
https://fleet.cit.api.here.com/2/calculateroute.json?routeMatch=1&mode=car&attributes=SPEED_LIMITS_FCn(*)&&app_id=APP_ID&app_code=APP_CODE
with body:
LATITUDE,LONGITUDE
37.401996,-122.041338
37.416438,-122.086022
I'm receiving back built route with very many coordinates.
But I'm interested in only two coordinates...
Is there a better way to get speed-limit for a few (~10-100) coordinates?
This will get an array of link and if speed limit is available in map data, it would be returned for the link. linkAttributes and routeAttributes will limit the response of parameters. the default response however can't be limited.
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey=xxx&waypoint0=42.4065,-113.3798&waypoint1=42.2821,-83.74847&mode=fastest;car&inkAttributes=speedLimit,dynamicSpeedInfo&legAttributes=links
speedinfo can come via geocoder API in the form of speed category like below that will be based on the address location.
https://geocoder.ls.hereapi.com/6.2/geocode.json?searchtext=Castro%20St%20Mountain%20View%20Santa%20Clara%20US&gen=9&apiKey=xxxxx&locationattributes=li

How draw route on Bing map from json response

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.

How to retreive speed limit from here maps given a latitude and longitude?

I'm trying to get speed limit from Here API maps but I can't find the way to do it. I tryed few example on web site but the only one that works is the one which require point of start and point of stop of the route.
I would like to get the speed limit given only one point ( or a box ). Which api do I have to use? Is there an example?
https://route.cit.api.here.com/routing/7.2/calculateroute.json?jsonAttributes=1&waypoint0=51.31854,9.51183&waypoint1=50.11208,8.68342&departure=2019-01-18T10:33:00&routeattributes=sh,lg&legattributes=li&linkattributes=nl,fc&mode=fastest;car;traffic:enabled&app_code=appcode&app_id=appid
This is the waypoint one but is not what I'm looking for, I would like to pass it only a Latitude / Longitude.
Thank you
You can achieve this by using PDE API(Platform Data Extension)
You have to first map your geocordinates(lat,long) to a navigable position(lat,long) for the given coord and the Functional Class(FC1-5) it is located in. This you can achieve by a simple geocoder request
You can calculate tilexy values based on the navigable lat,long and pass it to PDE API for querying speed limit layer on that particular FC class.
Look at https://tcs.ext.here.com/examples/v3/link_speed_locator example which covers this exact usecase.
Below is a sample geocoder request. Here prox parameter is your lat,long
https://reverse.geocoder.cit.api.here.com/6.2/reversegeocode.json?app_id=xxxx&app_code=yyyy&prox=50.133848, 8.715332,500&mode=retrieveAddresses&maxResults=1&additionaldata=SuppressStreetType,Unnamed&locationattributes=linkInfo
Below is a sample pde request
https://pde.cit.api.here.com/1/tiles.json?layers=SPEED_LIMITS_VAR_FC1,SPEED_LIMITS_VAR_FC2,SPEED_LIMITS_VAR_FC3,SPEED_LIMITS_VAR_FC4,SPEED_LIMITS_VAR_FC5,ROAD_GEOM_FC1,ROAD_GEOM_FC2,ROAD_GEOM_FC3,ROAD_GEOM_FC4,ROAD_GEOM_FC5&levels=9,10,11,12,13,9,10,11,12,13&tilexy=536,398,1073,797,2147,1594,4294,3188,8588,6377,536,398,1073,797,2147,1594,4294,3188,8588,6377&app_id=xxxx&app_code=yyyy
Read more about it in the developer site - https://developer.here.com/documentation/platform-data/topics/quick-start-view-map-data.html
Hope you find this useful!
The ReverseGeocoder has rarely used mode "trackPosition" (mode=trackPosition).
In combination with locationattributes=linkInfo you may retrieve the speed limit for that matching road.

Is there a size limit for an encoded path to the google static map API?

I've got an application that draws a map using a set of LatLng points to create a polyline. I want to generate a static map of this path using the Google Static Map API and passed the result of the polyline's getPath() method to google.maps.geometry.encoding.encodePath to generate the encoded path. When I pass this to: https://maps.googleapis.com/maps/api/staticmap?size=400x400&path=weight:3%7Ccolor:orange%7Cenc:polyline_data where "polyline_data" represents the encoded line I get a status of "400 (Bad Request)"
When I cut the number of points down so I only pass in every 20th point the encoded path renders a static map correctly. My polyline is comprised of about 6000 points and when cut down to about 300 it renders cleanly.
I understand the resolution of the points I started with is to fine grained but have not been able to find what the actual limit is for the number of LatLng points passed to the encodePath method such that this encoded string can be passed to the google static map API. Can someone help point me at the specified limits? Thank you.
From the Web Services Documentation
Additionally, URLs are limited to 8192 characters for all web services. For most services, this character limit will seldom be approached. However, note that certain services have several parameters that may result in long URLs.

Resources