GOOGLE定位
GOOGLE定位
/// <author>cxg 2018-3-27</author>
unit umap;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
FRM_BASS_MAIN, FMX.Effects, FMX.Controls.Presentation, FMX.Objects, System.Sensors,
FMX.ListBox, FMX.Layouts, System.Sensors.Components, FMX.WebBrowser;
type
Tfmap = class(TFrame_Base_Main)
ToolBar1: TLayout;
Button1: TButton;
WebBrowser1: TWebBrowser;
Layout1: TLayout;
ListBox1: TListBox;
ListBoxItemLatitude: TListBoxItem;
ListBoxItemLongitude: TListBoxItem;
ListBox2: TListBox;
ListBoxItemAdminArea: TListBoxItem;
ListBoxItemCountryCode: TListBoxItem;
ListBoxItemCountryName: TListBoxItem;
ListBoxItemFeatureName: TListBoxItem;
ListBoxItemLocality: TListBoxItem;
ListBoxItemPostalCode: TListBoxItem;
ListBoxItemSubAdminArea: TListBoxItem;
ListBoxItemSubLocality: TListBoxItem;
ListBoxItemSubThoroughfare: TListBoxItem;
ListBoxItemThoroughfare: TListBoxItem;
LocationSensor1: TLocationSensor;
procedure Button1Click(Sender: TObject);
procedure LocationSensor1LocationChanged(Sender: TObject; const OldLocation, NewLocation: TLocationCoord2D);
private
{ Private declarations }
FGeocoder: TGeocoder;
procedure OnGeocodeReverseEvent(const Address: TCivicAddress);
procedure Geocoder(location: TLocationCoord2D);
public
{ Public declarations }
Procedure Unitialize; override;
end;
var
fmap: Tfmap;
implementation
{$R *.fmx}
{ TFrame_Base_Main2 }
procedure Tfmap.Button1Click(Sender: TObject);
begin
LocationSensor1.Active := False;
LocationSensor1.Active := True;
end;
procedure Tfmap.Geocoder(location: TLocationCoord2D);
begin
// 利用 TGeocoder进行地名解析
//建立TGeocode实像,并为之设置事件代码
if not Assigned(FGeocoder) then
begin
if Assigned(TGeocoder.Current) then
FGeocoder := TGeocoder.Current.Create;
if Assigned(FGeocoder) then
FGeocoder.OnGeocodeReverse := OnGeocodeReverseEvent;
end;
//转换成地名
if Assigned(FGeocoder) and not FGeocoder.Geocoding then
FGeocoder.GeocodeReverse(Location);
end;
procedure Tfmap.LocationSensor1LocationChanged(Sender: TObject; const OldLocation, NewLocation: TLocationCoord2D);
var
URLString: string;
LSettings: TFormatSettings;
LDecSeparator: Char;
begin
LDecSeparator := FormatSettings.DecimalSeparator;
LSettings := FormatSettings;
try
FormatSettings.DecimalSeparator := '.';
// 显示当前位置
ListBoxItemLatitude.ItemData.Text := Format('纬度: %2.6f', [NewLocation.Latitude]);
ListBoxItemLongitude.ItemData.Text := Format('经度: %2.6f', [NewLocation.Longitude]);
// 用 Google Maps显示
URLString := Format('https://maps.google.com/maps?q=%2.6f,%2.6f', [NewLocation.Latitude, NewLocation.Longitude]);
finally
FormatSettings.DecimalSeparator := LDecSeparator;
end;
{ and track the location via Google Maps }
WebBrowser1.Navigate(URLString);
Geocoder(NewLocation);
end;
procedure Tfmap.OnGeocodeReverseEvent(const Address: TCivicAddress);
begin
ListBoxItemSubAdminArea.ItemData.Text := Format('子行政区: %s', [Address.SubAdminArea]);
ListBoxItemAdminArea.ItemData.Text := Format('省\州: %s', [Address.AdminArea]);
ListBoxItemCountryCode.ItemData.Text := Format('国家编码: %s', [Address.CountryCode]);
ListBoxItemCountryName.ItemData.Text := Format('国家名称: %s', [Address.CountryName]);
ListBoxItemFeatureName.ItemData.Text := Format('详细地址: %s', [Address.FeatureName]);
ListBoxItemSubLocality.ItemData.Text := Format('区\县: %s', [Address.SubLocality]);
ListBoxItemLocality.ItemData.Text := Format('城市: %s', [Address.Locality]);
ListBoxItemPostalCode.ItemData.Text := Format('邮政编码: %s', [Address.PostalCode]);
ListBoxItemSubThoroughfare.ItemData.Text := Format('子街道: %s', [Address.SubThoroughfare]);
ListBoxItemThoroughfare.ItemData.Text := Format('街道: %s', [Address.Thoroughfare]);
end;
procedure Tfmap.Unitialize;
begin
inherited;
FGeocoder.DisposeOf;
end;
end.
GOOGLE定位的更多相关文章
- Android网络定位服务定制简述
Android 添加高德或百度网络定位服务 Android的网络定位服务以第三方的APK方式提供服务,由于在国内Android原生自带的com.google.android.gms服务几乎处于不可用状 ...
- android 三种定位方式
http://www.cnblogs.com/oudi/archive/2012/03/22/2411509.html 最近在看android关于定位的方式,查了很多资料,也做了相关实验,在手机上做了 ...
- wifi定位原理
wifi定位和手机基站定位类别似,两者都需要收集wifi位置信息接入点. 其实WIFI奇妙,它靠的是侦測附近周围全部的无线网路基地台 (WiFi Access Point) 的 MAC Address ...
- [置顶] android LBS的研究与分享(附PPT)
早上起床后想想以前的工作有什么可以分享的... 两年前,前公司在做一个陌生人交友的社交软件(比陌陌还早),需要研究LBS的相关工作(这里面主要研究的是Google定位)... 一.简要调研结果 很多 ...
- 【转】百度API获取城市名地名(附源码)
在做一个软件时,用到了定位功能.网上有很多关于google 的GPS定位,但网上关于google定位都没有用, 搜索下原因:(这里建议大家在中国就尽量不使用系统自带的定位) 因为Google的服务器不 ...
- selenium java maven自动化测试环境搭建
版本说明: JDK 版本:1.8.0_112: Eclipse IDE: 4.6.1: Maven 版本:apache-maven-3.3.9: Selenium 版本: 3.0.1: Firefox ...
- [入门阅读]怎样在android中解析JSON
JSON入门介绍:http://kirin.javaeye.com/blog/616226 也参考了此篇:http://blog.163.com/fushaolin@126/blog/static/1 ...
- IOS中GPS定位偏移纠正(适用于Google地图)
在这个神奇的国度里,我们总得学习一些有中国特色的东东,例如“火星坐标”.也许有人还不知道这是什么玩意,我就简要介绍一下吧. 如果你有带GPS模块的智能手机,打开定位功能,然后访问Google ...
- Android开发之位置定位详解与实例解析(GPS定位、Google网络定位,BaiduLBS(SDK)定位)
在android开发中地图和定位是很多软件不可或缺的内容,这些特色功能也给人们带来了很多方便.定位一般分为三种发方案:即GPS定位.Google网络定位以及基站定位 最简单的手机定位方式当然是通过GP ...
随机推荐
- 查找内容grep命令
标准unix/linux下的grep通过以下参数控制上下文 grep -C 5 foo file 显示file文件中匹配foo字串那行以及上下5行 grep -B 5 foo file 显示foo及前 ...
- mknod命令
mknod - make block or character special filesmknod [OPTION]... NAME TYPE [MAJOR MINOR] option 有用的 ...
- scrapy使用PhantomJS和selenium爬取数据
1.phantomjs 安装 下载:http://phantomjs.org/download.html 解压: tar -jxvf phantomjs--linux-x86_64.tar.bz2 重 ...
- hdu 4678
HDU 4768: Flyer 题意: 有N个社团,每个社团三个属性A,B,C,表示会向编号A+k*C的同学发传单(k=0,1,2... && A+k*C <= B).题目保证 ...
- oracle相关命令收集-张
orcle相关命令收集 1,用管理员登陆 /as sysdba:2, 更改用户密码 alter user name identified by password: alter user exptest ...
- 初窥Linux 之 最常用20条命令
玩过Linux的人都会知道,Linux中的命令的确是非常多,但是玩过Linux的人也从来不会因为Linux的命令如此之多而烦恼,因为我们只需要掌握我们最常用的命令就可以了.当然你也可以在使用时去找一下 ...
- 字典dict常用方法
字典是列表中常用的方法,我们经常处理字典,字典嵌套,很多复杂的操作都来自于基础,只是改变了样式而已,本质是不变的.下面来看看字典中常用的功能都有那些: 1.clear(self) def cl ...
- 四 Python基础
Python是一种计算机编程语言.计算机编程语言和我们日常使用的自然语言有所不同,最大的区别就是,自然语言在不同的语境下有不同的理解,而计算机要根据编程语言执行任务,就必须保证编程语言写出的程序决不能 ...
- 编译PHP并与Ngnix整合
nginx本身不能处理PHP,它只是个web服务器,当接收到请求后,如果是php请求,则发给php解释器处理,并把结果返回给客户端. nginx一般是把请求发fastcgi管理进程处理,fascgi管 ...
- centos 7 安装python3.5
1.安装编译环境 yum groupinstall 'Development Tools' yum install zlib-devel bzip2-devel openssl-devel ncure ...