Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-11-2009, 02:02 AM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 12
Rojam Nairassoy is on a distinguished road
Default Adding a title to a location when linking to the Maps App

Hello everyone, I am linking to a specific location from my app to the Maps app, and I would like to give said location a custom title. I am very close to getting this working, but something wonky is happening whenever there is a space in the title and I can't figure out the correct code to get it working. Here is what I have:

Code:
NSString *mapURL = [[[NSString alloc] initWithFormat: @"http://maps.google.com/maps?f=q&source=s_q&hl=en&q=%@,+%@+(Custom%20Title%20Here)", videoLat, videoLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: mapURL]];
Everything is working correctly, the latitude and longitude variables and being pulled in, I just don't know the correct formatting to get the title working. The above example is pretty close, the title would be something like Custom2itle2ere. I also tried using %A0 for the spaces in the title, but this produced a bunch of garbled text. Anyhow, any help would be greatly appreciated, thanks!
Rojam Nairassoy is offline   Reply With Quote
Old 04-11-2009, 06:41 PM   #2 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 12
Rojam Nairassoy is on a distinguished road
Default

Bump.
Rojam Nairassoy is offline   Reply With Quote
Old 04-12-2009, 01:37 AM   #3 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Just a shot in the dark here:

Instead of stringByAddingPercentEscapesUsingEncoding: on the entire url, do it only for the title part.

Also, there's no need to use [[NSString alloc] ...] in your case. You can just use [NSString stringWithFormat:];
smithdale87 is offline   Reply With Quote
Old 04-12-2009, 07:06 AM   #4 (permalink)
Former NeXTStep Developer
 
Join Date: Mar 2009
Posts: 997
FlyingDiver will become famous soon enough
Default

Try this:

Code:
NSString *mapURL = [NSString stringWithFormat:@"http://maps.google.com/maps?f=q&source=s_q&hl=en&q=%@,+%@+%@",
     videoLat, videoLon, [[NSString stringWithString: @"(Custom Title Here)"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: mapURL]];
joe
FlyingDiver is offline   Reply With Quote
Old 04-12-2009, 11:37 PM   #5 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 12
Rojam Nairassoy is on a distinguished road
Default

Quote:
Originally Posted by FlyingDiver View Post
Try this:

Code:
NSString *mapURL = [NSString stringWithFormat:@"http://maps.google.com/maps?f=q&source=s_q&hl=en&q=%@,+%@+%@",
     videoLat, videoLon, [[NSString stringWithString: @"(Custom Title Here)"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: mapURL]];
joe
This worked wonderfully, thanks!
Rojam Nairassoy is offline   Reply With Quote
Old 04-21-2009, 02:37 PM   #6 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 97
fordracerguy is on a distinguished road
Default

Great stuff!
fordracerguy is offline   Reply With Quote
Reply

Bookmarks

Tags
google, location, maps, maps.app, title

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 330
7 members and 323 guests
blueorb, guusleijsten, jbro, Kryckter, LEARN2MAKE, n00b, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:58 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0