Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147376 | Sep 8,2019 07:20 PM UTC | Sep 18,2019 07:14 AM UTC | Xamarin.Forms | 5 |
![]() |
Tags: SfMaps |
<maps:SfMaps Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
x:Name="Map"
MinZoom="11"
EnableZooming="true"
ZoomLevel="10"
MaxZoom="13">
<maps:SfMaps.Layers>
<maps:ImageryLayer
x:Name="OpenStreetMap"
Markers="{Binding MapStations}"
GeoCoordinates="50.8088760375977,-1.18579387664795">
<maps:ShapeFileLayer.MarkerTemplate>
<DataTemplate>
<StackLayout>
<controls:WindIndicator
WidthRequest="70"
HeightRequest="70"
WindForce="{Binding Station.LatestReading.WindForce}"
WindDirection="{Binding Station.LatestReading.WindDirectionAsInt}">
</controls:WindIndicator>
</StackLayout>
</DataTemplate>
</maps:ShapeFileLayer.MarkerTemplate>
</maps:ImageryLayer>
</maps:SfMaps.Layers>
</maps:SfMaps>
The WindIndicator control is a custom control which uses SkiaSharp to draw wind direction and strength.
I want to invoke a Command when the WindIndicator is tapped - how can I do this? I've tried adding a GestureRecognizer to the StackLayout in the DataTemplate, but I think the tap behaviour of the SfMaps control itself is intercepting the tap.
…
<maps:SfMaps.Layers>
<maps:ImageryLayer x:Name="OpenStreetMap"
GeoCoordinates="50.8088760375977,-1.18579387664795"
MarkerSelected="Layer_MarkerSelected">
<maps:ImageryLayer.Markers>
<local:CustomMarker Latitude="50.8088760375977" Longitude= "-1.18579387664795" />
</maps:ImageryLayer.Markers>
…
</maps:SfMaps.Layers>
… |
…
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
this.BindingContext = new ColorMappingsViewModel();
}
private void Layer_MarkerSelected(object sender, MarkerSelectedEventArgs e)
{
var colorMappingsViewModel = (ColorMappingsViewModel)BindingContext;
if (colorMappingsViewModel.TapCommand.CanExecute(e))
{
colorMappingsViewModel.TapCommand.Execute(e);
}
}
}
… |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.