SiamPiwatIndoorMapSDK 0.9.6

SiamPiwatIndoorMapSDK 0.9.6

SmartSoftAsia维护。



 
依赖
RxSwift= 5.1.1
RxCocoa= 5.1.1
RxGesture= 3.0.2
Action= 4.1.0
Device= 3.2.1
Toast-Swift= 5.0.1
Kingfisher= 5.15.1
 

  • Siam Piwat Company Limited

Siam Piwat MappedIn Indoor Map iOS SDK

添加Pod

pod 'SiamPiwatIndoorMapSDK', '0.9.6'
run pod install

注意

请务必确认!

Project -> Build Settings -> Enable Bitcode -> No
Project -> Your Target-> Build Settings -> Enable Bitcode -> No
Project -> Pods -> Build Settings -> Enable Bitcode -> No

在AppDelegate中初始化SDK


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?


    override init() {
         super.init()
         SPWIndoorMapSDKManager.shared.initialSDK(slug: .oneSiam,
                                                 shops: [],
                                                 language: .en,
                                                 appDelegate: AppDelegate.self,
                                                 isDebug: true)

         // This is method for initialize IndoormapSDK you need to add it here.
         // MappedIn Service need to initialize with AppDelegate.self
         // remark if you not add it here the app will crash.
     }


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
}

设置调试

  SPWIndoorMapSDKManager.shared.setDebugMode(isDebug: true)

设置模拟导航

     SPWIndoorMapSDKManager.shared.setSimulateNavigation(simulateNavigation: true)

设置启用设备位置

将 CoreLocation 和 Privacy 模块导入至 Info.plist 文件的 Privacy - Location Always and When In Use Usage Description,Privacy - Location Always Usage Description,Privacy - Location When In Use Usage Description 中,并添加代理

 import CoreLocation

 var manager:CLLocationManager = CLLocationManager()
 self.manager.delegate = self
 self.manager.desiredAccuracy = kCLLocationAccuracyBest

extension ViewController: CLLocationManagerDelegate {

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){
        if let location = locations.last{
            print("latitude: \(location.coordinate.latitude) longitude: \(location.coordinate.longitude)")
            SPWIndoorMapSDKManager.shared.updateUserCurrentPosition(location)

        }
    }

    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error){
        print(error.localizedDescription)
    }


}
  SPWIndoorMapSDKManager.shared.setEnableDeviceLocation(isEnableDeviceLocation: true)

设置更新用户当前位置

在使用此方法之前,您需要通过 SPWIndoorMapSDKManager.shared.setEnableDeviceLocation(isEnableDeviceLocation: true) 来设置 EnableDeviceLocation

 SPWIndoorMapSDKManager.shared.updateUserCurrentPosition(CLLocationCoordinate2DMake(13.746478, 100.534629))

设置 AIS 存储

在初始化 SDK 之后,您必须设置 AIS 存储。我们使用 AIS 存储 Object 来显示存储名称、描述

    SPWIndoorMapSDKManager.shared.setAISShops(shops)
参数 描述
商店 字典数组(结构与下面相同)

AIS JSON 字典示例

 {
      "closeAt": [
        "22:00",
        "22:00",
        "22:00",
        "22:00",
        "22:00",
        "22:00",
        "22:00"
      ],
      "lineIds": [""],
      "mall_id": "5baa79c43280ac373f6c06e5",
      "positions": [
        {
          "x": "0",
          "y": "0",
          "z": "0"
        }
      ],
      "tag_ids": [""],
      "isDeleted": false,
      "publish": {
        "publishEndDate": "2119-01-09T03:33:41.720Z",
        "publishStartDate": "2019-01-09T03:33:41.720Z",
        "isPublish": true
      },
      "images": ["https://siampiwat.azureedge.net/shop/5863559047260669.png"],
      "floor_id": "5bc6e1050e17b1204c8829d2",
      "createdAt": "2019-01-08T09:00:54.000Z",
      "name": {
        "cn": "Fix & Wash",
        "en": "Fix & Wash",
        "th": "Fix & Wash"
      },
      "priority": 0,
      "cat_ids": ["5bccb5c913443b4720c2477c"],
      "updatedAt": "2019-10-21T08:14:25.000Z",
      "subcat_ids": ["5bccb5c513443b4720c24770"],
      "descThumbnail": {
        "cn": "",
        "en": "",
        "th": ""
      },
      "lot_no": "BR17",
      "tels": ["+6626581121"],
      "email": "",
      "zone_id": "",
      "id": "5bd9248dabc75d7da0f2c26a",
      "urls": ["https://th-th.facebook.com/fixandwash"],
      "openDay": [true, true, true, true, true, true, true],
      "desc": {
        "cn": "",
        "en": "",
        "th": ""
      },
      "imageThumbnail": "https://siampiwat.azureedge.net/shop/01178384601978566.png",
      "openAt": ["10:00", "10:00", "10:00", "10:00", "10:00", "10:00", "10:00"]
    }

获取场所

在调用地图书之前,您需要调用 "getVenues"。这是一个获取百货商店的方法。顺便说一句,该方法将过滤掉与您设置的 ais 存储 JSON 不匹配的商店

   self.showLoading()
   SPWIndoorMapSDKManager.shared.getVenues(completion: {
     self.hideLoading()
     self.showMapView()
    }) { (error) in
      self.hideLoading()
      print(error.errorDescription)
    }
参数 描述
完成 完成回调
失败 失败回调

地图视图控制器

这是获取MapViewController的属性。

  let vc = SPWIndoorMapSDKManager.shared.viewController
   self.navigationController?.pushViewController(vc, animated: true)
//        alternative way
//        let navC = UINavigationController(rootViewController: vc)
//        self.present(navC, animated: true, completion: nil)

获取所有门店

通过调用此方法,您可以获取所有门店。

    let stores =  SPWIndoorMapSDKManager.shared.stores()

通过外部ID获取门店

这是一个通过外部ID获取门店的方法。

     SPWIndoorMapSDKManager.shared.store("5bd9248dabc75d7da0f2c421")
参数 描述
外部ID 门店的ID

通过别名获取部门门店

  if let siamDiscovery = SPWIndoorMapSDKManager.shared.getDepartmentStore(slug: .siamDiscovery) {
     SPWIndoorMapSDKManager.shared.setDepartmentStore(departmentStore: siamDiscovery)
   }

获取当前部门门店

此方法将返回部门门店。


    let departmentStore = SPWIndoorMapSDKManager.shared.departmentStore()

更新用户当前位置

您可以通过向此方法发送AISLocation对象来在地图上显示用户当前位置。
如果楼层ID和楼层号与活动楼层不同,则该位置将不会显示在地图上。

     let location = SPWAISLocation(isIndoor: true, latitude: "13.7466", longitude: "100.534629",
                                        builId: "4409", buildName: "Siam Paragon", floorId: "8288", floorNumber: "0")
    SPWIndoorMapSDKManager.shared.updateUserCurrentPosition(location)

获取最近的商店

        SPWIndoorMapSDKManager.shared.setFloor(by: 0)
        let location = SPWAISLocation(isIndoor: true, latitude: "13.7466", longitude: "100.534629",
                                        builId: "4409", buildName: "Siam Paragon", floorId: "8288", floorNumber: "0")
        let store = SPWIndoorMapSDKManager.shared.getClosestStore(location: location)

设置起点

  SPWIndoorMapSDKManager.shared.setOrgin(storeA)

设置终点

  SPWIndoorMapSDKManager.shared.setDestination(storeA)

设置起点和终点

   SPWIndoorMapSDKManager.shared.setOrginAndDestination(orgin: storeA, destination: storeB)

重置起点和终点

     SPWIndoorMapSDKManager.shared.resetOrginAndDestination()

按楼层编号设置楼层

0是G,B是-1

    SPWIndoorMapSDKManager.shared.setFloor(by: -1)