-----------------------------------

Acquista i software ArcGIS tramite Studio A&T srl, rivenditore autorizzato dei prodotti Esri.

I migliori software GIS, il miglior supporto tecnico!

I migliori software GIS, il miglior supporto tecnico!
Azienda operante nel settore GIS dal 2001, specializzata nell’utilizzo della tecnologia ArcGIS e aderente ai programmi Esri Italia Business Network ed Esri Partner Network

-----------------------------------



sabato 12 dicembre 2009

Bing Maps Silverlight Control v1.0.1

At last the definitive version of Bing Maps Silverlight Control v1.0.1 has been issued.
Here you can download the SDK.
In order to use it you must also have Visual Studio 2008 sp1 and Silverlight 3 Tools for Visual Studio 2008 SP1.

To visualize StreetSide too download dll here

Here you can see a simple example of how to visualize StreetSide, BirdEye and how to add a video on the map ( hold key CRTL and drag a box on the map, the box is the video extent).



using System;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Maps.MapControl;
using Microsoft.Maps.MapControl.ExtendedModes;
using Microsoft.Maps.MapControl.Navigation;

namespace veslTest
{
    public partial class MainPage : UserControl
    {

        private MapLayer myLayer = null;


        public MainPage()
        {
            InitializeComponent();
            BirdseyeMode.AddModeToNavigationBar(MyMap);
            StreetsideMode.AddModeToNavigationBar(MyMap);

            //Change the mode to Birdseye Mode
            //MyMap.Mode = new BirdseyeMode();

            MyMap.Mode.Center = new Microsoft.Maps.MapControl.Location(34.05159, -118.24239);
            MyMap.Mode = new StreetsideMode();
            MyMap.Heading = 0.0;
            MyMap.Pitch = 12.3;

            myLayer = new MapLayer();
            MyMap.Children.Add(myLayer);

            //MyMap.MouseClick += new EventHandler<MapMouseEventArgs>(MyMap_MouseClick);

            OpacitySlider.Value = 1.0;
            MyMap.MouseDragBox += new EventHandler<MapMouseDragEventArgs>(MyMap_MouseDragBox);

        }
        void MyMap_MouseDragBox(object sender, MapMouseDragEventArgs e)
        {
            e.Handled = true;
            MediaElement video = new MediaElement();


            Location lFrom = MyMap.ViewportPointToLocation(e.FromViewportPoint);
            Location lTo = MyMap.ViewportPointToLocation(e.ViewportPoint);

          //MediaElement video = new MediaElement();
          video.Source = new Uri("http://download.microsoft.com/download/3/6/E/36E181F7-8392-419B-B4BC-A82E88C5348C/Bing%20Maps%20Video.wmv", UriKind.RelativeOrAbsolute);


          double opacity;
          if (double.TryParse(OpacityText.Text, out opacity))
          {
              video.Opacity = opacity;
          }


          video.HorizontalAlignment = HorizontalAlignment.Stretch;
          video.VerticalAlignment = VerticalAlignment.Stretch;
          video.MediaFailed += MediaFailed;


          myLayer.AddChild(video, new LocationRect(lFrom, lTo));



        }








        private void MediaFailed(object sender, ExceptionRoutedEventArgs e)
        {
            //Ignore the error
        }



        private void Button_Click_Rotate(object sender, RoutedEventArgs e)
        {
            RotateMapCommand rotateMapCommand = new RotateMapCommand(true);

            rotateMapCommand.Execute(MyMap);


        }



        private void Button_Click_RemoveAll(object sender, RoutedEventArgs e)
        {
            myLayer.Children.Clear();

        }

        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

            OpacityText.Text = string.Format("{0:F2}", e.NewValue);
        }


    }
}

xaml:

<UserControl x:Class="veslTest.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:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    <Grid.RowDefinitions>
      <RowDefinition Height="40" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*"/>
      <ColumnDefinition Width="500"/>
    </Grid.ColumnDefinitions>
    <m:Map CredentialsProvider="YOUR KEY" x:Name="MyMap" Center="34.05159,-118.24239" ZoomLevel="19" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Grid.ColumnSpan="2"/>
    <StackPanel Orientation="Horizontal" Opacity="0.7" Grid.Column="1" Grid.Row="0">
      <Button Click="Button_Click_Rotate"  Tag="Rotate" Margin="5">
        <TextBlock>Rotate</TextBlock>
      </Button>
      <Button Click="Button_Click_RemoveAll" Tag="Remove all" Margin="5">
        <TextBlock>Remove all</TextBlock>
      </Button>
      <TextBlock VerticalAlignment="Center">Opacity:</TextBlock>
      <Slider x:Name="OpacitySlider" Minimum="0" Maximum="1" ValueChanged="Slider_ValueChanged" Width="100"></Slider>
      <TextBox x:Name="OpacityText" Text="1" Width="50" Height="25" VerticalAlignment="Center"/>
    </StackPanel>
  </Grid>
</UserControl>