Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps SDK iOS change floor level programmatically

I dont find any way in the documentation how to change the floor level programmatically. For example:

I load a specific polygon for 1 room, and i want to change the floor map to the specific floor level (For example Zoom to Level 2, and then add my Polygon).

Polygon adding with Infoboxes are not the problem, ill just want to know if its possible to programmatically select the right floor level.

Like here:

enter image description here

I still know that there is the GMSIndoorDisplayDelegate - and i am able to set the active building. There should be an "activeLevel" method, but i am unable to assign any value.

like image 378
derdida Avatar asked Nov 19 '25 14:11

derdida


1 Answers

I found the solution on how to force the floor change for a particular building.

  1. Add the delegate GMSIndoorDisplayDelegate to the class,
  2. Set the delegates:

    mapView.delegate = self
    mapView.indoorDisplay.delegate = self
    
  3. Add the delegate methods:

    func didChangeActiveBuilding(building: GMSIndoorBuilding!) {
        if let currentBuilding = building {
            var levels = currentBuilding.levels as! [GMSIndoorLevel]
            mapView.indoorDisplay.activeLevel = levels[2] // set the level (key) 
        } 
    }
    
    func didChangeActiveLevel(level: GMSIndoorLevel!) { 
       println("will be called after activeBuilding")
    }
    

P.S. Just a friendly reminder, the upmost level is the first item in the array. It's backwards.

like image 178
derdida Avatar answered Nov 22 '25 03:11

derdida



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!