- (voID) connectionDIDFinishLoading:(NSURLConnection *)connection{ [self setString]; NSDictionary *dic = [NSJsONSerialization JsONObjectWithData:responseData options:0 error:nil]; NSDictionary *location = [dic objectForKey:@"location"]; NSDictionary *coordinate = [location objectForKey:@"coordinate"]; Nsstring *lat = [coordinate objectForKey:@"latitude"]; Nsstring *lon = [coordinate objectForKey:@"longitude"]; for (NSDictionary *diction in coordinate) { [array addobject:lat]; [array addobject:lon]; } { CLLocationCoordinate2D track; track.latitude = [lat doubleValue]; track.longitude = [lon doubleValue]; MapVIEwAnnotation *newAnnotation = [[MapVIEwAnnotation alloc] initWithTitle:@"Title of Place Here" andCoordinate:track]; [self.mapVIEw addAnnotation:newAnnotation]; }}
第2个问题,非常相关:
在实现上述问题的答案后,我已经修改了我的代码.现在,我的坐标从前一个视图到我的MKMapVIEw,所以我不必费心去做两次API调用,第二个是在MKMapVIEw中.目前在我的VIEwWillAppear中,我有以下内容,并且AGAIN遇到了一个问题,即视图不会居中并放大图钉:
if ([self.stringTodisplay isEqualToString: @"Firehouse gallery"]){ UIImage *img = [UIImage imagenamed:@"firehouse.jpg"]; [imageVIEw setimage:img]; CLLocationCoordinate2D track; track.latitude = [lat doubleValue]; track.longitude = [lon doubleValue]; MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta = 0.01; span.longitudeDelta = 0.01; region.span = span; region.center = track; MapVIEwAnnotation *newAnnotation = [[MapVIEwAnnotation alloc] initWithTitle:@"Firehouse gallery" andCoordinate:track]; [self.mapVIEw addAnnotation:newAnnotation]; [self.mapVIEw setRegion:region animated:TRUE]; [self.mapVIEw regionThatFits:region];}
反馈非常感谢,因为我不知道还应该做些什么.引脚加载到正确的坐标上,只是没有居中/缩放…
@H_502_13@解决方法@H_502_15@ 试试这个:{ CLLocationCoordinate2D track; track.latitude = [lat doubleValue]; track.longitude = [lon doubleValue]; MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta = 0.01; span.longitudeDelta = 0.01; region.span = span; region.center = track; MapVIEwAnnotation *newAnnotation = [[MapVIEwAnnotation alloc] initWithTitle:@"Title of Place Here" andCoordinate:track]; [self.mapVIEw addAnnotation:newAnnotation]; [self.mapVIEw setRegion:region animated:TRUE]; [self.mapVIEw regionThatFits:region];}总结
以上是内存溢出为你收集整理的xcode – 尝试在Pin上居中地图(MKMapView)全部内容,希望文章能够帮你解决xcode – 尝试在Pin上居中地图(MKMapView)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)