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 ...
随机推荐
- HDU 1079 Calendar Game(博弈找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1079 题目大意:给你一个日期(包含年月日),这里我表示成year,month,day,两人轮流操作,每 ...
- 三、ansible简要使用
1.ansible服务器生成公钥与私钥 ssh-keygen -t rsa 2.拷贝ansible公钥到客户机上 ssh-copy-id -i root@192.168.1.1 3.添加主机到ansi ...
- laravel5.1--数据库操作
1 配置信息 1.1配置目录: config/database.php 1.2配置多个数据库 //默认的数据库 'mysql' => [ 'driver' => 'mysql', 'hos ...
- IEnumerable的几个简单用法
咋一看到IEnumerable这个接口,我们可能会觉得很神奇,在一般的编程时,基本上我们是想不到去用它的,可是,俗话说得好,存在便是道理,那么,它对我们来说,能够带来哪些奇妙的事情呢? 要想弄懂它,我 ...
- T1,T2,T3 三个线程顺序执行
T1,T2,T3 三个线程顺序执行 现在有 T1.T2.T3 三个线程,你怎样保证 T2 在 T1 执行完后执行,T3 在 T2 执行完后执行?(T1->T2->T3) 这个线程问题通常会 ...
- Echarts怎么用后台传来的json数据
Echarts怎么用后台传来的json数据 <!DOCTYPE html> <html> <head> <meta http-equiv="Cont ...
- DP 题集 1
关于 DP 的一些题目 参考资料 [Tutorial] Non-trivial DP Tricks and Techniques DP Rain and Umbrellas Mr. Kitayuta, ...
- springMVC返回modelmap跟new hashMap的区别
今天遇到了个坑. 在springboot中 平时写接口,newHashMap,@ResponseBody 返回json对象,没什么问题 @RequestMapping("url") ...
- Typora ---一款简洁的Markdown编辑器
Typora BB in front 如果你是一个佛(lan)系(duo),内心文艺的程序员,并且你对其他Markdown编辑器的使用效果感觉不是很好的话,可以来了解一下该软件Typora. What ...
- oracle 查询重复纪录
DELETE FROM xx where aa in(select aa from xx group by aa having count(aa) >1) and rowid in (selec ...