Click here to Skip to main content
12,999,633 members (41,390 online)
Click here to Skip to main content
Add your own
alternative version

Stats

55.4K views
1.1K downloads
28 bookmarked
Posted 28 Nov 2006

VB.NET and C# virtual earth custom server control

, 28 Nov 2006
Rate this:
Please Sign up or sign in to vote.
An ASP.NET virtual earth custom server map control, with C# and VB.NET examples.

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

Share

About the Author

sydausguy
Web Developer
United States United States
Australian .NET Developer Living in Newport Beach California.

You may also be interested in...

Pro

Comments and Discussions

 
GeneralAamir Pin
az00866-Mar-10 18:53
memberaz00866-Mar-10 18:53 
GeneralCommercial usage license Pin
A. Bhandari a.k.a Amit Bhandari21-Apr-09 0:21
memberA. Bhandari a.k.a Amit Bhandari21-Apr-09 0:21 
Generaltrouble in Web Application Pin
dmiller71911-Sep-08 7:24
memberdmiller71911-Sep-08 7:24 
GeneralYeah ... It Works !!! Pin
Manish34543543 Shilpa345345348-Sep-08 22:52
memberManish34543543 Shilpa345345348-Sep-08 22:52 
GeneralRe: Yeah ... It Works !!! Pin
az00866-Mar-10 18:54
memberaz00866-Mar-10 18:54 
Question'VEMap' is undefined Pin
awybenga4-Sep-07 9:17
memberawybenga4-Sep-07 9:17 
AnswerRe: 'VEMap' is undefined Pin
WengNg8827-Jan-09 10:08
memberWengNg8827-Jan-09 10:08 
AnswerRe: 'VEMap' is undefined Pin
Aneke Ifeanyi U18-Jun-09 1:35
memberAneke Ifeanyi U18-Jun-09 1:35 
GeneralASP.NET AJAX Virtual Earth Server Control Pin
Christopher Pietschmann, MCSD, MCAD27-Mar-07 8:30
memberChristopher Pietschmann, MCSD, MCAD27-Mar-07 8:30 
GeneralRe: ASP.NET AJAX Virtual Earth Server Control Pin
sydausguy5-May-07 14:52
membersydausguy5-May-07 14:52 
GeneralRe: ASP.NET AJAX Virtual Earth Server Control Pin
Christopher Pietschmann, MCSD, MCAD6-May-07 5:24
memberChristopher Pietschmann, MCSD, MCAD6-May-07 5:24 
GeneralRe: ASP.NET AJAX Virtual Earth Server Control Pin
Christopher Pietschmann, MCSD, MCAD19-Oct-07 15:09
memberChristopher Pietschmann, MCSD, MCAD19-Oct-07 15:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170624.1 | Last Updated 28 Nov 2006
Article Copyright 2006 by sydausguy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid