Tuesday, October 4, 2011

Display a map from an iOS FireMonkey application

Q: How do you display a map on the iPhone using FireMonkey?
A: By opening a URL formatted like so - http://maps.google.com/maps?q=LOCATION

Below is a short snippet that will do show a map of the Embarcadero Scotts Valley offices.

Enjoy!

unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Location : String;
begin
{$IFDEF FPC}
Location := 'http://maps.google.com/maps?q=5617+Scotts+Valley+Drive,+Scotts+Valley,+CA';
UIApplication.sharedApplication.openUrl(NSUrl.URLWithString(NSSTR(PChar(Location))));
{$ENDIF}
end;

end.

3 comments:

  1. Prêt-à-porter et accessoires en ligne. Hommes, femmes, enfants. Petits prix, stocks limités pour une mode unique.

    ReplyDelete
  2. potent links...

    [...]The Hacker’s Corner » Blog Archive » Display a map from an iOS FireMonkey application[...]...

    ReplyDelete
  3. Supercharge your marketing campaign with our social media promotion services. Buy high quality likes/followers/views at highly competitive prices and with fast delivery.

    Get 1,000 Google+ Ones from:- http://khalaghor.com/google.html
    5) 5,000 Instagram Followers from:- http://khalaghor.com/instagram.html

    You can also order smaller or bigger package from our official website.

    ReplyDelete

Note: Only a member of this blog may post a comment.