How to convert an address into a Google Maps Link (NOT MAP)

前端 未结 14 2025
借酒劲吻你
借酒劲吻你 2020-12-02 03:38

After looking (Googling) on the web for a while, I can find nothing that takes an address like:

1200 Pennsylvania Ave SE, Washington, District of Columb

14条回答
  •  暖寄归人
    2020-12-02 04:06

    I know I'm very late to the game, but thought I'd contribute for posterity's sake.

    I wrote a short jQuery function that will automatically turn any

    tags into Google maps links.

    See a demo here.

    $(document).ready(function () {
       //Convert address tags to google map links - Michael Jasper 2012
       $('address').each(function () {
          var link = "" + $(this).text() + "";
          $(this).html(link);
       });
    });
    

    Bonus:

    I also came across a situation that called for generating embedded maps from the links, and though I'd share with future travelers:

    View a full demo

    $(document).ready(function(){
        $("address").each(function(){                         
            var embed ="";
            $(this).html(embed);             
        });
    });
    

提交回复
热议问题