IOS/iPhone sample code for selecting a location via placename &/or map via use of Google Maps API?

Any IOS/iPhone sample code for selecting a location via placename &/or map via use of Google Maps API?

So an example of letting the user select a location via user of both: - typing in location & letting Google Maps API attempt to find location and/or - moving placemarker on a map - so for example you could type a place and get close on the map, then adjust the precise location with the map - end result would be Lat,Long

-------------Problems Reply------------

What you are referring to is forward geocoding and unfortunately apple has not provided an api for it. However, there is the next best thing, a third party api. Check out this project, I used it successfully in two projects, works great: https://github.com/bjornsallarp/BSForwardGeocoder

Make sure you include the files necassary so that you can include BSForwardGeocoder without error. Then, simply make the class you want to use it in a BSForwardGeocoderDelegate, and implement the following two protocol methods in your class:

-(void)queryAddress
{
// Initialize member BSForwardGeocoder object
if (forwardGeocoder == nil) {
forwardGeocoder = [[BSForwardGeocoder alloc] initWithDelegate:self];
}

// send the request

[forwardGeocoder findLocation:@"Saint Paul, MN"];
}

and:

-(void)forwardGeocoderFoundLocation:(BSForwardGeocoder *)geocoder
{
/*
* BSForwardGeocoder delegate method. Receives the callback upon geocoding data gather completion.
*/
if (forwardGeocoder.status == G_GEO_SUCCESS) {

int searchResults = [forwardGeocoder.results count];

for (int i = 0; i < searchResults; i++) {

// See the sample project code fore other useful location properties...
// Here I retrieve the returned lat and lon.

Result *location = [forwardGeocoder.results objectAtIndex:i];
mLatitude = location.latitude;
mLongitude = location.longitude;
}
} else {
NSString *message = @"";

switch (forwardGeocoder.status) {
case G_GEO_BAD_KEY:
message [email protected]"Bad Api Key";
break;

case G_GEO_UNKNOWN_ADDRESS:
message = @"Address Not Found!";
break;

case G_GEO_TOO_MANY_QUERIES:
message = @"Too Many Queries";
break;

default:
break;
}

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Information"
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[ alert show ];
[ alert release ];
}
}

This would return the latitude and longitude of Saint Paul, Minnesota using the great library provided by sallarp.

If you want to drag annotations around the map and get their coordinate info this is possible as well, you need to make your class a mkmapview delegate and implement the mapView:annotationView:didChangeDragState:fromOldState: method. In your implementation, first check to see if newState is equal to mkAnnotationViewDragStateEnding, if so you can get its coordinate info via the annotationView.annotation.coordinate property. Of course you need to set your annotation views draggable property to YES. If you wanted, you could fire these coordinates in NSString format off to google via the BSForwardGeocoder query method and get it's associated info.

Greg

Category:iphone Views:0 Time:2011-12-09

Related post

  • download iphone sample code from apple 2010-04-04

    the iphone sdk documentation has links to sample code, but you have to download them individually from the web. Is there a bundle you can download all at once from apple ? For example, reading the first iphone tutorial at switchonthecode, the first n

  • AU Preset (.aupreset) resource path issue in iOS LoadPresetDemo sample code 2012-02-03

    I've been working with the iOS LoadPresetDemo sample code - if loads AUPreset files to configure different types of samplers (pretty cool) - and have run into a question/issue. The demo code runs fine but when I try to reuse the .aupreset files in te

  • Where can I find older versions of the iPhone sample code 2010-06-29

    I'm trying to find some of the old iphone sample code, becuase it seems like apple will only let you download the most recent versions (compatable with iphone 3.2 +). Is there an archive of these someplace, is there a reason that they remove the olde

  • digital zoom iphone sample code 2010-05-24

    any one has sample code or know of a tutorial on how to do a digital zoom for an iphone? or digital zoom in general ? thank in advanced. -Amir --------------Solutions------------- Consider these Categories for NSImage for ways in which you can zoom a

  • LazyTableImages for iPhone Sample Code Reload Question 2010-11-18

    I am using the LazyTableImages sample code to aynchronusly load images in my table view from an RSS feed. What I would like to know is, how to reload (restart the parsing operation) in this table once a new item has been added, specific to this examp

  • Google + API Iphone sample code 2011-10-12

    I need to integrate google + and +1 sharing in my iphone application. I am looking for a sample code from which i can get some help. Please help me out of this. Thanks, Divya --------------Solutions------------- There is a nice library written by goo

  • iOS: UIImageView Sample Code 2012-01-28

    I'm writing an application that allows users to upload photos from their camera roll and save them in the app. The only problem is that I'm not sure where to begin. I read over Apples documents on UIImageView, but that didn't seem to help as much as

  • How to select two geo-points on one page by clicking the Google map? 2011-04-20

    I have 4 fields and one map on my form. I have to choose Start Location and End location. The start latitude, start longitude, end latitude and end longitude are the four fields. What I have to do is, to choose the start and end locations by clicking

  • Determining if a hashtag refers to a location at the town/city level using the Google geolocation APIs 2013-12-06

    So I'm making a service which searches for a specific hashtag and then attempts to place the origin of those tweets on a map. There are three methods for determining the location. One is doing a reverse lookup on the geolocation data, which is only a

  • Load locations from two-dimensional array into bMap (a google maps for jQuery plugin) 2010-11-30

    I am using bMap jQuery plugin to ease up the process of working with Google Maps on my site. The way to load markers to the GoogleMap is using the following method. $('#map').data('bMap').insertMarkers({ "name":"Markers", "data":[ { "lat":51.49757618

  • Why does iPhone sample code use so many intermediate variables? 2011-08-12

    I'm currently working through Apress's "Beginning iPhone 3 Development". A standard they use in their example applications is like the following code: - (void)viewDidLoad { BlueViewController *blueController = [[BlueViewController alloc] initWithNibN

  • iOS / iPhone engine, code or framework used for Comic Apps? 2010-12-21

    I recently noticed most Comic book apps I've downloaded seem to use the same reader code. Walking Dead, Hetalia and Do Androids dream... have the exact same behaviour and even the same messages. Does anyone have any clue where can I find this shell.

  • Getting the Current Location Lat Long as 0.0 in Android google maps 2013-09-19

    I want to latitude and longtitude at current location. it run work on emulator but give lat/long 0.0 on mobile device. my device is LG 4x hd. src/.java file : private TextView txt_lat,txt_lon,txt_gps; private LocationManager lm; double lat, lon; prot

  • Locating GPS coordinates in an automated fashion through Google Maps 2009-10-20

    At http://maps.google.com, if you search for something like "Deschutes River, Oregon", you get an automatic GPS marker coordinate. Sometimes you get several different options on the side and I'm trying to figure out if you can obtain these markers au

  • How to start an android project with downloaded sample code 2010-06-01

    I'm pretty new to android, and just finished setup my environment and reading some tutorials. Then I got sdk samples from the web. Okay, what I wanna ask you is that is there a way to start a sample as a project in the Eclipse? I mean like clicking a

  • how to get country location on Google Map in iphone using Country name only? 2009-09-24

    In my iphone application i have integrated Google Map.I want to show the country location on Google map using only country Name Only.(Not needed to use its latitude and longitude).The input only will be the country name?(i.e India) to the google Map

  • How do you modify this sample code to stop Image Views from stacking? 2011-08-14

    http://developer.apple.com/library/ios/#samplecode/Touches/Introduction/Intro.html I'm new to IOS development, and have been playing around with the IOS dev sample code, trying to learn how things work, etc... I came across this sample code (the clas

  • How do i open Google Maps for directions using coordinates on the iphone 2009-10-10

    I am using UIMapView to display locations on the iPhone. I want to do a directions from current location to the location of interest, I don't think its possible using MapKit (but if it is please inform) So I will open either the Google Maps applicati

  • How to display location in Google Maps? 2012-03-09

    When I visit http://maps.google.com on my iOS device, the current location is shown as in the image below. I'm creating my own Map using the Google Maps API v3. How can I create this function? I've tried their sample using geolocation in the web brow

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.194 (s). 11 q(s)