Find data near to user location with split data in Xcode - iphone

I'm trying to figure out how i can find data (from JSON) near to the users location on iPhone.
My input consists out of 2 parts, so in order to get to the city and address, I have to get an ID from the province where the user is located.
Province (with ID to go to all Json data of the province)
Data
(Every piece of data has a name, city, address, ...)
Is it possible to find the province where the user is located. Then pass its ID to search the list of data for near to the user located events by reversing all the addresses and cities into coordinates,...?
I'm pretty new to location based programming! Any help is appreciated!
Thank you very much!

The first thing you'll want to do is add CoreLocation to your app. This tutorial shows you how to do that. This will give you the latitude and longitude of your current location.
The next thing you'll want to do is reverse geocode your coordinates. One common API for this is the Google Geocoding API. That will give you your province name.

Related

Get list of all important sub-location in a city by city name

I tried to google place API to get a list of all important sub-location within a city but it's not showing the complete list.It gives the result on the basis of some search like restaurant and all.
Is there any API to get a list of all sub-location within the city on the basis of city name?
try something as mentioned below:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=28.7041,77.1025&radius=50000&key=YOUR_API_KEY.
The link of format:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=[LATITUDE AND LONGITUDE OF CITY]&radius=50000[I have specified 50KM which is largest google api allows]&key=YOUR_API_KEY.
Do not specify the type.
radius: you get the approx size of city to restrict the value for radius.

Getting the latitude and longitude for a set of Node's

in my android application when i capture a picture the , GPS read info of my location (lat/long) , I need to get the lat/long for my town and insert it to my database , I download my region file by mean of JSOM software supported by www.openstreetmap.com the file was in osm extention , my mind tell me that i need to write a program to parse this file (raw data) and insert the whole node's (id + lat +long + other info ) to my database is that the best solution ,becasue time killing me ! .
In other word my Question is how to extract the data in file.osm
Note:every Node has it's unique ID
It's not quite clear what your actual problem is. Your smartphone should already be capable of obtaining lat and lon via the integrated GPS device.
Do you need the name of the town for the current position? In that case you can use Nominatim and run a simple reverse geocoding query.
Do you need the position of a specific town? In that case use Nominatim with a regular geocoding query.

Associate facebook user check-ins to list of cities based on latitude and longitude

I am studying the development of an application that would show a user which cities in the world their friends have traveled to. To do this, I was thinking of getting a list of check-ins for each of the user's friends and mapping those check-ins to my list of cities based on each check-in latitude and longitude.
This looks like the only way to achieve this since the Facebook graph API doesn't return a city locationId that I could use to map the check-in city to my own city list.
I have absolutely no idea how to perform this mapping from a check-in lat/long to the lat/long I have stored for each city in my city table.
Could anyone point me in the right direction or toward a tutorial explaining how this can be done?
I only have a single pair of lat/long coordinates, so I suppose I would need to define for each city a range of latitudes and longitudes around the city center lat/long that would qualify a check-in for being deemed to take place in any given city, and then do a SQL query against my city table to find which city any given check-in finds itself in?
Or is there another / better way of doing this?
Thanks in advance for any tip and suggestion.
Lothaire
You can use the search API https://developers.facebook.com/docs/reference/api/#searching to search for places around a specific lat/long location.
For example, caffes in San Francisco: https://graph.facebook.com/search?q=coffee&type=place&center=37.76,-122.427&distance=1000
Similarly, you could search for places around your coordinates and look at places type to filter out cities. You would do that by calling https://graph.facebook.com/PLACE_ID and looking at the details. For example, in the search example above, Philz Coffee (first result) - https://graph.facebook.com/151116474914629 - gives you "category": "Local business".
It's not ideal if you're aiming for cities, as check-ins are focused around places people go in the cities (you'd actually have more results of your friends checking into places probably, than them checking in to cities).

Guess location from city

I am developing a site where users can find/post - well, let's say - "things". These "things" have name, description, etc.. and the most important information about them is their location. The location consists of the city (country, sometimes state) and the street.
There is no separate input for country and state, because I want it to be filled automatically, I would like to give a list for the city, where the country and the state is given (for example the user types new, then he gets New York, NY, and other guesses.
My question is, that how could I do this most efficiently? (The site can be used from all over the world)
Thanks
You should use a service such as Geobytes API. It will provide you a way to autocomplete the city name, and then get its country, region, latitude/longitude, currency, etc.
You can perform up to 50,000 requests a day, which is enough for many cases.
Does it answer your question ?

Is there a chance that street and zipcode data wasn't enough to populate full address

I have a form where I ask the user to input their mailing address. Would there be any issues with asking only street address and zipcode and omitting city and state?
User zipcode in conjunction with zipcode database would result in having full address of the user. Would that be reliable considering that zipcode database is accurate?
Marcin,
There is not a one to one relationship between city and zipcode. A city can have multiple zipcodes. A zipcode can cross city lines.
Brian
I wouldn't do that.
A ZIP code can contain two different towns, each with a "#123 Main Street" address.
A ZIP code may cross state lines, which means you don't have enough information for shipping/tax details.
You'll have a very hard time dealing with any customers who live outside of the USA.