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

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

    What about this : http://support.google.com/maps/bin/answer.py?hl=en&answer=72644

    0 讨论(0)
  • 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 <address> 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 = "<a href='http://maps.google.com/maps?q=" + encodeURIComponent( $(this).text() ) + "' target='_blank'>" + $(this).text() + "</a>";
          $(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 ="<iframe width='425' height='350' frameborder='0' scrolling='no'  marginheight='0' marginwidth='0' src='https://maps.google.com/maps?&amp;q="+ encodeURIComponent( $(this).text() ) +"&amp;output=embed'></iframe>";
            $(this).html(embed);             
        });
    });
    
    0 讨论(0)
  • 2020-12-02 04:10

    How about this?

    https://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003

    https://maps.google.com/?q=term
    

    If you have lat-long then use below URL

    https://maps.google.com/?ll=latitude,longitude
    

    Example: maps.google.com/?ll=38.882147,-76.99017

    UPDATE

    As of year 2017, Google now has an official way to create cross-platform Google Maps URLs:

    https://developers.google.com/maps/documentation/urls/guide

    You can use links like

    https://www.google.com/maps/search/?api=1&query=1200%20Pennsylvania%20Ave%20SE%2C%20Washington%2C%20District%20of%20Columbia%2C%2020003 
    
    0 讨论(0)
  • 2020-12-02 04:10

    The best way is to use this line:

    var mapUrl = "http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=16900+North+Bay+Road,+Sunny+Isles+Beach,+FL+33160&amp;aq=0&amp;sll=37.0625,-95.677068&amp;sspn=61.282355,146.513672&amp;ie=UTF8&amp;hq=&amp;hnear=16900+North+Bay+Road,+Sunny+Isles+Beach,+FL+33160&amp;spn=0.01628,0.025663&amp;z=14&amp;iwloc=A&amp;output=embed"
    

    Remember to replace the first and second addresses when necessary.

    You can look at work sample

    0 讨论(0)
  • 2020-12-02 04:13

    Feb, 2016:

    I needed to do this based on client entered database values and without a lat/long generator. Google really likes lat/long these days. Here is what I learned:

    1 The beginning of the link looks like this: https://www.google.com/maps/place/

    2 Then you put your address:

    • Use a + instead of any space.
    • Put a comma , in front and behind the city.
    • Include the postal/zip and the province/state.
    • Replace any # with nothing.
    • Replace any ++ or ++++ with single +

    3 Put the address after the place/

    4 Then put a slash at the end.

    NOTE: The slash at the end was important. After the user clicks the link, Google goes ahead and appends more to the URL and they do it after this slash.

    Working example for this question:

    https://www.google.ca/maps/place/1200+Pennsylvania+Ave+SE,+Washington,+DC+20003/

    I hope that helps.

    0 讨论(0)
  • 2020-12-02 04:15

    On http://www.labnol.org/internet/tools/short-urls-for-google-maps/6604/ they show a short URL that works pretty well

    Google Maps URLs are pretty unwieldy especially when sending over an IM, tweet or email. MapOf.it provides you a quick way to link to Google Maps by simply specifying the address of the location as a search parameter.

    http://mapof.it/

    I used it for a few applications I've designed and it worked like a charm.

    0 讨论(0)
提交回复
热议问题