Google logo does not show up in Google Map (IPad Application) - iphone

I have a IPad application in which I add MKMapView programmatically without using the NIB.
{
CGRect r = CGRectMake(0, 0, 768, 980);
//CGRect r = CGRectMake(0, 0, 1004, 1004);
mapView = [[MKMapView alloc] initWithFrame:r];
mapView.showsUserLocation = FALSE;
mapView.mapType = MKMapTypeStandard;
//mapView.mapType = MKMapTypeHybrid;
//mapView.mapType = MKMapTypeSatellite;
mapView.delegate = self;
/*Region and Zoom*/
// one degree = 69 miles
// get the distance
// .01 = 1 mile square
//float distance = controller.itemDistance;
float distance = 1.0;
distance = distance/100.0;
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = distance;
span.longitudeDelta = distance;
CLLocationCoordinate2D location = mapView.userLocation.coordinate;
location.latitude = currLocation.coordinate.latitude;
location.longitude = currLocation.coordinate.longitude;
region.span = span;
region.center = location;
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
[self addSubview:mapView];
[self addAnnotation];
}
The problem that I am facing is that the GOOGLE Logo Does not show up at the bottom of the MAP and also not showing the copyright notice. Due to this the application has been rejected from App Store. Can anyone help to add the logo on the MAP ?
Thanks in advance

may be your mapview is bigger than your view that you want to add in. Log frame height and width of view, and see if it is smaller than mapView.
Also consider to add [self setClipToBounds:NO]; and see mapView is flooding.

Related

MKCoordinateRegion setRegion issue

I used this code for iPhone iOS 5.0 device. And everything was OK:
self.mapView = [[[MKMapView alloc]init] autorelease];
mapView.delegate = self;
mapView.frame = CGRectMake(0, 0, 320, 414);
[myView addSubview:mapView];
MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:zoomRegion];
[mapView setRegion:adjustedRegion animated:NO];
Then I tried it on iPhone 6.0, and it crashes at the string [mapView setRegion:adjustedRegion animated:NO];
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Invalid Region <center:+0.00000000, +0.00000000 span:+176.06470039, +360.00004292>'
What should I change in my code?
I think you have to set latitude span and longitude span before setRegion like this,,,,
MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
MKCoordinateRegion adjustedRegion;
adjustedRegion.center = self.mapView.userLocation.coordinate;
adjustedRegion.span.latitudeDelta = 0.01;
adjustedRegion.span.longitudeDelta = 0.01;
adjustedRegion = [mapView regionThatFits:zoomRegion];
[mapView setRegion:adjustedRegion animated:NO];
EDIT
In your case [mapView regionThatFits:zoomRegion]; it create issues.. remove it :
MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
// MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:zoomRegion];
[self.mapView setRegion:zoomRegion animated:NO];

MapKit Polyline custom zoom?

I am trying to learn how to use a polyline to connect two points on a map in ios6. First off, I have read over every tutorial on this subject that a simple Google search turns up and can not get polylines to work for one reason. Every tutorial that I have seen always adds the polyline to the map and adjusts the zoom of the map to fit the whole line. How would I go about making and adding a polyline to a map in ios6 if I want the map to stay zoomed in at a constant distance and only show the end of the polyline if it is larger then the current view?
For example say I had a polyline that was a mile long and wanted the map to stay zoomed in at a constand distacne equivelent to:
MKCoordinateRegion userRegion = MKCoordinateRegionMakeWithDistance(self.currentLocation.coordinate, 1000, 1000);
[self.mainMap setRegion:[self.mainMap regionThatFits:userRegion] animated:YES];
How would I go about doing this? Please provide full code examples or a sample project that I could download!
MKMapPoint * malloc / assign:
MKMapPoint *newPoints = malloc((sizeof (MKMapPoint) * nbPoints));
newPoints[index] = varMKMapPoint;
free(newPoints);
MKPolyline must be initialize in your needed :
MKPolyline *polyline = [MKPolyline polylineWithPoints:newPoints count:nbPoints];
[self.mapView addOverlay:polyline];
to display your MKPolyline, you have to use viewForOverlay :
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKOverlayView* overlayView = [[MKOverlayView alloc] initWithOverlay:overlay];
if([overlay isKindOfClass:[MKPolyline class]]) {
MKPolylineView *backgroundView = [[MKPolylineView alloc] initWithPolyline:overlay];
backgroundView.fillColor = [UIColor blackColor];
backgroundView.strokeColor = backgroundView.fillColor;
backgroundView.lineWidth = 10;
backgroundView.lineCap = kCGLineCapSquare;
overlayView = backgroundView;
}
return overlayView;
}
To use this method, you have to convert your points to CLLocation, it will returns a MKCoordinateRegion that you will set to mapView :
- (MKCoordinateRegion)getCenterRegionFromPoints:(NSArray *)points
{
CLLocationCoordinate2D topLeftCoordinate;
topLeftCoordinate.latitude = -90;
topLeftCoordinate.longitude = 180;
CLLocationCoordinate2D bottomRightCoordinate;
bottomRightCoordinate.latitude = 90;
bottomRightCoordinate.longitude = -180;
for (CLLocation *location in points) {
topLeftCoordinate.longitude = fmin(topLeftCoordinate.longitude, location.coordinate.longitude);
topLeftCoordinate.latitude = fmax(topLeftCoordinate.latitude, location.coordinate.latitude);
bottomRightCoordinate.longitude = fmax(bottomRightCoordinate.longitude, location.coordinate.longitude);
bottomRightCoordinate.latitude = fmin(bottomRightCoordinate.latitude, location.coordinate.latitude);
}
MKCoordinateRegion region;
region.center.latitude = topLeftCoordinate.latitude - (topLeftCoordinate.latitude - bottomRightCoordinate.latitude) * 0.5;
region.center.longitude = topLeftCoordinate.longitude + (bottomRightCoordinate.longitude - topLeftCoordinate.longitude) * 0.5;
region.span.latitudeDelta = fabs(topLeftCoordinate.latitude - bottomRightCoordinate.latitude) * 1.2; //2
region.span.longitudeDelta = fabs(bottomRightCoordinate.longitude - topLeftCoordinate.longitude) * 1.2; //2
// NSLog(#"zoom lvl : %f, %f", region.span.latitudeDelta, region.span.latitudeDelta);
return region;
}
Hope this helps.

How to center the US location in iphone

How to center the location's center in us map in map Kit view
I am sending my code here
mapView .scrollEnabled = YES;
appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
dataStore = [[DataStore alloc] init];
utility = [[Utility alloc] init];
self = [super initWithFrame:CGRectMake(0, 28, mapView.frame.size.width, mapView.frame.size.height)];
//[self setBackgroundColor:[UIColor whiteColor]];
[self setMapView:mapView];
MKCoordinateRegion region;
region.center.latitude = 41.603854;
region.center.longitude = -92.930628;
region.span.longitudeDelta = 47.00;
region.span.latitudeDelta = 10.00;
You need to set the region once you set it up.
region.center.latitude = 41.603854;
region.center.longitude = -92.930628;
region.span.longitudeDelta = 47.00;
region.span.latitudeDelta = 10.00;
[mapView setRegion:region animated:YES];

How to center a UIMapView in the middle of a MKOverlay

I am using the following code (based on the Apple WWDC 2010 TileMap example) to load an UIMapView with a MKOverlay image (this could is in the viewDidLoad method):
NSString *tileDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:#"Tiles"];
TileOverlay *overlay = [[TileOverlay alloc] initWithTileDirectory:tileDirectory];
[map addOverlay:overlay];
Next I was to center the UIMapView map in the center of this overlay. At the moment I am doing this my hard-coding the latitude and longitude as follows:
double myLatitude = ...;
double myLongitude = ...;
CLLocation *location = [[CLLocation alloc] initWithLatitude:myLatitude longitude:myLongitude];
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(location.coordinate, 4000, 4000);
MKCoordinateRegion adjustedRegion = [map regionThatFits:viewRegion];
[map setRegion:adjustedRegion animated:YES];
This works fine. I have tried to calculate the center of the overlay as follows:
double x, y;
x = MKMapRectGetMidX([overlay boundingMapRect]);
y = MKMapRectGetMidY([overlay boundingMapRect]);
CLLocationCoordinate2D coord = MKCoordinateForMapPoint(MKMapPointMake(x, y));
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(coord, 4000, 4000);
MKCoordinateRegion adjustedRegion = [map regionThatFits:viewRegion];
[map setRegion:adjustedRegion animated:YES];
But this does not work. The MKCoordinateForMapPoint returns a latitude/longitude outside the overlay. I don't understand why.
Can anyone suggest a solution?
Thanks in advance...

iPhone SDK: How to center map around a particular point?

New to MapKit. Having problems centering map around a specified point. Here is the code. Not sure why this is not working. We are expecting to see a map centered around Cincinnati, OH. What we are seeing is the default google map of the world.
Any help appreciated.
/ Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
CLLocationCoordinate2D mapCoords[2];
mapCoords[0].latitude = 39.144057;
mapCoords[0].latitude = -84.505484;
mapCoords[1].latitude = 39.142984;
mapCoords[1].latitude = -84.502534;
MKCoordinateSpan span;
span.latitudeDelta = 0.2;
span.longitudeDelta = 0.2;
MKCoordinateRegion region;
region.center = mapCoords[0];
region.span = span;
[mapView setRegion:region animated:YES];
}
Change:
mapCoords[0].latitude = 39.144057;
mapCoords[0].latitude = -84.505484;
mapCoords[1].latitude = 39.142984;
mapCoords[1].latitude = -84.502534;
To:
mapCoords[0].latitude = 39.144057;
mapCoords[0].longitude = -84.505484;
mapCoords[1].latitude = 39.142984;
mapCoords[1].longitude = -84.502534;
I do this in my code and it works fine:
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
CLLocationCoordinate2D location;
location.latitude = 39.144057;
location.longitude = -84.505484;
region.span=span;
region.center=location;
[mv setRegion:region animated:TRUE];
[mv regionThatFits:region];
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
The problem was a combination of the typos above and IB wiring problem.