How do I get my current location using Uber API? - 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.

Related

Using Google Map APIs

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.

How does Urbanspoon display map?

I've looked at Google's map API, which is all javascript and terribly slow on the iPhone. I then tried using the link option available at maps.google.com. That is fast but I can't see having much control over it. It also displays a little search box at the top of the map. Google's API says you must use maps in a website, which the iPhone isn't. I'm not sure about licensing for maps.google.com.
Urbanspoon's scope option does everything I want with maps in regards to displaying nearby businesses based on your location. Given the limited set of tools available for Google maps without mapkit, I don't know how they are doing it. It looks as though they have somehow integrated with mapkit. Clicking an annotation shows the callout and another click pushes a new view with details from that pin. Any ideas how this can be done?
-- EDIT --
Just to be clear, mapkit doesn't display surrounding businesses. That's the crux of the problem and I'm not sure how Urbanspoon got past it.
You can also use the Google AJAX Search API: http://code.google.com/apis/ajaxsearch/
It's a Javascript library, but for Flash, and other Non-Javascript environments, the API exposes a raw RESTful interface that returns JSON encoded results.
And within this API, what you want is the 'Local Search' if you are looking for nearby businesses based on the location.
Urbanspoon probably gets the data for the locations of nearby businesses via some other method than the MapKit API.
Then its likely that they use the MapKit API to display custom MapKit Annotations at those locations.
If you are looking for a business data provider you could look into yelp's API.

iPhone - can I use MapKit without displaying a Map?

I am writing an app that will use Reverse Geocoding to translate the user's current location into something like a Street Address or City. It seems the only way to get this kind of information is via MapKit (specifically the Placemark class).
Can I use this without having to display a map to the user?
The reason I am asking this is because in the Google HTTP Reverse Geocoding documentation it states:
Note: the geocoding service may only be used in conjunction with displaying results on a Google map; geocoding results without displaying them on a map is prohibited. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.
I'm wondering if this holds true for the MapKit API as well or if Google and Apple worked something out.
I answer my own question way too much around here -
10.12 use or display the Content without a corresponding Google map, unless you are explicitly permitted to do so in the Maps API Documentation, the Street View API Documentation, or through written permission from Google (for example, you must not use geocodes obtained through the Service except in conjunction with a Google map, but the Street View API Documentation explicitly permits you to display Street View imagery without a corresponding Google map); or
via Google Maps iPhone TOS
The Map Kit framework provides an embeddable map interface for your application. Use it to display map or satellite imagery from the windows and views of your custom applications. You can also use the framework to annotate your maps with points of interest and other custom information.
What was stated above about using Googles HTTP API for reverse geocoding would be a better way to display the information you are looking for and using a text box to read the information.

Adding pins for nearby places (e.g. pizzerias) in MapKit

MapKit doesn't natively support local search results, so I'm looking for a way to get a list of local pizzerias (or coffee shops, or a specific retailer) via some http api call.
The default google maps api requires javascript, so it's not clear to me how to integrate this into an iPhone app (without displaying a UIWebView).
I have found that a url in a format such as this:
http://maps.google.com/maps?output=json&q=pizza&near=37.3,-122&num=10
Does return a JSON-like list of results, but my usual friendly JSON parser, json-framework, barfs when it tries to parse this (even if I do clever-sounding things like leaving out the "while(1);" at the start of the reply). I'm also not sure how legitimate this URL is to use for this purpose.
I'm on the same quest. It seems that one option would be to perform the local search using Google's AJAX Search API, then plug that data into the mapkit.
That said, it's not entirely clear to me yet that this approach is in the clear vis a vis google's terms of service. Let's see here. Alright, changed my mind because of this. It's a post on google's own ajax api blog including video of a native iPhone app. Looks like this is the approved solution.

Integrate Google Maps API into an iPhone app

Update: iPhone SDk 3.0 now addresses the question here, however the NDA prevents any in depth discussion. Log in to the iPhone Dev Center if you need more info.
Ok, I have to admit I'm a little lost here.
I am fairly comfortable with Cocoa, but am having trouble picking up the bit of javascript needed to solve this problem.
I am trying to send a request to Google for a reverse geo code.
I have looked over the Google documentation I have viewed here:
http://code.google.com/apis/maps/documentation/index.html
http://code.google.com/apis/maps/documentation/geocoding/
Even after a rough reading, I am missing a basic concept:
How do I talk to google? In some examples, they show a url being sent to google (which seems easy enough), but in others they show javascript. It seems for reverse geocoding, the request might be be harder than sending the url with some parameters (but I hope I am wrong).
Can someone point me to the correct way to make a request? (In objective-C, so I can wrap my head around it)
UPDATE - iPhone 0.3 includes MapKit, which will hopefully be significantly faster than using the JS API. The blurb says that it will include reverse geocoding.
You can't make a request directly in objective-C, at least not within the terms of the Google API. The Google API is written in Javascript. You could use an objective-c to JS bridge, as the Google Maps Component does, but that doesn't really solve the issue - you're still making JS calls!
Unfortunately, that means you
a) need to use a webview
b) need to use the JS API which is slow... compare with the Google Maps application which uses a completely different OTA protocol (try packet sniffing it).
The Google Maps Component is, however, a useful tutorial in how to make simple calls to the API.
I have created SVGeocoder, a simple forward and reverse geocoder class for iOS. It uses the Google Geocoding API, returns SVPlacemark objects (an MKPlacemark subclass with a coordinate property) and uses blocks.
This is how you geocode an address string:
[SVGeocoder geocode:addressString
completion:^(NSArray *placemarks, NSError *error) {
// do something with placemarks, handle errors
}];
You can also reverse geocode a coordinate like this:
[SVGeocoder reverseGeocode:CLLocationCoordinate2DMake(45.53264, -73.60518)
completion:^(NSArray *placemarks, NSError *error) {
// do something with placemarks, handle errors
}];
The easiest way to get a Google map using Cocoa is to use the "Static Maps API". In practice, you need to prepare an NSURL that you use to contact Google. You get back your map as NSData, that you transform to an NSImage. Note that you can do both geocoding and reverse geocoding. You can also embed markers on the map. However, you loose the full controls you have access to if you use their JavaScript API.
Take a look at their reference guide here:
http://code.google.com/apis/maps/documentation/staticmaps/
Now that apple have release the MapKit API for OS 3.0, I think your question has been answered. Having looked at the API docs, I can see a heck of a lot of potential! I still would like to see reverse geocoding webservice from Google, but Yahoo will do in the meantime.
For your information: The reverse geocoding API from Google for requests by XML isn't public, so it's illegal to use. The only legal way is going through their JavaScript-API, which as you found out is harder to do in Cocoa than to simply send an HTTP request.
Alternatives: Reverse geocoding with simple XML/JSON requests is also available from Geonames or Yahoo.
Since iOS5 we have the following options as stated in the development doc:
* "A geocoder object uses a network service to convert between latitude and longitude values and a user-friendly placemark, which is a collection of data such as the street, city, state, and country information. Reverse geocoding is the process of converting a latitude and longitude into a placemark. Forward geocoding is the process of converting place name information into a latitude and longitude value. Reverse geocoding is supported in all versions of iOS but forward geocoding is supported only in iOS 5.0 and later."*
You can now use a CLGeocoder object.
Also try to take a look at google maps component.
Actually, I did not meant reverse geocoding as "translating a point into a human-readable address", but rather visualizing a point using a Google Map (that can also, depending on the accuracy level, show a human-readable address). This is the basic functionality that was required.
In practice, I just wanted to suggest the static maps API as a clean and fast way to:
1) given the coordinates obtained from the iPhone GPS sensor, retrieve a Google Map showing the point
2) given an address, transform it in the corresponding geographical coordinates and then use the coords to retrieve a Google Map showing the address given
Both are possible using simple NSURLs involving the staticmap and geo services
http://maps.google.com/staticmap?
http://maps.google.com/maps/geo?
passing of course the needed parameters to provide a suitable query string.
Kind regards
The big issue of course, is that the license agreement of both google and yahoo state you can't use these API's in "commercial applications". would hate to pub an app on the app store only to have it taken down and sued by yahoo or google. In reading the iPhone 3.0 map api and associated license this isn't mentioned but if you want an app to run on phones not upgraded....
Is there an answer for this that won't get one in trouble?
http://blog.cloudmade.com/2009/06/12/how-to-get-forward-geocoding-in-iphone-mapkit/
CloudMade seems to be an open-source map/location provider - the above blog post lists details on how to get forward geocoding.