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.
Related
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.
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...
I have a map image and I would like to be able to drag the image somewhere on the screen and then be able to go get another image from a webserver with the new map image being where the old image was dragged.
I've tried the UIImageView in a UIScrollView but the image is bounced back to fill the screen if I try to drag it off. Setting the UIScrollView .bounces = NO isn't what I need either because that just prevents me from dragging the image off of the screen. Is there an easy way to get this functionality?
I think you want to look at the UIResponder methods touchesBegan, touchesMoved and touchesEnded.
I ended up using UIPinchGestureRecognizer and UIPanGestureRecognizer to do this.
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
I haven't been able to figure this out. Could someone please help me? I am trying to stop one UIView in my app from rotating when the device is turned.
I am working on a drawing app. Right now, when the device is turned, all UI elements turn with it. What I am trying to do is have all the buttons, menus, etc. turn, but have my canvas UIView be static and ignore the rotation of the phone.
If the canvas view is a subview of a view that rotates, then it will rotate as well. It's inescapable.
If you have one element of a view that you do not want to appear to rotate, you have use a rotation transform to programmatically rotate that one view back to the orientation and frame you want it have.
You could use the following to prevent the view itself from rotating:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return false;
}
Then manually rotate the individual elements you want rotated.
OP here. Rotating the view using CGAffineTransformMakeRotate() worked like a charm. Thanks, TechZen!