Thursday, August 25, 2011

Google Map API Exercise 1: display a static google map via URL

这是一张以俺家为中心的static map,center的经纬度是通过javascript:void(prompt('',gApplication.getMap().getCenter()));获取的。其代码如下:

<img src=http://maps.googleapis.com/maps/api/staticmap?center=42.286959,-71.765538&zoom=17&size=512x512&maptype=satellite&markers=icon:http://bit.ly/pu5LFb|42.286959,-71.765538&sensor=true>

其中被shorten的地址(http://bit.ly/pu5LFb)的原地址为:http://chart.apis.google.com/chart?chst=d_map_spin&chld=0.84|30|FFFF88|10|_|%E4%BF%BA%E5%AE%B6



1 comment:

  1. There is a very nice learning note for the Chinese character encoding problem:

    http://www.ruanyifeng.com/blog/2010/02/url_encoding.html

    Summarized conclusion is:
    1. 网址路径的编码,用的是utf-8编码。e.g “春”和“节”的utf-8编码分别是“E6 98 A5”和“E8 8A 82”,因此, “%E6%98%A5%E8%8A%82”就是按照顺序,在每个字节前加上%而得到的, so, http://zh.wikipedia.org/wiki/春节 = http://zh.wikipedia.org/wiki/%E6%98%A5%E8%8A%82

    2. 查询字符串包含汉字, 用的是操作系统的默认编码. e.g. "http://www.baidu.com/s?wd=春节 " will be read as "http://www.baidu.com/s?wd=%B4%BA%BD%DA" in a Windows system using GB2312 encoding.

    3. GET和POST方法的编码,用的是网页的编码。Not very clear of the difference with the above #2.

    4. more ...

    ReplyDelete