Ich benutze Indoo.rs ios sdk von swift, um eine kleine App zu bauen, die meine Karte zeigt, das Problem ist, ich habe keine Idee, einen Code zu schreiben, Route zwischen 2 Punkt zu setzen auf der Karte, ich über die Dokumentation kam aber kein Ergebnis ... hier ist mein Code:Route auf einer Karte mit Indoo.rs ios sdk setzen
die Dokumentation ist hier: https://indoors.readme.io/docs/routing-1
Bitte, wenn es bei mir eine Idee Aktie. Dank
import UIKit
import CoreLocation
class ViewController: UIViewController , RoutingDelegate ,IndoorsServiceDelegate, ISIndoorsSurfaceViewControllerDelegate ,IndoorsSurfaceViewDelegate {
@IBOutlet var SetRouteButton: UIButton!
var _currentBuilding: IDSBuilding?
var dot : ISIndoorsSurface?
var _indoorsSurfaceViewController: ISIndoorsSurfaceViewController?
override func viewDidLoad() {
super.viewDidLoad()
// API key of the cloud application
_ = Indoors(licenseKey: "My_API_KEY" , andServiceDelegate: nil)
_indoorsSurfaceViewController = ISIndoorsSurfaceViewController()
_indoorsSurfaceViewController!.delegate = self
// Enabling dotOnRail Mode
_indoorsSurfaceViewController!.surfaceView.dotOnRailsJumpingDistance = 55000
_indoorsSurfaceViewController!.surfaceView.enableDotOnRails = true
// show currunt postion
_indoorsSurfaceViewController!.surfaceView.showsUserPosition = true
// Load the map in a view holding it
addSurfaceAsChildViewController()
_indoorsSurfaceViewController!.loadBuildingWithBuildingId(MyBuildingId)
// Route snaping
Indoors.instance().enablePredefinedRouteSnapping()
// Display All Zones
_indoorsSurfaceViewController!.surfaceView.setZoneDisplayMode(IndoorsSurfaceZoneDisplayModeAllAvailable)
// Set visible map
let mapRect: CGRect = _indoorsSurfaceViewController!.surfaceView.visibleMapRect
_indoorsSurfaceViewController!.surfaceView.setVisibleMapRect(mapRect, animated: true)
// Filters
Indoors.instance().enableStabilisationFilter = true
Indoors.instance().stabilisationFilterTime = 4000
}
// Add the map to the view controller
func addSurfaceAsChildViewController() {
self.addChildViewController(_indoorsSurfaceViewController!)
//_indoorsSurfaceViewController!.view.frame = self.view.frame
_indoorsSurfaceViewController!.view.frame = CGRectMake(0 , 0, self.view.frame.width, self.view.frame.height * 0.7)
self.view.addSubview(_indoorsSurfaceViewController!.view)
_indoorsSurfaceViewController!.didMoveToParentViewController(self)
}
func buildingLoaded(building : IDSBuilding!) {
_currentBuilding = building
self.calculateRoute(_currentBuilding)
print("@@@@@@@@@@@@@@@@@@")
}
func calculateRoute(building : IDSBuilding!) {
let start = IDSCoordinate(x: 1, andY: 111, andFloorLevel: 0);
let end = IDSCoordinate(x: 1, andY: 111, andFloorLevel: 0);
let path = [start, end]
Indoors.instance().routeFromLocation(start, toLocation: end, inBuilding: building, delegate: self)
self.setRoute(path)
}
// MARK: RoutingDelegate
func setRoute(path: [AnyObject]!) {
_indoorsSurfaceViewController!.surfaceView.showPathWithPoints(path)
}
}
Erweiterung Viewcontroller { // MARK: ISIndoorsSurfaceViewControllerDelegate
func indoorsSurfaceViewController(indoorsSurfaceViewController: ISIndoorsSurfaceViewController!, isLoadingBuildingWithBuildingId buildingId: UInt, progress: UInt) {
NSLog("Building loading progress: %lu", progress)
}
func indoorsSurfaceViewController(indoorsSurfaceViewController: ISIndoorsSurfaceViewController!, didFinishLoadingBuilding building: IDSBuilding!) {
NSLog("Building loaded successfully!")
// By Mohammed Hassan
UIAlertView(title: "Indoors", message: "Building loaded successfully!", delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "ok").show()
}
func indoorsSurfaceViewController(indoorsSurfaceViewController: ISIndoorsSurfaceViewController!, didFailLoadingBuildingWithBuildingId buildingId: UInt, error: NSError!) {
NSLog("Loading building failed with error: %@", error)
UIAlertView(title: error!.localizedDescription, message: error!.localizedFailureReason!, delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "ok").show()
}
// MARK: IndoorsServiceDelegate
func onError(indoorsError: IndoorsError!) {
}
func locationAuthorizationStatusDidChange(status: IDSLocationAuthorizationStatus) {
}
func bluetoothStateDidChange(bluetoothState: IDSBluetoothState) {
}
}
Ich kopierte den vollständigen Code .. Danke Mann für Ihre Mühe –
Gern geschehen. Ich kann es nicht selbst ausprobieren, aber es sieht wirklich so aus, als ob du 'setRoute' nicht selbst nennen solltest. Ein wirklich schlechter Name für eine Delegate-Methode, sollte etwas wie 'delegateDidSetRoute' oder so sagen. Ich schlage vor, einen Haltepunkt zu setzen und sicherzustellen, dass er nach 'Indoors.instance(). RouteFromLocation (start, toLocation: end, inBuilding: building, delegate: self) aufgerufen wird, um sicherzugehen. Sie können auch sicherstellen, dass 'Indoors.instance()' richtig funktioniert und gibt, was auch immer die Instanz sein soll. – Gero
Es gibt einen Delegaten namens RoutingDelegate, den ich bestätigt habe –