通过路径:http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
可以获取到这样的结果:
{ "results" : [ { "address_components" : [ { "long_name" : "1600", "short_name" : "1600", "types" : [ "street_number" ] }, { "long_name" : "Amphitheatre Parkway", "short_name" : "Amphitheatre Pkwy", "types" : [ "route" ] }, { "long_name" : "山景城", "short_name" : "山景城", "types" : [ "locality", "political" ] }, { "long_name" : "圣塔克拉拉县", "short_name" : "圣塔克拉拉县", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "加利福尼亚州", "short_name" : "CA", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "美国", "short_name" : "US", "types" : [ "country", "political" ] }, { "long_name" : "94043", "short_name" : "94043", "types" : [ "postal_code" ] } ], "formatted_address" : "1600 Amphitheatre Parkway, 山景城加利福尼亚州 94043美国", "geometry" : { "location" : { "lat" : 37.4219998, "lng" : -122.0839596 }, "location_type" : "ROOFTOP", "viewport" : { "northeast" : { "lat" : 37.4233487802915, "lng" : -122.0826106197085 }, "southwest" : { "lat" : 37.4206508197085, "lng" : -122.0853085802915 } } }, "types" : [ "street_address" ] } ], "status" : "OK" }这是一些纯文字数据,可以用PHP的file_get_contents函数先获取他们。
然后用json_decode方法进行json数组解析成PHP 数组。
当传递参数给一个URL作为file_get_contents的参数的时候,
可以用http_build_query把已知数组转换成正确格式的URL
public function get_coordination_by_address($address=''){ //get Coordination from address if (!$address) { $address = '1600 Amphitheatre Parkway, Mountain View, CA'; } $sensor = 'false'; //$ch = curl_init('http://maps.google.com/maps/api/geocode/json'); $data = array('address' => $address, 'sensor'=>$sensor); $content = json_decode(file_get_contents('http://maps.google.com/maps/api/geocode/json?'.http_build_query($data))); $location = $content->results[0]->geometry->location; return $location; } public function get_postcode_by_address($address=''){ //get Coordination from address if (!$address) { $address = '1600 Amphitheatre Parkway, Mountain View, CA'; } $sensor = 'false'; //$ch = curl_init('http://maps.google.com/maps/api/geocode/json'); $data = array('address' => $address, 'sensor'=>$sensor); $content = json_decode(file_get_contents('http://maps.google.com/maps/api/geocode/json?'.http_build_query($data))); foreach ($content->results[0]->address_components as $key=>$v) { foreach ($v->types as $keyi=>$vi) { if ($vi == 'postal_code') { return $v->long_name; } } } } public function get_postcode_coordination_by_address($address='') { if (!$address) { $address = '1600 Amphitheatre Parkway, Mountain View, CA'; } $sensor = 'false'; //$ch = curl_init('http://maps.google.com/maps/api/geocode/json'); $data = array('address' => $address, 'sensor'=>$sensor); $content = json_decode(file_get_contents('http://maps.google.com/maps/api/geocode/json?'.http_build_query($data))); $location = $content->results[0]->geometry->location; $result = array(); $result['location'] = $location; foreach ($content->results[0]->address_components as $key=>$v) { foreach ($v->types as $keyi=>$vi) { if ($vi == 'postal_code') { $result['postcode'] = $v->long_name; var_dump($result); return $result; } } } var_dump($result); return $result; }
相关推荐
本文档标题为《使用深度学习和大规模数据收集实现机器人手眼协调的抓取》,描述了谷歌研究团队如何利用深度学习技术实现机器人通过单目摄像头图像进行自适应抓取物体的方法。文章指出,这一研究成果对于机器人行业的...
ch18-Distributed Coordination.ppt
提供的“EN 50124-1:2017 Railway applications - Insulation coordination - Part 1:Basic requirements - Clearances and creepage distances for all electrical and electronic equipment - 完整英文版(54页...
Comparison of the relationship between two measures of visual-motor coordination and academic achievement Psychology in !he Schools Volume 19. October. 1982 COMPARISON OF THE RELATIONSHIP BETWEEN...
标题“EN 50124-2:2017 Railway applications - Insulation coordination -”涉及的是铁路应用中的绝缘协调标准,这是电气系统设计和实施的重要方面,特别是在铁路行业中。绝缘协调确保了设备和系统的安全性,防止...
DEN0022E-Power-State-Coordination-Interface-BETA 本文档是 Arm 公司发布的关于 Arm Power State Coordination Interface 平台设计文档的 Beta 版本,旨在从 Arm 的合作伙伴和内部获得反馈以便进行修改。该文档...
### WS-Coordination 规范概述 #### 一、引言 《WS-Coordination》规范是一份关于如何在分布式环境中实现协调管理的标准文档。该规范由微软(Microsoft)、IBM、IONA Technologies、BEA Systems 和 Hitachi 等公司...
D2EHPA-HCl-LA络合萃取分离镨钕的工艺,尹少华,吴文远,针对D2EHPA -HCl 体系中镨钕分离系数较低的问题,研究了含有乳酸的D2EHPA -HCl体系中的料液酸度、乳酸浓度对镨钕分配比,分离系数和萃取�
### 知识点总结 #### 一、论文背景与研究目的 本文主要研究了线性多智能体系统在动态交互拓扑下的领导者跟随框架中的协调问题。研究关注于多个具有通用线性系统动力学特性的智能体,在切换拓扑结构下的领导者跟随...
### ZooKeeper:无等待协调机制在互联网规模系统中的应用 #### 摘要与背景介绍 本文主要介绍了ZooKeeper,一种为分布式应用程序提供进程间协调的服务。由于ZooKeeper作为关键基础设施的一部分,其目标是提供一个...
中文-英文对照文档:【***-javadoc-API文档-中文(简体)-英语-对照版.zip】 jar包下载地址:【***.jar下载地址(官方地址+国内镜像地址).txt】 Maven依赖:【***.jar Maven依赖信息(可用于项目pom.xml).txt】 ...
### WS-Coordination200411:深入解析与理解 #### 一、概述 《WS-Coordination200411》是2004年11月发布的一项关于Web服务协调的技术规范。该文档由来自微软、IBM和BEA Systems等公司的多位专家共同撰写完成。此...
Localized charge polarization by less-coordination: Rh adatoms, step edges, and added rows,孙长庆,,The revolutionary impact of atomic under-coordination is indeed fascinating, which discriminates ...
Relationship between the expressive one-word picture vocabulary test and measures of intelligence, receptive vocabulary, and visual-motor coordination in borderline and mildly retarded children ...
基于TORCS仿真平台的关于车队协同控制的实验研究,徐志翔,江洁美,本论文是基于TORCS (The Open Racing Vehicle Simulator) 仿真平台的车队协同控实验研究。首先我们根据研究需求搭建了一个实验平台。...
Synthesis, Structure, and Clathration Ability of the Microporous Three-Dimensional Coordination Polymer [infin]3[[lcub]CuCN(4,4[prime]-bpy)[rcub][hairsp]·[hairsp]2(4,4[prime]-bpy)] ARTIKEL ...
基于混合配体构筑的的具有链状或T形配位环境的银配合物,张亚男,王尧宇,两种新颖的一维配合物{[Ag3(Hbptc)(bpa)2]•H2O}n(1)[Ag2(H2bptc)(bpp)2]n(2) (H4bptc= 3,3′,4,4′-benzophenonetetracarboxylic acid, bpa...
Polymer-immobilized catalysis has many ... We prepared three novel chiral 1,1-bi-2-naphthol-Ti coordination polymers with properly designed ligands and Ti(OiPr)4 under mild conditions. The prepared polym
IEC 60664-1-2020 Insulation coordination of LV system.pdf