how do implement search in iphone sdk - iphone

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?

Related

How to access to the Search functionality to get the map annotations similary to Maps IPhone application?

I need to use in my application the search functionality used in the Maps IPhone application.
The application user should be able to search locations by a commercial name and then to select one of the annotations (pins) proposed on the map.
Is this function available to use easily?
This functionality is not available in MKMapView
But i will give you a suggestion
Keep a TextField and accept the user search name from that. Then by using google API get the details about the searched location
http://maps.google.com/maps/geo?q=yourSearchName&output=xml
This will return all location information with latitude longitude, Parse those details.
I think Parsing will not be much complicated.
Use Annotations to pinpoint in the map with the latitude and longitude values you got from parsing.

How to find the long and lat of a city on the iphone?

I am trying to find the long and lat of a city on the iphone. Say the user is searching for London, I would call some function that would retrieve the long and lat of London. I have looked on the web and found you can use a Google API but there must be an Apple function somewhere to handle this?
I have come accross the MKReverseGeocoder which takes the long and lat and tells you what city you are near. e.g.
// reverse geocode the user location
geocoder = [[[MKReverseGeocoder alloc] initWithCoordinate:mapView.userLocation.location.coordinate] autorelease];
If it can reverse the process there must be some form of MKGeocoder class?
but there must be an Apple function somewhere to handle this
Why must there be? Because there isn't.
There are a number of web services you can use (e.g. Google) or you could download a place name database such as http://www.geonames.org/ and import it into your app. It's probably best to import it into an SQL database which you can then search from your app.
See OpenStreetMap. It gives you more flexibility in accessing its data. You could pre-populate a CoreData store with the informations you need.
There are some api-clients, i.e. route-me or cloudmade.
The iOS5 SDK has added support for both forward and reverse geocoding. Take a look at at the CLGeocoder class class for more info.
First, give up that there "must be" an Apple way. There really isn't. If you don't believe me and my nearly 2k of experience points, listen to Ole and his 13k.
There are three services I've seen.
I tried Google's geocoding API. It's decent, but a bit complicated, and they throttle your queries pretty harshly.
Then I tried MapQuest's, which I found to be surprisingly excellent. I have two apps bound for the app store in the next month or so that use MapQuest's API.
Then I found Geonames, which I'm very impressed by but haven't had the opportunity to use yet. Note that Geonames DOES allow you to download their data, so if you really need network-free service, this might be a solution.
Apart from that, you're going to be calling something off the device. Which, by the way, you are when you use MKReverseGeocoder--that's just a wrapper around Google's reverse geocoding service.

Location Based Application for iphone

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.

Search and display business locations on MKMapView

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

Perform reverse geolocation lookup

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