Xamarin.Forms.Maps integration in WinPhone Project

Map is an external component which will be obtained from the Nuget Component store.

Integration of Maps requires some config changes from platform to platforms. I have targeted the WinPhone project configuration here. In the next blog, will point to other platforms.

Simple Steps

  • Add Xamarin.Forms.Map to every project in the solution
  • Call the FormMaps.Init() method in each project to initialize the map
  • Create the Map object with region co-ordinates
  • Add that Map object in a layout in the PCL/Shared project

nuget-XamarinFormsMaps

In the PCL/Shared project, Let’s add a new Content page and name it as MapPage.cs. Now time to add the below code to it.

Project Specific configuration

In the Windows Phone Project, in MainPage.Xaml.cs initialize the Map

NOTE : Before publishing to the store, we need to make following changes in the MainPage.Xaml.cs

The application Id and Authentication Token will be obtained from the Store.

Setting up the permission
In windows phone project, in Properities > WMAppMenifest.xml allow

  • ID_CAP_LOCATION
  • ID_CAP_MAP

SettingMapCapability

Now we are ready to run the app.

In my next blog, I will point the Android project config changes.

Happy coding 🙂

Categories: Cross Platform Mobile App, CSharp, Visual Studio, Windows Phone, Xamarin

Leave a Reply

%d bloggers like this: