//******** android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.xmarinmapdmo" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="xmarinMapDmo.Android" android:theme="@style/MainTheme">
<meta-data android:name="com.google.android.geo.API_KEY" android:value="*** YOUR API KEY HERE ***" />
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
</manifest>
//*** mainpage.xaml
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:xmarinMapDmo;assembly=xmarinMapDmo"
x:Class="xmarinMapDmo.MapPage">
<local:CustomMap x:Name="customMap"
MapType="Street" />
</ContentPage>
//**** mainpage.cs
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
namespace xmarinMapDmo
{
public partial class MapPage : ContentPage
{
public MapPage()
{
InitializeComponent();
CustomPin pin = new CustomPin
{
Type = PinType.Place,
Position = new Position(41.02588959503038, 28.974647597264806),
Label = "Galata Kulesi",
Address = "Galata Kulesi İstanbul Türkiye",
Name = "Galata Kulesi",
Url = "www.istanbul.com.tr"
};
customMap.CustomPins = new List<CustomPin> { pin };
customMap.Pins.Add(pin);
customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(41.02588959503038, 28.974647597264806), Distance.FromKilometers(1.0)));
}
}
}
//** custommap.cs
using System.Collections.Generic;
using Xamarin.Forms.Maps;
namespace xmarinMapDmo
{
public class CustomMap : Map
{
public List<CustomPin> CustomPins { get; set; }
}
}
//*** custompin.cs
using Xamarin.Forms.Maps;
namespace xmarinMapDmo
{
public class CustomPin : Pin
{
public string Name { get; set; }
public string Url { get; set; }
}
}
GitHub public :
https://github.com/doktoralban/xmarinMapDmo
Yorumlar
Yorum Gönder