×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔõÑùʹÓÃThinkPHP6¾ÙÐеØÓ߶¨Î»²Ù×÷ £¿

Ëæ×ÅÒƶ¯»¥ÁªÍøµÄ¿ìËÙÉú³¤£¬µØÓ߶¨Î»¹¦Ð§ÒѾ­³ÉΪÁËÐí¶àÓ¦ÓóÌÐòÖбز»¿ÉÉٵĹ¦Ð§£¬ÈÃÓû§Äܹ»Ô½·¢Àû±ãµØ»ñÈ¡ÖܱßÐÅÏ¢£¬Ò²ÎªÉ̼ÒÌṩÁ˱ã½ÝµÄ½»»¥·½·¨¡£¶øÔÚÓ¦ÓÃÖÐʵÏÖµØÓ߶¨Î»¹¦Ð§£¬thinkphp6¿ò¼ÜÒ²ÌṩÁ˽ÏΪ±ã½ÝµÄ½â¾ö¼Æ»®¡£

±¾ÎĽ«ÏÈÈÝʹÓÃThinkPHP6¾ÙÐеØÓ߶¨Î»²Ù×÷µÄÏêϸҪÁì¼°°ì·¨¡£

Ò»¡¢×°ÖÃÀ©Õ¹

ÔÚʹÓÃÇ°£¬ÐèҪװÖÃthinkphp¹Ù·½ÌṩµÄthink-geoÀ©Õ¹£¬Ê¹ÓÃcomposer×°Öü´¿É¡£

composer require topthink/think-geo

µÇ¼ºó¸´ÖÆ

¶þ¡¢ÉèÖÃ

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

ÔÚÉèÖÃÎļþconfig/app.phpÖÐÉèÖÃÀ©Õ¹µÄprovidersÏÌí¼Ó hinkGeoServiceProviderЧÀÍÌṩÕß¼´¿É¡£

'providers'    => [
    // ¸ü¶àµÄЧÀÍÌṩÕß
        hinkGeoServiceProvider::class
],

µÇ¼ºó¸´ÖÆ

Èý¡¢Ê¹ÓÃ

»ñÈ¡µØÓß±àÂë

µØÓß±àÂë¼´½«ÈËÀà¿É¶ÁµÄµØµãת»»³ÉÅÌËã»ú¿É¶ÁµÄ¾­Î³¶ÈÊýÖµ£¬Ê¹µÃÎÒÃÇÄܹ»Í¨¹ý¾­Î³¶ÈÀ´Ïêϸ¶¨Î»ËùÔÚ¡£ÔÚThinkPHP6ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃGeoÀàÀ´¿ìËÙ¾ÙÐеØÓß±àÂë²Ù×÷¡£

use thinkGeo;

$address = '¹ã¶«Ê¡¹ãÖÝÊÐÌìºÓÇø»ª¾°Â·61ºÅ»ª¾°ÐÂÌìµØ';
$result = Geo::geocode($address);
dump($result);

µÇ¼ºó¸´ÖÆ

´úÂëÖÐ$addressΪÐèÒª¾ÙÐеØÓß±àÂëµÄµØµã£¬Geo::geocode()º¯Êý½«·µ»ØÒ»¸öGeoResult¹¤¾ß£¬¸Ã¹¤¾ß°üÀ¨Á˸õصãµÄµØÓß±àÂëÐÅÏ¢£¬°üÀ¨¾­Î³¶È¡¢ËùÔÚ¹ú¼Ò/Ê¡·Ý/¶¼»á/ÇøÓòµÈÐÅÏ¢¡£

»ñÈ¡ÄæµØÓß±àÂë

ÄæµØÓß±àÂë¼´½«ÅÌËã»ú¿É¶ÁµÄ¾­Î³¶ÈÊýֵת»»³ÉÈËÀà¿É¶ÁµÄµØµã¡£ÔÚThinkPHP6ÖУ¬ÎÒÃÇÖ»ÐèҪŲÓÃGeoÀàµÄreverseGeocode()º¯Êý¼´¿É»ñÈ¡ÄæµØÓß±àÂëÐÅÏ¢¡£

use thinkGeo;

$lng = 113.324520; // ¾­¶È
$lat = 23.102290; // γ¶È
$result = Geo::reverseGeocode($lng, $lat);
dump($result);

µÇ¼ºó¸´ÖÆ

´úÂëÖÐ$lngºÍ$latΪÐèÒª¾ÙÐÐÄæµØÓß±àÂëµÄ¾­Î³¶ÈÊýÖµ£¬Geo::reverseGeocode()º¯Êý½«·µ»ØÒ»¸öGeoResult¹¤¾ß£¬¸Ã¹¤¾ß°üÀ¨Á˸þ­Î³¶ÈËùÔڵصãµÄµØÓß±àÂëÐÅÏ¢¡£

ËÄ¡¢×ܽá

ÒÔÉϾÍÊÇʹÓÃThinkPHP6¾ÙÐеØÓ߶¨Î»²Ù×÷µÄÏêϸҪÁì¼°°ì·¨¡£Í¨¹ýÓ¦ÓøÃÀ©Õ¹£¬ÎÒÃÇ¿ÉÒÔÇáËÉʵÏÖÓ¦ÓÃÖеĵØÓ߶¨Î»¹¦Ð§£¬ÎªÓû§ÌṩԽ·¢±ãµ±µÄЧÀÍ¡£

ÒÔÉϾÍÊÇÔõÑùʹÓÃThinkPHP6¾ÙÐеØÓ߶¨Î»²Ù×÷ £¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ