<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>幼学笔记 &#187; 地图</title>
	<atom:link href="http://www.oncoding.cn/tag/map/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oncoding.cn</link>
	<description>追寻简单生活</description>
	<lastBuildDate>Sun, 29 May 2011 14:03:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>可以在前端实现的几个地理位置小功能</title>
		<link>http://www.oncoding.cn/2010/geo-location-frontend/</link>
		<comments>http://www.oncoding.cn/2010/geo-location-frontend/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 16:09:55 +0000</pubDate>
		<dc:creator>j5726</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[地图]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.oncoding.cn/?p=690</guid>
		<description><![CDATA[在Smashing Magazine上看到这篇Entering The Wonderful World of Geo Location，介绍了获取并处理用户地理位置的应用和方法，很有意思。结合原文的内容，加上之前的一些应用，整理了几个可以完全在前端实现的地理位置相关小功能。 1.通过IP获取用户位置 很多时候需要通过IP判断用户的位置，通常的办法是通过自己的后台程序查询数据库得到。如果用户位置只是应用在前端，或者有其他的特殊原因(比如，懒:)，也有一些其他办法来快速的获取用户位置。 maxmind.com提供了一个服务，通过引入一个js文件(http://j.maxmind.com/app/geoip.js)，可以把他判断到的用户的国家、城市、经纬度等信息加入到页面中来。下面是从青岛访问这个js文件返回的内容： 我们就可以利用这些信息做很多东西了：DEMO 另外，腾讯也有一个类似的接口，地址为 http://fw.qq.com/ipaddress，可以得到访问者的省、市信息，返回的格式如下： 具体的应用可以看这里： 断桥残雪WordPress天气插件 2.W3C共享位置接口 HTML5加入了的贡献地理位置的浏览器API接口，目前firefox3.5等浏览器已经支持这一功能。 用法： 看 DEMO 3. Google Gears 的 Geolocation API Google Gears是主要提供本地存储功能的浏览器扩展，新版本的Gears中，加入了判断用户地理位置的API，通过IP、WIFI热点等判断位置。不过Gears的使用似乎并不太广泛(Chrome内置了Gears，其他浏览器需要安装)，国内的地理位置信息也不够丰富，所以这个应用目前只可作为参考。 使用Gears的基本方法看这里，引入gears_init.js，使用Geolocation API的程序为： 更多内容参考这篇文章：使用Gears获取当前地理位置，以及DEMO。 4.逆经纬度解析 通过浏览器API等方式得到经纬度后，有时需要得到对应的城市名，这就是逆经纬度解析。 google maps api提供了一些经纬度解析方法，如果我们不想引入庞大的api，可以直接使用他的请求地址，通过jsonp方式得到google的经纬度解析数据。jsonp请求地址形式为： http://ditu.google.cn/maps/geo? output=json&#038;oe=utf-8&#038;q=纬度%2C经度 &#038;key=你申请到的key &#038;mapclient=jsapi&#038;hl=zh-CN&#038;callback=myfunction 参数q为经纬度，参数callback为回调函数名。 可以看下这个地址的返回结果，数据非常丰富，并且还是中文的： Yahoo提供的接口 雅虎提供了一些经纬度查询接口，可以使用YQL查询。 查询语句为： 用法： 使用YQL进行更多地理信息查询，可以看这个PPT：YQL Geo Library and Introduction to Geo Hacking [...]]]></description>
			<content:encoded><![CDATA[<p>在Smashing Magazine上看到这篇<a target="_blank" href="http://www.smashingmagazine.com/2010/03/08/entering-the-wonderful-world-of-geo-location/">Entering  The Wonderful World of Geo Location</a>，介绍了获取并处理用户地理位置的应用和方法，很有意思。结合原文的内容，加上之前的一些应用，整理了几个可以完全在前端实现的地理位置相关小功能。</p>
<h3>1.通过IP获取用户位置</h3>
<p>很多时候需要通过IP判断用户的位置，通常的办法是通过自己的后台程序查询数据库得到。如果用户位置只是应用在前端，或者有其他的特殊原因(比如，懒:)，也有一些其他办法来快速的获取用户位置。</p>
<p><a target="_blank" href="http://www.maxmind.com" >maxmind.com</a>提供了一个服务，通过引入一个js文件(<a target="_blank" href="http://j.maxmind.com/app/geoip.js">http://j.maxmind.com/app/geoip.js</a>)，可以把他判断到的用户的国家、城市、经纬度等信息加入到页面中来。下面是从青岛访问这个js文件返回的内容：<br />
<span id="more-690"></span></p>
<pre class="brush: jscript; title: ; notranslate">
function geoip_country_code() { return 'CN'; }
function geoip_country_name() { return 'China'; }
function geoip_city() { return 'Qingdao'; }
function geoip_region() { return '25'; }
function geoip_region_name() { return 'Shandong'; }
function geoip_latitude() { return '36.0986'; }
function geoip_longitude() { return '120.3719'; }
function geoip_postal_code() { return ''; }
</pre>
<p>我们就可以利用这些信息做很多东西了：<a href="http://isithackday.com/hacks/geo/js-location.html" target="_blank">DEMO</a></p>
<p>另外，腾讯也有一个类似的接口，地址为 http://fw.qq.com/ipaddress，可以得到访问者的省、市信息，返回的格式如下：</p>
<pre class="brush: jscript; title: ; notranslate">
var IPData = new Array(&quot;123.235.153.126&quot;,&quot;&quot;,&quot;山东省&quot;,&quot;青岛市&quot;);
</pre>
<p>具体的应用可以看这里：<a target="_blank" href="http://www.js8.in/wordpress-weather"> 断桥残雪WordPress天气插件</a></p>
<h3>2.W3C共享位置接口</h3>
<p>HTML5加入了的贡献地理位置的浏览器API接口，目前firefox3.5等浏览器已经支持这一功能。</p>
<p><a target="_blank" href="http://www.oncoding.cn/wp-content/uploads/2010/03/w3c-geo.jpg"><img src="http://www.oncoding.cn/wp-content/uploads/2010/03/w3c-geo-300x76.jpg" alt="" title="w3c-geo-api" width="300" height="76" class="aligncenter size-medium wp-image-693" /></a></p>
<p>用法：</p>
<pre class="brush: jscript; title: ; notranslate">
// if the browser supports the w3c geo api
if(navigator.geolocation){
  // get the current position
  navigator.geolocation.getCurrentPosition(

  // if this was successful, get the latitude and longitude
  function(position){
    var lat = position.coords.latitude;
    var lon = position.coords.longitude;
  },
  // if there was an error
  function(error){
    alert('ouch');
  });
}
</pre>
<p>看 <a target="_blank" href="http://isithackday.com/hacks/geo/distance.php">DEMO</a> </p>
<h3>3. Google Gears 的 Geolocation API</h3>
<p><a target="_blank" href="http://gears.google.com/">Google Gears</a>是主要提供本地存储功能的浏览器扩展，新版本的Gears中，加入了判断用户地理位置的API，通过IP、WIFI热点等判断位置。不过Gears的使用似乎并不太广泛(Chrome内置了Gears，其他浏览器需要安装)，国内的地理位置信息也不够丰富，所以这个应用目前只可作为参考。</p>
<p>使用Gears的基本方法看<a target="_blank" href="http://code.google.com/intl/zh-CN/apis/gears/design.html">这里</a>，引入<a href="http://code.google.com/intl/zh-CN/apis/gears/gears_init.js" target="_blank">gears_init.js</a>，使用Geolocation API的程序为：</p>
<pre class="brush: jscript; title: ; notranslate">
var geo = factory.create('beta.geolocation'); //创建geolocation对象
var okCallback = function(d){
  alert('当前位置(纬度，经度): ' + d.latitude + ',' + d.longitude);
};
var errorCallback = function(err){
  alert(err.message);
};
geo.getCurrentPosition(okCallback , errorCallback);
</pre>
<p>更多内容参考这篇文章：<a href="http://www.qgy18.com/2009/09/%E4%BD%BF%E7%94%A8google-gears%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D%E5%9C%B0%E7%90%86%E4%BD%8D%E7%BD%AE/" target="_blank">使用Gears获取当前地理位置</a>，以及<a target="_blank" href="http://www.qgy18.com/lab/gears/">DEMO</a>。</p>
<h3>4.逆经纬度解析</h3>
<p>通过浏览器API等方式得到经纬度后，有时需要得到对应的城市名，这就是逆经纬度解析。</p>
<p>google maps api提供了一些经纬度解析方法，如果我们不想引入庞大的api，可以直接使用他的请求地址，通过<strong>jsonp方式得到google的经纬度解析数据</strong>。jsonp请求地址形式为：</p>
<blockquote><p>http://ditu.google.cn/maps/geo?<br />
output=json&#038;oe=utf-8&#038;q=纬度%2C经度<br />
&#038;key=<em>你申请到的key</em><br />
&#038;mapclient=jsapi&#038;hl=zh-CN&#038;callback=myfunction</p></blockquote>
<p>参数q为经纬度，参数callback为回调函数名。</p>
<p>可以看下<a target="_blank" href="http://ditu.google.cn/maps/geo?output=json&#038;oe=utf-8&#038;q=36.06023%2C120.3024&#038;key=ABQIAAAAira30FR5tVprWCJ-8_WcqxSrc1zAT9YCtP2kOyoD7kBAJfliJBROJEdu9hUE13rp9a4OHneyOoW5gg&#038;mapclient=jsapi&#038;hl=zh-CN&#038;callback=myfunction">这个地址</a>的返回结果，数据非常丰富，并且还是中文的：</p>
<pre class="brush: jscript; collapse: true; light: false; title: ; toolbar: true; notranslate">
myfunction &amp;&amp; myfunction( {
  &quot;name&quot;: &quot;36.06023, 120.3024&quot;,
  &quot;Status&quot;: {
    &quot;code&quot;: 200,
    &quot;request&quot;: &quot;geocode&quot;
  },
  &quot;Placemark&quot;: [ {
    &quot;id&quot;: &quot;p1&quot;,
    &quot;address&quot;: &quot;中国山东省青岛市市南区台西三路6号-10号&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 8,
   &quot;Country&quot; : {
      &quot;AdministrativeArea&quot; : {
         &quot;AdministrativeAreaName&quot; : &quot;山东省&quot;,
         &quot;Locality&quot; : {
            &quot;DependentLocality&quot; : {
               &quot;DependentLocalityName&quot; : &quot;市南区&quot;,
               &quot;Thoroughfare&quot; : {
                  &quot;ThoroughfareName&quot; : &quot;台西三路6号-10号&quot;
               }
            },
            &quot;LocalityName&quot; : &quot;青岛市&quot;
         }
      },
      &quot;CountryName&quot; : &quot;中国&quot;,
      &quot;CountryNameCode&quot; : &quot;CN&quot;
   }
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0633254,
        &quot;south&quot;: 36.0570301,
        &quot;east&quot;: 120.3054361,
        &quot;west&quot;: 120.2991409
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3024027, 36.0602271, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p2&quot;,
    &quot;address&quot;: &quot;中国山东省青岛市市南区台西三路8号阿双美容美发厅&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 9,
   &quot;Country&quot; : {
      &quot;AdministrativeArea&quot; : {
         &quot;AdministrativeAreaName&quot; : &quot;山东省&quot;,
         &quot;Locality&quot; : {
            &quot;DependentLocality&quot; : {
               &quot;AddressLine&quot; : [ &quot;阿双美容美发厅&quot; ],
               &quot;DependentLocalityName&quot; : &quot;市南区&quot;,
               &quot;Thoroughfare&quot; : {
                  &quot;ThoroughfareName&quot; : &quot;台西三路8号&quot;
               }
            },
            &quot;LocalityName&quot; : &quot;青岛市&quot;
         }
      },
      &quot;CountryName&quot; : &quot;中国&quot;,
      &quot;CountryNameCode&quot; : &quot;CN&quot;
   }
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0632366,
        &quot;south&quot;: 36.0569414,
        &quot;east&quot;: 120.3055696,
        &quot;west&quot;: 120.2992744
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3024220, 36.0600890, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p3&quot;,
    &quot;address&quot;: &quot;中国青岛市市南区台西四路站&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 9,
   &quot;AddressLine&quot; : [ &quot;台西四路站&quot; ]
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0630636,
        &quot;south&quot;: 36.0567684,
        &quot;east&quot;: 120.3063986,
        &quot;west&quot;: 120.3001034
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3032510, 36.0599160, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p4&quot;,
    &quot;address&quot;: &quot;中国青岛市市南区云南路(台西四路口)站&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 9,
   &quot;AddressLine&quot; : [ &quot;云南路(台西四路口)站&quot; ]
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0643586,
        &quot;south&quot;: 36.0580634,
        &quot;east&quot;: 120.3073456,
        &quot;west&quot;: 120.3010504
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3041980, 36.0612110, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p5&quot;,
    &quot;address&quot;: &quot;中国青岛市市南区贵州路站&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 9,
   &quot;AddressLine&quot; : [ &quot;贵州路站&quot; ]
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0614856,
        &quot;south&quot;: 36.0551904,
        &quot;east&quot;: 120.3036956,
        &quot;west&quot;: 120.2974004
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3005480, 36.0583380, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p6&quot;,
    &quot;address&quot;: &quot;中国青岛市市南区团岛站&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 9,
   &quot;AddressLine&quot; : [ &quot;团岛站&quot; ]
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0629146,
        &quot;south&quot;: 36.0566194,
        &quot;east&quot;: 120.3022496,
        &quot;west&quot;: 120.2959544
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.2991020, 36.0597670, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p7&quot;,
    &quot;address&quot;: &quot;中国山东省青岛市市南区团岛四路海湾花园&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 9,
   &quot;Country&quot; : {
      &quot;AdministrativeArea&quot; : {
         &quot;AdministrativeAreaName&quot; : &quot;山东省&quot;,
         &quot;Locality&quot; : {
            &quot;DependentLocality&quot; : {
               &quot;AddressLine&quot; : [ &quot;海湾花园&quot; ],
               &quot;DependentLocalityName&quot; : &quot;市南区&quot;,
               &quot;Thoroughfare&quot; : {
                  &quot;ThoroughfareName&quot; : &quot;团岛四路&quot;
               }
            },
            &quot;LocalityName&quot; : &quot;青岛市&quot;
         }
      },
      &quot;CountryName&quot; : &quot;中国&quot;,
      &quot;CountryNameCode&quot; : &quot;CN&quot;
   }
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0642706,
        &quot;south&quot;: 36.0579754,
        &quot;east&quot;: 120.3006386,
        &quot;west&quot;: 120.2943434
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.2974910, 36.0611230, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p8&quot;,
    &quot;address&quot;: &quot;中国山东省青岛市市南区&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 4,
   &quot;Country&quot; : {
      &quot;AdministrativeArea&quot; : {
         &quot;AdministrativeAreaName&quot; : &quot;山东省&quot;,
         &quot;Locality&quot; : {
            &quot;DependentLocality&quot; : {
               &quot;DependentLocalityName&quot; : &quot;市南区&quot;
            },
            &quot;LocalityName&quot; : &quot;青岛市&quot;
         }
      },
      &quot;CountryName&quot; : &quot;中国&quot;,
      &quot;CountryNameCode&quot; : &quot;CN&quot;
   }
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0954205,
        &quot;south&quot;: 36.0413849,
        &quot;east&quot;: 120.4266629,
        &quot;west&quot;: 120.2858189
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3877350, 36.0667110, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p9&quot;,
    &quot;address&quot;: &quot;中国山东省青岛市&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 4,
   &quot;Country&quot; : {
      &quot;AdministrativeArea&quot; : {
         &quot;AdministrativeAreaName&quot; : &quot;山东省&quot;,
         &quot;Locality&quot; : {
            &quot;LocalityName&quot; : &quot;青岛市&quot;
         }
      },
      &quot;CountryName&quot; : &quot;中国&quot;,
      &quot;CountryNameCode&quot; : &quot;CN&quot;
   }
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.3313685,
        &quot;south&quot;: 35.9407727,
        &quot;east&quot;: 120.6326294,
        &quot;west&quot;: 120.0970459
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3827710, 36.0663480, 0 ]
    }
  }, {
    &quot;id&quot;: &quot;p10&quot;,
    &quot;address&quot;: &quot;中国山东省&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 2,
   &quot;Country&quot; : {
      &quot;AdministrativeArea&quot; : {
         &quot;AdministrativeAreaName&quot; : &quot;山东省&quot;
      },
      &quot;CountryName&quot; : &quot;中国&quot;,
      &quot;CountryNameCode&quot; : &quot;CN&quot;
   }
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 38.4055838,
        &quot;south&quot;: 34.3851760,
        &quot;east&quot;: 122.7159599,
        &quot;west&quot;: 114.8033683
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 117.0198960, 36.6692270, 0 ]
    }
  } ]
}
 )
</pre>
<p><strong>Yahoo提供的接口</strong></p>
<p>雅虎提供了一些经纬度查询接口，可以使用<a target="_blank" href="http://developer.yahoo.com/yql">YQL</a>查询。</p>
<p>查询语句为：</p>
<pre class="brush: sql; title: ; notranslate">select * from flickr.places where lat=36.06023 and lon=120.3024</pre>
<p>用法：</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
 function getPlaceFromFlickr(lat,lon,callback){
   // the YQL statement
   var yql = 'select * from flickr.places where lat='+lat+' and lon='+lon;

   // assembling the YQL webservice API
   var url = 'http://query.yahooapis.com/v1/public/yql?q='+
              encodeURIComponent(yql)+'&amp;format=json&amp;diagnostics='+
              'false&amp;callback='+callback;

   // create a new script node and add it to the document
   var s = document.createElement('script');
   s.setAttribute('src',url);
   document.getElementsByTagName('head')[0].appendChild(s);
 };

 // callback in case there is a place found
 function output(o){
   if(typeof(o.query.results.places.place) != 'undefined'){
     alert(o.query.results.places.place.name);
   }
 }

 // call the function with my current lat/lon
 getPlaceFromFlickr(36.6692270,117.0198960,'output');
&lt;/script&gt;
</pre>
<p>使用YQL进行更多地理信息查询，可以看这个PPT：<a target="_blank" href="http://www.wait-till-i.com/2010/03/11/yql-geo-library-and-introduction-to-geo-hacking-talk/">YQL Geo Library and Introduction to Geo Hacking talk</a></p>
<h3>5.经纬度解析</h3>
<p>经纬度解析就是通过地名取得经纬度数据，同样利用google那个请求地址，可以实现这一功能，请求地址格式为：</p>
<blockquote><p>http://ditu.google.cn/maps/geo?output=json&#038;oe=utf-8<br />
&#038;q=<em>地名的url encode编码</em><br />
&#038;key=<em>你申请到的key</em><br />
&#038;mapclient=jsapi&#038;hl=zh-CN&#038;callback=myfunction</p></blockquote>
<p>参数q为encodeURI(“中国山东省青岛市市北区”)，callback是jsonp回调函数名。</p>
<p><a target="_blank" href="http://ditu.google.cn/maps/geo?output=json&#038;oe=utf-8&#038;q=%E4%B8%AD%E5%9B%BD%E5%B1%B1%E4%B8%9C%E7%9C%81%E9%9D%92%E5%B2%9B%E5%B8%82%E5%B8%82%E5%8C%97%E5%8C%BA&#038;key=ABQIAAAAira30FR5tVprWCJ-8_WcqxSrc1zAT9YCtP2kOyoD7kBAJfliJBROJEdu9hUE13rp9a4OHneyOoW5gg&#038;mapclient=jsapi&#038;hl=zh-CN&#038;callback=myfunction">举个例子</a>，返回结果：</p>
<pre class="brush: jscript; collapse: true; light: false; title: ; toolbar: true; notranslate">
myfunction &amp;&amp; myfunction( {
  &quot;name&quot;: &quot;中国山东省青岛市市北区&quot;,
  &quot;Status&quot;: {
    &quot;code&quot;: 200,
    &quot;request&quot;: &quot;geocode&quot;
  },
  &quot;Placemark&quot;: [ {
    &quot;id&quot;: &quot;p1&quot;,
    &quot;address&quot;: &quot;中国山东省青岛市市北区&quot;,
    &quot;AddressDetails&quot;: {
   &quot;Accuracy&quot; : 4,
   &quot;Country&quot; : {
      &quot;AdministrativeArea&quot; : {
         &quot;AdministrativeAreaName&quot; : &quot;山东省&quot;,
         &quot;Locality&quot; : {
            &quot;DependentLocality&quot; : {
               &quot;DependentLocalityName&quot; : &quot;市北区&quot;
            },
            &quot;LocalityName&quot; : &quot;青岛市&quot;
         }
      },
      &quot;CountryName&quot; : &quot;中国&quot;,
      &quot;CountryNameCode&quot; : &quot;CN&quot;
   }
},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.1237216,
        &quot;south&quot;: 36.0515859,
        &quot;east&quot;: 120.4388307,
        &quot;west&quot;: 120.3107713
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3748010, 36.0876620, 0 ]
    }
  } ]
}
 )
</pre>
<h3>6.google maps 图片接口</h3>
<p>有时候我们只想展示简单的地图，不需要交互和拖动，可以通过google maps提供的<a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/staticmaps/" target="_blank">静态地图API</a>引入动态生成的地图图片，不过需要为你的域名申请一个key。</p>
<p>引入图片的url格式为：</p>
<pre class="brush: jscript; title: ; notranslate">

http://maps.google.com/maps/api/staticmap?

sensor=false
&amp;size=200x200
&amp;maptype=roadmap
&amp;key=&lt;em&gt;你申请到的KEY&lt;/em&gt;
&amp;markers=color:blue|label:1|37.4447,-122.161
&amp;markers=color:red|label:2|37.3385,-121.886
&amp;markers=color:green|label:3|37.3716,-122.038
&amp;markers=color:yellow|label:4|37.7792,-122.42
</pre>
<p>得到图片：</p>
<p><img src="http://maps.google.com/maps/api/staticmap?sensor=false&#038;size=400x250&#038;maptype=roadmap&#038;key=ABQIAAAANYuHabJr5Z8J0b86Q2gfvhR1W14e20gxBFMhpdYy_DdVp1kFtxTi-_5WaVDeQjdfRBmrQT3Diu153g&#038;markers=color:blue|label:1|37.4447,-122.161&#038;markers=color:red|label:2|37.3385,-121.886&#038;markers=color:green|label:3|37.3716,-122.038&#038;markers=color:yellow|label:4|37.7792,-122.42" alt="null" /></p>
<h3>后记</h3>
<p>关于地图的更多操作，可以参见以前的这篇文章：<a target="_blank" href="http://www.oncoding.cn/2009/google-maps-api/">Google Maps Api介绍与基础操作</a>。</p>
<p>随着互联网的发展，越来越多的功能可以在前端实现，出现了越来越多的强大的第三方服务，我们可以很方便的在我们的网站上加入一些实用的功能。这也许就是web2.0的魅力吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oncoding.cn/2010/geo-location-frontend/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>TED2010：下一代的地图技术在微软而非Google</title>
		<link>http://www.oncoding.cn/2010/bing-map-niubility/</link>
		<comments>http://www.oncoding.cn/2010/bing-map-niubility/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 14:16:25 +0000</pubDate>
		<dc:creator>j5726</dc:creator>
				<category><![CDATA[地图]]></category>
		<category><![CDATA[微软]]></category>

		<guid isPermaLink="false">http://www.oncoding.cn/?p=685</guid>
		<description><![CDATA[点击”View subtitles”可以显示中文字幕 TED2010上，来自微软的Blaise Aguera y Arcas展示了全新的结合虚拟现实体验的Bing地图技术，震撼了在场观众。如果你还在感慨Google街景，那么看看这个吧。看看他们怎么把流畅的街景技术和实时动态影像、天文景观结合在一起。让用户仿佛徜徉在异国他乡。街景也不再局限于街道，在一个小市场里，你可以看到你朋友拍得照片动态匹配到他曾经所看到的位置上。 看到他们的实时video，这种能够将影像和地图街景动态匹配的技术看起来非常炫，不知道多久会出现在Bing里面。 现在看来，整合了silverlight技术的Bing Map,将会对Google Maps最终形成非常大的挑战。]]></description>
			<content:encoded><![CDATA[<p><embed flashvars="vu=http://video.ted.com/talks/dynamic/BlaiseAguerayArcas_2010-medium.mp4&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/BlaiseAgueraYArcas-2010.embed_thumbnail.jpg&amp;vw=432&amp;vh=240&amp;ap=0&amp;ti=766&amp;introDuration=16500&amp;adDuration=4000&amp;postAdDuration=2000&amp;adKeys=talk=blaise_aguera;year=2010;theme=new_on_ted_com;theme=the_creative_spark;theme=a_taste_of_ted2010;event=TED2010;" allowfullscreen="true" bgcolor="#ffffff" wmode="transparent" pluginspace="http://www.macromedia.com/go/getflashplayer" src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" width="446" type="application/x-shockwave-flash" height="326"></embed></p>
<blockquote><p>点击”View subtitles”可以显示中文字幕</p></blockquote>
<p><span id="more-685"></span><br />
TED2010上，来自微软的Blaise Aguera y Arcas展示了全新的结合虚拟现实体验的Bing地图技术，震撼了在场观众。如果你还在感慨Google街景，那么看看这个吧。看看他们怎么把流畅的街景技术和实时动态影像、天文景观结合在一起。让用户仿佛徜徉在异国他乡。街景也不再局限于街道，在一个小市场里，你可以看到你朋友拍得照片动态匹配到他曾经所看到的位置上。</p>
<p>看到他们的实时video，这种能够将影像和地图街景动态匹配的技术看起来非常炫，不知道多久会出现在Bing里面。</p>
<p>现在看来，整合了silverlight技术的Bing Map,将会对Google Maps最终形成非常大的挑战。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oncoding.cn/2010/bing-map-niubility/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>居家旅行必备：全国170大城市公交地图列表</title>
		<link>http://www.oncoding.cn/2009/%e5%b1%85%e5%ae%b6%e6%97%85%e8%a1%8c%e5%bf%85%e5%a4%87%ef%bc%9a%e5%85%a8%e5%9b%bd170%e5%a4%a7%e5%9f%8e%e5%b8%82%e5%85%ac%e4%ba%a4%e5%9c%b0%e5%9b%be%e5%88%97%e8%a1%a8/</link>
		<comments>http://www.oncoding.cn/2009/%e5%b1%85%e5%ae%b6%e6%97%85%e8%a1%8c%e5%bf%85%e5%a4%87%ef%bc%9a%e5%85%a8%e5%9b%bd170%e5%a4%a7%e5%9f%8e%e5%b8%82%e5%85%ac%e4%ba%a4%e5%9c%b0%e5%9b%be%e5%88%97%e8%a1%a8/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 08:03:35 +0000</pubDate>
		<dc:creator>j5726</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[地图]]></category>

		<guid isPermaLink="false">http://www.oncoding.cn/?p=152</guid>
		<description><![CDATA[5.2M的页面，耐心等待，不全请刷新。。 建议保存到本地，方便随时查阅 地址:  http://oncoding.net/manuals/buslist.htm 示例： 青岛市 1路上行(湖北路-四方) 1路下行(四方-湖北路) 10路(板桥坊-板桥坊) 11路上行(极地海洋世界-榉林公园) 11路下行(榉林公园-极地海洋世界) 12路(海洋地质所-开封路) 12路区间(海洋地质所-沙岭庄) 15路(天泰体育场-天泰体育场) 19路上行(台东(菜市二路)-汽车东站) 19路下行(汽车东站-台东(菜市二路)) 101路(沧口公园-中韩小商品城) 102路上行(海游路-李村公园) 102路下行(李村公园-海游路) 103路(城阳十五中-李村) 104路上行(流清河-台东(威海路)) 104路下行(台东(威海路)-流清河) 105路(李村-流亭市场) 106路(李村-垭口) 106路区间(李村-小庄) 109路(李村公园-港西) 110路(台东(威海路)-北九水) 110路支线(台东(威海路)-仰口) 111路(百盛崂山店-郝家营社区) 112路(板桥坊-卧龙村) 113路(板桥坊-流清河) 113路区间1(板桥坊-崂山六中) 113路区间2(李村公园-海大崂山校区) 114路(李村公园-409医院) 。。。。]]></description>
			<content:encoded><![CDATA[<p>5.2M的页面，耐心等待，不全请刷新。。</p>
<p>建议保存到本地，方便随时查阅</p>
<p>地址:  <a id="url_2" onclick="return checkUrl(this)" href="http://oncoding.net/manuals/buslist.htm" target="_blank">http://oncoding.net/manuals/buslist.htm</a></p>
<p>示例：</p>
<div class="quote"></div>
<blockquote>
<div class="text">
<p><span style="font-size: medium;"><strong><a id="url_3" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bp&amp;cid=188" target="_blank">青岛市</a> </strong></span><br />
<a id="url_4" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=1%E8%B7%AF%E4%B8%8A%E8%A1%8C%28%E6%B9%96%E5%8C%97%E8%B7%AF-%E5%9B%9B%E6%96%B9%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">1路上行(湖北路-四方)</a><br />
<a id="url_5" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=1%E8%B7%AF%E4%B8%8B%E8%A1%8C%28%E5%9B%9B%E6%96%B9-%E6%B9%96%E5%8C%97%E8%B7%AF%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">1路下行(四方-湖北路)</a><br />
<a id="url_6" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=10%E8%B7%AF%28%E6%9D%BF%E6%A1%A5%E5%9D%8A-%E6%9D%BF%E6%A1%A5%E5%9D%8A%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">10路(板桥坊-板桥坊)</a><br />
<a id="url_7" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=11%E8%B7%AF%E4%B8%8A%E8%A1%8C%28%E6%9E%81%E5%9C%B0%E6%B5%B7%E6%B4%8B%E4%B8%96%E7%95%8C-%E6%A6%89%E6%9E%97%E5%85%AC%E5%9B%AD%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">11路上行(极地海洋世界-榉林公园)</a><br />
<a id="url_8" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=11%E8%B7%AF%E4%B8%8B%E8%A1%8C%28%E6%A6%89%E6%9E%97%E5%85%AC%E5%9B%AD-%E6%9E%81%E5%9C%B0%E6%B5%B7%E6%B4%8B%E4%B8%96%E7%95%8C%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">11路下行(榉林公园-极地海洋世界)</a><br />
<a id="url_9" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=12%E8%B7%AF%28%E6%B5%B7%E6%B4%8B%E5%9C%B0%E8%B4%A8%E6%89%80-%E5%BC%80%E5%B0%81%E8%B7%AF%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">12路(海洋地质所-开封路)</a><br />
<a id="url_10" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=12%E8%B7%AF%E5%8C%BA%E9%97%B4%28%E6%B5%B7%E6%B4%8B%E5%9C%B0%E8%B4%A8%E6%89%80-%E6%B2%99%E5%B2%AD%E5%BA%84%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">12路区间(海洋地质所-沙岭庄)</a><br />
<a id="url_11" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=15%E8%B7%AF%28%E5%A4%A9%E6%B3%B0%E4%BD%93%E8%82%B2%E5%9C%BA-%E5%A4%A9%E6%B3%B0%E4%BD%93%E8%82%B2%E5%9C%BA%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">15路(天泰体育场-天泰体育场)</a><br />
<a id="url_12" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=19%E8%B7%AF%E4%B8%8A%E8%A1%8C%28%E5%8F%B0%E4%B8%9C%28%E8%8F%9C%E5%B8%82%E4%BA%8C%E8%B7%AF%29-%E6%B1%BD%E8%BD%A6%E4%B8%9C%E7%AB%99%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">19路上行(台东(菜市二路)-汽车东站)</a><br />
<a id="url_13" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=19%E8%B7%AF%E4%B8%8B%E8%A1%8C%28%E6%B1%BD%E8%BD%A6%E4%B8%9C%E7%AB%99-%E5%8F%B0%E4%B8%9C%28%E8%8F%9C%E5%B8%82%E4%BA%8C%E8%B7%AF%29%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">19路下行(汽车东站-台东(菜市二路))</a><br />
<a id="url_14" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=101%E8%B7%AF%28%E6%B2%A7%E5%8F%A3%E5%85%AC%E5%9B%AD-%E4%B8%AD%E9%9F%A9%E5%B0%8F%E5%95%86%E5%93%81%E5%9F%8E%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">101路(沧口公园-中韩小商品城)</a><br />
<a id="url_15" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=102%E8%B7%AF%E4%B8%8A%E8%A1%8C%28%E6%B5%B7%E6%B8%B8%E8%B7%AF-%E6%9D%8E%E6%9D%91%E5%85%AC%E5%9B%AD%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">102路上行(海游路-李村公园)</a><br />
<a id="url_16" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=102%E8%B7%AF%E4%B8%8B%E8%A1%8C%28%E6%9D%8E%E6%9D%91%E5%85%AC%E5%9B%AD-%E6%B5%B7%E6%B8%B8%E8%B7%AF%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">102路下行(李村公园-海游路)</a><br />
<a id="url_17" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=103%E8%B7%AF%28%E5%9F%8E%E9%98%B3%E5%8D%81%E4%BA%94%E4%B8%AD-%E6%9D%8E%E6%9D%91%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">103路(城阳十五中-李村)</a><br />
<a id="url_18" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=104%E8%B7%AF%E4%B8%8A%E8%A1%8C%28%E6%B5%81%E6%B8%85%E6%B2%B3-%E5%8F%B0%E4%B8%9C%28%E5%A8%81%E6%B5%B7%E8%B7%AF%29%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">104路上行(流清河-台东(威海路))</a><br />
<a id="url_19" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=104%E8%B7%AF%E4%B8%8B%E8%A1%8C%28%E5%8F%B0%E4%B8%9C%28%E5%A8%81%E6%B5%B7%E8%B7%AF%29-%E6%B5%81%E6%B8%85%E6%B2%B3%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">104路下行(台东(威海路)-流清河)</a><br />
<a id="url_20" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=105%E8%B7%AF%28%E6%9D%8E%E6%9D%91-%E6%B5%81%E4%BA%AD%E5%B8%82%E5%9C%BA%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">105路(李村-流亭市场)</a><br />
<a id="url_21" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=106%E8%B7%AF%28%E6%9D%8E%E6%9D%91-%E5%9E%AD%E5%8F%A3%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">106路(李村-垭口)</a><br />
<a id="url_22" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=106%E8%B7%AF%E5%8C%BA%E9%97%B4%28%E6%9D%8E%E6%9D%91-%E5%B0%8F%E5%BA%84%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">106路区间(李村-小庄)</a><br />
<a id="url_23" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=109%E8%B7%AF%28%E6%9D%8E%E6%9D%91%E5%85%AC%E5%9B%AD-%E6%B8%AF%E8%A5%BF%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">109路(李村公园-港西)</a><br />
<a id="url_24" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=110%E8%B7%AF%28%E5%8F%B0%E4%B8%9C%28%E5%A8%81%E6%B5%B7%E8%B7%AF%29-%E5%8C%97%E4%B9%9D%E6%B0%B4%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">110路(台东(威海路)-北九水)</a><br />
<a id="url_25" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=110%E8%B7%AF%E6%94%AF%E7%BA%BF%28%E5%8F%B0%E4%B8%9C%28%E5%A8%81%E6%B5%B7%E8%B7%AF%29-%E4%BB%B0%E5%8F%A3%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">110路支线(台东(威海路)-仰口)</a><br />
<a id="url_26" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=111%E8%B7%AF%28%E7%99%BE%E7%9B%9B%E5%B4%82%E5%B1%B1%E5%BA%97-%E9%83%9D%E5%AE%B6%E8%90%A5%E7%A4%BE%E5%8C%BA%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">111路(百盛崂山店-郝家营社区)</a><br />
<a id="url_27" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=112%E8%B7%AF%28%E6%9D%BF%E6%A1%A5%E5%9D%8A-%E5%8D%A7%E9%BE%99%E6%9D%91%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">112路(板桥坊-卧龙村)</a><br />
<a id="url_28" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=113%E8%B7%AF%28%E6%9D%BF%E6%A1%A5%E5%9D%8A-%E6%B5%81%E6%B8%85%E6%B2%B3%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">113路(板桥坊-流清河)</a><br />
<a id="url_29" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=113%E8%B7%AF%E5%8C%BA%E9%97%B41%28%E6%9D%BF%E6%A1%A5%E5%9D%8A-%E5%B4%82%E5%B1%B1%E5%85%AD%E4%B8%AD%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">113路区间1(板桥坊-崂山六中)</a><br />
<a id="url_30" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=113%E8%B7%AF%E5%8C%BA%E9%97%B42%28%E6%9D%8E%E6%9D%91%E5%85%AC%E5%9B%AD-%E6%B5%B7%E5%A4%A7%E5%B4%82%E5%B1%B1%E6%A0%A1%E5%8C%BA%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">113路区间2(李村公园-海大崂山校区)</a><br />
<a id="url_31" onclick="return checkUrl(this)" href="http://ditu.pojaa.com/#tab=bu&amp;for=bt&amp;name=114%E8%B7%AF%28%E6%9D%8E%E6%9D%91%E5%85%AC%E5%9B%AD-409%E5%8C%BB%E9%99%A2%29&amp;city=%E9%9D%92%E5%B2%9B%E5%B8%82" target="_blank">114路(李村公园-409医院)</a></p>
<p>。。。。</p></div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.oncoding.cn/2009/%e5%b1%85%e5%ae%b6%e6%97%85%e8%a1%8c%e5%bf%85%e5%a4%87%ef%bc%9a%e5%85%a8%e5%9b%bd170%e5%a4%a7%e5%9f%8e%e5%b8%82%e5%85%ac%e4%ba%a4%e5%9c%b0%e5%9b%be%e5%88%97%e8%a1%a8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Maps Api介绍与基础操作</title>
		<link>http://www.oncoding.cn/2009/google-maps-api/</link>
		<comments>http://www.oncoding.cn/2009/google-maps-api/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 14:52:59 +0000</pubDate>
		<dc:creator>j5726</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[地图]]></category>
		<category><![CDATA[Google Maps API]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.oncoding.cn/?p=699</guid>
		<description><![CDATA[一. 关于Google Maps Api “API”，即“应用程序编程接口”，是指软件或网站为第三方开发人员提供的接口，利用这个接口，可以使用软件的一些功能而不必了解它的内部机理。 具体拿Google Maps Api来说，它提供了一个JavaScript库，具体就是我们上节课在页面头部引入的这个url：http://ditu.google.com/maps?file=api&#38;v=2&#38;key=KEY ，它会自动载入地图所需的js文件，Firefox肿的Firebug插件是前端开发必备工具，使用它我们可以方便的查看网页的内容，可以看到Google Maps Api引入的几个JS文件： ( Google Maps Api引入的文件 ) Google Maps Api的作用是，将Google Maps服务器上的地图图片和数据下载到客户端并正确显示，显示程序定义的地标点、折线和多边形，实现地址搜索、驾车导航等扩展功能。你可以在网页中直接调用它定义的类和方法，而不必了解它的运行机制，当然这些js文件是可见的，需要的话你可以重载它的函数，来实现你想要的功能。 二. 概览Google Maps Api 使用Google Maps Api必不可少的东西就是其开发手册：http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html 我们可以看到，Google Maps Api的地图的显示、标点、划线等操作包含59个类，空间、叠加层等包含18个类。 看到这个长达一百多屏的参考手册，是不是有点晕？不要着急，在本节及以后的讲解中，我们只会学习并使用其中一部分的类来实现我们的功能。 三. 在自己的项目中使用Google Maps Api Google Maps Api采用申请密钥的方式授权使用，每个密钥只能对应一个网站，当然，任何一个密钥都可以在Localhost上使用：），申请地址：http://code.google.com/intl/zh-CN/apis/maps/signup.html 我们为apus.net.cn申请了一个密钥： 申请密钥成功 Google Map调用方式 申请成功的页面上给出了三种API调用方式：“JavaScript Maps API”、“Maps API for Flash”、“HTTP Service”，我们使用第一种 — JavaScript Maps API。 OK，下面我们一起看下Google Maps [...]]]></description>
			<content:encoded><![CDATA[<h3>一. 关于Google Maps Api</h3>
<p>“API”，即“应用程序编程接口”，是指软件或网站为第三方开发人员提供的接口，利用这个接口，可以使用软件的一些功能而不必了解它的内部机理。</p>
<p>具体拿Google Maps Api来说，它提供了一个JavaScript库，具体就是我们上节课在页面头部引入的这个url：http://ditu.google.com/maps?file=api&amp;v=2&amp;key=KEY ，它会自动载入地图所需的js文件，Firefox肿的Firebug插件是前端开发必备工具，使用它我们可以方便的查看网页的内容，可以看到Google Maps Api引入的几个JS文件：</p>
<p style="text-align: center;"><a href="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308Bgb.png" target="_blank"><img class="aligncenter" src="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308Bgb.png" alt="" width="435" height="206" /></a><br />
( Google Maps Api引入的文件 )<br />
<span id="more-699"></span><br />
Google Maps Api的作用是，将Google Maps服务器上的地图图片和数据下载到客户端并正确显示，显示程序定义的地标点、折线和多边形，实现地址搜索、驾车导航等扩展功能。你可以在网页中直接调用它定义的类和方法，而不必了解它的运行机制，当然这些js文件是可见的，需要的话你可以重载它的函数，来实现你想要的功能。</p>
<p>二. 概览Google Maps Api</p>
<p>使用Google Maps Api必不可少的东西就是其开发手册：<a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html</a></p>
<p>我们可以看到，Google Maps Api的地图的显示、标点、划线等操作包含59个类，空间、叠加层等包含18个类。<br />
看到这个长达一百多屏的参考手册，是不是有点晕？不要着急，在本节及以后的讲解中，我们只会学习并使用其中一部分的类来实现我们的功能。</p>
<p>三. 在自己的项目中使用Google Maps Api</p>
<p>Google Maps Api采用申请密钥的方式授权使用，每个密钥只能对应一个网站，当然，任何一个密钥都可以在Localhost上使用：），申请地址：http://code.google.com/intl/zh-CN/apis/maps/signup.html<br />
我们为apus.net.cn申请了一个密钥：</p>
<p style="text-align: center;"><a href="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308J70.png" target="_blank"><img class="aligncenter" src="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308J70.png" alt="" width="548" height="469" /></a><br />
申请密钥成功</p>
<p style="text-align: center;"><a href="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308J70.png" target="_blank"><img class="aligncenter" src="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308J70.png" alt="" width="548" height="469" /></a><br />
Google Map调用方式</p>
<p>申请成功的页面上给出了三种API调用方式：“JavaScript Maps API”、“Maps API for Flash”、“HTTP Service”，我们使用第一种 —  JavaScript Maps API。</p>
<p>OK，下面我们一起看下Google Maps API如何引入地图，和一些基本的操作。</p>
<h3>四. Google Maps Api基本功能</h3>
<h4>1.加载并显示地图</h4>
<p>我们首先要加载Google Maps Api并显示了地图，</p>
<pre class="brush: xml; title: ; notranslate">
 &lt;!DOCTYPE html &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
  &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
  &lt;head&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
    &lt;title&gt;显示地图&lt;/title&gt;
    &lt;!--引入Google Maps JS文件，此处key=你申请到的key--&gt;
    &lt;script src=&quot;http://ditu.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAAira30FR5tVprWCJ-8_WcqxSrc1zAT9YCtP2kOyoD7kBAJfliJBROJEdu9hUE13rp9a4OHneyOoW5gg&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
      //initMap()函数，将地图程序加入页面
      function initMap() {
        if (GBrowserIsCompatible()) {
          //在ID为&quot;Gmap&quot;的层内显示地图
          var map = new GMap2(document.getElementById(&quot;Gmap&quot;));
          //设置地图中心点和缩放级别
          map.setCenter(new GLatLng(36.167, 120.407), 10);
        }
      }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload=&quot;initMap()&quot; onunload=&quot;GUnload()&quot;&gt;
    &lt;!--定义显示地图的层--&gt;
    &lt;div id=&quot;Gmap&quot; style=&quot;width: 600px; height: 400px&quot;&gt;&lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>这样，我们就很轻松的在网页上显示出了Google地图：</p>
<p style="text-align: center;"><a href="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308iT6.png" target="_blank"><img class="aligncenter" src="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203308iT6.png" alt="" width="438" height="373" /></a></p>
<p>GMap2是Api中的中心类，作用为在给定的容器DIV中创建地图。可选参数opts.size可以设置地图大小，默认使用容器DIV的大小。</p>
<p><a href="/demos/gmap/loadmap.html" target="_blank">查看演示&gt;&gt;</a></p>
<h4>2.添加控件</h4>
<p>Google Maps的控件包括左侧的“鱼骨”控件和比例尺、右侧的地图类型按钮和小地图。</p>
<p>现在我们加载常用的四种控件：</p>
<pre class="brush: jscript; title: ; notranslate">
          //加载大“鱼骨”，包含方向、缩放按钮和缩放级别控制滑块
          map.addControl(new GLargeMapControl());
          //加载地图类型按钮
          map.addControl(new GMapTypeControl());
          //加载小地图
          map.addControl(new GOverviewMapControl());
          //加载比例尺
          map.addControl(new GScaleControl());
</pre>
<p>此外，还有四种类型的控件，可以在小尺寸地图上选用：</p>
<p>GSmallMapControl() 小“鱼骨”，仅包含方向、缩放按钮<br />
GSmallZoomControl() 更小“鱼骨”，仅包含缩放按钮<br />
GMenuMapTypeControl()  下拉框式地图类型选择<br />
GHierarchicalMapTypeControl()  按钮、下拉框组合式地图类型选择</p>
<p>具体见Api参考中的class GControl   <a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GControlImpl" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GControlImpl</a></p>
<p><a href="/demos/gmap/addctrl.html" target="_blank">查看演示&gt;&gt;</a></p>
<h4>3. 在地图上添加标注</h4>
<p>基本步骤为：定义一个经纬度点GLatLng，定义一个标注对象GMarker，在地图上加入标注GMap2.addOverlay()</p>
<pre class="brush: jscript; title: ; notranslate">
          //定义一个经纬度点
          var point = new GLatLng(36.07868, 120.3599);
          //定义一个标注对象
          var marker = new GMarker(point);
          //在地图上加入标注
          map.addOverlay(marker);
</pre>
<p>我们还可以为这个标注添加气泡提示，这些要在addOverlay()之前定义：</p>
<pre class="brush: jscript; title: ; notranslate">
          //定义字符串
          var info = &quot;这是我的家&lt;br/&gt;&lt;font color='red'&gt;市北区宁夏路**号&lt;/font&gt;&quot;;
          //设置点击出现气泡，内容为预先定义的HTML字串
          marker.bindInfoWindowHtml(info);
</pre>
<p><a href="/demos/gmap/addpoint.html" target="_blank">查看演示&gt;&gt;</a></p>
<p>关于标注的其他操作、冒泡的方式内容等，还有几个其他的方法，具体可以阅读Api参考的class GMarker：     <a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GMarker" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GMarker</a></p>
<h4>4. 显示折线GPolyline、多边形GPolygon</h4>
<p>在我们的Apus项目中，显示旅行路径、活动范围必不可少的地图要素就是折线和多边形，</p>
<p>在地图中添加折线的方法非常简单，下面这段程序显示了直升机从我爷爷家飞到学校放下行李然后去金沙滩游玩的路线^_^：</p>
<pre class="brush: jscript; title: ; notranslate">
          //定义一个折线对象
          polyline = new GPolyline([
            //定义这线上的三个折点、线条颜色、宽度、透明度
            new GLatLng(36.07868,120.3599),
            new GLatLng(36.00259,120.1227),
            new GLatLng(35.95482,120.2426)
            ], //折点对象数组
            &quot;#ff6600&quot;, //线条颜色
            3, //线条宽度
            0.9 //线条透明度
            );
          //将折线加入地图
          map.addOverlay(polyline);
</pre>
<p><a href="/demos/gmap/addline.html" target="_blank">查看演示&gt;&gt;</a></p>
<p>其他操作参见GPolyline类参考： <a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GPolyline" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GPolyline</a></p>
<p>GPolyline的构造函数：GPolyline(latlngs,  color?,  weight?,  opacity?,  opts?)</p>
<p>其中opts? 为可选参数，class GPolylineOptions定义的属性，包括折线是否可点击clickable、表现地球弧度geodesic。<br />
添加多边形的原理和折线类似：</p>
<pre class="brush: jscript; title: ; notranslate">
          //定义一个多边形对象
          polygon = new GPolygon(
            [
               new GLatLng(36.17477,120.37609),
               new GLatLng(36.09167,120.49577),
               new GLatLng(36.06035,120.30181),
               new GLatLng(36.17477,120.37609)
            ], //折点对象数组
            &quot;#FF6600&quot;, //线条颜色
            4, //线条宽度
            0.8, //线条透明度
            &quot;#66FF00&quot;, //填充颜色
            0.5 //填充透明度
            );
          //将多边形加入地图
          map.addOverlay(polygon);
</pre>
<p><a href="/demos/gmap/addgon.html" target="_blank">查看演示&gt;&gt;</a></p>
<p>其他操作参见GPolygon类参考： <a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GPolygon" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GPolygon</a></p>
<p>GPolyline的构造函数： GPolygon(latlngs,  strokeColor?, strokeWeight?,  strokeOpacity?,  fillColor?,  fillOpacity?,  opts?)<br />
其class GPolygonOptions只包含clickable，即是否可点。</p>
<h4>5. 经纬度编码</h4>
<p>阅读了上边的内容，你可能会产生这样的疑问：如果一条轨迹或区域包含了成百上千个拐点，那岂不是很麻烦。没错，这里我们可以使用一个办法把这些点信息放在一串编码后的简短的字符串里，交给客户端去解码并显示，而我们的网络仅需要传输这一串编码，这里我们要用到GPolyline和GPolygon的工厂方法fromEncoded，</p>
<p>它的原型为：fromEncoded(color?,  weight?, opacity?,  latlngs, zoomFactor,  levels, numLevels)<br />
我们以一个例子来演示它，下面的代码展示了这样的路线：我们乘坐上面那架直升机，从轮渡码头飞往栈桥观光，但栈桥没有停机坪，我们只好转道飞往江苏路教堂游览，稍作停留后回到了宁夏路家中。</p>
<pre class="brush: jscript; title: ; notranslate">
          //编码
          polyline  = new GPolyline.fromEncoded({
            color: &quot;#FF6600&quot;,
            weight: 3,
            opacity: 0.9,
            /*
            未编码的折点数据：
            new GLatLng(36.066570000000006,120.30366000000001),
            new GLatLng(36.05875,120.32037000000001),
            new GLatLng(36.072480000000006,120.32842000000001),
            new GLatLng(36.079930000000004,120.35917)
            */
            points: agc{E{xg}Uzo@mgBytAiq@qm@e_E,  //折点编码
            zoomFactor: 32,  //levels字符串中邻近缩放级别集合之间的放大倍率
            levels: &quot;BBBB&quot;,  //缩放级别编码
            numLevels: 4  //levels字符串中包含的缩放级别数
          });
         map.addOverlay(polyline);
 </pre>
<p><a href="/demos/gmap/encode.html" target="_blank">查看演示&gt;&gt;</a></p>
<p>可以看到，编码后的数据变得非常轻巧，但是这一串字符是怎样编出来的呢？Google给出了一个在线编码工具，</p>
<p>中文版地址(目前有错误无法使用)：<a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/polylineutility.html" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/polylineutility.html</a></p>
<p>英文版地址(目前可用)：<a href="http://code.google.com/apis/maps/documentation/polylineutility.html" target="_blank">http://code.google.com/apis/maps/documentation/polylineutility.html</a></p>
<p>这可以作为练习时的快速编码工具，但在实际的项目开发中，我们不可能把用户的每个点都手工去编码，由于<a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/polylinealgorithm.html" target="_blank">编码的算法是公开的</a> ，我们可以自己编写程序来进行编码，这里有Javascript版和PHP版的编码程序：<a href="http://oncoding.cn/2009/gmaps-encode.html">http://oncoding.cn/2009/gmaps-encode.html</a></p>
<h3>五. Google Maps Api高级功能介绍</h3>
<h4>1.地址解析与逆地址解析</h4>
<p>所谓“地址解析”，是指根据地点名称得到经纬度坐标；“逆地址解析”则是根据经纬度坐标得出其地点名称。这一功能在实际的地图开发中尤为有用。</p>
<p>Google Maps Api中的GClientGeocoder类提供了这一系列的功能，类参考见： <a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GClientGeocoder" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/reference.html#GClientGeocoder</a></p>
<p>举一个小例子来试一下，下面程序返回“栈桥”的坐标</p>
<pre class="brush: jscript; title: ; notranslate">
          //地址解析
          geocoder = new GClientGeocoder();
          geocoder.getLatLng('栈桥', function(response) {
            alert (response);
          });
</pre>
<p>运行结果：</p>
<blockquote><p>栈桥的坐标：(36.0647287, 120.3184891)</p></blockquote>
<p>getLatLng方法的作用是返回查询地点的经纬度坐标；</p>
<p>另外一个方法getLocations，则同时具备了地址解析和逆地址解析的功能，它可以传入地点名称或坐标值，返回包括坐标、城市等更详细的数据。</p>
<pre class="brush: jscript; title: ; notranslate">
     //initMap()函数，将地图程序加入页面
      function initMap() {
        //GBrowserIsCompatible()确定Api能否兼容当前浏览器
        if (GBrowserIsCompatible()) {
          //在ID为&quot;Gmap&quot;的层内显示地图
          var map = new GMap2(document.getElementById(&quot;Gmap&quot;));
          //设置地图中心点和缩放级别
          map.setCenter(new GLatLng(36.09778, 120.37236), 12);
          //地址解析getLocations
          var geocoder = new GClientGeocoder();
          geocoder.getLocations('栈桥', function(response) {
            place = response.Placemark[0];
            point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
            marker = new GMarker(point);
            map.addOverlay(marker);
            marker.openInfoWindowHtml(getGeocodeHtml(response));
          });
       }
     }
     //组装冒泡内的HTML数据
     function getGeocodeHtml(response){
       pname = response.name;
       paddress = response.Placemark[0].address;
       plat = response.Placemark[0].Point.coordinates[1];
       plon = response.Placemark[0].Point.coordinates[0];
       return(&quot;地点：&quot;+pname+&quot;&lt;br /&gt;位置：&quot;+paddress+&quot;&lt;br /&gt;坐标：&quot;+plat+&quot;,&quot;+plon);
     }
</pre>
<p><a href="/demos/gmap/geocodelocations.html" target="_blank"> 查看演示&gt;&gt;</a></p>
<p>getLocations以JSON格式返回如下数据，其Placemark可能有许多个，在实际使用时需要考虑多个返回值的情况。JSON格式是一种在JavaScript中使用非常简单方便的数据格式：</p>
<pre class="brush: jscript; title: ; notranslate">
{
  &quot;name&quot;: &quot;栈桥&quot;,
  &quot;Status&quot;: {
    &quot;code&quot;: 200,
    &quot;request&quot;: &quot;geocode&quot;
  },
  &quot;Placemark&quot;: [ {
    &quot;id&quot;: &quot;p1&quot;,
    &quot;address&quot;: &quot;栈桥, 青岛市&quot;,
    &quot;AddressDetails&quot;: {&quot;AddressLine&quot;:[&quot;栈桥&quot;],&quot;Accuracy&quot;: 9},
    &quot;ExtendedData&quot;: {
      &quot;LatLonBox&quot;: {
        &quot;north&quot;: 36.0678763,
        &quot;south&quot;: 36.0615811,
        &quot;east&quot;: 120.3216367,
        &quot;west&quot;: 120.3153415
      }
    },
    &quot;Point&quot;: {
      &quot;coordinates&quot;: [ 120.3184891, 36.0647287, 0 ]
    }
  } ]
}
</pre>
<h4>2. 本地搜索</h4>
<p>我们可以在地图上加入一个位置搜索框，只需要短短几行代码：</p>
<pre class="brush: jscript; title: ; notranslate">
          //在ID为&quot;Gmap&quot;的层内显示地图，设置加载搜索框
          var map = new GMap2(document.getElementById(&quot;Gmap&quot;),
                                                    {googleBarOptions: {showOnLoad : true}} );
          ....

          //加入搜索框
          map.enableGoogleBar();
</pre>
<p><a href="/demos/gmap/search.html" target="_blank">查看演示&gt;&gt;</a></p>
<p>如果要使用更多可定制性的搜索，可以使用Google Ajax Search Api： <a href="http://code.google.com/intl/zh-CN/apis/ajaxsearch/" target="_blank">http://code.google.com/intl/zh-CN/apis/ajaxsearch/</a> ，以后我们需要的话会进一步学习。</p>
<h4>3. 驾车路线：</h4>
<p>使用GDirections类可以获取驾车路线：</p>
<pre class="brush: jscript; title: ; notranslate">
          //驾车导航
          driveLine = new GDirections(map);
          driveLine.load(&quot;from: 青岛 to: 烟台&quot;, { &quot;locale&quot;: &quot;zh-CN&quot; });
</pre>
<p><a href="/demos/gmap/drive.html" target="_blank">查看演示&gt;&gt;</a></p>
<h4>4. 静态地图</h4>
<p>上一节课说过，Google Maps提供三种形式的API，其中一种是“静态地图API”，所谓静态，就是只生成一张图片，不会有任何交互功能。这种方式特别适用于手机的地图应用。</p>
<p>例如：http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203309iz4.jpg</p>
<p>得到图片：</p>
<p style="text-align: center;"><a href="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203309iz4.jpg" target="_blank"><img class="aligncenter" src="http://www.oncoding.cn/wp-content/uploads/09img/2010/03/203309iz4.jpg" alt="" width="420" height="280" /></a></p>
<p>参数：center=地图中心点&amp;zoom=缩放级别&amp;size=宽x高&amp;markers=第一个标点经度,纬度,颜色字母|第二个标点经度,纬度,颜色字母…&amp;key=你的KEY</p>
<h4>5. KML</h4>
<p>KML是用于描述和保存地理信息（如点、线、图像、多边形和模型等）的一种数据语言，它以被Google Earth和Google Maps方便的识别并显示。现在很多便携式GPS设备和手机软件可以生成KML格式的路径文件，事实上已经成为了GPS设备的标准路径文件格式。<br />
以下是一个KML文件的格式：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;kml xmlns=&quot;http://earth.google.com/kml/2.1&quot;&gt;
&lt;Document&gt;
 &lt;name&gt;zhanqiao.kml&lt;/name&gt;
 &lt;Style id=&quot;sh_ylw-pushpin&quot;&gt;
  &lt;IconStyle&gt;
   &lt;scale&gt;1.3&lt;/scale&gt;
   &lt;Icon&gt;
    &lt;href&gt;http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png&lt;/href&gt;
   &lt;/Icon&gt;
   &lt;hotSpot x=&quot;20&quot; y=&quot;2&quot; xunits=&quot;pixels&quot; yunits=&quot;pixels&quot;/&gt;
  &lt;/IconStyle&gt;
 &lt;/Style&gt;
 &lt;Style id=&quot;sn_ylw-pushpin&quot;&gt;
  &lt;IconStyle&gt;
   &lt;scale&gt;1.1&lt;/scale&gt;
   &lt;Icon&gt;
    &lt;href&gt;http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png&lt;/href&gt;
   &lt;/Icon&gt;
   &lt;hotSpot x=&quot;20&quot; y=&quot;2&quot; xunits=&quot;pixels&quot; yunits=&quot;pixels&quot;/&gt;
  &lt;/IconStyle&gt;
 &lt;/Style&gt;
 &lt;StyleMap id=&quot;msn_ylw-pushpin&quot;&gt;
  &lt;Pair&gt;
   &lt;key&gt;normal&lt;/key&gt;
   &lt;styleUrl&gt;#sn_ylw-pushpin&lt;/styleUrl&gt;
  &lt;/Pair&gt;
  &lt;Pair&gt;
   &lt;key&gt;highlight&lt;/key&gt;
   &lt;styleUrl&gt;#sh_ylw-pushpin&lt;/styleUrl&gt;
  &lt;/Pair&gt;
 &lt;/StyleMap&gt;
 &lt;Placemark&gt;
  &lt;name&gt;zhanqiao&lt;/name&gt;
  &lt;LookAt&gt;
   &lt;longitude&gt;120.3157798974425&lt;/longitude&gt;
   &lt;latitude&gt;36.05886498176855&lt;/latitude&gt;
   &lt;altitude&gt;0&lt;/altitude&gt;
   &lt;range&gt;739.971375569545&lt;/range&gt;
   &lt;tilt&gt;4.084272649574626e-011&lt;/tilt&gt;
   &lt;heading&gt;-0.1127864185136748&lt;/heading&gt;
  &lt;/LookAt&gt;
  &lt;styleUrl&gt;#msn_ylw-pushpin&lt;/styleUrl&gt;
  &lt;Point&gt;
   &lt;coordinates&gt;120.3152418576393,36.05858830488904,0&lt;/coordinates&gt;
  &lt;/Point&gt;
 &lt;/Placemark&gt;
&lt;/Document&gt;
&lt;/kml&gt;
</pre>
<p>其中包含主要的标签：Document，Document包含kml的文件信息和显示样式以及所有的地标点信息，每个地标信息对应一个Placemark标签。</p>
<blockquote><p>KML中Placemark中主要标签的定义：<br />
name   该地标名称<br />
description   地标描述，支持HTML代码<br />
LookAt    试图相关信息<br />
styleUrl   样式<br />
Point  地标点</p></blockquote>
<p><a href="/demos/gmap/kml.html" target="_blank">查看演示&gt;&gt;</a></p>
<p>更具体的信息：<a href="http://www.step1.cn/googleapi/map/kml.htm" target="_blank">http://www.step1.cn/googleapi/map/kml.htm</a></p>
<p>编程处理KML文件：</p>
<pre class="brush: jscript; title: ; notranslate">
          //GGeoXml对象，处理KML文件
          var gXml = new GGeoXml(&quot;http://oncoding.net/demos/zhanqiao.kml&quot;);
          //将KML内容在地图上显示
          map.addOverlay(gXml);
</pre>
<h3>后记</h3>
<p>本节所有示例程序的压缩包可以在这里下载：http://code.google.com/p/apus/downloads/list 。注意要改成你自己的KEY，才能正常运行。</p>
<p>这篇文章其实是自己以前计划写的Google Maps API网站开发教程中的一节，后来因为种种原因，没能坚持吧教程写完。现在把这一节单独整理出来，作为一个Google Maps API的入门教程吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oncoding.cn/2009/google-maps-api/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>国产先行——比Google抢先的中国街景地图</title>
		<link>http://www.oncoding.cn/2009/china_street_view/</link>
		<comments>http://www.oncoding.cn/2009/china_street_view/#comments</comments>
		<pubDate>Thu, 14 May 2009 02:16:17 +0000</pubDate>
		<dc:creator>j5726</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[地图]]></category>
		<category><![CDATA[街景]]></category>

		<guid isPermaLink="false">http://www.oncoding.cn/?p=141</guid>
		<description><![CDATA[Google由于法律问题迟迟未能进入中国拍摄街景地图，而中国有公司已经抢了先，并且数据已相当丰富，拍摄完成了许多县级市的地图，一起欣赏一下： http://www.city8.com/ 青岛教堂 爷爷家的老房子 地图很新，说不定就能看到逛街的你 哈哈，Here 另外他们提供了收费API，可以开发很多好玩的应用：http://www.dujiala.com/]]></description>
			<content:encoded><![CDATA[<p>Google由于法律问题迟迟未能进入中国拍摄街景地图，而中国有公司已经抢了先，并且数据已相当丰富，拍摄完成了许多县级市的地图，一起欣赏一下： <a href="http://www.city8.com/" target="_blank">http://www.city8.com/</a></p>
<p><a href="http://www.oncoding.cn/wp-content/uploads/2009/05/sview.png"><img class="aligncenter size-full wp-image-142" title="街景地图" src="http://www.oncoding.cn/wp-content/uploads/2009/05/sview.png" alt="" width="500" height="204" /></a></p>
<p style="text-align: center;">青岛教堂</p>
<p style="text-align: center;"><span id="more-141"></span></p>
<p><a href="http://www.oncoding.cn/wp-content/uploads/2009/05/sview1.png"><img class="aligncenter size-full wp-image-143" title="街景地图" src="http://www.oncoding.cn/wp-content/uploads/2009/05/sview1.png" alt="" width="498" height="308" /></a></p>
<p style="text-align: center;">爷爷家的老房子</p>
<p><a href="http://www.oncoding.cn/wp-content/uploads/2009/05/sview4.png"><img class="aligncenter size-full wp-image-144" title="街景地图" src="http://www.oncoding.cn/wp-content/uploads/2009/05/sview4.png" alt="" width="498" height="308" /></a></p>
<p style="text-align: center;">地图很新，说不定就能看到逛街的你</p>
<p><a href="http://www.oncoding.cn/wp-content/uploads/2009/05/sview3.png"><img class="aligncenter size-full wp-image-145" title="街景地图" src="http://www.oncoding.cn/wp-content/uploads/2009/05/sview3.png" alt="" width="500" height="308" /></a></p>
<p style="text-align: center;">哈哈，Here</p>
<p style="text-align: left;">另外他们提供了收费API，可以开发很多好玩的应用：http://www.dujiala.com/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oncoding.cn/2009/china_street_view/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Maps经纬度编码算法的JavaScript及PHP实现</title>
		<link>http://www.oncoding.cn/2009/gmaps-encode/</link>
		<comments>http://www.oncoding.cn/2009/gmaps-encode/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 07:00:14 +0000</pubDate>
		<dc:creator>j5726</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[前端]]></category>
		<category><![CDATA[地图]]></category>
		<category><![CDATA[Google Maps]]></category>

		<guid isPermaLink="false">http://www.oncoding.cn/?p=133</guid>
		<description><![CDATA[Google Maps API 的 GPolyline和GPolygon类提供了工厂方法fromEncoded，可以将大量的经纬度信息编码为简短的字符串，方便网络传输和存储。 这里是Google对此算法的说明：http://code.google.com/intl/zh-CN/apis/maps/documentation/polylinealgorithm.html 这里是Google在线编码程序英文版(中文版目前出错不可用)：http://code.google.com/apis/maps/documentation/polylineutility.html 由于我们在实际开发中会经常对经纬度信息进行编码，在服务端使用PHP编码发送，在客户端使用JavaScript编码提交，今天对这两种语言的编码程序进行了整理，发出来共享，有需要的可以下载。 另外本人正在编写一系列PHP+Google Maps API的网站开发教程，欢迎关注，教程地址：oncoding.net 点击下载 幼学笔记原创内容，根据CC协议发布，欢迎具名转载。]]></description>
			<content:encoded><![CDATA[<p>Google Maps API 的 GPolyline和GPolygon类提供了工厂方法fromEncoded，可以将大量的经纬度信息编码为简短的字符串，方便网络传输和存储。</p>
<p>这里是Google对此算法的说明：<a href="http://code.google.com/intl/zh-CN/apis/maps/documentation/polylinealgorithm.html" target="_blank">http://code.google.com/intl/zh-CN/apis/maps/documentation/polylinealgorithm.html</a></p>
<p>这里是Google在线编码程序英文版(中文版目前出错不可用)：<a href="http://code.google.com/apis/maps/documentation/polylineutility.html" target="_blank">http://code.google.com/apis/maps/documentation/polylineutility.html</a></p>
<p>由于我们在实际开发中会经常对经纬度信息进行编码，在服务端使用PHP编码发送，在客户端使用JavaScript编码提交，今天对这两种语言的编码程序进行了整理，发出来共享，有需要的可以下载。</p>
<p>另外本人正在编写一系列PHP+Google Maps API的网站开发教程，欢迎关注，教程地址：<a href="http://oncoding.net" target="_blank">oncoding.net</a></p>
<p><a href="http://www.oncoding.cn/wp-content/uploads/2009/04/GmapEncode.zip" target="_blank">点击下载</a></p>
<p style="text-align: right;"><a href="http://www.oncoding.cn/2009/gmaps-encode/">幼学笔记</a>原创内容，根据<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/">CC协议</a>发布，欢迎具名转载。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oncoding.cn/2009/gmaps-encode/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

