Skip to main content

Microsoft Silverlight

Answered Question VE map in SilverlightRSS Feed

(0)

darkcrawler
darkcrawler

Member

Member

25 points

20 Posts

VE map in Silverlight

 Hi there!

I'm trying to get a VE map in my application. I can do that... The thing is, I just want to show the map when i press a button.

My idea is, have the mapContainer div hidden (or width and height with value 0) and when i press the button, change the div style! But does not wok!

Can you help me?

.aspx code:

<head>

...

<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></script>
<script type="text/javascript" src="views.js"></script>

</head> 

<body>
    <div id='errorLocation' style="font-size: small;color: Gray;"></div>
   
    <div id="silverlightControlHost">
        <form id="form1" runat="server" style="height: 100%;">
       
        <div id='mapContainer' runat="server" style="visibility: hidden; position: absolute;">
        </div>

       
        <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" width="100%" height="100%">
            <param name="source" value="ClientBin/MapTeste.xap"/>
            <param name="onerror" value="onSilverlightError" />
            <param name="background" value="white" />
           
            <param value="true" name="windowless"/>
           
            <a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;">
                 <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
            </a>
        </object>
       
        <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
        </form>
    </div>
</body>

 

page.xaml.cs code:

private VEMap map;

        public Page()
        {
            InitializeComponent();
        }       


        private void test_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            map = new VEMap("mapContainer");
            HtmlPage.RegisterScriptableObject("SLMAP", map);

            HtmlElement m = HtmlPage.Document.GetElementById("mapContainer");
            if (m != null)
            {
                m.SetStyleAttribute("left", "50");
                m.SetStyleAttribute("right", "50");
                m.SetStyleAttribute("width", "320");
                m.SetStyleAttribute("height", "240");
                m.SetStyleAttribute("visibility", "visible");
            }
            map.LoadMap();
        }
    }

pade.xaml code:

<Grid x:Name="LayoutRoot" Background="White">
        <Button x:Name="teste" Width="80" Height="20" Content="testar" MouseLeftButtonDown="test_MouseLeftButtonDown"></Button>
    </Grid>
 

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: VE map in Silverlight

Hello, I didn't test Virtual Earth. But I think your problem is you're trying to handle a Button's MouseLeftButtonDown event. Why don't handle the Click event? MouseLeftButtonDown is handled by Button internally and marked as Handled, so you won't get it. Use Click instead. If you want the event handler to be invoked as soon as the mouse button is down, set the Button's ClickMode to Press.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

darkcrawler
darkcrawler

Member

Member

25 points

20 Posts

Re: Re: VE map in Silverlight

 Ok...

Works fine with the Click event!

I had other wrong things, but is working now...

Thanks
 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities