开发者

Is there any way to rotate an MKMapView and still show the Google Logo?

Ok, so I've seen some similar questions to this, but can't seem to find any that really answer the question so here goes.

I'm rotating (or would like to) an MKMapView:

[mapView setTransform:CGAffineTransformMakeRotation(angle)];

This works fine, except that the Google Logo gets rotated with it, which I hear is a no no. Also I would like to actually make my mapView larger than the screen so that when开发者_StackOverflow rotated the entire screen still shows map, but this would also move the Google Logo off the screen.

So is it possible to rotate an MkMapView and still show the Google Logo ??? Maybe a call out to some Google Web AP


So I've figured out a way to do this, although I still feel its a bit of a hack because Apple could change things in future releases that will break this technique.

MKMapView has 2 subviews. One of them is a UIImageView that holds the "Google" image for copyright purposes.

So in IB you can setup your own UIImageView that sits at the lower left corner, and in code you can set its image to be the same image as the one in the UIImageView inside the map view:

-(void) getImage {
    for(UIView *v in mapView.subviews) {

        if([v isKindOfClass:[UIImageView class]]) {
            NSLog(@"%@",v);
            self.cpyView.image=((UIImageView *)v).image;
        }
    }

}

Now when you rotate your MKMapView, your UIImageView won't get rotated.

Now the other trick here is to have the MKMapView embeded in another view (viewForMap) (idea borrowed from Beginning iOS 4 by Wei-Meng Lee).

Drop a UIView into IB and size it to the size you want the visible map to be. Set it to clip sub views in IB.

In code you'll alloc] initWithFrame an MKMapView so that the MKMapView sits centered on this viewForMap, but is larger than it.

For example, if your viewForMap is 320, 372, then do this:

mapView=[[MKMapView alloc] initWithFrame:CGRectMake(-90,-64,500,500)];
mapView.mapType=MKMapTypeHybrid;
mapView.delegate=self;
[viewForMap addSubview:mapView];

Now you can rotate your map mapView.transform=CGAffineTransformMakeRotation(-M_PI/2);

Your UIImageView that is holding the "Google" image won't get rotated so it stays visible. The "Google" image inside the MKMapView will be off screen.


You can do this:

  1. Make a picture "Google" logo in any image editing program.
  2. Increase the size of your MKMapView, that would not have seen the logo.
  3. Add a subview of your picture to MKMapView.

If you'll do without the logo of Google, your application will be rejected according to the following:

8.6 Google Maps and Google Earth images obtained via the Google Maps API can be used within an application if all brand features of the original content remain unaltered and fully visible. Apps that cover up or modify the Google logo or copyright holders identification will be rejected

And best of all, use this: http://wiki.openstreetmap.org/wiki/IPhone

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜