Thursday, 29 November 2018

Open Google Map URL in iphone and Android using Xamarian

Open Google map url in Android phone.

  var uri = new Uri("https://www.google.com/maps/place/" + CustomerAddress.Replace("<br/>", ""));
                    Device.OpenUri(uri);


For android phone it is easy to open map. But for IOS device the code is different. First check if location service is turned on or off. The location service in iphone should be on.

Below is the code for IOS

   var name = Uri.EscapeUriString(CustomerAddress.Replace("<br/>", "").Replace("&", "and")); // var name = Uri.EscapeUriString(place.Name);
                    var request = Device.OnPlatform(string.Format("http://maps.apple.com/maps?q={0}", name.Replace(' ', '+')), null, null);
                    Device.OpenUri(new Uri(request));


No comments:

Post a Comment