Separate names with a comma.
Discussion in 'iPhone/iPad Programming' started by Narmer, May 16, 2008.
How can I add google maps control to my applicacion?
You can't, not really. There are no hooks for integrating into the google maps bit that apple ships the iPhone with. Also the licensing agreements for free use of the google maps API indicate that whatever you build must be freely available and it must be used in the context of a web browser. You might be able to get around this by hosting a google maps interaction inside a WebView but I don't know how much you can then go and integrate that with the rest of your application (like, I don't know if you can plot data from the phone on the map and cause code to run on the phone as a result of something being taped or moved on the map) *shrug*
Other than that you might be able to get an enterprise subscription to google maps that will let you embed it in your app but you'd probably end up having to rewrite all the map caching and pixel -> lat/long conversions etc yourself. I think they google maps enterprise license runs around 10k as well.
There is maybe a solution, you can look here :
mahm create a "MapView", which is an UIView, "over" a UIWebView, provide some functionnality such as zoom or moving.
So if you want more than zooming, or moving, you should have to implements the other methods. That's why i'm going to try, since I need to add pin, and things like that.
thanks for pointing that out, I had somehow missed it getting announced
if it's really like the android mapview then it should allow you to do some basic stuff like overlays (I just finished a project where we did some pretty extensive hacking with the MapView) but, of course, it's hard to tell without playing with the code
anyway, thanks again
I'm going to try it!!!
It's easy to add overlays
Google Maps Project Update?
I was wondering if there was still an updated version of this project in the works?
Also, I'm relatively new to Objective-C and development in general and was curious as to how I could implement overlays to customize the existing project to suit my needs.
Firstly, I'd like to create tappable markers on the map that can pull up driving directions from the phone's current location.
Any ideas? Thanks in advance!
do the google maps terms of service still apply when using this api? can i, for instance, use this MapView in an app that i'm going to charge for on the app store?
please share some ideas for overlay
Thanks a lot for such nice feature added.
I would appreciate you giving me some hints for adding overlays in this mapview.
You could try placing a UIView over it, setting opaque to NO, clear the view's rect; then drawing your overlay.
This map seems to have accessed http://www.enear.com/iphone-test/ ...
Cant I use it for google maps ?
I tried changing the url to google maps, but it resulted the screen being white. If i use enear ... iphone-test, then how can I specify lattitude and longitude of my choice ?
thanks and regards
UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 300.0, 300.0)];
myView.center = self.center;
self.iView = myView;
I understand i will have to do something like this. But I want to display that view only when I tap on the map. on that location
please guide me how to do that. again on second tap it should hide
I am trying to display an image overlay over the mapview. I changed the code to following, map displays but the image does not display. image displays if i draw the same code in blank view
if (! (self = [super initWithFrame:frame]))
self.onClickHandler = nil;
self.autoresizesSubviews = YES;
self.multipleTouchEnabled = YES;
mMapWebView = [[[MapWebView alloc] initWithFrame:self.bounds] autorelease];
overlayView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 150.0)];
overlayView.image = [UIImage imageNamed"spongebg.jpg"];
overlayView.center = self.center;
this line is not commented ... still it is not showing image on top of the webview
Could the layering be an issue? Perhaps try addSubview: positioned: relativeTo: to make sure the overlay is in front of the map view?
Edit - ignore the above, that's Mac-only. Look at the iPhone view class docs, there are methods that can order the subviews for you - if that's the issue. I don't want to give any iPhone specific details with the NDA still in place!
it seems positioned : relativeto is not there in iphone sdk. tried
[self bringSubviewToFrontverlayView]; in touches ended, but when i tap and release nothing happens !
Some things you could try:
Debug the code, and see if overlayView is actually allocated.
Also check if imageNamed: is actually returning a valid image.
Maybe you could try making the overlay a subview of the mapview, instead of a subview of "self" in the code above.
You could try using a setNeedsDisplay to force the overlay view to redraw.
tried everything u said, even tried making it
... no luck !
I was able to show an view as overlay, by adding it as a separate view in the window.
thanks and regards
I am new to this plateform and I need to integrate the google map in one of my iphone project. I have downloaded the project from given link, but I need to highlight the current location where I am. Please let me know how can I point this google map to current location by using latitude and longitude values.
Thanks & Regards,
I am wondering how to specify position of overlay?
We have the center location, but we don't know the size...
Also, even we do , do we have to calculate the overlay position based on the map by ourselves? It means every time user moves the map, or rezoom, we have to redraw the overlay?
Oh, so in order to get maps, you have to call external API? No wonder why the applications with maps were so slow.
In case it helps, I am using static google maps, although it does not provide the zooming and other functionality, it does go very quick and allow you to create overlays (basic).
Likewise, I have a need to embed the map functionality inside of an app I'm writing at work. Basically I want the map in the top 2/3 of the screen, and a table on the bottom 1/3. I need to be able to have pushpins show up on the map at specific locations (based on the data in the table).
1) how does one go about putting the pushpins or icons or something like that onto the map?
2) Is there a way to add this component into the Interface Builder Palette?
3) I noticed in the code for the MapView that there's a call to:
If #1 has to be done via KML, how do I get the KML injected into the page? Don't I have to host the KML somewhere else? (sorry, I have only very limited experience dealing with Google Maps/Earth.)
Any help is appreciated. I'm on a tight deadline to get this all working....
Wow, it seems like the author of this is totally out of the loop...
I've been playing/fighting with this Map View all day and am having several annoying headaches...
I'm just experimenting with the example app that came in R12.
I made the appDelegate also be a delegate for the MapWebView:
So in MapViewAppDelegate.h:
@interface MapViewAppDelegate : NSObject <UIApplicationDelegate, UIWebViewDelegate, MapWebViewDelegate>
then in MapViewAppDelegate.m, in applicationDidFinishLaunching():
I then implemented the following:
- (void) mapZoomUpdatedTo: (int)zoomLevel
NSLog(@"Zoom level is now: %d",[mapView.mMapWebView getZoom]);
- (void) mapCenterUpdatedToLatLng: (GLatLng)latlng
GLatLng centerpoint = [mapView.mMapWebView getCenterLatLng];
NSLog(@"Center Lat = %f Long = %f", centerpoint.lat, centerpoint.lng);
- (void) mapCenterUpdatedToPixel: (GPoint)pixel
GPoint centerpoint = [mapView.mMapWebView getCenterPixel];
NSLog(@"Center Pt x,y = %d,%d",centerpoint.x,centerpoint.y);
- (void)webViewDidFinishLoad: (UIWebView *)webView
center = [mapView.map getCenterLatLng];
NSLog(@"Current Center is: %f, %f",center.lat,center.lng);
center.lat = 37.137740;
center.lng = -76.652384;
center.lat = 37.137740;
center.lng = -76.652384;
NSLog(@"Finished Loading Page...");
My intention was to try to get the map to be centered on a specific point once the map loads up.
Unfortunately, I'm seeing the zoom level change, and the map type changes to Hybrid correctly, but I'm not seeing the map change to the specified center location. If I take that same code that is trying to set the center, and copy it into the MapView's touchesEnded method, if I try to move the map, it immediately re-centers on the point specified.
What am I doing wrong??? How do I get the map to start up at the point I want???!?!
Additionally, it doesn't seem like any of the MapWebView delegate methods are ever getting invoked.
And has anyone figured out a way to overlay touchable icons onto the map at specific Lat/Long points? I need a way to push and update some icons at specific Lat/Long points, and when you touch them have the display flip to another view that has detailed data about that item at that location.
And is there any way to get this to show up in the Interface Builder so I can make the Map not take up the whole display? I really want to add a toolbar of buttons at the bottom so the user can recenter the display, etc.
Any help would be GREATLY appreciated!!!