mkmapview

How to store CLLocationCoordinate2D?

故事扮演 提交于 2019-12-30 03:20:07
问题 I'm attempting to build an application that builds and saves routes similar to map my run. I'm using the Breadcrumb sample code, specifically the CrumbPath and CrumbPathView as the base of my routes, from Apple. Two questions: If I try to access the MKMapPoint *points object of the CrumbPath like so: [_route lockForReading]; NSLog(@"%@", _route.points); NSLog(@"%d", _route.pointCount); [_route unlockForReading]; my app crashes, saying: Thread 1: EXC_BAD_ACCESS (code: 1, address: 0x9450342d)

Check whether zoom level changed

自作多情 提交于 2019-12-29 11:36:37
问题 I'm using MapKit on iPhone. How can I know when the user changes the zoom level (zoom in\out the map)? I've tried to use mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated; but that's called even when the map is only dragged. Unfortunately, when the map is dragged the mapView.region.span changes as well... Help? 10x 回答1: It is pretty simple to calculate the zoom level. See the snippet below. You can get the mRect parameter from the visibleMapRect property on your MKMapView

how to make mapview zoom to 5 mile radius of current location

痞子三分冷 提交于 2019-12-29 11:35:35
问题 I know its a very common issue but I am not getting the exact answer for this thing. How to make MKMapView defaults to a zoom of a 5 mile radius of current location. Thanks in advance. 回答1: Use the following code when ever you want to zoom to 5 miles radius: double miles = 5.0; double scalingFactor = ABS( (cos(2 * M_PI * newLocation.coordinate.latitude / 360.0) )); MKCoordinateSpan span; span.latitudeDelta = miles/69.0; span.longitudeDelta = miles/(scalingFactor * 69.0); MKCoordinateRegion

how to make mapview zoom to 5 mile radius of current location

纵然是瞬间 提交于 2019-12-29 11:35:09
问题 I know its a very common issue but I am not getting the exact answer for this thing. How to make MKMapView defaults to a zoom of a 5 mile radius of current location. Thanks in advance. 回答1: Use the following code when ever you want to zoom to 5 miles radius: double miles = 5.0; double scalingFactor = ABS( (cos(2 * M_PI * newLocation.coordinate.latitude / 360.0) )); MKCoordinateSpan span; span.latitudeDelta = miles/69.0; span.longitudeDelta = miles/(scalingFactor * 69.0); MKCoordinateRegion

How to go to second view controller after click on disclosure indicator button

[亡魂溺海] 提交于 2019-12-29 09:34:36
问题 I would like to remove existing annotation from mapview. Scenerio is to click on existing annotation callout part (disclosureindicator button) and it would lead user to another viewcontroller and shows a button you could remove the selected annotation. Actually, I am working on to create exactly same google map application, that is part I am struggling now. Any help would be appreciated! 回答1: The MKMapView class has two methods you need to add/remove annotations: addAnnotation: id

MkMapView cancel loading google tiles

旧巷老猫 提交于 2019-12-29 08:45:29
问题 I have a case where I need to import an overlay map in top of MkMapView. The overlay totally covers the google tiles below so there is no need loading, plus it adds overhead to the app. Is there a way to tell mkMapView to stop loading tiles? 回答1: Actually there are 2 ways to implement the real "Hide Google tiles" method (johndope solution only puts an overlay on top of it but doesn't prevent the tiles from loading). Beware that option one described below might get your application rejected

Annotation on the map problem

…衆ロ難τιáo~ 提交于 2019-12-29 08:19:17
问题 I am trying to create a map app where the user can tag a map with a photo, comment or video, but I am having a problem putting an annotation on the map. My scenario is like this: On the 1st page, the user can see three button with the map (1.photo, 2.comment and 3.video). When he wants to tag the map by clicking on the photo button. I use cammerView class, which gives three more buttons (1.take photo, 2.choose photo and 3.use photo); after taking a photo he has a choice of using photo or not.

different coloured polygon overlays

假装没事ソ 提交于 2019-12-29 07:13:17
问题 is it possible to create different coloured polygons on a map view using the following method? -(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id )overlay{ say if i had 2 polygons could i set one to red and the other to yellow? 回答1: One way is to use the title property to tell one polygon from another. When adding the polygons, set their title accordingly: pone.title = @"one"; [mapView addOverlay:pone]; pother.title = @"other"; [mapView addOverlay:pother]; Then in

Adding a route to a MKMapView

℡╲_俬逩灬. 提交于 2019-12-29 07:08:43
问题 I'm trying to add a routing feature to an app I'm working on. I found Craig Spitzkoff's article on how to draw lines on an MKMapView which works pretty good. But since I don't have the coordinates of the points on the roads that doesn't help me as expected. Is there any way to determine the coordinates between to given points, say my current position and another address? 回答1: Basically you will need to make an HTTP request to the Google Directions API. The terms of service state that you have

Is this a bug with MKMapKitDelegate mapView:didUpdateUserLocation?

笑着哭i 提交于 2019-12-28 18:04:12
问题 I've created a test application with only one view containing an MKMapView and a controller which acts as the MapView's delegate. When I do a fresh build (removed from the device completely before re-installing) and log the callbacks, I can see that mapView:didUpdateUserLocation is called twice before the user has indicated whether they wish to show their current location or not. The MKUserLocation objects passed to the callback are invalid: 2012-03-13 08:20:17.518 MapTest[3325:707] Did