Avinash
Avinash

Reputation: 633

implementing the Bing maps in Windows phone 7

I am new to the Windows phone 7, Please help me

<phone:PhoneApplicationPage 
    x:Class="Sample1.PanoramaPage1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps">
    <my:Map x:Name="map1" CredentialsProvider="{Binding CredentialsProvider}" Height="462" HorizontalAlignment="Left" Margin="6,6,0,0"  VerticalAlignment="Top" Width="444" >
                    <my:MapItemsControl x:Name="mapItemsControl" ItemsSource="{Binding Path=Locations}">
                    <my:MapItemsControl.ItemTemplate>
                        <DataTemplate>
                            <m:Pushpin  MouseLeftButtonUp="Pushpin_MouseLeftButtonUp" Background="Red" Location="{Binding}">

                            </m:Pushpin>
                        </DataTemplate>
                    </my:MapItemsControl.ItemTemplate>
                </my:MapItemsControl>
                </my:Map>

And my .xaml.cs is like this:

public PanoramaPage1()
        {
            InitializeComponent();
            //map1.Mode = new RoadMode();  
            Pushpin pushpin = new Pushpin();
            Location location = new Location();
            location.Latitude = 53.550556;
            location.Longitude = 9.993333;
            pushpin.Location = location;
            pushpin.Background = new SolidColorBrush(Colors.Red);
            map1.Children.Add(pushpin);
}

if we see i have two(2) map control are added to the page those are

xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl" xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"

if i use the map of the Microsoft.Maps.MapControl pushpin is working but the below code is not working.

<m:Map.Mode>
                <m:AerialMode ShouldDisplayLabels="True" />
                </m:Map.Mode>

it is giving error as "The property 'ShouldDisplayLabels' was not found in type 'AerialMode'."

If i use map of the Microsoft.Phone.Controls.Maps then Pushpin is not working means pushpin staying stable when we are moving the map(map is moving but pushpin is staying satble). And also if add the two pushpins like below:

 public PanoramaPage1()
            {
                InitializeComponent();
                //map1.Mode = new RoadMode();

                GeoCoordinate lHamburg = new GeoCoordinate(53.550556, 9.993333);

                Pushpin pushpin = new Pushpin();
                Location location = new Location();
                location.Latitude = 53.550556;
                location.Longitude = 9.993333;
                pushpin.Location = location;
                pushpin.Background = new SolidColorBrush(Colors.Red);
                map1.Children.Add(pushpin);

                pushpin = new Pushpin();
                location = new Location();
                location.Latitude = 83.550556;
                location.Longitude = 9.993333;
                pushpin.Location = location;
                pushpin.Background = new SolidColorBrush(Colors.Yellow);
                map1.Children.Add(pushpin);
    }

only second pushpin(Colors.Yellow) i am able to see on the map.

Please help me out.

Upvotes: 1

Views: 884

Answers (1)

LudwigGhislain
LudwigGhislain

Reputation: 90

You have two instances with the names 'pushpin'

Upvotes: 1

Related Questions