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

MouseOver Map

10 Answers 267 Views
Map
This is a migrated thread and some comments may be shown as answers.
Dharmesh Trivedi
Top achievements
Rank 1
Dharmesh Trivedi asked on 19 Nov 2009, 04:22 PM
I would like to put  a push pin in the map and when a mouse hover show detail for that push pin (e.g. contact name, address , phone etc) for that state.

10 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 24 Nov 2009, 04:17 PM
Hi Dharmesh Trivedi,

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.
0
Arvind Dhasmana
Top achievements
Rank 1
answered on 29 Apr 2010, 10:34 AM
Hi

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
0
Andrey
Telerik team
answered on 30 Apr 2010, 02:42 PM
Hi Arvind Dhasmana,

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.
0
Arvind Dhasmana
Top achievements
Rank 1
answered on 03 May 2010, 11:03 AM
Hi

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
0
Andrey
Telerik team
answered on 05 May 2010, 08:37 AM
Hello Arvind Dhasmana,

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.
0
Arvind Dhasmana
Top achievements
Rank 1
answered on 10 May 2010, 10:36 AM
Hi

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
0
Andrey
Telerik team
answered on 11 May 2010, 03:38 PM
Hello Charu,

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.
0
Arvind Dhasmana
Top achievements
Rank 1
answered on 14 May 2010, 11:40 AM
Hi

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
0
Andrey
Telerik team
answered on 14 May 2010, 01:20 PM
Hi Charu,

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.
0
Arvind Dhasmana
Top achievements
Rank 1
answered on 17 May 2010, 11:51 AM
Hi

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

 

Tags
Map
Asked by
Dharmesh Trivedi
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
Arvind Dhasmana
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or