PDA

View Full Version : iphone sdk map




Narmer
May 16, 2008, 07:16 AM
Hi,

How can I add google maps control to my applicacion?

Thanks



shadowfaux
May 20, 2008, 12:38 AM
Hi,

How can I add google maps control to my applicacion?

Thanks

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.

StrAbZ
May 20, 2008, 04:42 PM
There is maybe a solution, you can look here :

http://code.google.com/p/iphone-google-maps-component/

mahm create a "MapView", which is an UIView, "over" a UIWebView, provide some functionnality such as zoom or moving.

And the WebView "translate" action from the UIView in javascript.

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.

shadowfaux
May 20, 2008, 09:09 PM
There is maybe a solution, you can look here :

http://code.google.com/p/iphone-google-maps-component/

mahm create a "MapView", which is an UIView, "over" a UIWebView, provide some functionnality such as zoom or moving.

And the WebView "translate" action from the UIView in javascript.

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

Narmer
May 21, 2008, 03:28 AM
Thanks!!

I'm going to try it!!!


Best regards,

gammal
May 26, 2008, 03:38 PM
I'm the author of that project, and I'd like to tell you that adding extra features, such as overlays, should be trivial. It was indeed inspired by Android's MapView, but I chose to stick to the Javascript API in naming the methods. There's even a generic method for calling any JS maps method that doesn't have an Objective-C wrapper yet. I'm using the component in a separate project I'm working on, and I actually need to add support for overlays beside other features as well. Naturally, when those features will be added, I'm going to update the Google Code project.

vosens
Aug 27, 2008, 11:45 AM
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!

johnellisdm
Aug 27, 2008, 06:22 PM
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?

jagatnibas
Sep 1, 2008, 07:35 AM
Hi gammal,

Thanks a lot for such nice feature added.

I would appreciate you giving me some hints for adding overlays in this mapview.

please

regards
Jagat

whooleytoo
Sep 1, 2008, 12:49 PM
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.

jagatnibas
Sep 2, 2008, 01:21 AM
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
Jagat

jagatnibas
Sep 2, 2008, 07:49 AM
secondly,

UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 300.0, 300.0)];
myView.center = self.center;
self.iView = myView;
[myView release];
[self addSubview:iView];


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

regards
Jagat

jagatnibas
Sep 11, 2008, 12:11 PM
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

please help

if (! (self = [super initWithFrame:frame]))
return nil;

self.onClickHandler = nil;
self.autoresizesSubviews = YES;
self.multipleTouchEnabled = YES;

mMapWebView = [[[MapWebView alloc] initWithFrame:self.bounds] autorelease];
//[self addSubview:mMapWebView];

overlayView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 150.0)];
overlayView.image = [UIImage imageNamed:@"spongebg.jpg"];
//[self.overlayView setAlpha:0.5];
overlayView.center = self.center;
[overlayView setOpaque:YES];
[self addSubview:overlayView];

[self resetTouches];

return self;

jagatnibas
Sep 11, 2008, 12:14 PM
correction!

//[self addSubview:mMapWebView];

this line is not commented ... still it is not showing image on top of the webview

Jagat

whooleytoo
Sep 11, 2008, 12:22 PM
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! ;)

jagatnibas
Sep 11, 2008, 12:42 PM
it seems positioned : relativeto is not there in iphone sdk. tried

[self bringSubviewToFront:overlayView]; in touches ended, but when i tap and release nothing happens !

whooleytoo
Sep 11, 2008, 12:49 PM
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.

jagatnibas
Sep 11, 2008, 01:20 PM
tried everything u said, even tried making it

window addsubview

:(... no luck !

jagatnibas
Sep 15, 2008, 02:09 AM
I was able to show an view as overlay, by adding it as a separate view in the window.

thanks and regards
Jagat

ranjit
Sep 15, 2008, 08:22 AM
There is maybe a solution, you can look here :

http://code.google.com/p/iphone-google-maps-component/

mahm create a "MapView", which is an UIView, "over" a UIWebView, provide some functionnality such as zoom or moving.

And the WebView "translate" action from the UIView in javascript.

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.

Hi guys,


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,
Ranjit Singh

bluedolphin
Sep 30, 2008, 09:27 PM
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?

Niiro13
Sep 30, 2008, 10:29 PM
Oh, so in order to get maps, you have to call external API? No wonder why the applications with maps were so slow.

varchar
Oct 4, 2008, 01:16 PM
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).

2002cbr600f4i
Oct 12, 2008, 12:32 PM
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).

Couple questions:

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:

"http://maps.google.com/iphone-test?width=%d&height=%d&zoom=%d"

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....

--Mike

2002cbr600f4i
Oct 14, 2008, 01:28 PM
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():

[mapView.map setDelegate:self];

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
{
if(loadcounter==0)
{
GLatLng center;
center = [mapView.map getCenterLatLng];
NSLog(@"Current Center is: %f, %f",center.lat,center.lng);

center.lat = 37.137740;
center.lng = -76.652384;

[mapView.map setCenterWithLatLng:center];
[mapView.map setMapType:G_HYBRID_MAP];
[mapView.map setZoom:7];
loadcounter++;
}
else if(loadcounter==1)
{
GLatLng center;
center.lat = 37.137740;
center.lng = -76.652384;

[mapView.map setCenterWithLatLng:center];
loadcounter++;
}
else
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.

Help!!!

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!!!

--Mike

2002cbr600f4i
Oct 17, 2008, 02:20 PM
Anyone else having problems with this component today (in the simulator)??? All of a sudden now I can't get it to show a map, even from a virgin download of the component + test app! ARGH!

santangeli
Oct 20, 2008, 07:21 AM
I could figure that the problem not updating the center with Lat Lng is because of a javascript error.
At the
- (void) setCenterWithLatLng:(GLatLng)latlng
method on MapWebView change:

NSString *script =
[NSString stringWithFormat:
@"var newCenterLatLng = map.fromContainerPixelToLatLng(newCenterPixel);"
"map.setCenter(new GLatLng(%lf, %lf));",
latlng.lat, latlng.lng];


to :

NSString *script =
[NSString stringWithFormat:
@"var newCenter;"
"if(newCenter==null || newCenter == 'undefined') { "
"newCenter = new GLatLng(%lf, %lf); "
"}"
"map.setCenter(newCenter, 17);",
latlng.lat, latlng.lng];

and this should solve the problem.

The "17" parameter is the zoom level. :)

to add custom icons i'm using the same function because of my project needs. But is easy to create another function for this. The code is below:

<CODE>
NSString *script =
[NSString stringWithFormat:
@"var newCenter;"
"if(newCenter==null || newCenter == 'undefined') { "
"newCenter = new GLatLng(%lf, %lf); "
"}"
"map.setCenter(newCenter, 17);"

"var myIcon = new GIcon(G_DEFAULT_ICON);"
"myIcon.image = 'http://URL_OF_YOUR_CUSTOM_ICON/ICON.png';"
"myIcon.shadow = '';"

"myIcon.iconSize = new GSize(27, 31);"

"markerOptions = { icon:myIcon };"

"var marker = new GMarker(newCenter, markerOptions);"
"map.addOverlay(marker);",

latlng.lat, latlng.lng];
</CODE>

just change the URL to find the icon and the size of it and voila :)

You do things with javascript with this project , and I'm using it a lot.

Thanks a lot to the author.

2002cbr600f4i
Oct 20, 2008, 03:04 PM
Thanks for the center fix!

Yeah, I know how I can add A marker... thing is, I will be getting data from a data feed containing the positions of multiple items I need to place on the map. I'll be getting them one at a time, and they'll need to update position.

Now,I could certainly stuff those all into a data model, and whenever there's an update to teh data model, drop all the layers and create a whole new batch, but I'm going to be getting an update from each item every 5 seconds... 7 items, each refreshing all 7 every 5 seconds = a LOT of blinking! I really need a way to be able to tell the JS to MOVE the markers, and track which marker is which and only move that one...

Any ideas???

And I'm still having issues with the map showing up just as a white screen in the simulator. It was working fine when I tried it the other day, but now I can't even get a fresh download of the MapTest application to run. It just shows a white screen in the sim.

chhoda
Oct 25, 2008, 03:30 AM
Dear Mr Gammal,

Thanks a lot for such a wonderful post and sharing it. Looking at this code, I understand that in your website you have written a kind of plugin which fetches map from Google maps and modfies their javascript to somewhat and delivers to the client. i would be much grateful if you can share that part of the server side code, so that we can use this webview control freely. If not, at least some hints how to do those things will be much helpful if you can share with us.

regards
ch

varchar
Oct 25, 2008, 10:03 AM
Anyone experience very slow map load using this code? since the initial load is slow, I just decided to use google static map which loads 70% quicker then this... of course the downside is that no zoom, no panning, etc...

anyone have solutions for increasing speeD?

2002cbr600f4i
Oct 25, 2008, 08:49 PM
Dear Mr Gammal,

Thanks a lot for such a wonderful post and sharing it. Looking at this code, I understand that in your website you have written a kind of plugin which fetches map from Google maps and modfies their javascript to somewhat and delivers to the client. i would be much grateful if you can share that part of the server side code, so that we can use this webview control freely. If not, at least some hints how to do those things will be much helpful if you can share with us.

regards
ch

Actually, all you need to do is point your normal machines' browser to that URL, capture the source of the page that's returned, and host that HTML yourself (changing the Google Developer' key to your own...) That's all. There's no magic taking place on the server side...

chhoda
Oct 26, 2008, 11:08 AM
But why am I not able to change Lat and Long for this demo mapview application ? If I casn where should I do ?

secondly, why is this demo application not directly fetching map from google map rather is fetching through weneae/iphone_test ?

I suspect there are changes in javascript which if shared can do a lot good for understanding this.

regards
ch

chhoda
Oct 27, 2008, 06:18 AM
shame on me! :(

I figured out there are some rudimentary javascript written in wenear site, which i copied and pasted to a local file of my own and it worked !

But one thing I tried failed. I wanted to pass latitude and longitude parameter values.

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"me1" ofType:@"html"];
filePath = [filePath stringByAppendingString:@"?latitude=21.786600&longitude=82.794762&zoom=10"];

NSLog(filePath);

NSURL *url = [NSURL fileURLWithPath:filePath];

[self loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];

I tried the above code. It did not work.

when i did NSLog([url parameterString]); it wrote a blank in the log.

why so ? If I can pass parameters to this html file properly, my problem will be solved. Please give ideas, I know it is html/javascript related, but ... stuck, unfortunately

regards
ch

chhoda
Oct 27, 2008, 07:47 AM
Damn me... :confused:

http://forums.macrumors.com/showthread.php?t=545705&highlight=html+parameter

this solved my problem, thanks all for the time being, i will comeback on overlays though :P

ch

chhoda
Oct 29, 2008, 06:44 AM
Now again, I need to display a marker at appropriate location of the map if it is visible. Say, if my map center lat lng is 27.7777 and 122.2222 respectively, I need to display an icon corresponding to lat lng 27.1111 and 122.1111

in this scenario I need to know current bounds of the map etc.

I tried using fromLatLngToContainerPixel

But this javascript function returns empty string. So location comes zero or garbage....

Please help if anybody have succeded

regards
Ch

chhoda
Oct 30, 2008, 01:24 PM
It seems the function moveby and pantocenter, these 2 functions are only working.

basically the function which should return a value through sscanf is not working. the string returns by evaljs is null.

even getCenterPixel getCenterLatLng are also not working. were these functions ever tested properly ?

please guys share your findings.

unless i find out the pixels and corresponding lat lng, how would i display and reposition on zoom, drag the overlays ?

regards
Ch

chhoda
Oct 31, 2008, 04:37 AM
Pardon me, I figured out that all those functions are working only when i call it after the whole map is loaded.

now i have a real problem before me. As soon as my aplication starts, i need to display maps with overlays. I cannot determine overlay positions at viewdidload function because mapview us still loading. How would i write a function which gets notified when map loading is finished ?

please help anybody ....

regards
Jagat

yalag
Feb 23, 2009, 09:09 AM
Does anyone know if it is possible to place pins on that map component?

drivefast
Feb 23, 2009, 10:59 AM
yes it is, they are called markers in the google maps slang. i am sure you will figure out how, the google maps api documentation is one of the best api documentations i ever saw. they have plenty of examples too.

yalag
Feb 23, 2009, 11:02 AM
yes it is, they are called markers in the google maps slang. i am sure you will figure out how, the google maps api documentation is one of the best api documentations i ever saw. they have plenty of examples too.

No we are not talking about the google map webpage here. The whole thread has been talking about the google map component, a library that you embed into your UIView. And I want to know if that component supports adding pin/marker.

jnic
Feb 23, 2009, 11:35 AM
No we are not talking about the google map webpage here. The whole thread has been talking about the google map component, a library that you embed into your UIView. And I want to know if that component supports adding pin/marker.

Yes, we are. The API is just a wrapper around a UIWebView. From the project's home page:

A component that you can add to your iPhone application to access all basic features of Google Maps (similar to Android's MapView). It uses a UIWebView in the background to load the HTML/Javascript version of Google Maps, and offers a set of Objective-C methods that mimic a subset of the original Javascript methods for controlling the map.

mgwinthrop
Feb 24, 2009, 05:22 PM
I am a newbie for iphone dev, so please forgive the basic nature of the questions.

The google map code provides the "launching" code for the map in the MapViewAppDelegate. However, I am creating an application that is a tab bar based app and want to launch the app when the tab is clicked. So I have two questions:

1) How would I modify the current launch code the map?
[tabBarController addSubView:mapView]; ?

2) Should I put the launch code in my MapViewController class in the loadView, didLoad, or initWithNibName class?


Thanks

cglode
Feb 25, 2009, 02:53 PM
Hi all

I wanted to share that my company has developed a framework that lets you plug in a nice, tiled map view into your native iPhone application. It's called mapNinja. You can literally have a full featured map experience in your app in a matter of a few lines of code. There is support for image and geometry overlays, text annotations and more. We also have out of box connectors for most popular map providers. Feel free to PM me for more info if you are interested, or check out our FB page for some more info:

http://www.facebook.com/pages/mapNinja/65460296809?ref=ts

Thanks
Chris

yalag
Feb 25, 2009, 02:58 PM
Your account does not allow for PM. Do you have an email contact?

cglode
Feb 25, 2009, 03:20 PM
Your account does not allow for PM. Do you have an email contact?

Ugh. My bad. I will enable PM, or you can email me at christopher dot glode at useful-networks.com

Pring
Feb 25, 2009, 04:08 PM
You guys are aware that you can't use Google Maps in an application that you charge for?

In fact, even using it in a Mobile application at all is dubious. See http://code.google.com/apis/maps/terms.html

Google HAS acted on this and can do at any time.


9.1 Free, Public Accessibility to Your Maps API Implementation. Your Maps API Implementation must be generally accessible to users without charge. You may require users to log in to your Maps API Implementation if you do not require users to pay a fee. Unless you have entered into a separate written agreement with Google or obtained Google's written permission, your Maps API Implementation must not:

(a) require a fee-based subscription or other fee-based restricted access; or
(b) operate only behind a firewall or only on an internal network (except during the development and testing phase).

10.8 use the Static Maps API other than in an implementation in a web browser;

cglode
Feb 26, 2009, 11:17 AM
You guys are aware that you can't use Google Maps in an application that you charge for?

In fact, even using it in a Mobile application at all is dubious. See http://code.google.com/apis/maps/terms.html

Google HAS acted on this and can do at any time.

Our mapNinja product provides out-of-box connectivity to Microsoft Virtual Earth maps, several open-source map providers, and our in-house map server. Depending on requirements there are a lot of cost effective ways to enable a killer maps experience within free or paid apps. It pains me to see so much time and effort being spent by people all trying to solve the same problem (nice in-app maps on the iphone) which is we we developed the mapNinja iPhone maps SDK.

yalag
Feb 26, 2009, 11:20 AM
Our mapNinja product provides out-of-box connectivity to Microsoft Virtual Earth maps, several open-source map providers, and our in-house map server. Depending on requirements there are a lot of cost effective ways to enable a killer maps experience within free or paid apps. It pains me to see so much time and effort being spent by people all trying to solve the same problem (nice in-app maps on the iphone) which is we we developed the mapNinja iPhone maps SDK.

Everyone is trying to solve the dame problem because non one refuse to share their work. And that includes you because mapninja requires you to show ads.

cglode
Feb 26, 2009, 02:06 PM
Everyone is trying to solve the dame problem because non one refuse to share their work. And that includes you because mapninja requires you to show ads.

For clarification: the mapNinja product is available for free, which requires ad display. Alternatively, it is available for a one-time fee, which does not require ad display. The price is a fraction of what it costs to develop and test such a component from scratch; we invested heavily in making a high quality and well documented SDK. The mapNinja has been used by tens of thousands of end customers in our own apps, which provides a level of maturity and stability within the product that is not achievable any other way.

dejo
Feb 26, 2009, 03:07 PM
For clarification: the mapNinja product is available for free, which requires ad display. Alternatively, it is available for a one-time fee, which does not require ad display. The price is a fraction of what it costs to develop and test such a component from scratch; we invested heavily in making a high quality and well documented SDK. The mapNinja has been used by tens of thousands of end customers in our own apps, which provides a level of maturity and stability within the product that is not achievable any other way.
You may want to tone down the commercial advertising, which is against forum rules, or you may find yourself getting reported.

Glibnobin
Mar 7, 2009, 08:01 PM
I'm trying to get the center of the map to return Lat, and Long variables to my app. Can someone point me in the right direction?
Thanks

johnsteve
Apr 20, 2009, 11:31 AM
Hello Mike have u got the solution to get tochable icons on the map???
If u can , Could you please share it here , it will be very help full for me.

Thanks,
Narendar

vt9r
May 26, 2009, 11:53 AM
I'm assuming you implemented these methods in the MapViewAppDelegate.m file. I'm getting errors because of the mapView variable reference in those methods....I'm assuming you did not put all the code you wrote in the example. I'm new to objective c so if you could please update with that code i'd be much obliged.

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():

[mapView.map setDelegate:self];

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
{
if(loadcounter==0)
{
GLatLng center;
center = [mapView.map getCenterLatLng];
NSLog(@"Current Center is: %f, %f",center.lat,center.lng);

center.lat = 37.137740;
center.lng = -76.652384;

[mapView.map setCenterWithLatLng:center];
[mapView.map setMapType:G_HYBRID_MAP];
[mapView.map setZoom:7];
loadcounter++;
}
else if(loadcounter==1)
{
GLatLng center;
center.lat = 37.137740;
center.lng = -76.652384;

[mapView.map setCenterWithLatLng:center];
loadcounter++;
}
else
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.

Help!!!

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!!!

--Mike