![]() |
Web Development »
Custom Controls »
General
Intermediate
VB.NET and C# virtual earth custom server controlBy sydausguyAn ASP.NET virtual earth custom server map control, with C# and VB.NET examples. |
C#, VB, Javascript, Windows, .NET 2.0, ASP.NET, VS2005, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||


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.
The JavaScript code and the related framework can be found here.
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.
//
<%@ Register Assembly="Asm.Map.VbNet"
Namespace="Asm.Map.VbNet" TagPrefix="cc1" %>
<cc1:MapControl ID="MapControl1" runat="server"
Height="600px" Width="700px" />
//
//
<%@ Register Assembly="Asm.Map.Csharp"
Namespace="Asm.Map.Csharp" TagPrefix="cc1" %>
<cc1:MapControl ID="MapControl1" runat="server"
Height="600px" Width="700px" />
//
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.
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
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();
}
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 28 Nov 2006 Editor: Smitha Vijayan |
Copyright 2006 by sydausguy Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |