[Visual Basic 6.0]
Public SpinDirection As Integer
Public KeepMoving As Boolean
Private Sub Form_Load()
Dim objMap As MapPointCtl.Map
Dim objLoc As MapPointCtl.Location
KeepMoving = True
' Open a North American map.
Me.MappointControl1.NewMap geoMapNorthAmerica
' Set the map object to the current map.
Set objMap = MappointControl1.ActiveMap
' Set the location to Latitude 15.0000, Longitude 0.0000, Altitude 35,000 miles
Set objLoc = objMap.GetLocation(15, 0, 35000)
' Move to the location settings.
objLoc.GoTo
' Set the projection so that you will see a globe instead
' of a flat map at higher altitudes.
objMap.Projection = geoGlobeViewWhenZoomedOut
' Change the map style to the Political style
objMap.MapStyle = geoMapStylePolitical
' Set the font to the smallest size
objMap.MapFont = geoMapFontSmallest
' Set the starting spin direction to the west.
SpinDirection = geoWest
End Sub
Private Sub Form_Unload(Cancel As Integer)
MappointControl1.ActiveMap.Saved = True
End Sub
Private Sub Timer1_Timer()
Dim objMap As MapPointCtl.Map
Set objMap = MappointControl1.ActiveMap
If KeepMoving = True Then
' Pan (spin) the map in the direction specified
' and in steps expressed as a fraction of the screen width or height.
objMap.Pan SpinDirection, 0.01
End If
MappointControl1.ActiveMap.Saved = True
End Sub
Private Sub Command1_Click()
' Spin to the west.
SpinDirection = geoWest
End Sub
Private Sub Command2_Click()
' Spin to the east.
SpinDirection = geoEast
End Sub
Private Sub Command3_Click()
' Go north to the top of the earth.
' Once you go all the way to the North Pole it will stop.
SpinDirection = geoNorth
End Sub
Private Sub Command4_Click()
' Go south to the bottom of the earth.
' Once you go all the way to the South Pole it will stop.
SpinDirection = geoSouth
End Sub
Private Sub Command5_Click()
' Move out from the earth.
Dim objMap As MapPointCtl.Map
Set objMap = MappointControl1.ActiveMap
objMap.Altitude = objMap.Altitude + 500
End Sub
Private Sub Command6_Click()
' Move in to the earth.
Dim objMap As MapPointCtl.Map
Set objMap = MappointControl1.ActiveMap
objMap.Altitude = objMap.Altitude - 500
End Sub
Private Sub Command7_Click()
If KeepMoving = True Then
KeepMoving = False
Command7.Caption = "Rotate"
Else
KeepMoving = True
Command7.Caption = "Stop"
End If
End Sub
Private Sub Command8_Click()
Dim objMap As MapPointCtl.Map
Dim objLoc As MapPointCtl.Location
Dim Latitude, Longitude, Altitude As Long
' Stop the rotation in preparation for the goto.
KeepMoving = False
Command7.Caption = "Rotate"
' Set the map object to the current map
Set objMap = MappointControl1.ActiveMap
' Set the location latitude, longitude & altitude.
' to values entered in Text1, Text2 & Text3
Latitude = Val(Text1.Text)
Longitude = Val(Text2.Text)
Altitude = Val(Text3.Text)
' Check to make sure the latitude is within allowable range.
If Latitude < -90 Or Latitude > 90 Then
MsgBox ("Latitude outside of allowable range!")
Exit Sub
End If
' Check to make sure the longitude is within allowable range.
If Longitude < -180 Or Longitude > 180 Then
MsgBox ("Longitude outside of allowable range!")
Exit Sub
End If
' Check to make sure the altitude is within allowable range.
If Altitude < 1 Or Altitude > 50000 Then
MsgBox ("Altitude outside of allowable range!")
Exit Sub
End If
Set objLoc = objMap.GetLocation(Latitude, Longitude, Altitude)
' Move to the location settings.
objLoc.GoTo
End Sub
Private Sub Command9_Click()
Dim objMap As MapPointCtl.Map
' Set the map object to the current map.
Set objMap = MappointControl1.ActiveMap
If Command9.Caption = "Flat" Then
' Set the projection so that you will see a flat map instead
' of a globe at higher altitudes.
objMap.Projection = geoFlatViewWhenZoomedOut
Command9.Caption = "Globe"
Else
' Set the projection so that you will see a globe instead
' of a flat map at higher altitudes.
objMap.Projection = geoGlobeViewWhenZoomedOut
Command9.Caption = "Flat"
End If
End Sub