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

Pinpoints

9 Answers 204 Views
Map
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 16 Feb 2010, 05:49 PM
I am trying to use the code from here: Adding Pin Points  and it seems to be formatted incorrectly with commas instead of semi colons and missing braces. Does anyone have a working example of adding a Pinpoint to a map in C#?

Thanks!
Sam


9 Answers, 1 is accepted

Sort by
0
Joshua Holt
Top achievements
Rank 2
answered on 16 Feb 2010, 11:39 PM
Hi Scott,
The code in the mentioned example is formatted correctly, however, it is using C# object initializers :)

-Josh
0
James Foxall
Top achievements
Rank 1
answered on 18 Feb 2010, 02:58 PM

0
Sam
Top achievements
Rank 1
answered on 18 Feb 2010, 03:05 PM
Thanks Josh,

I am getting build errors though.
0
Accepted
Joshua Holt
Top achievements
Rank 2
answered on 18 Feb 2010, 04:05 PM
Hi Guys,
I am sorry to hear that you are having issues.  I double checked the code, and it compiled fine for me in VS2008.  Here is the code I used:
  public MainPage() 
        { 
            InitializeComponent(); 
            AddPin(); 
        } 
 
        private void AddPin() 
        { 
            MapPinPoint pinPoint = new MapPinPoint() 
            { 
                Background = new SolidColorBrush(Colors.White), 
                Foreground = new SolidColorBrush(Colors.Red), 
                FontSize = 14, 
                ImageSource = new BitmapImage(new Uri("/Telerik.Silverlight.RadMap;component/Resources/Refresh.png", UriKind.Relative)), 
                Text = "Regular Pin Point" 
            }; 
            MapLayer.SetLocation(pinPoint, new Location(37.684297, -122.06924)); 
            this.InformationLayer.Items.Add(pinPoint); 
        } 


XAML:
<UserControl xmlns:my="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.DataVisualization"  x:Class="Mapping.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
    xmlns:layer="clr-namespace:Telerik.Windows.Controls.Map;assembly=Telerik.Windows.Controls.DataVisualization" 
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    <Grid x:Name="LayoutRoot"
        <my:RadMap Name="myMap"
            <layer:InformationLayer Name="InformationLayer"/> 
        </my:RadMap> 
    </Grid> 
</UserControl> 

Please ensure you have the following name spaces at the top of your code page, as they are not included by default:
using Telerik.Windows.Controls.Map; 
using System.Windows.Media.Imaging; 


Hope this helps :)

-Josh

0
Sam
Top achievements
Rank 1
answered on 19 Feb 2010, 04:22 PM
Thanks Josh it works now. I have a question, are there any built in pin point images? I assume we can use anything but the one this code generates is just a white box.

Thanks!
Sam
0
Joshua Holt
Top achievements
Rank 2
answered on 19 Feb 2010, 04:43 PM
Hi Sam,
I am glad to here it works for you now.  I just reflected the code, and didn't really find any resources for pin points.   However, you are correct in saying that you can use anything.  You are only bound to the restrictions silverlight imposes itself( no cross site images, unless properly configured).  You can easily reference a file in the root of your ClientBin by adding code like:
new BitmapImage(new Uri("/pinPoint.png", UriKind.Relative)),

Good luck!
-Joshua Holt
0
Sam
Top achievements
Rank 1
answered on 19 Feb 2010, 05:09 PM
Thanks,

I have one more question, I seem to have lost the text next to the radio buttons for Road view and Aerial, any idea why that would happen? Screen shot attached.

0
Joshua Holt
Top achievements
Rank 2
answered on 19 Feb 2010, 05:30 PM
Hi Sam,
I am not sure could you post the xaml snippet for your map? Might help me find out what is going on.

Thanks,
Josh
0
Sam
Top achievements
Rank 1
answered on 19 Feb 2010, 06:44 PM
I got it back, thanks for all your help!

Tags
Map
Asked by
Sam
Top achievements
Rank 1
Answers by
Joshua Holt
Top achievements
Rank 2
James Foxall
Top achievements
Rank 1
Sam
Top achievements
Rank 1
Share this question
or