How To Use Google Maps In Xamarin Forms
Subscribe the requesttileuri event of imagerylayer as demonstrated in the following code example.
How to use google maps in xamarin forms. To determine if it s there we are going to check for it using xamarin essentials. This article describes how to use google maps api to show google maps using imagerylayer of the sfmaps control. First install the xamarin essentials nuget into all your projects first. Select xamarin googleplayservices maps and click install. Forcing to open google maps by default on ios.
Namespace xamgooglemapsapp public class mapspage. You can check the full source code here. Click enable api and services. When google maps is installed it tells the os that it s there and it can be called. Xamarin forms maps renders its native maps based on the os used by the device e g.
Openuri of xamarin forms but we also have to validate if we can open that uri so it s better using launch from xamarin. Click on google maps android api. Click browse and enter xamarin google play services maps in the search field. To open a uri could use the class device. What i want to achieve here is to also have google maps for ios since the main map that we are using is google maps.
You can show the google maps using the requesttileuri event of imagerylayer. If this package had been installed previously click update. Copy the full code behind class here. Var openlocation new button text open location using built in maps app. According to the google s documentation to open google m aps on ios you have to use the url scheme comgooglemaps.
Notice that the following dependency packages are also installed. To achieve that will use the xamarin essentials geolocation api. Google maps for android and mapkit for ios which makes it easier for the android to have google maps of course. Then create a new project here and name it googlemapusingxamarinforms. On the next page you will find a list of apis.