ZMSMapView

Objective-C

@interface ZMSMapView : UIView <UIGestureRecognizerDelegate,
                                UITableViewDataSource, UITableViewDelegate>

Swift

class ZMSMapView : UIView, UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate

地図クラス

地図の生成・表示・コントロールを行うメインクラス。

Note

ZMSMapViewはメインスレッドから読み込まれ、更新される。
ほかのスレッドから呼び出されると、例外や未定義の動作となる。
  • 地図イベントのデリゲート

    イベントの発生を受け取るクラスを設定する。

    Declaration

    Objective-C

    @property (nonatomic, weak) id<ZMSMapViewDelegate> delegate;

    Swift

    weak var delegate: ZMSMapViewDelegate! { get set }
  • カメラ位置情報

    ZMSCameraPosition のインスタンス。
    地図のカメラ位置を取得する。

    Declaration

    Objective-C

    @property (nonatomic, readonly) ZMSCameraPosition *camera;

    Swift

    var camera: ZMSCameraPosition! { get }
  • 座標とスクリーン座標情報

    ZMSProjection のインスタンス。
    緯度・経度座標とスクリーン座標関連の処理を行う。

    Declaration

    Objective-C

    @property (nonatomic, readonly) ZMSProjection *projection;

    Swift

    var projection: ZMSProjection! { get }
  • 位置情報のバックグラウンド取得フラグ

    true、または指定なしの場合はフォアグラウンド時のみ取得する。falseの場合はバックグラウンドでも取得する。

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL onlyForegroundLocationUpdatesAllowed;

    Swift

    var onlyForegroundLocationUpdatesAllowed: Bool { get }
  • 現在地取得の有効化

    このフラグが有効(YES)で、ユーザーが現在地取得を許可した場合、現在地の取得を開始し、地図上に現在地を示すマーカーが表示される。

    Note

    有効(YES) / 無効(NO)
    デフォルト値: NO

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isMyLocationEnabled) BOOL myLocationEnabled;

    Swift

    var isMyLocationEnabled: Bool { get set }
  • 現在地の位置情報

    現在地取得が無効の場合やユーザーが現在地取得を許可していない場合は場合はNULLが返る。
    値を設定した場合に、現在地の取得を停止し、現在地マーカーが指定した位置に表示される。
    ユーザー指定の現在地の変更を解除したい場合はNULLを設定する。

    Declaration

    Objective-C

    @property (nonatomic, nullable) CLLocation *myLocation;

    Swift

    var myLocation: CLLocation? { get set }
  • ヘディングアップモードの有効化

    このフラグが有効(YES)の場合、端末の位置情報・向きに合わせて、camera が常時更新される。

    Note

    有効(YES) / 無効(NO)
    デフォルト値: NO

    Declaration

    Objective-C

    @property (nonatomic) BOOL headingUp;

    Swift

    var headingUp: Bool { get set }
  • 選択されているマーカー

    選択されているマーカーを取得したり、設定したマーカーを選択状態にする。

    Note

    何も選択されていない場合はNULLが戻る。
    NULLを設定した場合マーカーの選択状態が解除される。

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) ZMSMarker *selectedMarker;

    Swift

    var selectedMarker: ZMSMarker? { get set }
  • マップタイプ

    地図のデザインを取得・設定する。

    Declaration

    Objective-C

    @property (nonatomic) NSString *mapType;

    Swift

    var mapType: String! { get set }
  • 地図タイプリスト

    設定できるマップタイプの一覧を取得する。

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<NSString *> *mapTypeList;

    Swift

    var mapTypeList: [String]! { get }
  • 最小ズームレベル (読み取り専用)

    Declaration

    Objective-C

    @property (nonatomic, readonly) float minZoom;

    Swift

    var minZoom: Float { get }
  • 最大ズームレベル (読み取り専用)

    Declaration

    Objective-C

    @property (nonatomic, readonly) float maxZoom;

    Swift

    var maxZoom: Float { get }
  • UIの制御 (読み取り専用)

    ZMSUISettings のインスタンス。
    ジェスチャーの有効・無効、コンパスボタン・現在地ボタン・スケールバー・現在地マーカーの表示状況・表示位置などを変更する。

    Declaration

    Objective-C

    @property (nonatomic, readonly) ZMSUISettings *settings;

    Swift

    var settings: ZMSUISettings! { get }
  • パディングの設定

    地図の4辺にパディングを設定する。
    パディングはUIの表示位置、地図の中心に影響する。

    Note

    UI(コンパスボタン・現在地ボタン等)は地図の表示領域からパディングを除いた領域に配置される。
    同様にパディングを除いた領域の中心部分がカメラ位置の座標になる。

    Declaration

    Objective-C

    @property (nonatomic) UIEdgeInsets padding;

    Swift

    var padding: UIEdgeInsets { get set }
  • 必須パラメーターからZMSMapViewを生成する

    地図の生成を行う。

    Declaration

    Objective-C

    + (instancetype)mapWithFrame:(CGRect)frame camera:(ZMSCameraPosition *)camera;

    Swift

    class func map(withFrame frame: CGRect, camera: ZMSCameraPosition!) -> Self!

    Parameters

    frame:

    フレーム

    camera:

    カメラ位置情報

    Return Value

    地図

  • 必須パラメーターからZMSMapViewを生成する

    地図の生成を行う。

    Declaration

    Objective-C

    + (instancetype)mapWithFrame:(CGRect)frame
                                      camera:(ZMSCameraPosition *)camera
        onlyForegroundLocationUpdatesAllowed:
            (BOOL)onlyForegroundLocationUpdatesAllowed;

    Swift

    class func map(withFrame frame: CGRect, camera: ZMSCameraPosition!, onlyForegroundLocationUpdatesAllowed: Bool) -> Self!

    Parameters

    frame:

    フレーム

    camera:

    カメラ位置情報

    onlyForegroundLocationUpdatesAllowed:

    バックグラウンドでの位置情報更新を可能にするかどうかのBOOL値。YES: バックグラウンドでの位置情報更新可能, NO: バックグラウンドでの位置情報更新不可

    Return Value

    地図

  • 必須パラメーターからZMSMapViewを非同期で生成する

    地図の生成を非同期で行う。

    Declaration

    Objective-C

    + (instancetype)mapWithFrame:(CGRect)frame
                          camera:(ZMSCameraPosition *)camera
                          target:(id)obj
                        selector:(SEL)mapDidLoad;

    Swift

    class func map(withFrame frame: CGRect, camera: ZMSCameraPosition!, target obj: Any!, selector mapDidLoad: Selector!) -> Self!

    Parameters

    frame:

    フレーム

    camera:

    カメラ位置情報

    target:

    呼び出し元

    selector:

    コールバック (地図を受け取る)

  • 必須パラメーターからZMSMapViewを非同期で生成する

    地図の生成を非同期で行う。

    Declaration

    Objective-C

    + (instancetype)mapWithFrame:(CGRect)frame
                                      camera:(ZMSCameraPosition *)camera
                                      target:(id)obj
                                    selector:(SEL)mapDidLoad
        onlyForegroundLocationUpdatesAllowed:
            (BOOL)onlyForegroundLocationUpdatesAllowed;

    Swift

    class func map(withFrame frame: CGRect, camera: ZMSCameraPosition!, target obj: Any!, selector mapDidLoad: Selector!, onlyForegroundLocationUpdatesAllowed: Bool) -> Self!

    Parameters

    frame:

    フレーム

    camera:

    カメラ位置情報

    target:

    呼び出し元

    selector:

    コールバック (地図を受け取る)

    onlyForegroundLocationUpdatesAllowed:

    バックグラウンドでの位置情報更新を可能にするかどうかのBOOL値。YES: バックグラウンドでの位置情報更新可能, NO: バックグラウンドでの位置情報更新不可

  • 地図に追加されている全ての重畳物を削除する

    Warning

    メインスレッドで実行すること。

    Declaration

    Objective-C

    - (void)clear;

    Swift

    func clear()
  • ズームレベルの最小値と最大値を設定する

    Note

    有効範囲: 2.0 - 21.0
    minZoom > maxZoomの場合は無視される。

    Declaration

    Objective-C

    - (void)setMinZoom:(float)minZoom maxZoom:(float)maxZoom;

    Swift

    func setMinZoom(_ minZoom: Float, maxZoom: Float)

    Parameters

    minZoom:

    最小ズームレベル

    maxZoom:

    最大ズームレベル

  • カメラ位置を更新する

    指定されたカメラ位置更新情報で現在のカメラ位置を更新する。

    Declaration

    Objective-C

    - (void)moveCamera:(ZMSCameraUpdate *)update;

    Swift

    func moveCamera(_ update: ZMSCameraUpdate!)

    Parameters

    update:

    カメラ位置更新情報

  • カメラ位置情報でアニメーションを実行する

    現在のカメラ位置から、指定されたカメラ位置情報まで指定時間でアニメーション移動する。

    Declaration

    Objective-C

    - (void)animateToCameraPosition:(ZMSCameraPosition *)cameraPosition
                           duration:(double)duration;

    Swift

    func animate(to cameraPosition: ZMSCameraPosition!, duration: Double)

    Parameters

    cameraPosition:

    カメラ位置情報

    duration:

    時間 (秒)

  • 座標でアニメーションを実行する

    現在のカメラ位置から、指定された座標まで指定時間でアニメーション移動する。

    Declaration

    Objective-C

    - (void)animateToLocation:(CLLocationCoordinate2D)location
                     duration:(double)duration;

    Swift

    func animate(toLocation location: CLLocationCoordinate2D, duration: Double)

    Parameters

    location:

    座標(緯度/経度)

    duration:

    時間 (秒)

  • ズームレベルでアニメーションを実行する

    現在のカメラ位置から、指定されたズームレベルまで指定時間でアニメーション移動する。

    Note

    ズームレベルの有効範囲: 2.0 - 21.0 (2.0が最も引いた状態)
    有効範囲を超えた分は有効範囲内に正規化される。

    Declaration

    Objective-C

    - (void)animateToZoom:(float)zoom duration:(double)duration;

    Swift

    func animate(toZoom zoom: Float, duration: Double)

    Parameters

    zoom:

    ズームレベル

    duration:

    時間 (秒)

  • 方位角でアニメーションを実行する

    現在のカメラ位置から、指定された方位角まで指定時間でアニメーション移動する。

    Note

    有効範囲: 0 - 360度 (時計回り)
    デフォルト値: 0
    有効範囲を超えた分は循環し、360度以内に正規化される。

    Declaration

    Objective-C

    - (void)animateToBearing:(CLLocationDirection)bearing duration:(double)duration;

    Swift

    func animate(toBearing bearing: CLLocationDirection, duration: Double)

    Parameters

    bearing:

    方位角

    duration:

    時間 (秒)

  • 傾き角度でアニメーションを実行する

    現在のカメラ位置から、指定された傾き角度まで指定時間でアニメーション移動する。

    Note

    有効範囲: 0 - 30度 (0度は地図平面に対して直角)
    デフォルト値: 0
    超えた分は有効範囲内に正規化される。

    Declaration

    Objective-C

    - (void)animateToViewingAngle:(double)viewingAngle duration:(double)duration;

    Swift

    func animate(toViewingAngle viewingAngle: Double, duration: Double)

    Parameters

    viewingAngle:

    傾き角度

    duration:

    時間 (秒)

  • カメラ位置更新情報でアニメーションを実行する

    現在のカメラ位置を、指定されたカメラ位置更新情報に応じて指定時間をかけてアニメーション移動する。

    Declaration

    Objective-C

    - (void)animateWithCameraUpdate:(ZMSCameraUpdate *)cameraUpdate
                           duration:(double)duration;

    Swift

    func animate(with cameraUpdate: ZMSCameraUpdate!, duration: Double)

    Parameters

    update:

    カメラ位置更新情報

    duration:

    時間 (秒)

  • 移動範囲

    カメラが移動できる領域を制限する。
    指定した範囲外には移動できなくなる。

    Note

    指定した領域の左下と右上の緯度・経度が同一の場合、移動範囲の制限は行われない。

    Declaration

    Objective-C

    - (void)setMovableRegion:(ZMSCoordinateBounds *)bounds;

    Swift

    func setMovableRegion(_ bounds: ZMSCoordinateBounds!)

    Parameters

    bounds:

    領域

  • コンパスアイコンがタップされていない時の背景画像を設定する

    Note

    NULLの場合、デフォルトの画像が設定される。
    背景部分は地図の回転に連動せず固定表示される。

    Declaration

    Objective-C

    - (void)setCompassBackgroundImage:(nullable UIImage *)backgroundImage;

    Swift

    func setCompassBackgroundImage(_ backgroundImage: UIImage?)

    Parameters

    image:

    画像

  • コンパスアイコンがタップされた時の背景画像を設定する

    Note

    NULLの場合、デフォルトの画像が設定される。
    背景部分は地図の回転に連動せず固定表示される。

    Declaration

    Objective-C

    - (void)setCompassBackgroundFocusImage:(nullable UIImage *)backgroundFocusImage;

    Swift

    func setCompassBackgroundFocus(_ backgroundFocusImage: UIImage?)

    Parameters

    image:

    画像

  • コンパスアイコンの針画像を設定する

    Note

    NULLの場合、デフォルトの画像が設定される。
    針画像は地図の回転にともない回転する。

    Declaration

    Objective-C

    - (void)setCompassNeedleImage:(nullable UIImage *)needleImage;

    Swift

    func setCompassNeedleImage(_ needleImage: UIImage?)

    Parameters

    image:

    画像

  • 現在地ボタンがタップされていない時の画像を設定する

    Note

    NULLの場合、デフォルトの画像が設定される。

    Declaration

    Objective-C

    - (void)setgpsOnImage:(nullable UIImage *)onImage;

    Swift

    func setgps(on onImage: UIImage?)

    Parameters

    image:

    画像

  • 現在地ボタンがタップされた時の画像を設定する

    Note

    NULLの場合、デフォルトの画像が設定される。

    Declaration

    Objective-C

    - (void)setgpsFocusImage:(nullable UIImage *)focusImage;

    Swift

    func setgpsFocus(_ focusImage: UIImage?)

    Parameters

    image:

    画像

  • 指定した座標とズームレベルで地図が描画できるか問い合わせる

    Note

    サーバー通信を行うため、ネットワーク状況によっては処理に時間がかかる。
    非同期で実行される。

    Declaration

    Objective-C

    - (CheckMapAreaResult)checkMapArea:(CLLocationCoordinate2D)coordinate
                                  zoom:(float)zoom;

    Swift

    func checkMapArea(_ coordinate: CLLocationCoordinate2D, zoom: Float) -> CheckMapAreaResult

    Parameters

    coordinate:

    座標(緯度/経度)

    zoom:

    ズームレベル

    Return Value

    CheckMapAreaResult