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?
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)
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).
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.
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.
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.
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;
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.
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?
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.
@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.
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...
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.
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
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.
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