Menu

DPF MapView AddAnnotation display problem

Bryan
2014-05-18
2014-05-18
  • Bryan

    Bryan - 2014-05-18

    Hello group.
    I hope someone can help me with this problem I'm having with AddAnnotation method with DPFMapView

    I generate 100 random Latitude and Longitude values and add those points to a MapView with an image icon as the Map Point.

    The problem is the image does not show right away. The pin shows. After I zoom in and back out a few times, the image icons finally start to show up on the map slowly.

    I would like for the image icons to show up immediately instead of the pins.

    I hope someone can tell me how to fix it.

    Regards,
    Bryan

    P.S. I did not see where I could add attachments for some reason... it was there before.
    Anyway, here's the unit.
    Just add a DPFMapView to the form and drop a button on the map.

    Since I cannot attach the sample program, you will have to add a sample small icon to the deployment and set the remote path to ".\Documents\"

    Also you may have to rename the "Earthquake.png" below to whatever you named the sample icon file.

    unit Unit1;

    interface

    uses
    System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
    FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
    DPF.iOS.UIButton, DPF.iOS.UILabel, DPF.iOS.BaseControl, DPF.iOS.UITextField,
    DPF.iOS.MapKit, Generics.Collections, iOSapi.CoreLocation,
    MacApi.ObjectiveC, DPF.iOS.MKMapView, DPF.iOS.UIView, System.Math;

    type
    TForm1 = class(TForm)
    Map: TDPFMapView;
    DPFButton1: TDPFButton;
    procedure FormOnShow( Sender: TObject );
    procedure DPFButton1Click(Sender: TObject);
    private
    { Private declarations }
    protected
    { Protected declarations }
    procedure PaintRects( const UpdateRects: array of TRectF ); override;
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.fmx}

    // Important for performance
    procedure TForm1.PaintRects( const UpdateRects: array of TRectF );
    begin
    { }
    end;

    // Important for performance
    procedure TForm1.DPFButton1Click(Sender: TObject);

    Function GenerateRandomLat : Double;
    begin
    Result := RandomRange(-60, 60);
    end;

    Function GenerateRandomLon : Double;
    begin
    Result := RandomRange(-179, 179);
    end;

    var
    MKPoint : MKPointAnnotation;
    x : Integer;
    begin
    for x := 0 to 100 do
    begin
    MKPoint:= Map.AddAnnotation('test',
    'test comments',
    GenerateRandomLat,
    GenerateRandomLon,
    -1,
    '',
    false,
    1,
    pcRed,
    '/Documents/Earthquake.png',
    '',
    true,
    false);
    end;

    end;

    procedure TForm1.FormOnShow( Sender: TObject );
    begin
    self.Active := true; // very important for no crashing
    // Application.Terminate; // Important For Application Speed up Performance !!!
    end;

    end.

     
  • Bryan

    Bryan - 2014-05-18

    I was finally able to add an attachment.
    No need to copy and paste the above code, you can just download and use the sample program.

    Thanks for any suggestions.
    Regards,
    Bryan

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.