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

Pushpins Not Transforming During Map Events

Jul 29, 2015 at 2:35 AM
Whenever the map is moved or zoomed, the pushpins stay in the same position and scaling as they were when first drawn. It only changes when the collection of pushpins is updated. Something that was noticed when debugging was that LocationVisibilityConverter.Convert is never called during panning or zooming the map like it is in the Sample App.

Any idea what could cause this issue?
Coordinator
Jul 29, 2015 at 7:42 AM
No idea why your pushpins don't move. You haven't shown any of your code. Take a look at how it's done in the sample application. There the pushpins do move.
Jul 29, 2015 at 5:51 PM
Hi. Thanks for quick response. Here is the XAML code:
 <m:Map Center="{Binding MapCenter}" ZoomLevel="10" Grid.Column="0" Name="MyMap">
                    <m:MapItemsControl ItemsSource="{Binding}" Name="MyMapCtrl">
                    </m:MapItemsControl>
                </m:Map>
I want to use different pushpin icons depending on Style property of my pin class. This is why I modified my xaml code like this:
 <m:Map Center="{Binding MapCenter}" ZoomLevel="10" Grid.Column="0" Name="MyMap">
                    <m:MapItemsControl ItemsSource="{Binding}" Name="MyMapCtrl">
                        <m:MapItemsControl.ItemTemplate>
                            <DataTemplate>
                                <m:MapItem Style="{Binding Style}"></m:MapItem>
                            </DataTemplate>
                        </m:MapItemsControl.ItemTemplate>
                    </m:MapItemsControl>
                </m:Map>
Now XAML code generates the appropriate icon based on pin style property but pushpins are no longer scaling, by which I mean they remain at the same space on the map canvas. However if i use the same style for all pushpins and the xaml code looks like this it is working properly:
 <m:Map Center="{Binding MapCenter}" ZoomLevel="10" Grid.Column="0" Name="MyMap">
                    <m:MapItemsControl ItemsSource="{Binding}" ItemContainerStyle="{StaticResource Location}" Name="MyMapCtrl">
                    </m:MapItemsControl>
                </m:Map>
Here is the example of style I created:
 <Style x:Key="Location" TargetType="m:MapItem">
            <Setter Property="Width" Value="25"/>
            <Setter Property="Height" Value="39"/>
            <Setter Property="m:MapPanel.Location" Value="{Binding Location}"/>
            <Setter Property="Visibility">
                <Setter.Value>
                    <MultiBinding Converter="{StaticResource LocationToVisibilityConverter}">
                        <Binding Path="(m:MapPanel.ParentMap)" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="RenderTransform" RelativeSource="{RelativeSource Self}"/>
                    </MultiBinding>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="m:MapItem">
                        <Image Source="./img/currentlocation.png"  Stretch="Uniform" HorizontalAlignment="Left"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
Coordinator
Jul 29, 2015 at 7:44 PM
Edited Jul 29, 2015 at 7:46 PM
You shouldn't do this:
<m:MapItemsControl.ItemTemplate>
    <DataTemplate>
        <m:MapItem Style="{Binding Style}"></m:MapItem>
    </DataTemplate>
</m:MapItemsControl.ItemTemplate>
It would create a MapItem as Content of another MapItem (the one which is internally created by the MapItemControl), which doesn't make sense. It's like a ListBoxItem in the ItemTemplate of a ListBox.
Jul 29, 2015 at 8:04 PM
Thanks for your reply ClemensF. I understood what you meant. Just found a workaround the issue I had.
And thanks for this project. It really helped me.