Add Google Maps driving directions to your website添加Google Maps上的行车路线到您的网站

Posted on April 29, 2008 at 5:23 am张贴于2008年4月29日在上午05时23分

I love using Google Maps “Get Directions” feature any time I need to figure how to get from point A to B. It’s one of the best ways to get driving directions in the USA for sure.我爱使用Google Maps “指示”功能,任何时候我需要的数字,如何从A点B.它奇摩的最佳途径之一,以获取驾车路线,在美国是肯定的。

So what if you have a wedding website or a MySpace page and you’re throwing a big party, wouldn’t it be nice if your guests could go to your site, type in the address they will be coming from and automatically get directions to the event location!?那么,如果您有一个婚礼类网站,或MySpace网页,而您投掷一个大党,不会是很好,如果您的客人可以到您的网站中,输入地址,他们将来自和自动获得指示活动地点! ? Not sure what I mean?不知道我的意思吗? Type your address in the box below and you’ll get directions from your address to my house:输入您的地址在下面的框中您将得到指示,从您的地址到我家:

Enter your starting address:输入您的起始地址:

Cool huh?酷吧? You can easily create this little form on any website, blog, or anywhere you can put in some HTML code!您可以轻松地创造了这张小小的表格,对任何网站,博客或任何你可以把在某些HTML代码! This is also great for small business web sites as you can throw it up on your contact page and people can get directions quickly, rather than having to copy your address, open a new window, and then type in their starting address.这亦是伟大的为小型企业的网站,您可以把它在您的联系方式网页和人民可以得到迅速的方向,而不是复制到您的地址,打开一个新窗口,然后输入自己的起始地址。

So how do we go about creating this modified get directions box?因此,我们如何去创造这一修改得到的指示框吗? Well first, we’ll need to get the correct syntax for the URL that Google uses for directions.以及首先,我们将需要获得正确的语法为网址, Google用为方向。 Luckily, we can figure that out by getting directions between two places and then clicking on the Send link at the top right.幸运的是,我们可以数字指出,由获得方向之间的两地,然后点击发送链接在右上角。

Here’s what you end up getting:以下是您最终获得:

地图得到directios

Notice the link in the email message!通知的电子邮件中的链接的讯息! That’s what we need!这正是我们最需要的! Here’s what the entire link looks like right now:这里的什么整个连结看起来像现在的权利:

http://maps.google.com/maps?f=d&hl=en&geocode=&saddr= 6348+Pratt+Dr,+New+Orleans,+LA+70122+(Pratt+Home)&daddr=4601+lennox+blvd,+new+orleans,+la&sll=37.0625,-95.677068&sspn=33.214763,82.265625&ie=UTF8&z=12 http://maps.google.com/maps?f=d&hl=en&geocode=&saddr = 6348 + +普拉特博士, +新+新奥尔良, +香格里拉70122 + (普拉特+首页) & daddr = 4601 +蓝妮克丝+大道, +新+新奥尔良, +香格里拉& sll = 37.0625 , -95.677068 & sspn = 33.214763,82.265625 &即= utf8进行& z = 12

Eeeks! eeeks ! That’s pretty long!这是相当长的! There are a lot of fields in the URL, such as SADDR (starting address), DADDR (destination address), hl (language), and some more stuff related to the latitude and longitude.有很多领域,在网址,如saddr (起始地址) , daddr (目的地地址) , hl (语文) ,和一些相关的更多的东西向的经度和纬度。

However, you don’t really need all of these fields in order for Google to give you driving directions!不过,你不真的需要所有这些领域,为了让Google给你的行车路线! All you need is this:你所需做的一切是这样的:

http://maps.google.com/maps?saddr=start&daddr=end http://maps.google.com/maps?saddr=start&daddr=end

Go ahead and give it a shot.继续并给它一个镜头。 Put in an address in quotes for the starting and ending address and paste the URL into your browser!提出在一个地址在寻获起始和结束地址和URL粘贴到您的浏览器! I replaced start with my home city New Orleans and end with Houston, TX, so this is what my Google Maps directions URL looks like: i取代,开始与我的家乡城市新奥尔良和年底与休斯敦,得克萨斯州,所以这是我的Google地图的指示网址看起来就像这样:

http://maps.google.com/maps?saddr=”new orleans, la”&daddr=”houston, tx” http://maps.google.com/maps?saddr = “新的新奥尔良,香格里拉” & daddr = “休斯敦,得克萨斯州”

Pretty nifty eh!相当漂亮的高血压! Isn’t it fun to mess around with these types of things!是不是很有趣的烂摊子左右,与这些类型的东西! Ok, so now that we have a URL that we can pass into Google Maps, we need to create a simple form with two fields, one for the starting address and one for the destination address.确定,所以现在我们有一个网址,我们可以通过进入Google Maps上,我们需要创建一个简单的表格,连同两个领域,一为起始地址和一个目的地地址。

If you want people to just type in their address and get directions to your place, then we’ll want the second field to be hidden and already set to the destination address.如果您想要的人只需键入在其施政报告并获得指示,以您的位置,那么我们将要第二个栏位,以隐藏的和已定,到目的地地址。

<form action=”http://maps.google.com/maps” method=”get” target=”_blank”> <form action="http://maps.google.com/maps" method="get" target="_blank">请
Enter your starting address: 输入您的起始地址:
<input type=”text” name=”saddr” /> <input type="text" name="saddr" />
<input type=”hidden” name=”daddr” value=”6348 Pratt Dr, New Orleans, LA” /> <input type="hidden" name="daddr" value="6348普拉特dr,新orleans, la" />
<input type=”submit” value=”get directions” /> <input type="submit" value="get directions" />
</form> < /表格>

Check out the code above.检查上面的代码。 The first line starts out form and says that when the submit button is clicked, the data should be sent to maps.google.com/maps.第一线出发的形式和说,当提交按钮按下,数据应发送到maps.google.com /图。 The target=blank means that we want the result to open in a new window. 目标=空白 ,就是我们想要的结果,以在新窗口中打开。 Then we have a text box for the starting address, which is blank.然后我们有一个文本框为起始地址,这是空白。

The second text box is hidden and the value is the destination address that we desire.第二个文本框是隐藏的和值是目的地地址,我们的愿望。 Finally, there is a submit button with the title “Get Directions”.最后,有一个提交按钮与标题“指示” 。 Now when someone types in their address, they’ll get this:现在,当有人在他们的类型地址,他们将获得:

获取驾车指南

You can customize the directions and map even more by following the same procedure as I went through above.您可以自订的方向和地图更是按照同样的程序,正如我经历了以上。 For example, let’s say you don’t want the default view to be maps, but instead want it to be Satellite and show Traffic .举例来说,假设您不想默认视图要地图,而是希望它是卫星和显示交通 Type in your directions and then press the Satellite and Traffic buttons on the Google map.输入您的指示,然后按下卫星和交通的按钮上的Google地图。 Next, click on Send and you’ll see the modified URL:接下来,按一下就发送,您会看到修改网址:

http://maps.google.com/maps?saddr=%22new+orleans,+la%22&daddr=%22houston,+tx%22&ie=UTF8&t=h&z=7&layer=t http://maps.google.com/maps?saddr = % 22new +新奥尔良, +香格里拉% 22 & daddr = % 22houston , +德克萨斯州% 22 &即= utf8进行& T的=在H & z = 7 &层=吨

Notice the layer=t and t=h fields in the URL.公告层=吨t = h领域的网址。 layer=t is for the traffic layer and t=h means satellite in some strange fashion!层=吨,是为交通层和t = h指卫星在一些奇怪的时装! Just tack those on to your final URL and you’ve now got a highly customized Google Maps Get Directions form on your site!刚才那些钉到您最后的网址和你现在这种做法已经得到高度定制的Google Maps得到指示的形式对您的网站! Source:资料来源: AskDaveTaylor askdavetaylor

Have any issues with this, post a comment and I’ll try to help!有任何问题,这一点,张贴评论,我将尽力帮助! Enjoy!享受!

If you enjoyed this post, make sure you 如果您喜欢这个职位,请务必 subscribe to my RSS feed 订阅我的RSS馈送 !

» Filed Under »提交下 Google Software/Tips Google软件/秘诀

Related Posts相关文章

One Response to “Add Google Maps driving directions to your website” 1回应“添加Google Maps上的行车路线到您的网站”

  1. MJ said on : 兆焦耳说,就:

    Really cool feature.真的很酷的功能。 I have tried it before, it’s really helpful.我曾尝试之前,它的真正帮助。

    Thanks.谢谢。


    Please post your comments/suggestions!请张贴您的意见/建议!