Using Google Map APIs - rest

I am currently working on a personal project to develop a REST API which would perform tasks similar to what UBER, OLA like taxi aggregators do. Below is the brief about the functionality that I plan to add:
1)I have a fleet of cabs whose location is determined by its latitude and longitude.
2)A customer can call one of the cabs by providing their location and my API should assign the nearest cab available.
This I suppose would be accomplished by using Google Map APIs. My question is how do i start on using these APIs, to simulate such functionality?

You may use the following references:
Choose from the Google Maps APIs documentations depending on your needs. There are actually tutorials given within the documentations.
Answers to Frequently Asked Questions will also help especially the getting started part to fully understand how Google Maps APIs work.
Last but definitely not the least, this example in GitHub might help you exactly on the implementation.

Related

Building a City/Country Search box. Can Bing API support this?

I'm currently building a search box for a mobile app that can search for a Country/ State/ Country. I'm currently looking for APIs that can support this... An option for me would be the Google Places API but as much as possible I don't want to use Google for my project.
So before I import the Bing SDK into my project, I'm curious if anyone knows if this is possible with Bing API.
With Bing Maps you can use the location query API: https://learn.microsoft.com/en-us/bingmaps/rest-services/locations/find-a-location-by-query however, it will also find addresses if you pass them in. Generally though, if you type just a state or country, this API will return the expected result. You can add a bit of code to look through the results and filter them based on their entity type if required.
Since you tagged Azure Maps, you can use the Azure Maps address search API: https://learn.microsoft.com/en-us/rest/api/maps/search/get-search-address It has filtering parameters available that might be better suited for this scenario.

How do I get my current location using Uber API?

Imagine I am a user/Uber driver, how can I use the Uber API to get my current location and plot the location on the map? I want to track the user on the map. All this to be done using Python API.
The API endpoint /requests/current responds with a location object including lat & lng values. You could use these for your mapping feature. Otherwise, there's another method /requests/{request_id}/map that responds with a URL to a map provided by the API.
As for Python, the SDK provides you the above-mentioned methods:
get_current_ride_details
get_ride_map
Through Python you can their IP address to track their location. This question talks about how to use FreeGeoIP to track their location. Using the IP address won't be perfectly accurate, so if you need a more accurate representation, you'll need a way to interact with the GPS system on a device. This question has an example of using Android and Python together, and agraebe mentioned you can use the HTML5 Geolocation features in his comment. Pythonista looks like a Python IDE for IOS that has a locations service. I don't have much experience with these, but I hope some of these resources help.

Providing latitude/longitude to google RESTful search API

I have been trying to find a search implementation that is able to consistently provide good quality results for local searches, and after much mucking about, I've discovered it is possible to use local search via Google's RESTful API.
For instance this URL:
https://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=skydiving&near=new%20york%20ny
Provides a list of skydiving centers near New York, NY.
However, finding this out has been pure experimentation, as I've yet to find any documentation on local search REST features/parameters.
Does anyone know if it is possible to provide a Latitude/Longitude, rather than a city/state?

List / database of valid addresses for geolocation / geospatial testing

I'm running some geospatial tests to demonstrate use of the MongoDB geo APIs. The problem is that I don't have a list of valid addresses with which I can test.
The idea is to query the latitude and longitude through Bing Maps as my sample application is a job search website where the locations I will be indexing to query against would be entered as listing for new job opportunities and would be entered using addresses rather than latitude and longitude coordinates.
Any help would be much appreciated!
I don't suspect Microsoft provides a list of fake locations that will register to valid lat/long coordinates on Bing (for this exact purpose or similar), but if they do...that would be equally acceptable.
FWIW, I did thoroughly check Microsoft's documentation and found nothing on this.
Alternatively, I could just query common places like Starbuck's or POI's (probably what I'll end up doing), but it would be nicer if there were a testing mode where you could use addresses that would register with Bing. Microsoft, in case you happen to subscribe to Stack Overflow tags, I would post this suggestion on the Bing community forums but there is no way to post an answer or question there, please fix this.
Decided just to use the Bing Maps API to query some popular companies although this is not ideal.

Get zip code from latitude, longitude?

I want to get zip code from users current location(Latitude, Longitude), I had used MKReverse Geocoder delegate methods, but sometimes I am not able to get zip code information based on latitude & longitude (valid values). Are there any other alternatives for MKReverseGeocoder ? ZipCode database are specific to countries, that's why I don't want to use them. Any other idea or clue?
Thanks
Consider the GeoNames web service. It's a complete geocoding/reverse geocoding suite under a Creative Commons attribution license. You can either download their data, or hit their web service. The best thing is, they don't require any API keys or licensing silliness--you just hit their web app and bang you got data.
Here's an example: http://ws.geonames.org/findNearbyPostalCodesJSON?formatted=true&lat=36&lng=-79.08 That'll return you a JSON object for the zip codes around the Chapel Hill, NC area.
It's also international. Here's Seaford, England, and the only difference is the lat/lng pair I'm sending: http://ws.geonames.org/findNearbyPostalCodesJSON?formatted=true&lat=50.5&lng=0.08
Then you need to learn to make web requests and parse JSON (if you don't already have a grip on those things), and you're all set.
This is actually a tricky question. Using a geocoding solution like GeoNames is likely to lead to major errors for a lot of queries. The reason for this is that GeoNames by looking up the record in their database that is closest to your query point and then returning the ZIP code they have on record for that point. This works great when your query point is right on top of a record in their database, but can lead to errors otherwise. For example, if their nearest record is a few blocks away in a different ZIP code, you'll get the wrong answer.
The US Census Bureau has created maps of the ZIP codes:
https://www.census.gov/geo/reference/zctas.html
Please see their notes on that page.
I have also worked on a project that uses the Census maps to provide an API that gives back the ZIP code for a given latitude and longitude. It is at:
http://askgeo.com
We offer both a web API and a Java Library that you can run on your own server. The library has excellent performance. Since our site offers additional information than just the ZIP code, you can read about our ZIP code service here:
http://askgeo.com/database/UsZcta2010
And you read about the documentation for the Web API here:
http://askgeo.com/#web-api
The GeoNames methodology is fundamentally flawed for this type of query. If you are looking for the polygon that contains a given query point, you need a map with the polygons, and you need a spatial index to provide fast look-ups. GeoNames has neither. AskGeo has both.
If you have a free db (available from that site? Just search for zip code database and you'll see it)
then you can run an internal SQL query testing for nearby lat/longs. That way you won't need to worry about licensing a web service.
You have three options then. SQL BETWEEN statement, the hypotenuse equation, or Haversine. Haversine being the best, luckily it's tutorial'd elsewhere
EDIT:
Couple of other options I've seen recently:
http://developer.yahoo.com/geo/placefinder/guide/index.html
http://jamiethompson.co.uk/projects/2010/04/30/an-open-free-uk-postcode-geocoding-web-service/
http://www.postcodeanywhere.co.uk/geocoding-service/api.aspx
--
Take a look at the Google Maps API - Reverse Geocoding (only useful if embedding results in a Google Maps interface).
Sample code here:
Get Zipcode from results[1].formatted_address
https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse