Look Around, a window to reality

manu_coding

Manu Rodríguez

Posted on October 4, 2022

Look Around, a window to reality

One of the main innovations that Apple showed at the last WWDC was undoubtedly the improvements in MapKit and the new features that it incorporated in its latest version to provide the user with a better user experience. Perhaps one of the most striking has been the possibility of adding the functionality of Look Around (name given to the Street View developed by Apple) in your application, which allows us to see in 360 a location as if we were on site.

Requirements

To be able to use this new functionality, you must meet the following requirements

  • Xcode 14.0
  • iOS 16.0

Adding it to your application

Our first step will be to generate an MKLookAroundScene, which we can obtain from a location that we pass to the MKLookAroundSceneRequest class as shown in the example code:

Once we have obtained our MKLookAroundScene, we will have to create a MKLookAroundViewController (it will be in charge of showing our street view). For it we can do it in the following way:

Oops... something went wrong

Ok... at this point you are probably thinking that you can use MKLookAroundViewController as another UIViewController inside your application and make a classic navigation with this controller (present, push...), surely if you have tried it without reading on you will have found that something strange is happening with your player, like you can't navigate through the streets, the name of the street doesn't appear, etc...

All is fine
This is because in order to use this new UIViewController, you cannot use it as if it was a classic UIViewController with its own navigation system. You must use it as an embedded view inside a UIViewController of your view hierarchy as in the following example:

Handicaps

A priori it seems a little strange to have to use this functionality in this way and not be able to use MKLookAroundViewController as if it were an independent UIViewController, it is something that hopefully Apple will end up solving in future versions of Swift.
MKLookAroundViewController has another handicap at the time of being used and it is the following one: it cannot be used on a view that comes from a modal present, since in the case of being used in that view, this one will appear disabled when our MKLookAroundViewController is closed.
If you need to display it over a view that has been displayed through a present, you must display the parent view using the .overFullScreen mode.

parentViewController.modalPresentationStyle = .overFullScreen
Enter fullscreen mode Exit fullscreen mode

Congratulations on getting this far! You have successfully implemented Look Around in your brand new application. Now you will give your users a better user experience if they want to know what is near a location.

Great!

💖 💪 🙅 🚩
manu_coding
Manu Rodríguez

Posted on October 4, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related