Get directions for an existing polyline path? - ios

Using the Google Directions API you can provide a starting latitude and longitude and a destination latitude and longitude and get back walking directions from the start to end location. This provides you with the route the user can take and you draw that route on the map then show them the directions. That works, but what if you already have a route drawn on the map? Can you get directions given an existing GMSPath and GMSPolyline?
You can imagine an app that allows users to draw a route on the map they want to take then get walking directions for that route, instead of getting directions for a route Google suggests. How can that be accomplished? If Google doesn't offer that ability, is there another service that can give you directions given an existing route?

I think the best option would be to use each point from your polyline as a waypoint when calculating directions. Depending on your polyline though, it may not follow the same path exactly, but it should be pretty close.

Related

Method for obtaining the boundary range of a specified location(University Campus)

Recently, I have made an iOS map application, using the Google Maps for iOS SDK. I also succeeded in using GMSPolygon to draw a polygon on the map, and these areas were located on the map by human resources then displayed on the map. I know this is not an appropriate way, so I want to ask Google whether you have provided this kind of API for developers to call in order to obtain boundary longitude and latitude information of a designated university or business district. The effect is shown in the following picture.
Example

Check if a location exists in a route in Map API

I'm using MapBox iOS SDK for showing route between two locations. I would like to know if there is any possibility to check whether a location lies in a route.
I need this functionality so that if any incident happen one location and if that location lies in the route, I need to alert the user about this and need to show the alternate route.
For e.g.:- Say I have plotted a route between location A and location B. I want to check if location C lies in the route between A and B. Any suggestion from MapBox Api or google maps Api is welcomed.
you can get a list of coordinate from mapbox route, then i think calculate distance from points to your interested point. it can yield an acceptable result

Google Maps Directions API

Does the JSON returned on a Directions API query provide the lat/long of the waypoints sent?
I have a situation where I am adding a map feature to a app used by our sales team. For each sales rep I get their customer list out of SAP, the geo data for each customer is provided by a 3rd party service. In the app I have the customers stored in Core Data as a Customer entity, with properties for lat/long. I use those to make the customer marker (pin) on the map.
The app lets the sales team map out their day. On occasion, the route drawn (from addresses sent to the Directions API) will not touch all of the customer markers (see image below)
From comparing to Google Maps I am getting a match for the markers, first image is my map, second is Google's web site:
And the address I used to get the pin on the Google Map web site is the same address I am sending to the Google Directions API.
Additionally, if you look at the zoom in of my map, the polylines returned are not even hitting any actual roads. The request is not being optimized, just sending a origin, destination, series of waypoints and getting the results and displaying. Is this on my end or Googles and if it is my end, how can I resolve it?
Edit: If I change some of the customers and resubmit the Directions request Google seems to be able to resolve the directions. I think this is a Google issue.
Thanks
You get waypoints indirectly in the legs array returned by google directions api.For ex. if you add only one waypoint you'll get two objects in legs array with first object having waypoint as its end_location with latitude and longitude (as you asked) and waypoint as start_location for second object. "waypoint_order" provides order in in which your waypoints are added to the route.I have used waypoints=optimize:true to get optimized waypoint usage.just check out response json and you'll get it.Hope it helps... :)

ios - How to get turn-by-turn directions of an specific route?

I have a MKPolyline that I want MKMapkit to give me the turn-by-turn directions.
I know there is a way to get all the possible routes from point A to point B, but in my app I need to be able to provide turn-by-turn directions of route with certain restrictions:
Has to go through a certain street.
Avoid certain streets
Avoid lights
Take some detours, for sightseeing.
So is there a way to ask for trun-by-turn directions with restrictions?
Or can I ask turn-by-turn directions of a specific polyline that I know?
The Apple directions API (MKDirections / MKDirectionsRequest) can give you directions from point A to point B, but does not allow any other restrictions to be placed on the route.
The Google Directions API (not part of the Google Maps SDK, but can be used through standard HTTP requests) does allow more restrictions, but not to the level you require.
It does allow you to add up to 8 waypoints, so this would allow you to specific specific streets or detours in the directions request. It also allows you to avoid toll roads or motorways. It does not allow you to avoid certain streets or lights - I don't know of any directions API that has that level of detail.
One other restriction of using Google Directions API is that you must show the results on a Google map.

Ruby on Rails and gmap location

I come here to ask you some informations or maybe help to try to do what i want.
Here it's what i want to realize:
I have a website and on it i have some places in database (with lattitude and longitude saved). I want allow users, when they click on a button, display a map with a marker on their actual position and others markers who will represent the places from the database near them.
I found some tools like google map API v3. With it i can show the user position but i don't know how i can display the position of the places store in my database.
If you have any ideas or examples.
Thank you.
(PS: Sorry for my english)
I built a similar app with Spring and Java. What you'll have to do is create Placemark JS objects and pass them to the Google Maps API. You can also pass a map size to determine the scope of the map returned to the user.
In order to determine nearby locations, simply build some ruby/rails code to limit the distance of locations from the user location.
Get user location
Determine which locations to show on map within your rails app
Pass desired placemarks to Google Maps (This can be found in API docs which are great)
Display the map returned by Google Maps on a view.
I think you could use geocoder gem for that:
http://www.rubygeocoder.com/

Resources