This is a migrated thread and some comments may be shown as answers.

Map clicking doesn't work as expected

2 Answers 91 Views
Map
This is a migrated thread and some comments may be shown as answers.
liviu
Top achievements
Rank 1
liviu asked on 08 Feb 2011, 05:02 PM
Hi, I display some pushpins on the map, and when I "LeftMouseButtonDown" on either of them I show a popup.
I have the following code:     

<telerik:RadMap x:Name="radMap" Grid.Row="0" ZoomLevel="1" DistanceUnit="Kilometer" MouseClickMode="None" InitializeCompleted="radMap_InitializeCompleted">
    <telerik:InformationLayer x:Name="informationLayer">
        <telerik:InformationLayer.ItemTemplate>
            <DataTemplate>
                <Grid telerik:MapLayer.Location="{Binding Location}" MinWidth="250" MaxWidth="600" Height="100" Background="Transparent" MouseLeftButtonDown="Grid_MouseLeftButtonDown" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                     
                     
                    <telerik:Pushpin Grid.Row="1" HorizontalAlignment="Center" MouseLeftButtonDown="Pushpin_MouseLeftButtonDown"/>
                </Grid>
            </DataTemplate>
        </telerik:InformationLayer.ItemTemplate>
    </telerik:InformationLayer>
</telerik:RadMap>

Code behind is:
public MainPage()
{
    InitializeComponent();
    this.radMap.Provider = new BingMapProvider(MapMode.Road, true, "key");
    ClosePopup.Click += new RoutedEventHandler(ClosePopup_Click);
}
 
void ClosePopup_Click(object sender, RoutedEventArgs e)
{
    MyPopup.IsOpen = false;
}
 
 
private ObservableCollection<MapItem> GetMapData()
{
    ObservableCollection<MapItem> data = new ObservableCollection<MapItem>();
    data.Add(new MapItem("Sofia", new Location(42.6957539183824, 23.3327663758679), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Plovdiv", new Location(80.1429369264591, 24.7498095849434), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Burgas", new Location(12.5131732087098, 27.4611884843576), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Varna", new Location(80.2073941930888, 90.9275176988258), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Varna", new Location(120.2073941930888, 10.9275176988258), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Varna", new Location(1.2073941930888, 12.9275176988258), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Sofia", new Location(42.6957539183824, 73.3327663758679), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Sofia", new Location(100.6957539183824, 115.3327663758679), 5, new ZoomRange(5, 12)));
    data.Add(new MapItem("Sofia", new Location(100.6957539183824, 1.3327663758679), 5, new ZoomRange(5, 12)));
    return data;
}
 
private void Pushpin_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    MyPopup.IsOpen = true;
}
 
private void radMap_InitializeCompleted(object sender, EventArgs e)
{
    this.informationLayer.ItemsSource = GetMapData();
}
 
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    //MyPopup.IsOpen = true;
}


The problem is that the "Pushpin_MouseLeftButtonDown" doesn't always get called. Sometimes it does, sometimes it doesn't.
I did notice thought that the "Grid_MouseLeftButtonDown" always gets called, but that doesn't help because I really need to have "Pushpin_MouseLeftButtonDown" always called.

Do you know how I could achieve this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 10 Feb 2011, 05:46 PM
Hello liviu,

This is the expected behavior for events handling in Silverlight. You set the transparent to background of the Grid element. So, it handles mouse events. When the grid overlaps another with its pushpin then the pushpin cannot handle mouse events.
You can just remove the background of the grid. In this case pushpins will get mouse event as expected.

All the best,
Andrey Murzov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
liviu
Top achievements
Rank 1
answered on 11 Feb 2011, 09:23 AM
The problem is now fixed.
Many thanks for helping me with the answer, Andrey.
Tags
Map
Asked by
liviu
Top achievements
Rank 1
Answers by
Andrey
Telerik team
liviu
Top achievements
Rank 1
Share this question
or