vuott   18-04-2021, 00:45
#1
Apuntar Big Grin  en el mapa de un MapView: 

Código:
Private MapView1 As MapView
Private mp As MapPoint = MapPoint(36.490590, -6.238170)  ' en honor de mi amigo, Romanorum Consul Shell
Private DrawingArea1 As DrawingArea
 
 
Public Sub Form_Open()
 
  Dim pn As Panel
 
  With Me
    .W = Screen.AvailableWidth
    .H = Screen.AvailableHeight
    .Arrangement = Arrange.Fill
    .Mouse = Mouse.Blank
  End With
  With MapView1 = New MapView(Me) As "MapView1"
    .Map.AddTile("GoogleMap", "https://mt0.google.com/vt/lyrs=s&hl=&x={x}&y={y}&z={z}")
    .Map.Zoom = 11
' Imposta il centro della mappa:
    .Map.Center = mp
  End With
 
  pn = MapView1.Children[0]
  DrawingArea1 = pn.Children[0]
   
End
 
Public Sub MapView1_MouseMove()
 
  Dim pt As New Point(Mouse.X, Mouse.Y)
  Dim lat As Float = MapView1.Map.PixelToMapPointRel(pt).Lat
  Dim lon As Float = MapView1.Map.PixelToMapPointRel(pt).Lon
 
  mp = MapPoint(lat, lon)
 
  MapView1.Refresh
  MapView1.Map.Refresh
 
End

Public Sub MapView1_Draw()
 
  Dim c, x, y, r As Short
  Dim po As Point = MapView1.Map.MapPointToPixelRel(mp)
 
  With Paint
    .Begin(DrawingArea1)
    .Brush = .Color(Color.DarkOrange)
    .LineWidth = 2.0
    .Arc(MapView1.Map.MapPointToPixelRel(mp).X, MapView1.Map.MapPointToPixelRel(mp).Y, 50, 0, 360, False)
    .Arc(MapView1.Map.MapPointToPixelRel(mp).X, MapView1.Map.MapPointToPixelRel(mp).Y, 30, 0, 360, False)
    .Stroke
    .Brush = .Color(Color.Red)
    .Arc(MapView1.Map.MapPointToPixelRel(mp).X, MapView1.Map.MapPointToPixelRel(mp).Y, 1.5, 0, 360, False)
    .Fill
    
    r = 50
    x = po.X
    y = po.Y
    
    For c = 0 To 360 Step 90
      po.X = x + r * Cos(Rad(c))
      po.Y = y + r * Sin(Rad(c))
      .MoveTo(po.X, po.Y)
' Per ridurre la lunghezza della "x" per i gradi 0, 90, 180 e 270 è necessaria questa sequenza: +n 0 -n 0 che si ottiene con il Coseno di c.
' Per ridurre la lunghezza della "y" per i gradi 0, 90, 180 e 270 è necessaria questa sequenza: 0 -n 0 +n che si ottiene con il Coseno di c + 90.
      .LineTo(x + (20 * Cos(Rad(c))), y - (20 * Cos(Rad(c + 90))))
      .Stroke
    Next
    .Brush = .Color(Color.Yellow)
    .DrawText(Format(mp.Lat, "0.######"), x + r * Cos(Rad(270)) - (Me.Font.TextWidth(Format(mp.Lat, "0.######")) / 2), (y + (r + 15) * Sin(Rad(270))), Me.Font.TextWidth(Format(mp.Lat, "0.######")), Me.Font.TextHeight(Format(mp.Lat, "0.######")), Align.Left)
    .DrawText(Format(mp.Lon, "0.######"), x + r * Cos(Rad(0)) - (Me.Font.TextWidth(Format(mp.Lon, "0.######")) / 2), (y + (r + 15) * Sin(Rad(0))), Me.Font.TextWidth(Format(mp.Lon, "0.######")), Me.Font.TextHeight(Format(mp.Lon, "0.######")), Align.Left)
    .End
  End With
 
End
Última modificación: 19-04-2021, 01:59 por vuott.

« Los horizontes perdidos nunca regresan. » (F. Battiato, 1983)

« Las ondas nunca regresan. » (Genesis: Ripples, 1976)

« Vita non suavis esse potest, nec Mors amara. »  (...vuott)
  
Usuarios navegando en este tema: 1 invitado(s)
Powered By MyBB, © 2002-2024 MyBB Group.
Made with by Curves UI.