คำตอบ Multiple Pushpins

  • 8 martie 2012 16:39
     
      Are cod

    I am new to Silverlight and the Bing Maps Control. Have succeeded in loading map but one Pushpin appears when 2 are coded.

    XAML as follows:

    <UserControl x:Class="BristolMap.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:DesignHeight="640" d:DesignWidth="480">
        <Grid x:Name="LayoutRoot" Background="White">
            <m:Map Name="Bris1" CredentialsProvider="My Creds" Center="51.450432, -2.525862" ZoomLevel="14"></m:Map>
            <m:Pushpin Name="Avalon" Location="51.450432,-2.525862" Background="Green" Content="Avalon" ToolTipService.ToolTip="Avalon Lane"></m:Pushpin>
            <m:Pushpin Name="Wick" Location="51.456357, -2.433805" Background="Orange" Content="Wick" ToolTipService.ToolTip="Milford Ave, Wick"></m:Pushpin>
        </Grid>
    </UserControl>

    When clicked I want to redirect to another aspx page.

    With thanks


Toate mesajele

  • 9 martie 2012 15:38
    Moderator
     
     Răspuns

    Concerning the 2 pushpins, you should see if the two are well positionned and if they are not overlaping each other.
    Also try: http://www.microsoft.com/maps/isdk/silverlight/#MapControlInteractiveSdk.Tutorials.TutorialSimplePushpin

    To open a new page while you click on a pushpin, you should bind the click event on the pushpin elements to do so.
    Since it's a control in Silverlight, you can bind it from the code-behind or in the declaration.

    http://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.pushpin.aspx

    http://www.microsoft.com/maps/isdk/silverlight/#MapControlInteractiveSdk.Tutorials.TutorialEvents


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/

  • 10 martie 2012 01:16
    Moderator
     
     Răspuns

    Make sure the Pushpins are children of the Map in your XAML. Try moving the Map closing tag after the pushpins.

     <Grid x:Name="LayoutRoot" Background="White">
           
    <m:Map Name="Bris1" CredentialsProvider="My Creds" Center="51.450432, -2.525862" ZoomLevel="14">       

                   <m:Pushpin Name="Avalon" Location="51.450432,-2.525862" Background="Green" Content="Avalon" ToolTipService.ToolTip="Avalon Lane"></m:Pushpin>
                 
    <m:Pushpin Name="Wick" Location="51.456357, -2.433805" Background="Orange" Content="Wick" ToolTipService.ToolTip="Milford Ave, Wick"></m:Pushpin>


         </m:Map>
        </Grid>


  • 10 martie 2012 19:20
     
     Răspuns Are cod

    Thanks for your suggestion. I have implemented what you suggest. My problem seems that the first Pushpin only comes up centered on the map (which is the same co-ordinates of the Centre).

    <UserControl x:Class="BristolMap.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:DesignHeight="640" d:DesignWidth="480">
        <Grid x:Name="LayoutRoot" Background="White">
            <m:Map Name="Bris1" CredentialsProvider="My Credsl" Center="51.450432, -2.525862" ZoomLevel="14">
                <m:Pushpin Name="Avalon" Location="51.4509468078613, -2.52622008323669" Background="Green" Content="Avalon" ToolTipService.ToolTip="Avalon Lane"></m:Pushpin>
                <m:Pushpin Name="Wick" Location="51.455020904541, -2.43373799324036" Background="Orange" Content="Wick" ToolTipService.ToolTip="Milford Ave, Wick"></m:Pushpin>
            <m:Pushpin Name="Fishponds" Location="51.4741172790527, -2.49118208885193" Background="Blue" Content="Fishponds" ToolTipService.ToolTip="Station Road, Fishponds"></m:Pushpin>
            </m:Map>
        </Grid>
    </UserControl>


    • Marcat ca răspuns de eharford 11 martie 2012 14:43
    • Anulare marcare ca răspuns de eharford 11 martie 2012 14:46
    • Editat de eharford 11 martie 2012 14:48
    • Marcat ca răspuns de eharford 11 martie 2012 14:50
    •