Overview

I had an opportunity to extract latitude and longitude from a Google Maps short URL like the following.

https://goo.gl/maps/aPxUgDJ9KP2FLFkN7

https://goo.gl/maps/aPxUgDJ9KP2FLFkN7

At that time, two sets of latitude and longitude could be obtained, so this is a personal note on the matter.

Extraction Method

I received the following answer from GPT-4.

-– Answer below —

It is not possible to directly extract latitude and longitude from a Google Maps short URL (goo.gl/maps/...). However, by expanding this short URL to obtain the original URL, you can extract the latitude and longitude from that URL.

You can obtain the latitude and longitude with the following steps:

  1. Expand the short URL.
  2. Extract the latitude and longitude from the expanded URL.

Here is an example in Python:

iidulpmmerarppfltioo_nrrg#ril#mie=lttteefoaflo(tEsnEts"nlrr_xprgxcmehaeelpoer_thalr:rt=tqaanseurtaeet_utnsptra=ctttpgle_deoulch,uuseoslnrtr:rr:tntot=sn=elnn/_)snhel.o/l_er.NrasnfNgafesoetelootrsqtnsia=ono_ohuaeptrae.lmoetoucmtgo_rsundha(lngttsse(tl/_os_ercamfoU.c.a'htargRgohn@.)polLeded(g,smetea[r/__(dl\ofagus!eo-ulPorh=rn0poxolosg-saUg(r3[i9(tglst0't.)(Deh_2lu]lJ_ou:od+o9urrce)nKrtla,)Pl_,tf(2(uir[Furaoo\Lrllnm-Fl)l'0k):o]t-Nwh97_e."r]ee+dx)ip'ra,encdlteosdn=gFU_aRulLrsle))

This code is basic for expanding a short URL and extracting latitude and longitude. However, it is recommended to add error handling and exception processing according to the actual usage environment and purpose.

-– End of answer —

Using the above, I was able to obtain the latitude and longitude contained in the following URL (here, 28.3410487,129.9769402).

https://www.google.com/maps/place/鹿児島県大島郡喜界町大字伊砂/@28.3410487,129.9769402,3868m/data=!3m2!1e3!4b1!4m5!3m4!1s0x351f80a0620f4335:0x35d406a5040d7197!8m2!3d28.3439714!4d129.9838012?shorturl=1

However, when specifying these coordinates, the following location was indicated, which appeared to be offset from the desired coordinates.

Fix

Upon checking the following URL, coordinates !3d28.3439714!4d129.9838012 were also found at the end.

https://www.google.com/maps/place/鹿児島県大島郡喜界町大字伊砂/@28.3410487,129.9769402,3868m/data=!3m2!1e3!4b1!4m5!3m4!1s0x351f80a0620f4335:0x35d406a5040d7197!8m2!3d28.3439714!4d129.9838012?shorturl=1

So I modified the program to allow specifying the prefix and delimiter.

iidulpmmerarppfltioo_nrrg#rilp#pmie=lttteeforaaflo(tEsniEtts"nlrr_xprgnxtcmehaeelpoer_ttehalr:rt=tqaanseu(rrtaeet_utnsptrlan=ctttpgle_deouloch,uuseoslnrnt=r:rr:tntot=sn=gelnn/_)snhe_lr.o/l_er.Nrua'snfNgafesoert{elootrsqtnslipa=ono_ohuaep)trrae.lmoetouecmtgo_rsundfha(lngttssei(tl/_os_expcamfoU.c.a}ahtargRgohn(t.)polLeded[tg,smetea\er/__(dl-rofagus!eo0nulPorh=rn-,poxolosg9saUg(r3[i.l(tglst0't]o)(Deh_2lu+nlJ_ou:od)go9urrce{_nKrtladu)Pl_,tfer2(uirllFuraooi)LrllnmmFl,l'ik,o]ttNpwhe7pr_er"rer}efee(fidx[ixip\x=ra-=en0""cd-!@te93"sd.d,=]"FU+,daR)elL'dls.eieflm)oiirmtmieatrte(r=p=r""e!,f4"id)x":=)re.escape(prefix),delimiter=re.escape(delimiter))

As a result, 28.3439714,129.9838012 was obtained. When using these coordinates, a pin was placed at a location closer to the desired target, as shown below.

Summary

There is no single definitive answer, but I hope this serves as a useful reference for extracting latitude and longitude from Google Maps short URLs.