Nsstring *placeLatitude = [elementCoords objectForKey:@"placeLatitude"];Nsstring *placeLongitude = [elementCoords objectForKey:@"placeLongitude"];CLLocationCoordinate2D location;location.latitude = [placeLatitude doubleValue];location.longitude = [placeLongitude doubleValue];
我如何修改以下内容以不关注用户的当前位置,而是关注上面指定的纬度和经度?
MKCoordinateRegion mapRegion;mapRegion.center = mapVIEw.userLocation.coordinate;mapRegion.span.latitudeDelta = 0.05;mapRegion.span.longitudeDelta = 0.05;解决方法 我会使用
setCenterCoordinate:animated:
来移动地图焦点.如果您正在加载视图并希望立即将其设置到正确的位置,请设置动画:否,否则,如果要平移地图以平滑居中位置,则设置动画:是 [mapVIEw setCenterCoordinate:location animated:YES];
当然,这不会改变地图视图的缩放级别.如果要更新缩放级别,则应使用setRegion:animated:
.例如,如果要放大两倍:
// Halve the wIDth and height in the zoom level.// If you want a constant zoom level,just set .longitude/latitudeDelta to the// constant amount you would like.// Note: a constant longitude/latitude != constant distance depending on distance// from poles or equator.MKCoordinateSpan span = { .longitudeDelta = mapVIEw.region.span.longitudeDelta / 2,.latitudeDelta = mapVIEw.region.span.latitudeDelta / 2 };// Create a new MKMapRegion with the new span,using the center we want.MKCoordinateRegion region = { .center = location,.span = span };[mapVIEw setRegion:region animated:YES];总结
以上是内存溢出为你收集整理的iphone – 使用MKCoordinateRegion在NSString纬度和经度坐标上聚焦MKMapView全部内容,希望文章能够帮你解决iphone – 使用MKCoordinateRegion在NSString纬度和经度坐标上聚焦MKMapView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)