跳至主要内容

把Google Maps加到自己的Blog里"

具体效果可以看我主页的About me,这也算是Google Map最简单的玩法了,我就用dancemoon.net作例子,具体介绍一下在Blog添加Google Maps的方法。

首先需要到http://www.google.com/apis/maps/申请一个API key,你需要用你的GmailID登录。申请成功以后你会得到一个API key,和一段添加到网页的事例代码,去掉一些没有用的Html代码以后剩下:

<script src=" http://maps.google.com/maps?file=api&v=1&key= [API key]" type="text/javascript"></script>     <div id="map" style="width: 500px; height: 400px"></div>     <script type="text/javascript">     //<![CDATA[          var map = new GMap(document.getElementById("map"));     map.addControl(new GSmallMapControl());     map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);          //]]>     </script>


其中
<div id="map" style="width: 500px; height: 400px"></div>

这行可以自定义显示Google Maps的宽(width)和高(height)。

map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);

这行算是整段代码最重要的部分,可以用来调整Google Maps显示的地理位置(-122.1419, 37.4419)和大小(4)。我们下面要做的就是把这两行代码替换成适合自己的。

http://maps.google.com在地图上找到自己所在的位置,用鼠标双击,你双击的那点就会显示在地图的中央,然后点击右上角的Link to this page,地址栏里的地址就包含了你的坐标信息,比如我在的大连地址是:

http://maps.google.com/?ll=38.794768,121.294556&spn=1.051049,2.04071

其中38.794768,121.294556,就是大连的坐标,把他们替换到代码里:

map.centerAndZoom(new GPoint(121.294556, 38.794768), 15);

因为Google Maps显示的中国的信息有限,所以不要把最后的数值设得太小,我写的是15(最大到16),具体自己把握就行。

如果想在自己的位置上加个标记,那把下面这段代码加到map.centerAndZoom...这行下面:

map.addOverlay(new GMarker(new GPoint(121.294556, 38.794768)));

还想在标记上加上弹出气泡的功能,就加入下面一段:

    var dalian = new GMarker (new GPoint (121.294556, 38.794768));  GEvent.addListener (dalian, "click", function() {  dalian.openInfoWindowHtml ("我在大连 Oh!Yeah!");  });  map.addOverlay (dalian);

最后的代码就是这些:

<script src="http://maps.google.com/maps?file=api&v=1&key= [API key]" type="text/javascript"></script>     <div id="map" style="width: 400px; height: 300px"></div>     <script type="text/javascript">     //<![CDATA[          var map = new GMap(document.getElementById("map"));     map.addControl(new GSmallMapControl());     map.centerAndZoom(new GPoint(121.294556, 38.794768), 15);         var dalian = new GMarker (new GPoint (121.294556, 38.794768));  GEvent.addListener (dalian, "click", function() {  dalian.openInfoWindowHtml ("我在大连 Oh!Yeah!");  });  map.addOverlay (dalian);     //]]>     </script>

1/11/2006 6:19:25 AM Post by[dancemoon.net]

评论

此博客中的热门博文

How to Design a Store Front Sign

In this Article we will talk about designing a store front for a business. What color or size should your Letters & designs be? What to put on your sign and why?, then be ready to Get in touch with sign people and get your best deal. Large lettering with out a front sign could save you time and money Do your products have a special shape or color to emulate on your sign? Kodak is always in yellow and black, Coca-Cola white on red, Etc. Muffler places, have a sign in the shape of a muffler. your phone number on the store front some place, but not on the identification sign, (door, or window) Your Product & logos can be arranged on the front sign, or window. Not on the Pole sign, Store hours & phone number could fit in your design and by using the product color, it could add product recognition & enhance your design. Suppliers may provide plenty of advert

music forum (zt)

24. moonlight - ≡ Sound Of Nature ≡ -     15. Tone Quebec Network 17.Ukoo http://www.hispeed.com.cn/Forum/LoadForum.asp?Foru m / a> http://bbs.dd81.com/index.php 30. Jazz pawnshop http://www.sogua.com/ 6. Lyrics 吾爱 http://www.inkui.com Reading of the singer in mind 2. Hyun tone http://d.sogou.com/ http://www.beihai365.com/bbs/forumdisplay.php?f/a> 20. Left Bank • Teana http://bbs.flamesky.com/ 8. Sogou sogou- 25.U Shadow 吾爱 sound waves 4. Need 14.HDCD http://www.commus.com/ 29, Buddhist music, do not know the name of the http://www.itpub.net/forum79.html http://bbs.kugoo.com/index.asp http://bbs.uying.com/176/Index.aspx http://board.verycd.com/ http://board.verycd.com/f8.html 13.MP3 barrage http://bbs.51lrc.com/index.asp?board/a> A pleasant song - "Dancing circulation" 19.Verycd of http://bbs.breezecn.com/ http://www.mp4cn.com/2008/index.html Sound of Music Forum, http://www.jazzsky.com/lb/cgi-bin/leobbs.cgi http://www.luopo.co

找到一个可以替代ghs.google.com的地址

用Goole Blogger的自定义域名功能需要用到 ghs.google.com 做CNAME,或者用ping ghs.google.com 得出的IP做一个A记录.但是,伟大的GFW已经把 ghs.google.com 和部分IP屏蔽在大陆之外.这样的壮举使得我们的自定义域名不能正常访问,或者让你的网页背景.图片被滤掉,精心做成的模板变得惨白不堪. 那么,我们可不可以找一个替代 ghs.google.com 的地址呢?当然能.因为Google是强大的.它有许多有用的IP地址让你去探寻. 对 ghs.google.com 分析研究后发现, ghs.google.com 这台服务器并没有提供实质性的服务,而只是选择访问者访问最快的服务器(Google全球性公司,很多地区都有服务器).我们只要找到其他服务器的IP地址,并且这个IP地址没被屏蔽,那么就成了. 寻找这样的IP地址需要用到tracert命令.即在CMD模式下输入:tracert ghs.google.com ,在已经屏蔽的当下,最后自然得不出结果,这就需要我们使用代理了.使用不同地区的代理运行tracert ghs.google.com 命令. tracert ghs.google.com 的最后一跳会有类似这样的域名: eh-in-f121.google.com 如果在不用代理的情况下,你能ping通这个域名,那么恭喜你,你找到了!现在就可以用这个域名代替 ghs.google.com 设置你的CNAME了,ping出的IP地址可以做A记录,CNAME和A记录,只做其中之一就可以. hs-in-f121.google.com 64.233.179.121 eh-in-f121.google.com 72.14.207.121 bx-in-f121.google.com 66.249.81.121 ik-in-f121.google.com 66.249.91.121 这4个在我所在地区不能使用,而可以使用 tw-in-f121.google.com 72.14.235.121 或者209.85.171.121也可用 下面是一些不断更新的:74.125.43.121 除了使用代理来寻找,也可以通过一些网站提供的功能来寻找这个地址,很方便,就是使用网站提供的Traceroute.这些网站有: h