This question is locked. New answers and comments are not allowed.
Hi..
I have mulitple KML files how can I load them all and allow a user to click on a 'shape' and bring up a messagebox?
(I have the fifty states and want break up dialog box when each is clicked)
Thanks in advance
I have mulitple KML files how can I load them all and allow a user to click on a 'shape' and bring up a messagebox?
(I have the fifty states and want break up dialog box when each is clicked)
Thanks in advance
3 Answers, 1 is accepted
0
Hello Jon,
You can use the KmlReader to read KML files. You can find more details here:
http://www.telerik.com/help/silverlight/radmap-features-kml-data-import.html
You can use the following code to identify the shape where the mouse button is clicked and show dialog:
Regards,
You can use the KmlReader to read KML files. You can find more details here:
http://www.telerik.com/help/silverlight/radmap-features-kml-data-import.html
You can use the following code to identify the shape where the mouse button is clicked and show dialog:
<
telerik:RadMap
x:Name
=
"RadMap1"
Center
=
"40,-100"
ZoomLevel
=
"3"
MapMouseClick
=
"MapMouseClick"
>
<
telerik:RadMap.Provider
>
<
telerik:OpenStreetMapProvider
/>
</
telerik:RadMap.Provider
>
<
telerik:InformationLayer
x:Name
=
"InformationLayer"
>
</
telerik:InformationLayer
>
</
telerik:RadMap
>
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
}
private
void
MapMouseClick(
object
sender, Telerik.Windows.Controls.Map.MapMouseRoutedEventArgs eventArgs)
{
IEnumerable<
object
> list =
this
.InformationLayer.GetItemsInLocation(eventArgs.Location);
foreach
(
object
item
in
list)
{
MapShape shape = item
as
MapShape;
if
(shape !=
null
)
{
MessageBox.Show(
"Sate: "
+ shape.ExtendedData.GetValue(
"STATE"
));
break
;
}
}
}
}
Regards,
Andrey Murzov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jon
Top achievements
Rank 1
answered on 15 Mar 2012, 12:14 PM
Thanks.. BUT the tooltips prevent the mouse click when I add this.. How can I do both?
void mapShapeReader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs)
{
foreach (FrameworkElement element in eventArgs.Items)
{
MapShape polygon = element as MapShape;
if (polygon != null)
{
var tooltip = new ToolTip();
tooltip.Content = polygon.ExtendedData;
tooltip.ContentTemplate = this.Resources["ToolTipTemplate"] as DataTemplate;
ToolTipService.SetToolTip(element, tooltip);
polygon.MouseEnter += new MouseEventHandler(polygon_MouseEnter);
}
}
0
Hi Jon,
The MouseEnter event can't be used for implementing the reaction on mouse click. You should use MouseLeftButtonDown and MouseLeftButtonUp events instead.
Regards,
The MouseEnter event can't be used for implementing the reaction on mouse click. You should use MouseLeftButtonDown and MouseLeftButtonUp events instead.
Regards,
Andrey Murzov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>