![](/forums/images/avatarimages/default.gif)
10 Answers, 1 is accepted
To do this you need to add a freamwork element to the map information layer and set the map location as an attached property. You can see how this is done in this example: http://demos.telerik.com/silverlight/#Map/Integration/MapPieChart
You can then do whatever you want with the mouse over event of that FrameworkElement etc. You can even put a control there (like in our example).
Regards,
Vladimir Milev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
![](/forums/images/avatarimages/default.gif)
I have the same requirement but i don't want to use the kml file , i want to show map of US and Canada and some puspins
1) I want on mouseover on pushpin it should show me popup (data coming from DB here )
2) I want pushpins can be of different color according to my condition.
3) also can i change the shape of the pushpins .
Please reply ASAP.
Regards
Charu Pahuja
Please see the Items Virtualization example.
http://demos.telerik.com/silverlight/#Map/DynamicLayer
The example uses different styles (colors) for items depending on the data. It uses the ContentControl element with different Control Templates. So, you can use any shapes inside the template.
You can attach the mouse enter and mouse leave events to the element you add to the layer.
Please look at the DataServiceGetStoresCompleted method of the Example.xaml.cs (it contains the code that attaches the mouse events). Then you can show or hide popup when the events occur.
The example uses WCF service to retrieve items that are displayed on the map. You can look at source code of service on your PC using the following path:
C:\Program Files\Telerik\RadControls for Silverlight Q1 2010\Demos\ExamplesWeb\RadMapDataService.svc.cs
You don't need to use kml. You can create a WCF service that will retrieve data from your DataBase.
Best wishes,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
![](/forums/images/avatarimages/default.gif)
Thanks for your reply ,
I have started the work in the same way ,
1) On mouse over which kind of pop up i should use , to display data (as data is coming from the Service ) and set its properties for the position to display??
I am not getting i want to show data same like "Name", No, Address, ... etc so how it will be done?
Regards
Charu Pahuja
You can simply use a standard Tooltip control as popup. You can specify it in the control template and bind to the data you'd like to show. For example:
<
ControlTemplate
x:Key
=
"marketTemplate"
TargetType
=
"ContentControl"
>
<
Grid
Width
=
"30"
Height
=
"30"
layer:MapLayer.Location
=
"{Binding Path=Location}"
>
<
ToolTipService.ToolTip
>
<
ToolTip
>
<
ToolTip.Content
>
<
Border
BorderBrush
=
"Red"
BorderThickness
=
"2"
Background
=
"#7FFFFFFF"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"Auto"
/>
<
ColumnDefinition
Width
=
"Auto"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Grid.Row
=
"0"
Grid.Column
=
"0"
Foreground
=
"Green"
Text
=
"Name:"
/>
<
TextBlock
Grid.Row
=
"0"
Grid.Column
=
"1"
Foreground
=
"Brown"
Text
=
"{Binding Path=Title}"
/>
<
TextBlock
Grid.Row
=
"1"
Grid.Column
=
"0"
Foreground
=
"Green"
Text
=
"Description:"
/>
<
TextBlock
Grid.Row
=
"1"
Grid.Column
=
"1"
Foreground
=
"Brown"
Text
=
"{Binding Path=Description}"
/>
</
Grid
>
</
Border
>
</
ToolTip.Content
>
</
ToolTip
>
</
ToolTipService.ToolTip
>
<
Ellipse
Width
=
"30"
Height
=
"30"
>
<
Ellipse.Fill
>
<
LinearGradientBrush
StartPoint
=
"0.5,0"
EndPoint
=
"0.5,1"
>
<
GradientStop
Offset
=
"0"
Color
=
"#4F009F00"
/>
<
GradientStop
Offset
=
"0.3"
Color
=
"#7F00CF00"
/>
<
GradientStop
Offset
=
"0.5"
Color
=
"#FF00FF00"
/>
<
GradientStop
Offset
=
"0.7"
Color
=
"#7F00CF00"
/>
<
GradientStop
Offset
=
"1"
Color
=
"#4F009F00"
/>
</
LinearGradientBrush
>
</
Ellipse.Fill
>
</
Ellipse
>
</
Grid
>
</
ControlTemplate
>
Set your data object as DataContext to the content control and bind texts in the tooltip to the fields in your data object.
Greetings,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
![](/forums/images/avatarimages/default.gif)
Thanks for your reply
Now after doing this i also want to divide my map in given regions using this same dynamic layer concept and dividing the data into regions.
e.g : - US states are divided into 8 ISO regions.So i want these region should have boundary defined How this can be achieved.
You have given this region example againg with kml files only.
Is it possible to do it without that .
Please reply ASAP.
Regards
CHaru Pahuja
The dynamic layer does not work with ISO regions. It uses the rectangular areas which divides the world map like a grid.
If you just want to show some regions without using KML, then you can use the MapPolygon class instances directly. Also you can use an information layer to show them once separately from the dynamic layer.
Please see the following sample code:
<
map:RadMap
x:Name
=
"RadMap1"
Center
=
"40,-100"
ZoomLevel
=
"4"
>
<
layer:InformationLayer
x:Name
=
"informationLayer"
/>
</
map:RadMap
>
private
void
AddPolygon()
{
var points =
new
LocationCollection
{
new
Location(43, -122),
new
Location(40, -93),
new
Location(37, -111),
new
Location(33, -115),
new
Location(43, -122)
};
var polygon =
new
MapPolygon()
{
Points = points,
Stroke =
new
SolidColorBrush(Colors.Brown),
Fill =
new
SolidColorBrush(Color.FromArgb(128, 55, 77, 99)),
StrokeThickness = 1
};
informationLayer.Items.Add(polygon);
}
Kind regards,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
![](/forums/images/avatarimages/default.gif)
Thanks a lot for your reply :).It is working now
Query :
if i want to divide US into ISO regions with kml file then how many files i have to include in my code.
Regards
Charu Pahuja
The KML format allows to have multiple polygons in a single file. So, it will be enough to use a single one.
All the best,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
![](/forums/images/avatarimages/default.gif)
1) I need the output as it is in "EmptyProvider" of your demo but you have hardcoded here the population range and i want to read the Name of the State through that kml file is it possible if yes how?? Because you are taking the framework element that is giving me only coordinates of map polygon not the name .
2) My Project has multiple xap files , But i am not able to read the " file "xml" it is giving me null alwaz
"
StreamResourceInfo streamInfo = Application.GetResourceStream(
new Uri("/States/UsaSimplified.xml", UriKind.Relative));"
I have used this and it is giving me null i am not able to find what is the path here it require
My solution structure is (Solution Name)A- > Modules ( Folder ) --> My Site Locator Module(Folder)-->Presenter(Folder) (where i load my file )
and my "UsaSimplified.xml" this file is in states folder of My Site Locator Module(Folder)
i.e presenter and states are in "My Site Locator Module Folder"
Please help
Regards
Charu Pahuja