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

Evaluating telerik Openstreetmap Please respond...

2 Answers 77 Views
Map
This is a migrated thread and some comments may be shown as answers.
Vivek
Top achievements
Rank 1
Vivek asked on 15 Jul 2011, 04:12 PM
Hi Team,

I am working for the custom search option. I have one text box for custom search and one button to search the map item. Please find my code in code block.
<Window x:Class="DetailData.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBox Margin="12,4,0,6" Height="30" Width="300" HorizontalAlignment="Left" Name="Txtbx_Search"></TextBox>
        <Button Margin="318,4,135,6" Height="30" Width="50" Content="Search" Name="Search" Click="Search_Click"></Button>
        <telerik:RadMap x:Name="radMap" Grid.Row="1" Center="60.1755556, 24.9341667" MouseDoubleClickMode="None" ZoomLevel="5"  >
            <telerik:RadMap.Provider>
                <telerik:OpenStreetMapProvider />
            </telerik:RadMap.Provider>
            <telerik:InformationLayer Name="informationLayer">
                <telerik:InformationLayer.ItemTemplate>
                    <DataTemplate>
                        <Border Background="Transparent"
                                BorderThickness="1"
                                Padding="2,2,2,2">
                            <ToolTipService.ToolTip>
                                <ToolTip Content="{Binding Path=Title}" />
                            </ToolTipService.ToolTip>
                            <telerik:MapLayer.HotSpot>
                                <telerik:HotSpot X="0.5" Y="1.0"  XUnits="Fraction" YUnits="Fraction" ElementName="Pin"/>
                            </telerik:MapLayer.HotSpot>
                            <Canvas x:Name="Pin" Height="32" Width="20">
                                <Path Data="M1054.5088,458.105L1065.5188,458.105C1067.7278,458.105,1069.5188,459.896,1069.5188,462.105L1069.5188,473.084C1069.5188,475.293,1067.7278,477.084,1065.5188,477.084C1065.5188,477.084,1062.6868,476.831,1062.2128,479.103C1061.6608,481.751,1060.2208,489.11,1060.2208,489.11L1059.3548,489.11C1059.3548,489.11,1058.0138,482.546,1057.2888,479.106C1056.8538,477.041,1054.5088,477.084,1054.5088,477.084C1052.2998,477.084,1050.5088,475.293,1050.5088,473.084L1050.5088,462.105C1050.5088,459.896,1052.2998,458.105,1054.5088,458.105z" Fill="White" Height="32.005" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" Stroke="Black" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Width="20.01"/>
                                <Path  Canvas.Top="2.989" Canvas.Left="3.188" Data="M1066.6162,472.8125C1066.6212,473.9125,1065.7252,474.8125,1064.6252,474.8125L1055.2502,474.8125C1054.1502,474.8125,1053.2462,473.9125,1053.2412,472.8125L1053.1962,462.5935C1053.1912,461.4935,1054.0872,460.5935,1055.1872,460.5935L1064.5622,460.5935C1065.6622,460.5935,1066.5662,461.4935,1066.5712,462.5935z" Fill="Black" Height="14.219" Stretch="Fill" Width="13.42"/>
                            </Canvas>
 
                        </Border>
                    </DataTemplate>
                </telerik:InformationLayer.ItemTemplate>
            </telerik:InformationLayer>
            <telerik:InformationLayer Name="informationLayer2" />
        </telerik:RadMap>
    </Grid>
</Window>

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Map;
using System.Windows.Media;
 
namespace DetailData
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private bool initialized;
        private RadWindow window;
        private Point topRightPoint;
 
        public MainWindow()
        {
            InitializeComponent();
 
            this.radMap.InitializeCompleted += new EventHandler(radMap_InitializeCompleted);
        }
 
        void radMap_InitializeCompleted(object sender, EventArgs e)
        {
            if (!this.initialized)
            {
                this.initialized = true;
                // add pushpin              
                Pushpin pushpin = new Pushpin();
                MapLayer.SetLocation(pushpin, new Location(60.1755556, 24.9341667));
                pushpin.MouseDoubleClick += new MouseButtonEventHandler(pushpin_MouseDoubleClick);
                this.informationLayer.Items.Add(pushpin);
            }
        }
 
        private void pushpin_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var pushpin = sender as Pushpin;
            if (pushpin != null)
            {
                e.Handled = true;
                LocationRect bounds = this.informationLayer.GetGeoBounds(pushpin);
                bounds.MapControl = this.radMap;
                Location topRight = bounds.Northwest;
                this.topRightPoint = topRight.GetPoint(this.radMap);
                 
                this.topRightPoint.X += this.Left;
                this.topRightPoint.Y += this.Top;
 
                if (this.window != null && this.window.IsOpen)
                {
                    this.window.Close();
                }
 
                this.window = new RadWindow()
                 
                {
                    Content = "My first Pinpoint info"
 
                };
                window.ResizeMode = System.Windows.ResizeMode.NoResize;
                this.window.SizeChanged += new System.Windows.SizeChangedEventHandler(window_SizeChanged);
                this.window.ShowDialog();
            }
        }
 
        private void window_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
        {
            var window = sender as RadWindow;
            if (window != null && e.NewSize.Width > 0)
            {
                Canvas.SetLeft(window, this.topRightPoint.X - e.NewSize.Width);
                Canvas.SetTop(window, this.topRightPoint.Y);
            }
        }
 
        
 
        private void Search_Click(object sender, RoutedEventArgs e)
        {
            string query = this.Txtbx_Search.Text;
            //radMap.Center =
 
 
        }
 
 
 
 
    }
}

I need to show the search point by adding one pinpoint. do you have some custom search example for openstreetmap?

Please provide some sample code for the openstreetmap.



Thanks,
Vivek.

2 Answers, 1 is accepted

Sort by
0
Vivek
Top achievements
Rank 1
answered on 18 Jul 2011, 05:03 PM
Hi Team,

Please support us with some code example.

Thanks,
Vivek
0
Accepted
Andrey
Telerik team
answered on 20 Jul 2011, 01:40 PM
Hello Vivek,

Unfortunately OpenStreet have not geocode, routing and search services. Currently RadMap support these operations using Bing services only. You can find example for Bing search service here:

http://demos.telerik.com/silverlight/#Map/Search

Greetings,
Andrey Murzov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Map
Asked by
Vivek
Top achievements
Rank 1
Answers by
Vivek
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or