Why result roadApi is different "how to get" on google.maps? - google-maps-api-3

I try polyline snap to road between two points on "road api". I have answer: "warningMessage:"Input path is too sparse. You should provide a path where consecutive points are closer to each other. Refer to the 'path' parameter in Google Roads API documentation.""
But if I do same at https://www.google.com.ua/maps/dir/%D0%94%D0%BD%D0%B8%D0%BF%D1%80%D0%BE,+%D0%94%D0%BD%D0%B5%D0%BF%D1%80%D0%BE%D0%BF%D0%B5%D1%82%D1%80%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F+%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C/%D0%97%D0%B0%D0%BF%D0%BE%D1%80%D0%BE%D0%B6%D1%8C%D0%B5,+%D0%97%D0%B0%D0%BF%D0%BE%D1%80%D0%BE%D0%B6%D1%81%D0%BA%D0%B0%D1%8F+%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C/#48.1444745,34.1118762,8z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x40dbe303fd08468f:0xa1cf3d5f2c11aba!2m2!1d35.046183!2d48.464717!1m5!1m1!1s0x40dc673dfa85bb03:0x7e675cd9074d3f4a!2m2!1d35.139567!2d47.8388?hl=ru
Result is great, how I can do it like as google.com/maps

You have to use Directions API instead of Roads API in order to get route between two points.
The request is something like
https://maps.googleapis.com/maps/api/directions/json?origin=%D0%94%D0%BD%D0%B8%D0%BF%D1%80%D0%BE%2C%20%D0%94%D0%BD%D0%B5%D0%BF%D1%80%D0%BE%D0%BF%D0%B5%D1%82%D1%80%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F%20%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C%2C%20%D0%A3%D0%BA%D1%80%D0%B0%D0%B8%D0%BD%D0%B0%2C%2049000&destination=%D0%97%D0%B0%D0%BF%D0%BE%D1%80%D0%BE%D0%B6%D1%8C%D0%B5%2C%20%D0%97%D0%B0%D0%BF%D0%BE%D1%80%D0%BE%D0%B6%D1%81%D0%BA%D0%B0%D1%8F%20%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C%2C%20%D0%A3%D0%BA%D1%80%D0%B0%D0%B8%D0%BD%D0%B0%2C%2069061&key=YOUR_API_KEY
You can also see this result in Directions calculator:
https://directionsdebug.firebaseapp.com/?origin=%D0%94%D0%BD%D0%B8%D0%BF%D1%80%D0%BE%2C%20%D0%94%D0%BD%D0%B5%D0%BF%D1%80%D0%BE%D0%BF%D0%B5%D1%82%D1%80%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F%20%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C%2C%20%D0%A3%D0%BA%D1%80%D0%B0%D0%B8%D0%BD%D0%B0%2C%2049000&destination=%D0%97%D0%B0%D0%BF%D0%BE%D1%80%D0%BE%D0%B6%D1%8C%D0%B5%2C%20%D0%97%D0%B0%D0%BF%D0%BE%D1%80%D0%BE%D0%B6%D1%81%D0%BA%D0%B0%D1%8F%20%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C%2C%20%D0%A3%D0%BA%D1%80%D0%B0%D0%B8%D0%BD%D0%B0%2C%2069061
I hope this helps!

Related

HERE Maps Api Reverse Geocode and Street/Road Bearing

Using HERE Maps Api, for a geographic coordinate (lat, lng), I would like to find address information for the nearest routable road. Information that includes:
Address (street, house number, city, postal code, country)
Bearing/Heading of the road (0 to 360 degrees from True North)
How can I achieve this through HERE Maps API?
So far, this is what I have been able to achieve:
Calling the calculate Route API with identical start and end endpoints and mode=car will force the API to snap to the nearest routable point. This step is necessary for when the input coordinates are for a pedestrian street.
Using the nearest routable point coordinates, I can call reverse GeoCode API and I will be able to find the address information I need.
The next step is where I'm currently stuck. I'm able to find information like direction=NW, however I can't find the ~exact bearing in grad, for example bearing=265.
Is this achievable? Are 3 steps really necessary or is there a HERE Maps API endpoint that can provide all of this?
You can use the Fleet Telematics API to get the headings value for a particular road. Read more about the api here - https://developer.here.com/documentation/platform-data/topics/quick-start-view-map-data.html
You can also look at the field explanationshere - https://tcs.ext.here.com/pde/layer?region=WEU&release=19111&url_root=pde.api.here.com&layer=ADAS_ATTRIB_FC1
HEADINGS Horizontal road heading [10^-3 degree] at coordinate points along the link, when driving from Reference Node. Comma separated. Each value is relative to the previous. No values here for the ref/nonref nodes, because they are in the separate fields REFNODE_LINKCURVHEADS and NREFNODE_LINKCURVHEADS.

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.

Drag route anywhere using Maps API

I want to write an application that gives me the exact route of a subway.
When you use Google Maps it just connects two stops linearly, but not the actual way.
Is there a way to move a route anywhere on a map without being bound to roads?
If there's any solution (doesn't have to be with the Google Maps API) please let me know.
Edit:
Example
Google shows the train route like the brown line, but the train actually drives the blue line. What I would like to do is get the blue line so that I can get the coordinates of the route and calculate the curves and elevation.
I know that I could add like 50 waypoint and get get a "fake" route with them, but I would like to have it automatic and not done by hand.
To show the transit directions (subway, bus, tram, etc.) Google Maps uses the data provided by transit agencies in the form of GTFS feeds. This is a responsibility of the agency to provide a detailed shape of the route for the transport according to the GTFS specification. You can have a look at GTFS documentation to figure out how does it work:
https://developers.google.com/transit/gtfs/
https://developers.google.com/transit/gtfs/reference/#general_transit_feed_specification_reference
I hope this helps.

Plotting routes with here.com api

I'm using the Here.com "maptile" api to populate my map with map tiles. Now I want to add routes from point A to B to the map. I figured Here's routing api would provide me with a nice set of coordinates to use for plotting a line in the map, but the api only provides one coordinate pair per "maneuver" (that is, at roundabouts, exits, intersections etc). That is not detailed enough to use for plotting routes since all roads are not perfectly straight ;)
Example
This example at Here's api playground shows a red route plotted perfectly along a road using their map image api. However, if you run the start and end coordinates in the "m1" field through the routing api, you will get the following coordinates:
52.5408395,13.2626364,52.5403011,13.2630944,52.5289285,13.2687593,52.51873,13.2800306
If you enter these coordinates in the "r1" field and click Send Request, you will see that the route is plotted differently (straight line across the park, instead of along the yellow road).
Question
Is there any way to get more detailed data from Here.com's routing api (or any other Here api I may have overlooked), suitable for plotting roads?
Or is there perhaps some way to get map tiles from the maptile api with a route properly pre-rendered?
In HERE Routing API, you can ask for route shape with parameter &routeattributes=shape
This will return an array of coordinates which represents the exact shape of the route on the road. You can also use pedestrian mode which will take into account the roads only accessible on foot.
Unfortunately it's not possible to get map tiles with rendered route shape using Map Tiles API. This API is just for fetching tiles.

Maps API 3 Directions with fuzzy via co-ordinates

I have a number of GPS co-ordinates that describe a route. My intention is to draw a polyline along the route, and then colour segments based on some data I have.
Problem is, the GPS coordinates can occur on the roadside either side of main roads. When using the obvious Directions service solution a lot of "back and forth" occurs as Google tries to get me either side of a split lane road
What I am aiming for is a direct route from A-H passing through every way point. I have considered reverse geocoding the coordinates to a street name and having the directions use the street as a way point, but that picks a specific point on the street that may not be related to the actual route. Single polylines are also not an option as some routes have turns in them.
Is there a way to 'fuzzy' my waypoints so that the directions are happy when passing within a certain radius of the points? If not, has anyone got any other solutions?
Thanks heaps.
Edit: It's also not an option to just not use the middle way points because sometimes the path is not optimal.
Also have tried my own fuzzy coords now, by +- some small value to each consecutive lat/lng pair. Unsurprisingly I ran into OVER_QUERY_LIMIT pretty soon.

Resources