WEB开发网
开发学院图形图像Flash [玩转Silverlight]第五回:应用篇,在Silverlight... 阅读

[玩转Silverlight]第五回:应用篇,在Silverlight中使用Virutal Earth地图服务

 2009-03-31 12:01:47 来源:WEB开发网   
核心提示: 在Silverlight中添加调用布局<Gridx:Name="LayoutRoot"Background="Azure"><StackPanelOrientation="Vertical"><Sta

在Silverlight中添加调用布局

<Grid x:Name="LayoutRoot" Background="Azure">
  <StackPanel Orientation="Vertical" >
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
      <TextBox x:Name="tbPlace" Width="200" Height="30" Text="Beijing" Margin="5" />
      <Button x:Name="btnFind" Width="100" Content="Find" Height="30" Click="btnFind_Click" />
    </StackPanel> 
    <HyperlinkButton x:Name="codeload" HorizontalAlignment="Center" Content="Code Download" Margin="10" Click="codeload_Click" />
    <TextBlock HorizontalAlignment="Center" Text="2009, Anytao.com" />
  </StackPanel>
</Grid>

实现具体的调用逻辑

// Release : code01, 2009/03/03          
// Author : Anytao, http://www.anytao.com 
// List  : Page.xaml.cs
public partial class Page : UserControl
{
  private VEMap map;
  private VEShapeLayer layer;

  public Page()
  {
    InitializeComponent();

    Loaded += new RoutedEventHandler(Page_Loaded);
    codeload.Content = "Download: " + App.Current.GetType().Namespace;
  }

  void Page_Loaded(object sender, RoutedEventArgs e)
  {
    //Create from container
    map = new VEMap("myMap");
    HtmlPage.RegisterScriptableObject("SLMAP", map);

    //Location in Beijing
    VELatLong point = new VELatLong(39.92, 116.46);
    //Loading the earth
    map.LoadMap(point, 11);
  }

  private void btnFind_Click(object sender, RoutedEventArgs e)
  {
    //Find a location
    map.Find(string.Empty, tbPlace.Text);
  }
}

Tags:Silverlight 第五回 应用

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接