Last active
April 16, 2019 15:27
-
-
Save codercampos/429f68cd439e8f5694149a39954b9ef7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<google:Map MyLocationEnabled="True" ItemsSource="{Binding Items}"> | |
<google:Map.ItemTemplate> | |
<DataTemplate> | |
<google:Pin | |
Type="Place" | |
Position="{Binding Position}" | |
Label="{Binding Name}" | |
Address="{Binding FullAddress}" | |
Icon="{Binding Pin, Converter={StaticResource IconBitmapConverter}}"> | |
</google:Pin> | |
</DataTemplate> | |
</google:Map.ItemTemplate> | |
</google:Map> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using Xamarin.Forms; | |
using Xamarin.Forms.GoogleMaps; | |
namespace YourNameSpace.Converters | |
{ | |
public class IconBitmapConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
if (!(value is string icon)) return null; | |
return BitmapDescriptorFactory.FromBundle(icon); | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment