Click here to Skip to main content
Licence CPOL
First Posted 14 Aug 2007
Views 43,713
Downloads 1,320
Bookmarked 56 times

a little Virtual Earth Control

By | 2 Jun 2008 | Article
A small introduction to load Virtual Earth Maps into C#

Screenshot - scr.png

Introduction

I simply want to realize a User Control to load VEarth Maps into a Windows Form.

The Main problem is that you can load these maps in HTML pages.

So.. i will load in a WebBrowser Control... but a new problem occurs... capture events from HTML pages.

Background

If you use these maps for commercial purposes; read the Microsoft license ($$$$).

To save maps and copy pictures, i use a class from SharpDevelop (Juergen Thomas, Berlin (Germany) - http://www.codeproject.com/csharp/FormPrintPackage.asp).

Using the code

Using this control is very easy.

Create a New Windows Forms Project, then include the DLL as component.

Insert the Control in the form and simply call the method:

 
vEarthControl1.ShowInitialMap();

There are various method to control the map and the visualisation, I think no explication is needed:

// To Show the initial map 
public void ShowInitialMap()


// and to close the map
public void unInit() 

This methods are to change the map type and to show (or hide) the dashboard, and change it's style.

 
public enum DashboardStyleEnum  {
       Small,
       Normal,
       Tiny
}
public void DashBoardShow()
public void DashBoardHide()
public void DashBoardSet(DashboardStyleEnum dStyle)
 
 
public enum MapStyleEnum  {
        Road ,
        Aerial ,
        Hybrid ,
    BirdsEye
}
public void SetMapStyle(MapStyleEnum mStyle)
 

To move in the map and zoom:
All Coordinates are in decimal format.

 
public void GoToCoordinates(double Latit, double Longit) 
public void SetZoomLevel(Int16 zLevel)
public void ZoomOut()
public void ZoomIn()
public void ZoomWorld()
public void ZoomBest()
 

To add and remove pushpin on the map:

 
public void AddPushpin(Int32 IDPush, Double lat, Double lon, String Descrizione)
public void AddPushpin(Int32 IDPush, Double lat, Double lon, String Descrizione, String iconAddress)
public void RemovePushpin(Int32 IDPush)
public void RemoveAllPushpins()
 

To save the map and print it:

 
public Bitmap GetMapImage()
public Boolean SaveMapAsBitmap(String FileName)
public Boolean SaveMapAsBitmap()
public void PrintMapDefaultSettings()
public void PrintMapPreview()
public void PrintOptions()
 

Advanced methods, do not use them if you don't know how you can send as parameter!!!
I declared public to allow everyone send different command directly to the map, based on SDK specification:

 
public void ExecuteCommandOnMap(String commandText)
public void ExecuteCommandOnMap(String commandText, String commandParameters)
public void ExecuteCommand(String commandText)
public void ExecuteCommand(String commandText, String commandParameters)
  

The two events; always handle them to avoid a noisy sound when the mouse is on the map:

 
public class OnMoveOnMapEventArgs : EventArgs
{
public Double Lat;
public Double Lon;
public DateTime ora;
}

private void OnClickOnMap(object sender, VEarth.OnClickOnMapEventArgs e)
private void OnMoveOnMap(object sender, VEarth.OnMoveOnMapEventArgs e)
 

Points of Interest

Virtual Earth SDK: http://msdn2.microsoft.com/en-us/library/bb429619.aspx

History

uh.. first version :p

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Andrea_86

Web Developer

Italy Italy

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberSedArash4:24 16 Oct '11  
GeneralExecuteCommand and ExecuteCommandOnMap Pinmemberjonnesvik1:06 26 Aug '10  
GeneralMy vote of 1 PinmemberKerkia14:43 4 Mar '09  
Questioncs_Andr.Controls PinmemberKerkia14:41 4 Mar '09  
GeneralUse with compact framework PinmemberDalli7:05 15 Feb '09  
GeneralMouse movement on BirdsEye view Pinmembersteve gregory1:55 20 Jan '09  
GeneralNot much use PinmemberRichardTrainer3:20 5 Aug '08  
NewsThey uploaded the source. PinmemberAlpha Nerd9:55 2 Jun '08  
GeneralSource for the dll PinmemberMetalRob23:47 1 Jun '08  
GeneralRoutes and Directions PinmemberMegaSurfer11:01 19 May '08  
Generalneed help PinmemberAmine barigo14:30 8 May '08  
GeneralWould appreciate source for DLL Pinmembercwford014:03 24 Apr '08  
QuestionHow to get the Place name?? PinmemberMember 384581518:58 8 Apr '08  
Generalany news on the source for the DLL Pinmemberpcummings4:20 17 Feb '08  
QuestionAdding several pushpins PinmembergunnarJonsson22:00 4 Dec '07  
QuestionRe: Adding several pushpins PinmemberMember 361493018:19 31 Aug '08  
GeneralIconAddress PinmembergunnarJonsson3:25 29 Nov '07  
GeneralSources Pinmemberthaos2K26:28 6 Nov '07  
GeneralRe: Sources PinmemberAndrea_866:30 6 Nov '07  
GeneralRe: Sources PinmemberJohn Witcher9:22 7 Dec '07  
QuestionSourceCode Pinmembermichbex18:32 1 Nov '07  
QuestionSourcecode to VEarthControl.dll ? PinmemberGMEKS8:22 14 Aug '07  
AnswerRe: Sourcecode to VEarthControl.dll ? PinmemberPiascas1:24 14 Sep '07  
GeneralRe: Sourcecode to VEarthControl.dll ? Pinmembercnlsmuts10:10 17 Nov '07  
GeneralRe: Sourcecode to VEarthControl.dll ? PinmemberJohn Witcher17:32 27 Nov '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web01 | 2.5.120517.1 | Last Updated 2 Jun 2008
Article Copyright 2007 by Andrea_86
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid