When developing mobile applications sometimes we want to take the user to a map when tapping an address/location name. Launching the native map app installed by default (Google Maps in Android/ Maps in iOS) is pretty easy using Xamarin Essentials.
To use this library you can do it in three simple steps:
1-Install the plugin
2-Initialize it (Only on Android)
3-Use it
Forcing to open Google Maps by default on iOS
According to
To open a Uri could use the class Device.
1-Check if you can open the Google Maps Uri
2-In your Info.plist add the value
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
</array>
3-Open the Uri
This Uri will open a GoogleMaps with a placemark in the specified location with a name. In case you want to do some extra options
- Open a specific view: Pass the parameter &views=traffic
- Open it with zoom: Pass the parameter &zoom=14
- Center the map: Pass the parameter ¢er={latitud},{longitud}
Here is an example of opening the Google Maps app by default and if isn’t installed will open the iOS Maps app:
That’s all for now, you can check the full source code sample here.
Happy coding!
1 Comment
thanks….