Step 4
Copy the Backgroud Image.
Now, download the BackgroudImage.zip file (from the top of the article), unzip and copy the file "dreamstime_xxl_88693404.jpg" into the following folders:
Android,
- \Resources\drawable
- \Resources\mipmap-anydpi-v26
- \Resources\mipmap-hdpi
- \Resources\mipmap-mdpi
- \Resources\mipmap-xhdpi
- \Resources\mipmap-xxhdpi
- \Resources\mipmap-xxxhdpi
iOS,
Step 5
Add the correct permissions for every mobile platform.
Android:
Go to Solution Explorer -> GeoMap_Test.Android -> Properties. Double click on AssemblyInfo.cs file and add the following code to the end of the "Add some common permissions" block,
- [assembly: UsesFeature("android.hardware.location", Required = false)]
- [assembly: UsesFeature("android.hardware.location.gps", Required = false)]
- [assembly: UsesFeature("android.hardware.location.network", Required = false)]
iOS
Go to Solution Explorer -> GeoMap_Test.iOS. Hit F7 on the Info.plist file and add the following code to the last code block,
- <key>NSLocationWhenInUseUsageDescription</key>
- <string>Permission for using GPS.</string>
Step 6
Platform Implementation Specifics for both mobile platforms,
Android
Go to Solution Explorer -> GeoMap_Test.Android -> Double click on MainActivity.cs file and add the following code to the OnCreate Method,
- Xamarin.Essentials.Platform.Init(this, savedInstanceState);
iOS
No Platform Implementation Specifics.
Step 7 - Configure the GPS on the emulators.
Now, we have to configure the GPS of both the simulators (of course this step is not necessary if you install the app into your smartphone).
Android
Launch the simulator -> Click on the three dots (menu) - > Location -> Write the Location name -> Save the point -> Ok.
iOS
Launch the simulator -> Click on the gear (Settings) -> On Path choose "Apple".
Step 8
Output for both the mobile platforms.
Well, we've finally arrived to the end. The following images show you the output of the application in both the mobile platforms.
Android
iOS
Conclusion
In this tutorial I've shown you how to create a basic Xamarin.Forms application that gets your coordinates and retrieves them on your default map app.
Of course, you can improve it and it's possible to "clean the code", but It's not the purpose of this demo.
Feel free to share your feedback with me.
Thank you so much for your attention and interest.