Google Maps Directions API - ios

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... :)

Related

Tools for estimating nearby locations without calling external API (i.e Google Maps)

In my rails application i have some model Location that holds the address and corresponding latitude and longitude.
At the main page, user can search for a location from which he wants to find the nearest places in location table.
I use JavaScript Google API for geocoding on the client side. Since the limit per user is 25000 req/day i guess i do not need to worry about it cause no one will want to search for a location so many times. I use Ajax for sending geocoded latitude and longitude from client to the server.
Now i'm on the sever side and have a reference point and table of locations. But at this moment, i guess i cannot use geocoder gem which use Google API for estimating some nearby locations, cause from the server side there is a limit of 2500 requests per day and i expect to exceed it(don't want to pay either).
What tool can i use to easily return some nearby locations without calling external API? I know that there are other API's but all of them have either limitations or obligations and since it's more like mathematical calculation i can't see the reason to play around with API at this point.
Assuming that you're using a relational database, you can use ElasticSearch to index your Locations and search through them using Geo Distance Range Query.
Other similar option would be use a Mongo collection and take advantage of the Mongo's $near operator.
Edit:
There're some questions related to your question which can be useful if you're using MySQL/PostgreSQL:
Find closest 10 cities with MySQL using latitude and longitude?
postgres longitude longitude query

I need an API to plot waypoints and give me a route through them, and to give me city population. Which API should I use?

I'm making an iOS app that needs to be able to find the most populated cities within a radius from a certain point, and to calculate a route that passes through a certain number of those cities, that satisfy a certain time constraint. I'm planning to use Google to give me polylines that I can put directly on an Apple Map in the Mapkit for Xcode. I've looked into the Google Maps SDK for iOS, and Google Places. Google also has a Directions API, and a Distance Matrix API. With so many API's, I'm slightly confused about which one I should use, and for what.
Additionally, do Google API's provide city population, or should I find that via another database?
You can use Google Maps URL Scheme to get directions for Google Maps iOS.
If you are ever confused about which API to use for Google Maps, you can use API picker.
There is no Google API that give city population, so you would need to find it with a another database.

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/

Map search for specific query

I have a working map based ios app which centers on the users location and move as the user moves. I wish to add functionality to it so that when the map is opened it drops pins where the nearest 'butcheries' are. I can't find an example of such a 'search' query. Thanks
there are two ways
1) query a web API which delivers those results (i.e. factual.com)
2) forward the query to the local Google maps SDK (some dozen megabytes)

Locating closest GPS marker from Geonames database

I am developing an Android application that uses the geonames.org database. I only use the city/populated place category and their corresponding coordinates as provided by geonames.
I want the user to be able to provide his/her GPS coordinates and get a result back with the closest cities/populated places and their coordinates.
Even if the user is in a city I want that city's coordinates to be displayed along with the more distant ones.
Can this be done without the help of google or a web service? I might host the world city geolocations on my own server.
Thanks!
Since posting this I have found the answer to my own question. MongoDB supports geospatial indexing. Make sure that the longitude and latitude field is saved in one string and point the geospatial index to your loc: field. You can then perform queries with a bounding box to find closest locations within a certain radius for example. More about MongoDB geospatial indexing can be found here: http://www.mongodb.org/display/DOCS/Geospatial+Indexing

Resources