MKMapview transform rotate only the map content - iphone

I need to transform-rotate a MKMapview based on the course of the CLLocations I get from CoreLocation.
I basically have this already:
mapview.transform = CGAffineTransformMakeRotation(degreesToRadians(course));
However, this is not good since this rotates the entire map, with annotations. Now I can fix the annotations, but the problem is it also rotates the Google logo!
After searching all other posts here on this problem the main answer was this is not possible with the google logo but the thing is, I have seen some Apps (Trapster for example) that actually do this, they rotate the map but the google logo is always in the same place.
So my question is, is there a new function I don't know about that purely rotates the content of the map, or do all these apps rotate the mapview, fix rotations of the annotations and perhaps add their own google image to the view containing the mapview?
Thanks!

Probably you could do by finding the right view with mapView.subviews.
If I do:
for (UIView *aView in mapView.subviews){
NSLog(#"view class: %#", aView.class);
}
I get back:
view class: UILabel
view class: UIView
view class: UIImageView
view class: UILabel
I would guess one of these is the google logo and the map itself...

Related

Rotate MKMapView? [duplicate]

I need to rotate the content of the mapView according to the compass value:
float myHeadingValue = newHeading.trueHeading;
and for rotating the map I use this:
[mapView setTransform:CGAffineTransformMakeRotation( [self degreesToRadians:myHeadingValue] )];
but it rotates the view, not the content of the view.
How can I make it to rotate the content, not the whole view?
There may be an issue with the google logo being out of shot doing this though. Apple have contacted me to say that my app contravened the guidelines because the google logo was invisible.
I've solved it creating in Interface Builder a smaller UIView and putting the MKMapView into it. The new UIView does not show the leftover map.

iOS Map pin bubble out of screen

When i click on a pin on the map and if the pin is on the borders of the iPhone screen, the bubble comes off the screen, i.e. Half ourside of the viewport and half inside the viewport.
Is there is any property etc which will show the bubble automatically centered on the screen.!
Check this image below to know more about what i mean
http://i.stack.imgur.com/ZSWmZ.png
Any help will be highly appreciated.
You can try to make it so that everytime an annotation is selected, you change the map's center coordinate to the coordinate of your annotation? Instead of calculating the pop up view's dimensions, just do it every time instead. Here's the code to do this. Put this into your delegate for MKMapView
- (void)mapView:(MKMapView *) theMapView didSelectAnnotationView:(MKAnnotationView *)annoView{
[theMapView setCenterCoordinate:annoView.annotation.coordinate animated:YES];
}
Once you've done this, you should be all set.
Also, it's curious to note, that when I tried implementing a mapview, and I added annotations, whenever I selected them, the map automatically moved so as to display the whole calloutView. I wonder why yours isn't doing that. Anyway, if my answer helped, please accept it as your answer. Thnx
Mapkit does a great job of positioning the map when annotations are selected but it can't magically account for other UI elements you've placed in the scene that are obscuring things.
You need to either resize your mapview when your search box is down so it is not obscuring it or you need to add logic to reposition the map if a annotation is selected which is near the top of the view when the search box is visible.

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 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:
Make a picture "Google" logo in any image editing program.
Increase the size of your MKMapView, that would not have seen the logo.
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

Experience with MKMapView Rotation

I have an MKMapView that I am considering rotating in order to more conveniently display a series of Annotations to my users.
As of now I am planning on simply rotating the entire view with a CGAffineTransform, but I wanted to know if anyone had any experience with MKMapView rotation.
Are there any pitfalls or "gotchas" that you came across when adding rotation?
Is there an easier way to rotate a mapview?
If I have an overlay will the convertCoordinate:toPointToView: method still work the same way? I would assume that I'd have to apply the same transform to my overlay for the points to line up, but maybe the method is smarter than that.
If there's anything that you think could help out I'd love to hear it all.
Edit: After much experimentation I believe that I'll be using static maps that I can rotate and overlay myself, however, I would still be interested in any information about MKMapView rotation.
I also plan to use rotated MKMapView in my application. To show annotations unrotated I use the following code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
...
annotationView.transform = GAffineTransformInvert(mapView.transform);
...
}
It seems to work for me.
Sorry to revive a finished topic, but one more 'gotcha': if you size your map view to be large enough to rotate so that it always covers the entire screen then you'll end up cropping the 'Google' logo from the bottom left. This is explicitly contrary to the licence under which you use MapKit and may be grounds for an app rejection. In practice, adding a static version of the Google logo as a UIImageView on top seems to be considered acceptable by all parties.
That's a fresh sample of MKMapView rotation with iPhone ccelerometer. Hope it'll help.
I started working with MKMapView rotations and have found that:
When you apply a CGAffineTransform to the map view the method convertCoordinate:toPointToView: works the same.
Annotations rotate with the view, including annotation text.
Region that fits still appears to fit to a region on the screen, it doesn't fit to the map view (I made my map view larger than its parent view so it could rotate without showing the view behind).

Rotate the content of a MKMapView

I need to rotate the content of the mapView according to the compass value:
float myHeadingValue = newHeading.trueHeading;
and for rotating the map I use this:
[mapView setTransform:CGAffineTransformMakeRotation( [self degreesToRadians:myHeadingValue] )];
but it rotates the view, not the content of the view.
How can I make it to rotate the content, not the whole view?
There may be an issue with the google logo being out of shot doing this though. Apple have contacted me to say that my app contravened the guidelines because the google logo was invisible.
I've solved it creating in Interface Builder a smaller UIView and putting the MKMapView into it. The new UIView does not show the leftover map.