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定位的更多相关文章

  1. Android网络定位服务定制简述

    Android 添加高德或百度网络定位服务 Android的网络定位服务以第三方的APK方式提供服务,由于在国内Android原生自带的com.google.android.gms服务几乎处于不可用状 ...

  2. android 三种定位方式

    http://www.cnblogs.com/oudi/archive/2012/03/22/2411509.html 最近在看android关于定位的方式,查了很多资料,也做了相关实验,在手机上做了 ...

  3. wifi定位原理

    wifi定位和手机基站定位类别似,两者都需要收集wifi位置信息接入点. 其实WIFI奇妙,它靠的是侦測附近周围全部的无线网路基地台 (WiFi Access Point) 的 MAC Address ...

  4. [置顶] android LBS的研究与分享(附PPT)

    早上起床后想想以前的工作有什么可以分享的... 两年前,前公司在做一个陌生人交友的社交软件(比陌陌还早),需要研究LBS的相关工作(这里面主要研究的是Google定位)... 一.简要调研结果 很多 ...

  5. 【转】百度API获取城市名地名(附源码)

    在做一个软件时,用到了定位功能.网上有很多关于google 的GPS定位,但网上关于google定位都没有用, 搜索下原因:(这里建议大家在中国就尽量不使用系统自带的定位) 因为Google的服务器不 ...

  6. selenium java maven自动化测试环境搭建

    版本说明: JDK 版本:1.8.0_112: Eclipse IDE: 4.6.1: Maven 版本:apache-maven-3.3.9: Selenium 版本: 3.0.1: Firefox ...

  7. [入门阅读]怎样在android中解析JSON

    JSON入门介绍:http://kirin.javaeye.com/blog/616226 也参考了此篇:http://blog.163.com/fushaolin@126/blog/static/1 ...

  8. IOS中GPS定位偏移纠正(适用于Google地图)

    在这个神奇的国度里,我们总得学习一些有中国特色的东东,例如“火星坐标”.也许有人还不知道这是什么玩意,我就简要介绍一下吧.      如果你有带GPS模块的智能手机,打开定位功能,然后访问Google ...

  9. Android开发之位置定位详解与实例解析(GPS定位、Google网络定位,BaiduLBS(SDK)定位)

    在android开发中地图和定位是很多软件不可或缺的内容,这些特色功能也给人们带来了很多方便.定位一般分为三种发方案:即GPS定位.Google网络定位以及基站定位 最简单的手机定位方式当然是通过GP ...

随机推荐

  1. sql函数应用例子

    select p.province, data.existUserCount, data.addUserCount, data.cancelUserCount, data.threedayCancel ...

  2. POJ 2752 Seek the Name, Seek the Fame(KMP求公共前后缀)

    题目链接:http://poj.org/problem?id=2752 题目大意:给你一串字符串s找到所有的公共前后缀,即既是前缀又是后缀的子串. 解题思路: 如图所示 假设字符串pi与jq为符合条件 ...

  3. 使用Guava retryer优雅的实现接口重试机制

    转载自: 使用Guava retrying优雅的实现接口重调机制 Guava retrying:基于 guava 的重试组件 实际项目中,为了考虑网络抖动,加锁并发冲突等场景,我们经常需要对异常操作进 ...

  4. 字典dict常用方法

    字典是列表中常用的方法,我们经常处理字典,字典嵌套,很多复杂的操作都来自于基础,只是改变了样式而已,本质是不变的.下面来看看字典中常用的功能都有那些:     1.clear(self) def cl ...

  5. Robot FrameWork测试案例

    Robot FrameWork是一个自动测试框架,可到官网查看详细介绍. 安装 Robot Framework 本文中的Robot framework安装在Win7 (32 bit) 平台上. 接下来 ...

  6. 通过 JS 实现错误页面在指定的时间跳到主页

    通过 JS 实现错误页面在指定的时间跳到主页 <!DOCTYPE html> <html> <head> <title>浏览器对象</title& ...

  7. poj3414 Pots(BFS)

    题目链接 http://poj.org/problem?id=3414 题意 有两个杯子,容量分别为A升,B升,可以向杯子里倒满水,将杯子里的水倒空,将一个杯子里的水倒到另一个杯子里,求怎样倒才能使其 ...

  8. cordova编译crosswalk-webview插件报错的处理办法

    一直用得好好的.今天编译cordova失败了.报错如下: :processArmv7DebugManifest :processArmv7DebugResourcesERROR: In FontFam ...

  9. Apache+PHP环境搭建

    第一次搭建Apache+PHP+MySQL的开发环境,发现Apache与PHP的整合非常麻烦,先整理记录如下: 一.安装Apache 1.登录http://httpd.apache.org/downl ...

  10. flutter android沉浸式状态栏

    import 'package:flutter/services.dart'; import 'dart:io'; class _MyAppState extends State<MyApp&g ...