This project has moved. For the latest updates, please go here.
1

Closed

Map Items are in different places.

description

As you can see on attached screenshot pushpin & mapitems are in different map location. This happens also when you zoom in and go to corners of the map.

MapPanel LineNumber 139 is causing this issue.

viewportPosition = parentMap.LocationToViewportPoint(new Location(
                location.Latitude,
                Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude)));

file attachments

Closed May 26, 2016 at 8:41 AM by ClemensF
Can't be reproduced.

comments

ClemensF wrote May 26, 2016 at 8:40 AM

Please provide sample code that reproduces the issue. From the image it isn't clear what the actual problem is. And please post your problem as a new discussion unless the issue can't be exactly reproduced.

Haksu wrote May 26, 2016 at 9:34 AM

You can see second red dot on screenshoot that has to be next to pushpin but it's more on the right side of the map. When there're mapitems they should be display in same area of the map.

Sample code same as WPF Example.

<map:Pushpin map:MapPanel.Location="53.5,8.2" Background="Yellow" Foreground="Blue" Content="N 53° 30' E 8° 12'">
            <map:Pushpin.Visibility>
                <MultiBinding Converter="{StaticResource LocationToVisibilityConverter}">
                    <Binding Path="(map:MapPanel.ParentMap)" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="RenderTransform" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
            </map:Pushpin.Visibility>
        </map:Pushpin>
<Path map:MapPanel.Location="53.6,8.3" Stroke="Red" StrokeThickness="3" Fill="#1F007F00">
            <Path.Data>
                <EllipseGeometry RadiusX="1852" RadiusY="1852" Transform="{Binding ScaleTransform, ElementName=map}"/>
            </Path.Data>
        </Path>
As you see map:MapPanel.Location of to elements really close to each other but when they get arranged path moves to right side of the viewport because its aligned nearest location of center but pushpin aligned to left of the center.

Haksu wrote May 26, 2016 at 10:05 AM

This is another sample.
<map:Pushpin map:MapPanel.Location="53.5,8.2" Background="Yellow" Foreground="Blue" Content="53.5,8.2">
            <map:Pushpin.Visibility>
                <MultiBinding Converter="{StaticResource LocationToVisibilityConverter}">
                    <Binding Path="(map:MapPanel.ParentMap)" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="RenderTransform" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
            </map:Pushpin.Visibility>
        </map:Pushpin>
        <map:Pushpin map:MapPanel.Location="53.5,8.7" Background="Red" Foreground="Blue" Content="53.5,8.7">
            <map:Pushpin.Visibility>
                <MultiBinding Converter="{StaticResource LocationToVisibilityConverter}">
                    <Binding Path="(map:MapPanel.ParentMap)" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="RenderTransform" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
            </map:Pushpin.Visibility>
        </map:Pushpin>
When you move on the map this happens.

ClemensF wrote May 26, 2016 at 10:33 AM

That is how it is supposed to work. Any items on the map are placed with shortest distance to the center of the viewport.

Haksu wrote May 26, 2016 at 10:33 AM

If you change

viewportPosition = parentMap.LocationToViewportPoint(new Location(location.Latitude,Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude)));


with

var referenceLocation = parentMap.Children.Cast<UIElement>().Select(el => GetLocation(el)).Where(loc => loc != null).FirstOrDefault() ?? parentMap.Center;

viewportPosition = parentMap.LocationToViewportPoint(new Location(location.Latitude,Location.NearestLongitude(location.Longitude, referenceLocation.Longitude)));

all the mapitems path/canvas mapItems etc with mappanel.location property will be aligned in same area .

Haksu wrote May 26, 2016 at 12:13 PM

"That is how it is supposed to work. Any items on the map are placed with shortest distance to the center of the viewport."

I understand your point but if there're related mapitems they became visible on different part of the map because of that code. Also Items are gettings aligned in different TileGrid Area when you zoom in and
disappears normally they should be visible in same area .

My personal opinion you could add a DependencyProperty and by default aligns to Center location if we set otherwise aligns to first element with location.

I'm overwriting that part in my code anyways.