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

前端 未结 14 1967
借酒劲吻你
借酒劲吻你 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:26

    I had a similar issue where I needed to accomplish this for every address on the site (each wrapped in an address tag). This bit of jQuery worked for me. It'll grab each

    tag and wrap it in a google maps link with the address the tag contains contains!

    $("address").each(function(){
    
        var address = $(this).text().replace(/\,/g, '');
        var url = address.replace(/\ /g, '%20');
    
        $(this).wrap('');
    
    }); 
    

    Working example --> https://jsfiddle.net/f3kx6mzz/1/

提交回复
热议问题