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