×ðÁú¿­Ê±

ÔõÑùʹÓÃ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
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿