Hello,
I'm trying to change MarkerTemplate property of syncfusion map on the fly, as it is bound to a viewModel property that changes of value in commands but it doesn't work, seems like template is not refreshing or binding is not working when changing it. The first time it displays, binding is working as I set it in the viewModel constructor.
Here is the sfMap
<maps:SfMaps x:Name="sfmap" EnablePanning="False" EnableZooming="False" BackgroundColor="Transparent">
<maps:SfMaps.Layers>
<maps:ShapeFileLayer x:Name="ShapeLayer" Uri="FRA_adm0.shp" MarkerTemplate="{Binding Path=BindingContext.MarkerDataTemplate, Source={x:Reference carouselView}}">
<maps:ShapeFileLayer.ShapeSettings>
<maps:ShapeSetting ShapeFill="{StaticResource PrimaryColorOne}" ShapeStroke="white" ShapeStrokeThickness="2" >
</maps:ShapeSetting>
</maps:ShapeFileLayer.ShapeSettings>
<maps:ShapeFileLayer.Markers>
<local:CustomMarker Latitude="46,350907" Longitude="2,617358"></local:CustomMarker >
<local:CustomMarker Latitude="48,86666667" Longitude="2,33333"></local:CustomMarker >
<local:CustomMarker Latitude="43,296482" Longitude="5,36978"></local:CustomMarker >
</maps:ShapeFileLayer.Markers>
</maps:ShapeFileLayer>
</maps:SfMaps.Layers>
</maps:SfMaps>
And in this Command I'm just changing the MarkerDataTemplate property (i.e property bound to sf MarkerTemplate property)
private void DisplayMarkerTemplate(string type)
{
switch (type)
{
case "car":
MarkerDataTemplate = (DataTemplate)Application.Current.Resources["CarMarkerDataTemplate"];
break;
default:
MarkerDataTemplate = (DataTemplate)Application.Current.Resources["BusMarkerDataTemplate"];
break;
}
}
I've got images that are binded to a tappedCommand to the viewModel and changes MarkerTemplate considering commandParameter
<Image WidthRequest="30" HeightRequest="30" Source="ic_point_of_view.png">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.DisplayMarkerTemplateCommand, Source={x:Reference carouselView}}"
CommandParameter="Temperature"/>
</Image.GestureRecognizers>
</Image>
Thanks.