盒子
盒子
文章目录
  1. MapKit的核心类为MkMapKit
    1. 常用属性
    2. MKMapKit Function
    3. Delegate Functions
  2. MKAnnotationView
    1. Attributes
  3. MapView 的技巧与注意事项

iOS MapKit 总结

MapKit的核心类为MkMapKit

常用属性

  • showUserLocation: Bool

  • userLocation: MKUserLocation

  • userTrackingMode: MKUserTrackingMode

enum MKUserTrackingMode: NSInteger {
MKUserTrackingModeNone = 0,
MKUserTrackingModeFollow,
MKUserTrackingModeWithHeading,
}

  • mapType: MKMapType

enum MKMapType: NSInteger {
MKMapTypeStandard = 0,
MKMapTypeSatellite,
MKMapTypeSatelliteFlyover,
MKMapTypeBirdFloyover,
}

  • annotations:
  • zoomEnabled: Bool

  • scrollEnabled: Bool

  • rotateenabled: Bool

  • pitchEnabled: Bool

  • showsBuilding: Bool

  • showsTraffic: Bool

  • showsCompass: Bool

  • showsScale: Bool

MKMapKit Function

func addAnnotation( annotation: MKAnnotation)
func addAnnotations(
annotations: [MKAnnotation])

func removeAnnotation( annotation: MKAnnotation)
func removeAnnotations(
annotations: [MKAnnotation])

selectAnnotation: annotation animated: Bool
deselectAnnotation: annotation animated: Bool

viewForAnnotation: annotation
dequeueResuableAnnotationViewWithIdentifier

setRegion:Region, animated: Bool
SetCenterCoordinate: coordinate, animated: Bool

convertCoordinate: coordinate, toPointToView: view
convertPoint: oint, toCoordinateFromView: view

Delegate Functions

  • mapViewDidFinishLoadingMap

  • mapViewDidFailLoadingMap

  • mapViewDidUpdateUserLocation

  • mapViewRegionDidChangeAnimation

  • mapViewdidSelectedAnnotationView

  • mapViewdidDeselectedAnnotationView

  • mapviewViewForAnnotation

MKAnnotationView

Attributes

annotation: MKAnnotation
image: UIImage
reuseIdentifier: NSString
calloutOffset: CGPoint
seleted: Bool
canShowCallout: Bool
leftCalloutAccessoryView: UIView
rightCalloutAccessoryView: UIView

MapView 的技巧与注意事项

  1. refresing MKMapView for iphone developement
    Issue: add annotations after the view is loaded. The annotations cannot be displayed on the mapview
    Solution:
1
2
3
4
5
6
7
[self performSelectorOnMainThread;@selector(reloadMap) 
withObject: nil waitUntilDone: false];

- (void) reloadMap
{
[map setRegion: map.region animated: true];
}
  1. iOS refreshing annotations on MapView, simply remove all the annotations and then re-add them
    1
    2
    [mapView removeAnnotations: [mapView.annotations]];
    [mapView addAnnotations: [mapView.annotations]];
支持一下
扫一扫,支持forsigner
  • 微信扫一扫
  • 支付宝扫一扫