Simple markers won't show on map (Xamarin Forms)
alzaburetz opened this issue · 2 comments
alzaburetz commented
I try add markers on map:
<map:MapView x:Name="Map"
LogoEnabled="False"
Annotations="{Binding Annotations}"
ZoomLevel="1"
ShowUserLocation="True"
UserLocation="{Binding UserLocation}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>
Annotations is an ObservableCollection. I fill it with random points
for (int i = 0; i < 25; i++)
{
var lat = RandomExtension.NextDouble(rand, -90.0, 90.0);
var lon = RandomExtension.NextDouble(rand, -90.0, 90.0);
SymbolAnnotation point = new SymbolAnnotation()
{
IconColor = Color.Red,
Id = Guid.NewGuid().ToString(),
Coordinates = new LatLng(lat, lon),
IconSize = 5,
IsDraggable = true
};
Annotations.Add(point);
}
But nothing is shows on the map. Break point shows, that Annotations property of map contains List of Annotations
nakulLukan commented
If you are adding SymbolAnnotations
, try replacing your Annotations
Datatype as follows
public ObservableCollection<SymbolAnnotation> Annotations
{
get;
set;
}
tuyen-vuduc commented
To bind these items correctly, please assign Annotations property after style is loaded.
Please check out a sample here.
Let me know if it works.
Cheers.