Skip to content

Instantly share code, notes, and snippets.

@codercampos
Last active April 16, 2019 15:27
Show Gist options
  • Save codercampos/429f68cd439e8f5694149a39954b9ef7 to your computer and use it in GitHub Desktop.
Save codercampos/429f68cd439e8f5694149a39954b9ef7 to your computer and use it in GitHub Desktop.
<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>
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