How would I use MapKit to drop pin on a store with Zipcode / Postode - iphone

If the only information I have for a particular store or business (or restaurant etc) is its Name, Postcode (or Zipcode) and Country, how would I create an MKMapView which locates the store and drops a pin on the location?
So kind of replicating if I typed in "Pizza Paradiso, WC1E 7BS, UK", except without the info bubble (but with pin)

This is called geocoding and the MapKit currently only does reverse-geocoding (from lat/long to address) using the MKReverseGeocoder class.
To do geocoding, you'll have to use some other api like the Google Geocoding API and then take the latitude and longitude it gives you to create a region which you pass to the map view's setRegion:animated: method.
To drop a pin, you would take the resulting lat/long and create an annotation object and add it to the map view using addAnnotation.

Related

Is there an easy way to Map properties on Socrata?

Since some of the open data has to do with property and each city has a unique identifier for a property, is there an easy way to map those unique identifiers in Socrata?
Visually, given a list of property unique identifiers in the open data, I'd like to see the properties on a map in one step.
More examples: If you go to http://api.us.socrata.com/api/catalog/v1?column_names=bbl you will see hundreds of references because this is what New York City calls it's unique identifier for a property.
What would be helpful is if we could easily see these properties on a map. We know that datasets should have latitude and longitude, but they usually do not. Plus for a property it is better to see the outline of the property and not just a point on a map.
In order to make it easier to do this, there is a tool at https://map.tidalforce.org/ it allows you to paste a comma delimited NYC BBLs (borough, block and lot) list. For example, https://map.tidalforce.org/?1pNFsY5rnHcsFEpLW2CJ this maps the socrata dataset at https://data.cityofnewyork.us/City-Government/Open-Article-7-Petitions/aht6-vxai
Is there a way to integrate with Socrata to make it easier to map properties for each area, city, state, etc. Or does this functionality already exist.

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.

How can I associate a leaflet marker with an object id in my database

On a webpage with leaflet maps - I want to be able to display my database objects, each of which have a lat,lng. using markers on the map.
So when I click the marker, I would like to fetch information from db and display this.
How can I store the object id or associate it with a marker so that when a marker is clicked I can load my object from database and display detailed information?
I know I could use lat/lng to find the object using radius search or something, but this won't work and is not accurate, as there could be more than one object with same lat/lng.
Ok based on the answer provided by #Ivar in another thread: Leaflet: Add a link to the markers
You can associate a dbObject Id to the marker directly, after the marker is added to the map. when a marker is added to the map it gets assigned an ID called "_leaflet_id". This can be fetched through the target object, and also set to a custom value after it has been added to the map.
Now in the marker OnClick event you can just get the clicked marker's id and use it to query the database.
marker._leaflet_id = dbObjectId;
Not sure how you are connecting to your db, but the flow would be something like this:
grab the clicked point's lat/lng, then send that info to some logic that employs a spatial geometry lib like S2 or something. Create an envelope around the clicked point, and get all the points whose lat/lngs are within that envelope, then whichever's lat/lng is the shortest spherical distance to your clicked point is your match.
I am sure there is an easier way to do this through CartoDB or something like PostGIS.
--
Assuming your database objects are set up in a table like this:
ID(guid) | Name | Latitude | Longitude
fe124etc.| Marker1| 43.123 | -117.123
y75W2etc.| Marker2| 44.123 | -116.123
you do the method above and then once you have the marker you want, you send the other db data (name, address, w/e) back to a popup that is bound to the marker.
Another avenue to explore is (depending on the data) you can make a geoJSON layer out of it. (leaflet geojson use). If you do that, you can create/store/read attributes for each point.
Hope this makes it a little more clear.

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

Find data near to user location with split data in Xcode

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.