-2

The case that there is someone that will input a link in a form and I need to decode that link to get lat and long to place the pin on an embedded map for him

stack: JavaScript - Angular

the problem is the google maps shared link is like this https://goo.gl/maps/2vV46xBbqiKp18MQA

how can I extract the lat and long from this link using JavaScript

Horizon
  • 15
  • 6

1 Answers1

-1

A solution where you do not require users to give you an exact URL schema is to have logic that determines what the shortened link actually points to and then scrape its query params for lat and long values. See this answer: https://stackoverflow.com/a/72054044/17963017

Of course, you would need to make sure that the URL is valid, the domain points to Google Maps, etc.

ardentia
  • 684
  • 1
  • 9
  • 1
    When an answer already exists, flag the question as a duplicate. Don't duplicate the answer. – MrUpsidown Dec 22 '22 at 13:07
  • @MrUpsidown It's not a duplicate. The question in https://stackoverflow.com/a/72054044/17963017 is different from the one asked here – ardentia Dec 22 '22 at 13:15
  • 1
    If all what *your* answer does is pointing to that answer, then it can be considered a duplicate, even if the question is different. In any case it's a duplicate of other questions. – MrUpsidown Dec 22 '22 at 13:24
  • @MrUpsidown I still do not agree because it's not like I have just posted a link to the other answer, I added additional things that need to be done, including the example given there. – ardentia Dec 22 '22 at 13:43
  • Do you think it is a duplicate of the one I flagged? – MrUpsidown Dec 22 '22 at 13:47
  • @MrUpsidown The question you have flagged - yes, it is a duplicate and you flagged it after I gave my answer. My answer, however, was not a duplicate of the one in the flagged question. – ardentia Dec 22 '22 at 13:52
  • 1
    So you also agree it didn't need an answer, right? If that's the case (and it should be), this means you should also check whether a duplicate question exists before placing an answer. – MrUpsidown Dec 22 '22 at 13:56