I'm pretty new to iPhone SDK and Cocoa development. I'd like to know how to call a web service which will take the lat and long values from my iPhone and feed them to a webservice so I can retrieve the City,State. I already have the phone location stuff squared away. I'm only looking for where I should pass this info to and how I can parse this data back into my app.
Essentially, I only want "City,State" to be visible in a label on one of my views.
The first time I tried this was with geonames.org and it put my returned lat/lng location in the middle of nowhere many many many miles from where I actually was. I tried the same lat/lng values with google maps api and it was in the right place. The only problem I've had is parsing the JSON data back into my app. The returned info seems to have multiple versions of the same info which I can't seem to understand how that works.
So once again. Just looking for a simple HTTP style string I can pass somewhere with my lat/lng values and it returns "City,State". If the example you mention involves parsing data. Please refer to an example I can dissect - I'm a noob.
Oh and one last thing, I know this was made possibly easier with the iPhone 3.0 SDK but I'm currently building this project on 2.2.1 - and for more than enough reason HAVE to do it this way until the rest of the app is ported to 3.0.
Look at the replies here and here
Related
I want to implement local search and display locations on mkmapview. I know how to get current location, etc... but is there a google api for the iphone? the geo api is complex and requires loading JSON and other app delegate modules.
I asked the same question a little while back, I found http://www.geonames.org/ was quite useful and returns the long and lat in an xml format. This can then be used to init a CLocation object with coordinates. An example search URL would be http://www/geonames.org/search.html?q=london
I would recommend reading Ole Begemann's comments - How to find the long and lat of a city on the iphone?
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
I am newbie to iPhone development, I want to do a kind of POC which fulfill the following requirement.
It will be basically a calling card application where user will enter a toll free number followed by pin number. After entering a pin no. it will show the available contacts from the iPhone itself, user will select a desired destination number and call it.
I know this is a whole new native application, but can anyone guide me how I can start working on the same. I have collected a few information about what calling card is and how it works. I'm a bit confused about how can I get the information from calling cards service provider?. Do i need to call there API and how to do a code in the XCODE tool?
Please help me in this regard.
A quick google of calling card api's shows that most card companies have them, but they also don't publish them. Looks like you'll have to talk directly with them and get api specs. It may cost you? I'm guessing the actual API won't be very complicated... a couple of HTTP requests and a little bit of response parsing. You might want to look into asi-http-request for building the requests, and you can probably do most of the response parsing with NSStrings or NSXMLParser if they use XML.
I want to create an application which retrieves the latitude and longitude value of the current position of the iphone, give those values to some 3rd party server and gets details about that place, if possible show a map of that area on an imageview. I've done for the part of getting the locale information, ie to get the latitude and longitude value. I don't know about the providers those who are serving for the latter part. If anyone knows about this, pls help.
You can use the CLLocationManager class to retrieve longitude and latitude, then use a MKMapView to render it.
If I understand correctly you have the long and lat of the phone from CoreLocation and you want a server to retrieve some information from based on that location.
It's a bit of a broad question but here goes: If you want to build your own geo server, you should look at SimpleGeo. If you want to build something more complex, you are going to have to start building your own server. I would suggest Django-geo or if you have really specialised needs, the PostGIS extensions for Postgres as your foundation.
If you just want to build a simple test app, the Twitter geo apis are a good test bed.
In case you're working with the 3.0 SDK, this page may help you on your way.
I'm trying to find a way to search for a business, such as "grocery stores" and display them on a google map around the users current location. This used to be pretty simple with the old URL style of launching the apple map location but I can't find out how to do it with the MKMapView. I understand that I'll need to use the MKAnnotations classes but my problem is with finding the data. I've tried plugging in the URL below to get the info from google but the size of the data seems way too large.
http://maps.google.com/maps?q=grocery&mrt=yp&sll=37.769561,-122.412844&z=14&output=kml
Is there an easy way to just set a property that tells the MKMapView to search for a keyword and display all matching business around my current location? Or does anybody know how to get this information from google?
The KML file that's returned by that search has a lot of information in it. MKMapView doesn't have a way to query Google, so you have a couple of choices:
Use the data that you get from that query with NSXMLParser, and only extract the things you're interested in (probably title, latitude, longitude). KML is just a version of XML.
Look through the Google docs to find a call that gives a more lightweight data format. You can change the format in your url to json, but the information in it is the same.
The file's only about 50KB though. In my experience, downloading and parsing a 50KB XML file takes about 5 seconds over 3G.
Edit: Just found this, thought you might be interested:
Many people transfer data to and from web services to the iPhone via JSON. This is a much better way than using XML. Parsing XML on the iPhone just plain sucks. It's overly complicated and super confusing. Currently the YouVersion app, Bible, uses JSON to transfer everything back and forth from the server and it all works great.
If you don't really have a choice, at least use JSON. Here is a great library for JSON that I currently use
http://code.google.com/p/json-framework/
From here: http://samsoff.es/post/iphone-plist-tutorial/
You can get JSON by changing the request string to this:
http://maps.google.com/maps?q=grocery&mrt=yp&sll=37.769561,-122.412844&z=14&output=json
Another Edit
Here's another JSON library called Touch JSON. I've used this one, and it's quite easy to implement.
https://github.com/acf/TouchJSON
Rather than using the maps?q= string, it is better to use the the official API here:
http://code.google.com/apis/maps/documentation/geocoding/
The JSON replies of the API work with the JSON Parser http://code.google.com/p/json-framework/ better (the other URL doesn't return compliant JSON, and isn't a standard API so may be more subject to change).