Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMap.NET.Avalonia markers are not shown #178

Open
hangdog78 opened this issue Jan 21, 2023 · 1 comment
Open

GMap.NET.Avalonia markers are not shown #178

hangdog78 opened this issue Jan 21, 2023 · 1 comment

Comments

@hangdog78
Copy link

GMap.NET.Avalonia markers are not shown after adding to Markers collection. Any ideas why?

Example of code:
newpoint - marker coords.
Map - GMap control

GMapMarker iconmarker = new GMapMarker(new PointLatLng(newpoint.Lat, newpoint.Lng));
iconmarker.Shape = new Ellipse() { Width = 100, Height = 100, Fill = Brushes.Green, Stroke =Brushes.Red};

Map.Markers.Add(iconmarker);

Marker is in collection, but not shown =((

And because of use user32.dll for mouse cursor positioning, have to set MouseWheelZoomEnabled to False, or u catch exception under Unix.

@alex-valchuk
Copy link

alex-valchuk commented Jun 18, 2024

Looks like GMapControl for Avalonia UI never worked properly.
I tried to debug it checking it under the hood and found the following:
at least the xaml template used inside GMapControl is not compatible with avalonia.
Here is how it looks like (just a copy of WPF version):

<ItemsControl.ItemTemplate>
    <DataTemplate>
        <ContentPresenter Content="{Binding Path=Shape}" />
    </DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
        <Canvas />
    </ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
    <Style>
        <Setter Property="Canvas.Left" Value="{Binding Path=LocalPositionX}"/>
        <Setter Property="Canvas.Top" Value="{Binding Path=LocalPositionY}"/>
    </Style>
</ItemsControl.ItemContainerStyle>

And here is what is expected to be (ItemContainerTheme instead of ItemContainerStyle):

<ItemsControl.ItemTemplate>
    <DataTemplate>
        <ContentPresenter Content="{Binding Path=Shape}" />
    </DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
        <Canvas />
    </ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerTheme>
    <ControlTheme TargetType = "ContentPresenter">
        <Setter Property = "Canvas.Left" Value = "{Binding Path=LocalPositionX}" />
        <Setter Property = "Canvas.Top" Value = "{Binding Path=LocalPositionY}" />
    </ControlTheme >
</ItemsControl.ItemContainerTheme>

It seems like the ItemsControl (the parent class of GMapControl) behaves differently in comparison to one from WPF and it does not allow to map the data using the provided template.
I tried to map the data on the pure Avalonia ItemsControl with the provided template and saw it working.

So, the question is how to instruct the control that inherits from Avalonia ItemsControl to display items using the provided custom template?

I address the last question to the main Avalonia UI contributors. Maybe they can help us somehow to progress with this issue.
@MikeCodesDotNET, @kekekeks, @MrJul, @grokys, @maxkatz6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants