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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 09-12-2008, 07:31 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 95
Default Loading (google) Map in view (better way?)

Hi,

Anyone know the best way to load a google map to a view?

Basically, I am interested in displaying a google map and putting a pin at current location... (yes this can be done via the map app, but I am creating a GPS application in which I need to do this in the app).

Currently, the best way I figured out was to either use googles static map API or create a html file, put it on a server, and then from iphone call the html with currentlatitude/currentlongitude params to drop the pin.

Both strategies work well for me, but they are EXTREMELY slow in loading up. I am loading up using the webview control. (see below)

As I said, it works well, but is very slow... I am trying to see if anyone knows of a better way to do this?

Code:
webViewMap.scalesPageToFit = YES;
	[webViewMap loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:finalURL]]];

Thanks!
varchar is offline   Reply With Quote
Old 09-12-2008, 07:36 PM   #2 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Germany, Munich
Posts: 244
Default

Hi,

we have done a prototype in a UIWebView too (the touch handling is done in a overlay UIView that is calling the underlying JavaScript).

There are two solutions for a smooth and fast pane/zoom:

1) Caching the tiles loaded from google / virtual earth
2) Writing a own tile server and own pane/zoom in a simple UIView

Both are not simple to implement - we are on the way to do the first solution - the second is very hard to realize (you have to implement most of the javascript functions via objective-c)

Cheers
Ralf
rhuettl is offline   Reply With Quote
Old 09-12-2008, 07:39 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 95
Default

Thanks for the thoughts.

I just found an interesting piece of code:


iphone-google-maps-component - Google Code

It gives a good idea of how to do this quite well... I will be playing around with it now and see how it can accommodate my requirements.
varchar is offline   Reply With Quote
Old 09-12-2008, 07:47 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Germany, Munich
Posts: 244
Default

Hi,

i tested this component but you get tile failures on the iPhone when zooming and paning! The problem seems to be that the tiles could not be loaded fast enough (you have to use some smaller tiles and as i mentioned in my first post you have to write some kind of cache).

Lets stay in contact
Ralf
rhuettl is offline   Reply With Quote
Old 09-13-2008, 05:27 PM   #5 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 211
Default

Does the google map component require an API key? If so how does this affect commercial viability, i.e., selling it on the app store?
lapse is offline   Reply With Quote
Old 09-13-2008, 07:28 PM   #6 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 95
Default

Yes it requires an API key, since you are calling the google service to draw the map.

Being that you are calling your own web server which in turn is calling googles JS, it shouldnt be a problem selling an app on app store... unless you expect over 500 requests daily, then some permission is required.
varchar is offline   Reply With Quote
Old 09-13-2008, 10:37 PM   #7 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 177
Default

If you charge for the app, there will be a problem. You cannot use a free API key to render Google maps if users must pay to access your implementation of the maps.
skinrock is offline   Reply With Quote
Old 09-13-2008, 10:56 PM   #8 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 211
Default

I believe you can get around this by offering a free web version but charge for the iPhone app.
lapse is offline   Reply With Quote
Old 09-15-2008, 07:08 AM   #9 (permalink)
pdm
New Member
 
Join Date: Aug 2008
Posts: 56
Default

Hi guys,
It would be great if you could post the iPhone source code for that application.
It's definetly helps the beginers to learn.

Thanks,
pdm



Quote:
Originally Posted by varchar View Post
Thanks for the thoughts.

I just found an interesting piece of code:


iphone-google-maps-component - Google Code

It gives a good idea of how to do this quite well... I will be playing around with it now and see how it can accommodate my requirements.
pdm is offline   Reply With Quote
Old 09-15-2008, 07:55 AM   #10 (permalink)
Registered Member
 
Piruz's Avatar
 
Join Date: Sep 2008
Location: France
Posts: 49
Default

@pdm : It was in the "download" section :
iphone-google-maps-component - Google Code
Piruz is offline   Reply With Quote
Old 09-15-2008, 08:03 AM   #11 (permalink)
pdm
New Member
 
Join Date: Aug 2008
Posts: 56
Default

Hi,
I downloaded the source from iphone-google-maps-component - Google Code.
When I run the sample code, I can see only a 'blank white page' on the iPhone simulator.
Are there any config/code changes required to see the results on the simulator.

Thanks in advance.

pdm
pdm is offline   Reply With Quote
Old 09-15-2008, 08:15 AM   #12 (permalink)
Registered Member
 
Piruz's Avatar
 
Join Date: Sep 2008
Location: France
Posts: 49
Default

It's ok for me. I ran this and it works well.
But yeah, it is a little bit long to load. If you don't have a good connexion, it's maybe the problem.
Piruz is offline   Reply With Quote
Old 09-17-2008, 06:11 AM   #13 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 10
Default

Hi, here is an example to launch Google Maps application in your application

NSString *urltext=@"http://maps.google.com/maps?q=cupertino";
NSURL *url=[NSURL URLWithString:urltext];
NSLog(urltext);
[[UIApplication sharedApplication]openURL:url];

If you test in the simulator, it will launch safari to show google maps. If you test in a device, it will launch the google maps of your device.
beausejour is offline   Reply With Quote
Old 01-13-2009, 01:58 AM   #14 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 1
Default Loading Google Map in View

I've seen many are giving solutions but no one is providing detailed information that where it should be modified and how we can start running the application also in the Google-map-component there is no sample file included. So Here is the information for my friends who are new to Iphone map development!


To follow up on this issue, apparently the component is using wenear.com simply to host its javascript. That's unnecessary. The component can easily carry its own javascript with it and remove all non-google dependencies.

Place the current contents of iphone-test in a file called GoogleMapAPI.html in the project.

goto http://www.wenear.com/iphone-test and hit 'View Source'. Stick the contents of the source code into a new HTML file called GoogleMapAPI.html

Then change MapWebView -loadMap as follows.

- (void) loadMap {
int width = (int) self.frame.size.width;
int height = (int) self.frame.size.height;

NSString *path = [[[NSBundle mainBundle] pathForResource:@"GoogleMapAPI" ofType:@"html"]
stringByAppendingFormat:@"?width=%i&height=%i&zoom =%i",
width, height, DEFAULT_ZOOM_LEVEL];


NSURL *url = [[[NSURL alloc] initWithScheme:NSURLFileScheme host:@"localhost" pathath] autorelease];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self loadRequest:request];
}


Enjoye IPHONE Development

Last edited by ticket-directory; 01-13-2009 at 02:05 AM. Reason: to provide complete information
ticket-directory is offline   Reply With Quote
Old 01-13-2009, 03:30 AM   #15 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 148
Default

How does the api key work in this case? I tried this from a local file and it worked, however on my server it doesn't work. It appears locally you do not need a key (I removed it and it still worked).

I loaded that source from a file and it worked, so it doesn't seem to be an issue upfront.

The only issue I see is performance and there is no way to zoom out.

Last edited by john855; 01-13-2009 at 03:40 AM.
john855 is offline   Reply With Quote
Old 01-13-2009, 11:12 AM   #16 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 95
Default

ticket-directory,

Putting the html file locally does not seem to solve the problem with performance. It still seems to take 15+ seconds to load up on a 3G network. Interesting enough, it takes about 10 seconds to show anything, and then about 5 seconds to show tile by tile.

Any insights on how to improve the performance to work as close as possible as the maps app?
varchar is offline   Reply With Quote
Old 01-13-2009, 12:46 PM   #17 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 17
Default

Hi everyone!
I`m using in my app a Map too. i donīt know why apple donīt free the MapKit.framework, but that is another talk.

I use, Route Me, link
Itīs based on tiles, and uses VirtueEarth, OpenStreetMap or CloudMadeMaps, and the project in improving day by day (take a look to the Mailing list.

You can add Marker, manage them, and also, there a lot of delegate methods like double tap or many more.

There is an example inside the code.
If you have some problem to run it, let me know.

Bye
Pety is offline   Reply With Quote
Old 01-13-2009, 01:54 PM   #18 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
Default

@varchar: the html file is the smallest of your worries. Generally it is below 4 KB. What takes all the time to download is the Google Maps API javascript file that you load through the html. That is (currently) 68 KB. And then of course the map tiles.

I was thinking about including the html and JS files into the local project, but that would mean you'd miss out on any bug fixes that Google apply to their API, and I'm pretty sure somewhere in the Googely Fine Print (R) they bu-bu you for doing that.
lbendlin is offline   Reply With Quote
Old 01-13-2009, 11:23 PM   #19 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 95
Default

Pety,

Thank you so much for this link to the map component. I was playing with it for past several hours and all I can say is wow! it is exactly what I was looking for! It is perfect! runs so smooth, just like the native google maps...

Thanks again!
varchar is offline   Reply With Quote
Old 01-14-2009, 02:27 AM   #20 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 17
Default

Hi varchar,
it is great to read that this is what you were looking for.
i was looking for a map view, and i think Route Me is like Google Maps.
Now, iīm working and imporving the map too, if you have any doubts, let me know, ok??
What source are you using??I think VirtuaEarth is the most complete.

iīm waiting for your news.
Bye
Pety is offline   Reply With Quote
Old 01-14-2009, 10:32 AM   #21 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 95
Default

Pety,

Thanks again.

I am just getting into understanding how it all works. I was able to successfully integrate into my project and even add the map view a sub-view...

As far as map data source, I am not sure. How do I change it and finding out which one it is using?

Also, being that I will be releasing my app as a paid app, any pointers on how best to receive map data licensing?
varchar is offline   Reply With Quote
Old 01-18-2009, 11:58 AM   #22 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 17
Default

Hi varchar
Sorry for being late.
To Change the Map data source, double click at MapView.xcodeproj inside Frameworks Group of your project.
Then go to RMMapContents.m and import VirtualEarth for example,

Code:
#import "RMVirtualEarthSource.h"
And in - (id) initForView: (UIView*) view WithLocation:CLLocationCoordinate2D)latlong

change the first line with
Code:
id<RMTileSource> _tileSource = [[RMVirtualEarthSource alloc] init];
All sources avaliable are listed under Tile Source

i donīt know if you need a license to use Virtua Earth.
Iīm lookin for info, if you get it, tell us.

Bye!
Pety is offline   Reply With Quote
Old 02-01-2009, 03:56 AM   #23 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 148
Default

The solution I found was similar to the wenear example. I was worried about bandwidth, but since the tiles are loaded directly from google this turns out not to be an issue. The google code iphone app is dead and the other app I found had some pretty ugly maps and zoom in / zoom out issues.

You do have to intercept the touches on the google map version to get it to behave as expected.
john855 is offline   Reply With Quote
Old 02-11-2009, 04:40 AM   #24 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 83
Default licence

Quote:
Originally Posted by Pety View Post
Hi varchar
Sorry for being late.
To Change the Map data source, double click at MapView.xcodeproj inside Frameworks Group of your project.
Then go to RMMapContents.m and import VirtualEarth for example,

Code:
#import "RMVirtualEarthSource.h"
And in - (id) initForView: (UIView*) view WithLocation:CLLocationCoordinate2D)latlong

change the first line with
Code:
id<RMTileSource> _tileSource = [[RMVirtualEarthSource alloc] init];
All sources avaliable are listed under Tile Source

i donīt know if you need a license to use Virtua Earth.
Iīm lookin for info, if you get it, tell us.

Bye!
So.. does anybody knows more about the licence? I can integrate the virtualearth, but don't i have to pay a licence to microsoft? If yes: how?

And does anybody know how i can switch from "Road" to "Aerial" or "Birds eye" ? That would be nice

Thanks
peterj is offline   Reply With Quote
Old 02-12-2009, 06:57 AM   #25 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 17
Default

Quote:
Originally Posted by peterj View Post
So.. does anybody knows more about the licence? I can integrate the virtualearth, but don't i have to pay a licence to microsoft? If yes: how?

And does anybody know how i can switch from "Road" to "Aerial" or "Birds eye" ? That would be nice

Thanks
Hi peter.
Last night, i received an email from apple telling me that my app was submitted to the AppStore. Here is the app
http://itunes.apple.com/WebObjects/M...t?id=303473309

It has a RouteMe Map, based on VirtualEarth source,but i am waiting for Microsoft to reply my emails about licensing VirtualEarth in an iPhoneApp.
Pety is offline   Reply With Quote
Reply

Bookmarks

Tags
google map, mapview, webview

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: 244
23 members and 221 guests
ADY, AragornSG, bookesp, chillyh, dacapo, Dani77, Davey555, Dominus, dre, glenn_sayers, HemiMG, JasonR, karlam963, M.A.S., marshusensei, mer10, nobre84, Oral B, prchn4christ, Raggou, Rudy, spiderguy84, themathminister
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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