Click here to Skip to main content
5,789,909 members and growing! (17,370 online)
Email Password   helpLost your password?
Web Development » Custom Controls » General     Intermediate

VB.NET and C# virtual earth custom server control

By sydausguy

An ASP.NET virtual earth custom server map control, with C# and VB.NET examples.
C#, VB, Javascript, Windows, .NET 2.0, .NET, ASP.NET, Visual Studio, VS2005, Dev

Posted: 28 Nov 2006
Updated: 28 Nov 2006
Views: 22,900
Bookmarked: 15 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
6 votes for this Article.
Popularity: 2.08 Rating: 2.67 out of 5
2 votes, 33.3%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
1 vote, 16.7%
4
3 votes, 50.0%
5

Sample Image

Sample Image

Introduction

This control has two functions, one is to display a location at longitude, latitude, and zoom level. The other is to show a collection of locations and add pins to those locations. You could use this control to easily display maps.

Background

The JavaScript code and the related framework can be found here.

Using the code

To get the example to run, you will need to put the GetMap() function in OnLoad or attach it to a control on the page.

<body onload="GetMap;">

Add the control to the page, set the browsable properties Height and Width, and if you want to specific a location, set the properties for longitude and latitude and zoom level, and this will display you the map.

VB.NET

//
<%@ Register Assembly="Asm.Map.VbNet" 
        Namespace="Asm.Map.VbNet" TagPrefix="cc1" %>

<cc1:MapControl ID="MapControl1" runat="server" 
        Height="600px" Width="700px" />
//

C#

//
<%@ Register Assembly="Asm.Map.Csharp" 
        Namespace="Asm.Map.Csharp" TagPrefix="cc1" %>

<cc1:MapControl ID="MapControl1" runat="server" 
        Height="600px" Width="700px" />
//

Code-behind

If you want to show a collection of locations, you'll need to bind to the map control the list of longitude, latitude, title, and text. In the example, I'm listing a few locations and putting a link to those locations.

VB.NET

Protected Sub Page_Load(ByVal sender As Object, _
          ByVal e As System.EventArgs) Handles Me.Load 
    
    Dim theList() As String theList = New String() _ 
        {47.6, -122.33, "Wal Mart", "<a  " & _ 
        "href="" http: www.walmart.com=""><span " & _ 
        "style="text-decoration: underline">Click Here</span></a>", _
         46.6, -122.33, "Target", "<a href="" http: " & _ 
         "www.target.com=""></a><span " & _ 
         "style="text-decoration: underline">Click Here</span>"} 
    MapControl1.DataSource = theList 
    MapControl1.DataBind() 
End Sub

C#

protected void Page_Load(object sender, EventArgs e) 
{ 
    string[] theList; 
    theList = new string[] { "47.6", "-122.33", "Wal Mart", _
              "<a href='\"http://www.walmart.com\"'><span" & _ 
              " style="text-decoration: underline">Click " & _ 
              "Here</span></a>", "46.6", "-122.33", "Target", _
              "<a href='\"http://www.target.com\"'><span" & _ 
              " style="text-decoration: underline">Click " & _ 
              "Here</span></a>" }; 
    MapControl1.DataSource = theList; 
    MapControl1.DataBind(); 
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

sydausguy


Australian .NET Developer Living in Newport Beach California.
Occupation: Web Developer
Location: United States United States

Other popular Custom Controls articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
Generaltrouble in Web Applicationmemberdmiller7198:24 11 Sep '08  
GeneralYeah ... It Works !!!memberManish34543543 Shilpa3453453423:52 8 Sep '08  
Question'VEMap' is undefinedmemberawybenga10:17 4 Sep '07  
GeneralASP.NET AJAX Virtual Earth Server ControlmemberChristopher Pietschmann, MCSD, MCAD9:30 27 Mar '07  
GeneralRe: ASP.NET AJAX Virtual Earth Server Controlmembersydausguy15:52 5 May '07  
GeneralRe: ASP.NET AJAX Virtual Earth Server ControlmemberChristopher Pietschmann, MCSD, MCAD6:24 6 May '07  
GeneralRe: ASP.NET AJAX Virtual Earth Server ControlmemberChristopher Pietschmann, MCSD, MCAD16:09 19 Oct '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 28 Nov 2006
Editor: Smitha Vijayan
Copyright 2006 by sydausguy
Everything else Copyright © CodeProject, 1999-2009
Web08 | Advertise on the Code Project