FAMapView 0.1.0

FAMapView 0.1.0

fadi维护。



FAMapView 0.1.0

  • fadizant

FAMapView

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install

要求

  • iOS 9.0
  • 请使用plist中的位置描述
    <key>NSLocationWhenInUseUsageDescription</key>
	<string>$(EXECUTABLE_NAME) needs to access your Location</string>

如何使用

FAMapView 可以为您从您的位置或自定义位置开始创建地图上的大头针,并且您可以将它拖动以更改其位置,FAMapView 将为您返回大头针坐标、地址或地标信息。

您可以通过向 Map Kit View 添加自定义类或调用 "FAMapViewController" 来使用 FAMap。

至少在 UINavigationController 内显示 FAMapViewController,以便可以关闭视图,如果 UINavigationBar 中没有按钮,FAMapViewController 将显示关闭按钮。

使用 FAMap

Objc
  • 坐标
    _mapView.updateCoordinate = ^(CLLocationCoordinate2D coordinate) {
        NSLog(@"Coordinate = %f:%f",coordinate.latitude,coordinate.longitude);
    };
  • 坐标和地址
    _mapView.updateCoordinateWithAdress = ^(CLLocationCoordinate2D coordinate, NSString *address) {
        NSLog(@"Address = %@",address);
    };
  • 坐标和标记
    _mapView.updateCoordinateWithPlacemark = ^(CLLocationCoordinate2D coordinate, CLPlacemark *placemark) {
        NSLog(@"Country = %@ , City = %@",placemark.country,placemark.locality);
    };
Swift4
  • 坐标
    mapView.updateCoordinate = {(coordinate) in
        print("Coordinate = \(coordinate.latitude):\(coordinate.longitude)")
    }
  • 坐标和地址
    mapView.updateCoordinateWithAdress = {(coordinate, address) in
        print("Address = \(address ?? "")")
    }
  • 坐标和标记
    mapView.updateCoordinateWithPlacemark = {(coordinate, placemark) in
        print("Country = \(placemark?.country ?? "") , City = \(placemark?.locality ?? "")")
    }

使用FAMapViewController

Objc
  • 坐标
    FAMapViewController *mapView = [[FAMapViewController alloc]initUserLocationWithDragable:YES updateCoordinate:^(CLLocationCoordinate2D coordinate) {
        NSLog(@"Coordinate = %f:%f",coordinate.latitude,coordinate.longitude);
    }];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:mapView];
    nav.title = @"pik location";
    [self presentViewController:nav animated:YES completion:nil];
  • 坐标和地址
    FAMapViewController *mapView = [[FAMapViewController alloc]initUserLocationWithDragable:YES updateCoordinateWithAddress:^(CLLocationCoordinate2D coordinate, NSString *address) {
        NSLog(@"Address = %@",address);
    }];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:mapView];
    nav.title = @"pik location";
    [self presentViewController:nav animated:YES completion:nil];
  • 坐标和标记
    FAMapViewController *mapView = [[FAMapViewController alloc]initUserLocationWithDragable:YES updateCoordinateWithPlacemark:^(CLLocationCoordinate2D coordinate, CLPlacemark *placemark) {
        NSLog(@"Country = %@ , City = %@",placemark.country,placemark.locality);
    }];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:mapView];
    nav.title = @"pik location";
    [self presentViewController:nav animated:YES completion:nil];
Swift4
  • 坐标
    let mapView = FAMapViewController.init(userLocationCWithisDragable: true) { (coordinate) in
        print("Coordinate = \(coordinate.latitude):\(coordinate.longitude)")
    }
    if let map = mapView {
        self.navigationController?.pushViewController(map, animated: true)
    }
  • 坐标和地址
    let mapView = FAMapViewController.init(userLocationCAWithisDragable: true) { (coordinate, address) in
        print("Address = \(address ?? "")")
    }
    if let map = mapView {
        self.navigationController?.pushViewController(map, animated: true)
    }
  • 坐标和标记
    let mapView = FAMapViewController.init(userLocationCPWithisDragable: true) { (coordinate, placemark) in
        print("Country = \(placemark?.country ?? "") , City = \(placemark?.locality ?? "")")
    }
    if let map = mapView {
        self.navigationController?.pushViewController(map, animated: true)
    }

安装

FAMapView可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中

pod 'FAMapView'

作者

fadizant, [email protected]

许可协议

FAMapView 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。