Look Around, a window to reality
Tags: swift, ios
Published: 2022-10-04 16:17:22

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](https://developer.apple.com/documentation/mapkit/mklookaroundscene?changes=l_8)**, which we can obtain from a location that we pass to the **[MKLookAroundSceneRequest](https://developer.apple.com/documentation/mapkit/mklookaroundscenerequest)** class as shown in the example code:{% embed https://gist.github.com/manucodin/aabd1f221e44db22f40db2305d2d0b5b %} Once we have obtained our **[MKLookAroundScene](https://developer.apple.com/documentation/mapkit/mklookaroundscene?changes=l_8)**, we will have to create a **[MKLookAroundViewController](https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller?changes=_7)** (it will be in charge of showing our street view). For it we can do it in the following way:
{% embed https://gist.github.com/manucodin/42de3199c22238b0bdebcd276cbbbe26 %}

## Oops... something went wrong

Ok... at this point you are probably thinking that you can use **[MKLookAroundViewController](https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller?changes=_7)** 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6d1otn20j2jpy2gj5801.gif)
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:
{% embed https://gist.github.com/manucodin/5d9e3d7365eca2631ea7fd07a70697f8 %}

## Handicaps
A priori it seems a little strange to have to use this functionality in this way and not be able to use **[MKLookAroundViewController](https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller?changes=_7)** as if it were an independent UIViewController, it is something that hopefully Apple will end up solving in future versions of Swift.
**[MKLookAroundViewController](https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller?changes=_7)** 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](https://developer.apple.com/documentation/mapkit/mklookaroundviewcontroller?changes=_7)** 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.
```swift
parentViewController.modalPresentationStyle = .overFullScreen
```
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!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l2lt701bzlwdd46ctmss.gif)