Recent

Author Topic: tratando de adaptar un codigo  (Read 1471 times)

soymoe

  • New Member
  • *
  • Posts: 35
tratando de adaptar un codigo
« on: March 19, 2020, 10:35:50 pm »
hola estoy tratando de usar este codigo para usar con TMapviewer, para marcar puntos en el mapa pero no logro que compile, este es el codigo que quiero adaptar:
Code: Pascal  [Select][+][-]
  1.     procedure TMainForm.MapViewDrawGpsPoint(Sender, ACanvas: TObject;
  2.       APoint: TGpsPoint);
  3.     const
  4.       R = 5;
  5.     var
  6.       P: TPoint;
  7.       cnv: TFPCustomCanvas;
  8.       txt: String;
  9.       w, h: Integer;
  10.       bmp: TBitmap;
  11.       img: TLazIntfImage;
  12.     begin
  13.       // Screen coordinates of the GPS point
  14.       P := TMapView(Sender).LonLatToScreen(APoint.RealPoint);
  15.      
  16.       // Draw the GPS point as a circle
  17.       cnv := TFPCustomCanvas(ACanvas);
  18.       cnv.Brush.FPColor := colRed;
  19.       cnv.Ellipse(P.X-R, P.Y-R, P.X+R, P.Y+R);
  20.      
  21.       // Draw the "name" of the GPS point. Note: FPCustomCanvas, by default,
  22.       // does not support text output. Therefore we paint to a bitmap first and
  23.       // render this on the FPCustomCanvas.
  24.       txt := APoint.Name;
  25.       bmp := TBitmap.Create;
  26.       try
  27.         bmp.PixelFormat := pf32Bit;
  28.         w := bmp.Canvas.TextWidth(txt);
  29.         h := bmp.Canvas.TextHeight(txt);
  30.         bmp.SetSize(w, h);
  31.         bmp.Canvas.Brush.Color := clWhite;
  32.         bmp.Canvas.FillRect(0, 0, w, h);
  33.         bmp.Canvas.TextOut(0, 0, txt);
  34.         img := bmp.CreateIntfImage;
  35.         cnv.Draw(P.X - w div 2, P.Y - h - 2*R, img);
  36.         img.Free;
  37.       finally
  38.         bmp.Free;
  39.       end;
  40.     end;  
  41.  
  42.  
ademas no se como usarlo. adjunto mi unidad principal.Gracias desde ya.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: tratando de adaptar un codigo
« Reply #1 on: March 22, 2020, 11:59:40 am »
¿Qué quieres decir con que "no compila"?  ¿Devuelve error? ¿Qué error?
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

soymoe

  • New Member
  • *
  • Posts: 35
Re: tratando de adaptar un codigo
« Reply #2 on: March 22, 2020, 03:22:10 pm »
Gracias por responder. Ya he solucionado el tema con la ayuda del foro en ingles.

 

TinyPortal © 2005-2018