question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Map move events do not work with MapItemsControl

See original GitHub issue

When you add a container of elements to a map, such as a MapItemsControl, moving around the map does not work when you click on a child of MapItemsControl. Code example:

<m:Map>
    <m:MapItemsControl>
        <m:MapPolygon Fill="Blue" Stroke="Green" StrokeThickness="5"
                      Locations="47.6424,-122.3219 47.8424,-122.1747 47.5814,-122.1747"
                      Opacity="0.7">
            <m:MapPolygon.Style>
                <Style TargetType="m:MapPolygon">
                    <EventSetter Event="PreviewMouseRightButtonDown" Handler="PolygonMouseRightButtonDown" />
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Cursor" Value="Hand" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </m:MapPolygon.Style>
        </m:MapPolygon>
    </m:MapItemsControl>
</m:Map>

Demonstration: gif1

If we remove the container, then the movement will be processed correctly. This is just an example, since we are losing Binding to ItemsSource. Code example:

<m:Map>
        <m:MapPolygon Fill="Blue" Stroke="Green" StrokeThickness="5"
                      Locations="47.6424,-122.3219 47.8424,-122.1747 47.5814,-122.1747"
                      Opacity="0.7">
            <m:MapPolygon.Style>
                <Style TargetType="m:MapPolygon">
                    <EventSetter Event="PreviewMouseRightButtonDown" Handler="PolygonMouseRightButtonDown" />
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Cursor" Value="Hand" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </m:MapPolygon.Style>
        </m:MapPolygon>
</m:Map>

Demonstration: gif2

If we look, for example, at the Bing Maps Control, then the event of movement will be correctly processed by the children of MapItemsControl. Code example for bing maps:

<m:Map
    CredentialsProvider="BING_MAPS_KEY">
    <m:MapItemsControl>
        <m:MapPolygon Fill="Blue" Stroke="Green" StrokeThickness="5"
                      Locations="47.6424,-122.3219 47.8424,-122.1747 47.5814,-122.1747"
                      Opacity="0.7">
            <m:MapPolygon.Style>
                <Style TargetType="m:MapPolygon">
                    <EventSetter Event="PreviewMouseRightButtonDown" Handler="PolygonMouseRightButtonDown" />
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Cursor" Value="Hand" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </m:MapPolygon.Style>
        </m:MapPolygon>
    </m:MapItemsControl>
</m:Map>

Demonstration: gif3

Is it possible to somehow get the behavior as in the last example?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ClemensFischercommented, Jun 20, 2020

Ok, it’s a simple change. Set

e.Handled = false;

in line 26 in MapItemsControl.WPF.cs. Or derive from MapItemsControl and override OnMouseLeftButtonDown.

I’ll see if I can make this change in the library.

0reactions
paulrozhkincommented, Jun 20, 2020

Ok, thank you. It works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MapsItemControl and ObservableCollection behaviour
When I change the ObservableCollection, like the isVisible value (to show or to hide by the choices in the filter, the items didn't...
Read more >
Is there a On Map Move event in OpenLayers?
If the automatic Geolocation is enabled, the event is called either the map moved automatically or the user moved it. So, this is...
Read more >
azure-maps events not being added correctly in some ...
I have attempted adding events to map layers in various parts of my project, some work correctly and some don't, using the exact...
Read more >
Windows 10, UWP and Experimenting with Inking onto a ...
It might be possible to capture all the pointer events on the InkCanvas and then somehow manually 'pass them on' to the underlying...
Read more >
Event to notify when map has moved positioned with...
I am using the ArgGIS Javascript API v3.5. I have a map displayed in my browser, but it does not take up the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found