2024-09-29 17:20:01 发布
网友
我正在做一个项目,其中我在印度的主要城市有大约100000个地址(它是数据库中的一个表)。我想知道是否有可能获得到最近地标(商场、医院和机场等)的距离。理想情况下,我希望这些距离合并到父表中。我们有Java和Php程序员来完成它,一旦我们知道如何去做。任何建议都会有很大的帮助。谢谢您。在
(我可能会在这里陈述显而易见的情况,但如果是这样,请忽略这些要点,继续往下读。)
(“当乌鸦在飞”和限制搜索/处理负载)
确定两点之间的距离可以在SQL数据库/SELECT语句中完成。 参考号:MySQL Great Circle (Haversine Formula)
SELECT acos( cos(radians( $latitude0 )) * cos(radians( $latitude1 )) * cos(radians( $longitude0 ) - radians( $longitude1 )) + sin(radians( $latitude0 )) * sin(radians( $latitude1 )) )*6371 AS greatCircleDistanceKMs FROM yourTable
如果用于比较的点的纬度/长度可能会更改(即用户的地址等),或者在设置了用于比较的点(您办公室的位置等)的情况下,可以动态地使用它来更新多个文件
如果要动态使用它,那么还建议限制运行此函数的行集。在
实际上,这将在searchLatitude/searchLongitude点周围创建一个1度的框,并减少所需的计算数量。在
Google Directions API提供了使用一个简单的HTTP请求来获得两点之间实际行驶距离的功能。在例如,URL为“Chhatrapati Shivaji Int'l Airport”到“Taj Mahal Palace&Tower”:http://maps.google.com/maps/api/directions/xml?origin=Chhatrapati+Shivaji+International+Airport&destination=Taj+Mahal+Palace+%26+Tower,+Mahakavi+Bhushan+Road,+Apollo+Bandar+Mumbai&sensor=false它将返回一个XML响应:<?xml version="1.0" encoding="UTF-8"?> <DirectionsResponse> <status>OK</status> <route> <summary>Western Express Hwy/NH 8</summary> <leg> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0966100</lat> <lng>72.8656200</lng> </start_location> <end_location> <lat>19.1091100</lat> <lng>72.8539000</lng> </end_location> <polyline> <points>yxpsBcqv{LuAd@aEf@eBl@a^lQqDpBiS`PgAnAeArCoA`JiAbK</points> <levels>B???@?@???B</levels> </polyline> <duration> <value>112</value> <text>2 mins</text> </duration> <html_instructions>Head <b>north</b> on <b>Sahar Rd</b> toward <b>I A Project Rd</b> <div style="font-size:0.9em">Pass by Priyadeep (on the left in 1.9&nbsp;km)</div></html_instructions> <distance> <value>1978</value> <text>2.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.1091100</lat> <lng>72.8539000</lng> </start_location> <end_location> <lat>19.1061700</lat> <lng>72.8538800</lng> </end_location> <polyline> <points>}fssB{gt{LpHr@zCO|B_@</points> <levels>B??B</levels> </polyline> <duration> <value>52</value> <text>1 min</text> </duration> <html_instructions>Turn <b>left</b> toward <b>Western Express Hwy/NH 8</b></html_instructions> <distance> <value>332</value> <text>0.3 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.1061700</lat> <lng>72.8538800</lng> </start_location> <end_location> <lat>19.0991500</lat> <lng>72.8540500</lng> </end_location> <polyline> <points>qtrsBwgt{L|BAbTqCfCQrBJ|IvB</points> <levels>B??@?B</levels> </polyline> <duration> <value>82</value> <text>1 min</text> </duration> <html_instructions>Continue straight onto <b>Western Express Hwy/NH 8</b> <div style="font-size:0.9em">Pass by Giriraj Ceramic Products (on the left in 750&nbsp;m)</div></html_instructions> <distance> <value>799</value> <text>0.8 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0991500</lat> <lng>72.8540500</lng> </start_location> <end_location> <lat>19.0931000</lat> <lng>72.8507700</lng> </end_location> <polyline> <points>uhqsByht{LdMlDxG|AdC~@jBdAzBjB~@hAj@fA</points> <levels>B??@???B</levels> </polyline> <duration> <value>35</value> <text>1 min</text> </duration> <html_instructions>Slight <b>right</b> toward <b>Western Express Hwy/NH 8</b></html_instructions> <distance> <value>772</value> <text>0.8 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0931000</lat> <lng>72.8507700</lng> </start_location> <end_location> <lat>19.0507200</lat> <lng>72.8404700</lng> </end_location> <polyline> <points>{bpsBits{LjAfCr@rCbCdS`@vB\dAhAdBvBhB`Af@`Ch@bBHnAExCk@nAm@l@e@nGuF~Ay@fDaAlXcDxx@f@~UBbPPvVF|HLhXAdD\~Bn@lCxA|AbBjAdCz@nDfGfS</points> <levels>B????@???@??@????@@?????@???@??B</levels> </polyline> <duration> <value>252</value> <text>4 mins</text> </duration> <html_instructions>Continue straight onto <b>Western Express Hwy/NH 8</b> <div style="font-size:0.9em">Pass by St Joseph's (on the left in 3.5&nbsp;km)</div></html_instructions> <distance> <value>5666</value> <text>5.7 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0507200</lat> <lng>72.8404700</lng> </start_location> <end_location> <lat>19.0429200</lat> <lng>72.8401400</lng> </end_location> <polyline> <points>_zgsB}sq{LfBjBj@ZxB^h@XZfAN~Ab@b@l@VnJEn@MrBg@lQgH</points> <levels>B???????@?@?B</levels> </polyline> <duration> <value>54</value> <text>1 min</text> </duration> <html_instructions>Exit onto <b>S V Rd</b> <div style="font-size:0.9em">Pass by Saraswati Dattatray Electricals &amp; Co., (SDEC) (on the left in 500&nbsp;m)</div></html_instructions> <distance> <value>1019</value> <text>1.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0429200</lat> <lng>72.8401400</lng> </start_location> <end_location> <lat>19.0332800</lat> <lng>72.8422800</lng> </end_location> <polyline> <points>gifsB{qq{LXAxCcAfLsEzDiAxDs@jC[lFQtIDdFR</points> <levels>B????@???B</levels> </polyline> <duration> <value>77</value> <text>1 min</text> </duration> <html_instructions>Continue onto <b>A S Gaya Marg/Lady Jamshedji Rd</b> <div style="font-size:0.9em">Pass by Dawood Khan (on the left)</div></html_instructions> <distance> <value>1117</value> <text>1.1 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0332800</lat> <lng>72.8422800</lng> </start_location> <end_location> <lat>19.0249800</lat> <lng>72.8406100</lng> </end_location> <polyline> <points>_mdsBg_r{LtI^lb@pFbBXrA`@</points> <levels>B???B</levels> </polyline> <duration> <value>62</value> <text>1 min</text> </duration> <html_instructions>At Emerald Surgicare (P) Ltd, continue onto <b>Lady Jamshedjee Rd</b> <div style="font-size:0.9em">Pass by Petrol Pump (on the left)</div></html_instructions> <distance> <value>941</value> <text>0.9 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0249800</lat> <lng>72.8406100</lng> </start_location> <end_location> <lat>19.0217700</lat> <lng>72.8424900</lng> </end_location> <polyline> <points>cybsBytq{LvEeB~@gAlB}CXSx@SfDC</points> <levels>B?????B</levels> </polyline> <duration> <value>41</value> <text>1 min</text> </duration> <html_instructions>Turn <b>left</b> at Gadkari Chowk onto <b>NC Kelkar Rd</b> <div style="font-size:0.9em">Pass by Dhyan Securities Pvt Ltd (on the right)</div></html_instructions> <distance> <value>432</value> <text>0.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0217700</lat> <lng>72.8424900</lng> </start_location> <end_location> <lat>19.0179000</lat> <lng>72.8475600</lng> </end_location> <polyline> <points>aebsBq`r{L^c@tAm@XB^QpHeNbHoL</points> <levels>B?????B</levels> </polyline> <duration> <value>63</value> <text>1 min</text> </duration> <html_instructions>At the roundabout, take the <b>1st</b> exit onto <b>Tilak Bridge</b> <div style="font-size:0.9em">Pass by Vanmali Chk (on the right)</div></html_instructions> <distance> <value>702</value> <text>0.7 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0179000</lat> <lng>72.8475600</lng> </start_location> <end_location> <lat>19.0131500</lat> <lng>72.8550800</lng> </end_location> <polyline> <points>{lasBg`s{LUa@Fs@RSv@DvZ{j@</points> <levels>B????B</levels> </polyline> <duration> <value>160</value> <text>3 mins</text> </duration> <html_instructions>At the roundabout, take the <b>2nd</b> exit onto <b>Tilak Rd</b> <div style="font-size:0.9em">Pass by Sargam Florists (on the left)</div></html_instructions> <distance> <value>987</value> <text>1.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0131500</lat> <lng>72.8550800</lng> </start_location> <end_location> <lat>18.9933600</lat> <lng>72.8515000</lng> </end_location> <polyline> <points>eo`sBgot{LzB`AdDr@jMv@rHVhRN`Zj@vMjB~E^zEt@lIbCdDbC</points> <levels>B??@??@??@?B</levels> </polyline> <duration> <value>233</value> <text>4 mins</text> </duration> <html_instructions>Turn <b>right</b> at Shobha Hospital onto <b>Rafi Ahmed Kidwai Marg</b> <div style="font-size:0.9em">Pass by Sukkur Bhawan (on the left)</div></html_instructions> <distance> <value>2264</value> <text>2.3 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9933600</lat> <lng>72.8515000</lng> </start_location> <end_location> <lat>18.9675800</lat> <lng>72.8448800</lng> </end_location> <polyline> <points>os|rB{xs{L~AbBbMtOtYjb@dAn@pCr@`ZsEp[aEvJ}AzPwBzBa@nBI`E@zFz@~Ad@^T</points> <levels>B??@?@????@????B</levels> </polyline> <duration> <value>203</value> <text>3 mins</text> </duration> <html_instructions>Continue onto <b>Barrister Nath Pai Marg</b> <div style="font-size:0.9em">Pass by Everest Marine Ply - J. Himatlal &amp; Co. (on the left in 1.6&nbsp;km)</div></html_instructions> <distance> <value>3360</value> <text>3.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9675800</lat> <lng>72.8448800</lng> </start_location> <end_location> <lat>18.9382900</lat> <lng>72.8379900</lng> </end_location> <polyline> <points>krwrBoor{LxCf@rBh@`Bf@nCpAnAFpAEfBSr@Y^?dk@nIdm@rJbEb@rz@xM</points> <levels>B????????????B</levels> </polyline> <duration> <value>246</value> <text>4 mins</text> </duration> <html_instructions>At Our Lady of the Rosary Church, continue onto <b>P D Mello Rd</b> <div style="font-size:0.9em">Pass by Petrol Pump (on the left in 1.9&nbsp;km)</div></html_instructions> <distance> <value>3356</value> <text>3.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9382900</lat> <lng>72.8379900</lng> </start_location> <end_location> <lat>18.9344900</lat> <lng>72.8371000</lng> </end_location> <polyline> <points>i{qrBmdq{LjIlAvI|ArAD</points> <levels>B??B</levels> </polyline> <duration> <value>56</value> <text>1 min</text> </duration> <html_instructions>Continue onto <b>S Bhagat Singh Marg</b> <div style="font-size:0.9em">Pass by SIB (on the left)</div></html_instructions> <distance> <value>433</value> <text>0.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9344900</lat> <lng>72.8371000</lng> </start_location> <end_location> <lat>18.9321900</lat> <lng>72.8357900</lng> </end_location> <polyline> <points>qcqrB{~p{Ll@?bDf@^RtC`DbAf@</points> <levels>B????B</levels> </polyline> <duration> <value>32</value> <text>1 min</text> </duration> <html_instructions>Continue onto <b>Mint Rd</b> <div style="font-size:0.9em">Pass by Mint Police Station (on the left)</div></html_instructions> <distance> <value>302</value> <text>0.3 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9321900</lat> <lng>72.8357900</lng> </start_location> <end_location> <lat>18.9243200</lat> <lng>72.8320700</lng> </end_location> <polyline> <points>euprBuvp{LdIj@XNhAxArA`ApHfCtDX`C@lA\r@n@fAvCf@f@j@LNR?XnC`@</points> <levels>B???????@??????B</levels> </polyline> <duration> <value>97</value> <text>2 mins</text> </duration> <html_instructions>Continue onto <b>Shahid Bhagat Singh Rd/Shahid Bhagat SIngh Marg</b> <div style="font-size:0.9em">Go through 1 roundabout</div><div style="font-size:0.9em">Pass by Town Hall (on the left)</div></html_instructions> <distance> <value>1022</value> <text>1.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9243200</lat> <lng>72.8320700</lng> </start_location> <end_location> <lat>18.9230100</lat> <lng>72.8334800</lng> </end_location> <polyline> <points>_dorBm_p{LvFmERa@Ei@</points> <levels>B??B</levels> </polyline> <duration> <value>30</value> <text>1 min</text> </duration> <html_instructions>Turn <b>left</b> at CBI onto <b>Mahakavi Bhushan Rd/Rajkavi Ghushan Marg</b> <div style="font-size:0.9em">Pass by Kalajot Hospital (on the right)</div></html_instructions> <distance> <value>220</value> <text>0.2 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9230100</lat> <lng>72.8334800</lng> </start_location> <end_location> <lat>18.9219500</lat> <lng>72.8335500</lng> </end_location> <polyline> <points>y{nrBghp{LdA_@t@KvA\</points> <levels>B??B</levels> </polyline> <duration> <value>46</value> <text>1 min</text> </duration> <html_instructions>Turn <b>right</b> at Mumbai Hotels Booking onto <b>Appolo Bunder/P J Ramchandani Marg</b> <div style="font-size:0.9em">Destination will be on the right</div></html_instructions> <distance> <value>124</value> <text>0.1 km</text> </distance> </step> <duration> <value>1933</value> <text>32 mins</text> </duration> <distance> <value>25826</value> <text>25.8 km</text> </distance> <start_location> <lat>19.0966100</lat> <lng>72.8656200</lng> </start_location> <end_location> <lat>18.9219500</lat> <lng>72.8335500</lng> </end_location> <start_address>Chhatrapati Shivaji International Airport, Vile Parle East, Mumbai, Maharashtra, India</start_address> <end_address>Taj Mahal Palace & Tower, P J Ramchandani Marg, Apollo Bandar, Mumbai, Maharashtra 400001, India</end_address> </leg> <overview_polyline> <points>yxpsBcqv{LuAd@aEf@eBl@a^lQqDpBiS`PgAnAeArCoA`JiAbKpHr@nAChEk@|BAbTqCfCQl@@dAHhE`AbJhCxQvEfDdBzBjB~@hAvBnEr@rCbCdS`@vBh@xA|@pAvBhB`Af@`Ch@bBHnAExCk@nAm@l@e@nGuF~Ay@fDaAlXcDxx@f@~UBbPPvVF|HLhWClDX|Bh@fDdBz@x@l@z@~@rBz@nDfGfSfBjBj@ZxB^h@XZfAN~Ab@b@l@VnJErAYnA[vEgBPObJoDXAxCcAfLsEzDiAdB]vGw@jIM~DFzPr@lb@pFbBXrA`@vEeB~@gAlB}CXSx@SfDC^c@tAm@XB^QpHeNbHoLUa@Fs@RSv@DvZ{j@zB`AdDr@jMv@rHVhRN`Zj@vMjB`DRnFt@vJnChCfBjAhArNjQtYjb@dAn@pCr@`ZsEp[aEvJ}AzPwBzBa@nBI`E@zFz@~Ad@^TxCf@rBh@`Bf@nCpAnAFpAEfBSr@Y^?dk@nIdm@rJbEb@b\bFnWhEjOxBvI|A`CDbDf@^RtC`DbAf@dIj@XNhAxAzBxAhGnBtDX`C@lA\r@n@fAvCf@f@j@LNR?XnC`@vFmERa@Ei@dA_@t@KvA\</points> <levels>B???@?@???A??????@???@???@???@???A??@????@@?????@???@???@???????@?@?????????@??@??A???@?????@??????A??@??@???@?????@??????@??????@????@????????@??????@???@?????@??????B</levels> </overview_polyline> </route> </DirectionsResponse> 包含整个旅程细节的元素包括:方向响应>;路线>;距离>;值 以基本单位表示的整个旅程的距离方向响应>;路线>;距离>;文本 一段完整旅程的距离,用简单的英语表示方向响应>;路线>;持续时间>;值 整个行程的估计行程时间,以基本单位(秒)为单位方向响应>;路线>;持续时间>;文本 整个旅程的预计旅行时间,用简单的英语形式表示然后可以使用PHP DOMDocument CLASS解析结果并提取这些细节。在注意:从Google Directions API页面“使用Google Directions API的查询限制为每天2500个方向请求。单个方向请求最多可在请求中包含8个中间航路点。谷歌地图卓越理财客户每天最多可查询100000个方向请求,每个请求中最多允许23个航点。“
Google Directions API提供了使用一个简单的HTTP请求来获得两点之间实际行驶距离的功能。在
例如,URL为“Chhatrapati Shivaji Int'l Airport”到“Taj Mahal Palace&Tower”:http://maps.google.com/maps/api/directions/xml?origin=Chhatrapati+Shivaji+International+Airport&destination=Taj+Mahal+Palace+%26+Tower,+Mahakavi+Bhushan+Road,+Apollo+Bandar+Mumbai&sensor=false
它将返回一个XML响应:
<?xml version="1.0" encoding="UTF-8"?> <DirectionsResponse> <status>OK</status> <route> <summary>Western Express Hwy/NH 8</summary> <leg> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0966100</lat> <lng>72.8656200</lng> </start_location> <end_location> <lat>19.1091100</lat> <lng>72.8539000</lng> </end_location> <polyline> <points>yxpsBcqv{LuAd@aEf@eBl@a^lQqDpBiS`PgAnAeArCoA`JiAbK</points> <levels>B???@?@???B</levels> </polyline> <duration> <value>112</value> <text>2 mins</text> </duration> <html_instructions>Head <b>north</b> on <b>Sahar Rd</b> toward <b>I A Project Rd</b> <div style="font-size:0.9em">Pass by Priyadeep (on the left in 1.9&nbsp;km)</div></html_instructions> <distance> <value>1978</value> <text>2.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.1091100</lat> <lng>72.8539000</lng> </start_location> <end_location> <lat>19.1061700</lat> <lng>72.8538800</lng> </end_location> <polyline> <points>}fssB{gt{LpHr@zCO|B_@</points> <levels>B??B</levels> </polyline> <duration> <value>52</value> <text>1 min</text> </duration> <html_instructions>Turn <b>left</b> toward <b>Western Express Hwy/NH 8</b></html_instructions> <distance> <value>332</value> <text>0.3 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.1061700</lat> <lng>72.8538800</lng> </start_location> <end_location> <lat>19.0991500</lat> <lng>72.8540500</lng> </end_location> <polyline> <points>qtrsBwgt{L|BAbTqCfCQrBJ|IvB</points> <levels>B??@?B</levels> </polyline> <duration> <value>82</value> <text>1 min</text> </duration> <html_instructions>Continue straight onto <b>Western Express Hwy/NH 8</b> <div style="font-size:0.9em">Pass by Giriraj Ceramic Products (on the left in 750&nbsp;m)</div></html_instructions> <distance> <value>799</value> <text>0.8 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0991500</lat> <lng>72.8540500</lng> </start_location> <end_location> <lat>19.0931000</lat> <lng>72.8507700</lng> </end_location> <polyline> <points>uhqsByht{LdMlDxG|AdC~@jBdAzBjB~@hAj@fA</points> <levels>B??@???B</levels> </polyline> <duration> <value>35</value> <text>1 min</text> </duration> <html_instructions>Slight <b>right</b> toward <b>Western Express Hwy/NH 8</b></html_instructions> <distance> <value>772</value> <text>0.8 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0931000</lat> <lng>72.8507700</lng> </start_location> <end_location> <lat>19.0507200</lat> <lng>72.8404700</lng> </end_location> <polyline> <points>{bpsBits{LjAfCr@rCbCdS`@vB\dAhAdBvBhB`Af@`Ch@bBHnAExCk@nAm@l@e@nGuF~Ay@fDaAlXcDxx@f@~UBbPPvVF|HLhXAdD\~Bn@lCxA|AbBjAdCz@nDfGfS</points> <levels>B????@???@??@????@@?????@???@??B</levels> </polyline> <duration> <value>252</value> <text>4 mins</text> </duration> <html_instructions>Continue straight onto <b>Western Express Hwy/NH 8</b> <div style="font-size:0.9em">Pass by St Joseph's (on the left in 3.5&nbsp;km)</div></html_instructions> <distance> <value>5666</value> <text>5.7 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0507200</lat> <lng>72.8404700</lng> </start_location> <end_location> <lat>19.0429200</lat> <lng>72.8401400</lng> </end_location> <polyline> <points>_zgsB}sq{LfBjBj@ZxB^h@XZfAN~Ab@b@l@VnJEn@MrBg@lQgH</points> <levels>B???????@?@?B</levels> </polyline> <duration> <value>54</value> <text>1 min</text> </duration> <html_instructions>Exit onto <b>S V Rd</b> <div style="font-size:0.9em">Pass by Saraswati Dattatray Electricals &amp; Co., (SDEC) (on the left in 500&nbsp;m)</div></html_instructions> <distance> <value>1019</value> <text>1.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0429200</lat> <lng>72.8401400</lng> </start_location> <end_location> <lat>19.0332800</lat> <lng>72.8422800</lng> </end_location> <polyline> <points>gifsB{qq{LXAxCcAfLsEzDiAxDs@jC[lFQtIDdFR</points> <levels>B????@???B</levels> </polyline> <duration> <value>77</value> <text>1 min</text> </duration> <html_instructions>Continue onto <b>A S Gaya Marg/Lady Jamshedji Rd</b> <div style="font-size:0.9em">Pass by Dawood Khan (on the left)</div></html_instructions> <distance> <value>1117</value> <text>1.1 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0332800</lat> <lng>72.8422800</lng> </start_location> <end_location> <lat>19.0249800</lat> <lng>72.8406100</lng> </end_location> <polyline> <points>_mdsBg_r{LtI^lb@pFbBXrA`@</points> <levels>B???B</levels> </polyline> <duration> <value>62</value> <text>1 min</text> </duration> <html_instructions>At Emerald Surgicare (P) Ltd, continue onto <b>Lady Jamshedjee Rd</b> <div style="font-size:0.9em">Pass by Petrol Pump (on the left)</div></html_instructions> <distance> <value>941</value> <text>0.9 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0249800</lat> <lng>72.8406100</lng> </start_location> <end_location> <lat>19.0217700</lat> <lng>72.8424900</lng> </end_location> <polyline> <points>cybsBytq{LvEeB~@gAlB}CXSx@SfDC</points> <levels>B?????B</levels> </polyline> <duration> <value>41</value> <text>1 min</text> </duration> <html_instructions>Turn <b>left</b> at Gadkari Chowk onto <b>NC Kelkar Rd</b> <div style="font-size:0.9em">Pass by Dhyan Securities Pvt Ltd (on the right)</div></html_instructions> <distance> <value>432</value> <text>0.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0217700</lat> <lng>72.8424900</lng> </start_location> <end_location> <lat>19.0179000</lat> <lng>72.8475600</lng> </end_location> <polyline> <points>aebsBq`r{L^c@tAm@XB^QpHeNbHoL</points> <levels>B?????B</levels> </polyline> <duration> <value>63</value> <text>1 min</text> </duration> <html_instructions>At the roundabout, take the <b>1st</b> exit onto <b>Tilak Bridge</b> <div style="font-size:0.9em">Pass by Vanmali Chk (on the right)</div></html_instructions> <distance> <value>702</value> <text>0.7 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0179000</lat> <lng>72.8475600</lng> </start_location> <end_location> <lat>19.0131500</lat> <lng>72.8550800</lng> </end_location> <polyline> <points>{lasBg`s{LUa@Fs@RSv@DvZ{j@</points> <levels>B????B</levels> </polyline> <duration> <value>160</value> <text>3 mins</text> </duration> <html_instructions>At the roundabout, take the <b>2nd</b> exit onto <b>Tilak Rd</b> <div style="font-size:0.9em">Pass by Sargam Florists (on the left)</div></html_instructions> <distance> <value>987</value> <text>1.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>19.0131500</lat> <lng>72.8550800</lng> </start_location> <end_location> <lat>18.9933600</lat> <lng>72.8515000</lng> </end_location> <polyline> <points>eo`sBgot{LzB`AdDr@jMv@rHVhRN`Zj@vMjB~E^zEt@lIbCdDbC</points> <levels>B??@??@??@?B</levels> </polyline> <duration> <value>233</value> <text>4 mins</text> </duration> <html_instructions>Turn <b>right</b> at Shobha Hospital onto <b>Rafi Ahmed Kidwai Marg</b> <div style="font-size:0.9em">Pass by Sukkur Bhawan (on the left)</div></html_instructions> <distance> <value>2264</value> <text>2.3 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9933600</lat> <lng>72.8515000</lng> </start_location> <end_location> <lat>18.9675800</lat> <lng>72.8448800</lng> </end_location> <polyline> <points>os|rB{xs{L~AbBbMtOtYjb@dAn@pCr@`ZsEp[aEvJ}AzPwBzBa@nBI`E@zFz@~Ad@^T</points> <levels>B??@?@????@????B</levels> </polyline> <duration> <value>203</value> <text>3 mins</text> </duration> <html_instructions>Continue onto <b>Barrister Nath Pai Marg</b> <div style="font-size:0.9em">Pass by Everest Marine Ply - J. Himatlal &amp; Co. (on the left in 1.6&nbsp;km)</div></html_instructions> <distance> <value>3360</value> <text>3.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9675800</lat> <lng>72.8448800</lng> </start_location> <end_location> <lat>18.9382900</lat> <lng>72.8379900</lng> </end_location> <polyline> <points>krwrBoor{LxCf@rBh@`Bf@nCpAnAFpAEfBSr@Y^?dk@nIdm@rJbEb@rz@xM</points> <levels>B????????????B</levels> </polyline> <duration> <value>246</value> <text>4 mins</text> </duration> <html_instructions>At Our Lady of the Rosary Church, continue onto <b>P D Mello Rd</b> <div style="font-size:0.9em">Pass by Petrol Pump (on the left in 1.9&nbsp;km)</div></html_instructions> <distance> <value>3356</value> <text>3.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9382900</lat> <lng>72.8379900</lng> </start_location> <end_location> <lat>18.9344900</lat> <lng>72.8371000</lng> </end_location> <polyline> <points>i{qrBmdq{LjIlAvI|ArAD</points> <levels>B??B</levels> </polyline> <duration> <value>56</value> <text>1 min</text> </duration> <html_instructions>Continue onto <b>S Bhagat Singh Marg</b> <div style="font-size:0.9em">Pass by SIB (on the left)</div></html_instructions> <distance> <value>433</value> <text>0.4 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9344900</lat> <lng>72.8371000</lng> </start_location> <end_location> <lat>18.9321900</lat> <lng>72.8357900</lng> </end_location> <polyline> <points>qcqrB{~p{Ll@?bDf@^RtC`DbAf@</points> <levels>B????B</levels> </polyline> <duration> <value>32</value> <text>1 min</text> </duration> <html_instructions>Continue onto <b>Mint Rd</b> <div style="font-size:0.9em">Pass by Mint Police Station (on the left)</div></html_instructions> <distance> <value>302</value> <text>0.3 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9321900</lat> <lng>72.8357900</lng> </start_location> <end_location> <lat>18.9243200</lat> <lng>72.8320700</lng> </end_location> <polyline> <points>euprBuvp{LdIj@XNhAxArA`ApHfCtDX`C@lA\r@n@fAvCf@f@j@LNR?XnC`@</points> <levels>B???????@??????B</levels> </polyline> <duration> <value>97</value> <text>2 mins</text> </duration> <html_instructions>Continue onto <b>Shahid Bhagat Singh Rd/Shahid Bhagat SIngh Marg</b> <div style="font-size:0.9em">Go through 1 roundabout</div><div style="font-size:0.9em">Pass by Town Hall (on the left)</div></html_instructions> <distance> <value>1022</value> <text>1.0 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9243200</lat> <lng>72.8320700</lng> </start_location> <end_location> <lat>18.9230100</lat> <lng>72.8334800</lng> </end_location> <polyline> <points>_dorBm_p{LvFmERa@Ei@</points> <levels>B??B</levels> </polyline> <duration> <value>30</value> <text>1 min</text> </duration> <html_instructions>Turn <b>left</b> at CBI onto <b>Mahakavi Bhushan Rd/Rajkavi Ghushan Marg</b> <div style="font-size:0.9em">Pass by Kalajot Hospital (on the right)</div></html_instructions> <distance> <value>220</value> <text>0.2 km</text> </distance> </step> <step> <travel_mode>DRIVING</travel_mode> <start_location> <lat>18.9230100</lat> <lng>72.8334800</lng> </start_location> <end_location> <lat>18.9219500</lat> <lng>72.8335500</lng> </end_location> <polyline> <points>y{nrBghp{LdA_@t@KvA\</points> <levels>B??B</levels> </polyline> <duration> <value>46</value> <text>1 min</text> </duration> <html_instructions>Turn <b>right</b> at Mumbai Hotels Booking onto <b>Appolo Bunder/P J Ramchandani Marg</b> <div style="font-size:0.9em">Destination will be on the right</div></html_instructions> <distance> <value>124</value> <text>0.1 km</text> </distance> </step> <duration> <value>1933</value> <text>32 mins</text> </duration> <distance> <value>25826</value> <text>25.8 km</text> </distance> <start_location> <lat>19.0966100</lat> <lng>72.8656200</lng> </start_location> <end_location> <lat>18.9219500</lat> <lng>72.8335500</lng> </end_location> <start_address>Chhatrapati Shivaji International Airport, Vile Parle East, Mumbai, Maharashtra, India</start_address> <end_address>Taj Mahal Palace & Tower, P J Ramchandani Marg, Apollo Bandar, Mumbai, Maharashtra 400001, India</end_address> </leg> <overview_polyline> <points>yxpsBcqv{LuAd@aEf@eBl@a^lQqDpBiS`PgAnAeArCoA`JiAbKpHr@nAChEk@|BAbTqCfCQl@@dAHhE`AbJhCxQvEfDdBzBjB~@hAvBnEr@rCbCdS`@vBh@xA|@pAvBhB`Af@`Ch@bBHnAExCk@nAm@l@e@nGuF~Ay@fDaAlXcDxx@f@~UBbPPvVF|HLhWClDX|Bh@fDdBz@x@l@z@~@rBz@nDfGfSfBjBj@ZxB^h@XZfAN~Ab@b@l@VnJErAYnA[vEgBPObJoDXAxCcAfLsEzDiAdB]vGw@jIM~DFzPr@lb@pFbBXrA`@vEeB~@gAlB}CXSx@SfDC^c@tAm@XB^QpHeNbHoLUa@Fs@RSv@DvZ{j@zB`AdDr@jMv@rHVhRN`Zj@vMjB`DRnFt@vJnChCfBjAhArNjQtYjb@dAn@pCr@`ZsEp[aEvJ}AzPwBzBa@nBI`E@zFz@~Ad@^TxCf@rBh@`Bf@nCpAnAFpAEfBSr@Y^?dk@nIdm@rJbEb@b\bFnWhEjOxBvI|A`CDbDf@^RtC`DbAf@dIj@XNhAxAzBxAhGnBtDX`C@lA\r@n@fAvCf@f@j@LNR?XnC`@vFmERa@Ei@dA_@t@KvA\</points> <levels>B???@?@???A??????@???@???@???@???A??@????@@?????@???@???@???????@?@?????????@??@??A???@?????@??????A??@??@???@?????@??????@??????@????@????????@??????@???@?????@??????B</levels> </overview_polyline> </route> </DirectionsResponse>
包含整个旅程细节的元素包括:
方向响应>;路线>;距离>;值 以基本单位表示的整个旅程的距离
方向响应>;路线>;距离>;文本 一段完整旅程的距离,用简单的英语表示
方向响应>;路线>;持续时间>;值 整个行程的估计行程时间,以基本单位(秒)为单位
方向响应>;路线>;持续时间>;文本 整个旅程的预计旅行时间,用简单的英语形式表示
然后可以使用PHP DOMDocument CLASS解析结果并提取这些细节。在
注意:从Google Directions API页面“使用Google Directions API的查询限制为每天2500个方向请求
(我可能会在这里陈述显而易见的情况,但如果是这样,请忽略这些要点,继续往下读。)
一般距离
(“当乌鸦在飞”和限制搜索/处理负载)
确定两点之间的距离可以在SQL数据库/SELECT语句中完成。
参考号:MySQL Great Circle (Haversine Formula)
如果用于比较的点的纬度/长度可能会更改(即用户的地址等),或者在设置了用于比较的点(您办公室的位置等)的情况下,可以动态地使用它来更新多个文件
如果要动态使用它,那么还建议限制运行此函数的行集。在
^{pr2}$实际上,这将在searchLatitude/searchLongitude点周围创建一个1度的框,并减少所需的计算数量。在
精确距离
Google Directions API提供了使用一个简单的HTTP请求来获得两点之间实际行驶距离的功能。在
例如,URL为“Chhatrapati Shivaji Int'l Airport”到“Taj Mahal Palace&Tower”:
http://maps.google.com/maps/api/directions/xml?origin=Chhatrapati+Shivaji+International+Airport&destination=Taj+Mahal+Palace+%26+Tower,+Mahakavi+Bhushan+Road,+Apollo+Bandar+Mumbai&sensor=false
它将返回一个XML响应:
包含整个旅程细节的元素包括:
方向响应>;路线>;距离>;值
以基本单位表示的整个旅程的距离
方向响应>;路线>;距离>;文本
一段完整旅程的距离,用简单的英语表示
方向响应>;路线>;持续时间>;值
整个行程的估计行程时间,以基本单位(秒)为单位
方向响应>;路线>;持续时间>;文本
整个旅程的预计旅行时间,用简单的英语形式表示
然后可以使用PHP DOMDocument CLASS解析结果并提取这些细节。在
注意:从Google Directions API页面“使用Google Directions API的查询限制为每天2500个方向请求
。单个方向请求最多可在请求中包含8个中间航路点。谷歌地图卓越理财客户每天最多可查询100000个方向请求,每个请求中最多允许23个航点。“相关问题 更多 >
编程相关推荐