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 ...
随机推荐
- 让R与Python共舞
转载:http://ices01.sinaapp.com/?p=129 R(又称R语言)是一款开源的跨平台的数值统计和数值图形化展现 工具.通俗点说,R是用来做统计和画图的.R拥有自己的脚本 ...
- HDU 3001 Travelling(状态压缩DP+三进制)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3001 题目大意:有n个城市,m条路,每条路都有一定的花费,可以从任意城市出发,每个城市不能经过两次以上 ...
- beego学习笔记(4):开发文档阅读(4)
beego.Run() 这个运行后, 1)解析配置文件,也就是conf目录下的. 2)判断是否开启session,并作相应的工作 3)执行用户的hookfunc. 4)是否编译模板 5)是否开启文档功 ...
- Linux下突然不识别无线网卡
昨天还能用wifi的Linux,今天进去后发现没有了wifi的图标,ifconfig也不显示无线网卡.怎么办? 出现这种情况,肯定是上次关机之前做了一些操作导致的.我遇到过的一个情况是:Fedora2 ...
- Hive2.x 版本的安装及配置 以及要注意的事项
博主学习Hadoop学习到Hive,一开始跟着资料去安装Hive 1.x一点问题也没有,方便快捷啊,但是看了一下官方文档,上面好像说Hive 2.0修复了很多bug,那么我想,我还是用Hive2.0好 ...
- 【caffe-Windows】微软官方caffe之matlab接口配置,以及安装caffe的注意事项
1.在此之前,记录一下之前的错误,在参考博客[caffe-Windows]caffe+VS2013+Windows+GPU配置+cifar使用进行caffe的安装时,其中的一些步骤可以不做,具体见下图 ...
- Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition) D - Travel Card
D - Travel Card 思路:dp,类似于单调队列优化. 其实可以写的更简单... #include<bits/stdc++.h> #define LL long long #de ...
- 七 oracle 表查询二
1.使用逻辑操作符号问题:查询工资高于500或者是岗位为manager的雇员,同时还要满足他们的姓名首字母为大写的J?select * from emp where (sal > 500 or ...
- ssh自动登录(免密)
创建公钥 1 ssh-keygen -t rsa 无视它出来的任何提示,欢快的一路回车到底吧~ 把公钥复制到远程主机 把公钥id_rsa.pub复制到远程机器的 /home/username/.ssh ...
- SCU 4443 Range Query
二分图最大匹配,枚举. 可以计算出每一个位置可以放哪些数字,每个数字可以放在哪些位置,这样就可以建二分图了. 如果二分图最大匹配不到$n$,则无解.否则构造字典序最小的解,可以枚举每一位放什么数字,然 ...