August 5,2005 07:56
Google Maps API Browser Compability
基本上,Google Maps API 的 Browser Compability 做的蠻好的,幾乎可以不用擔心不同瀏覽器是不是會有不同的行為。但是最近幾天用了 GPolyline 在我自己的地圖上畫線,我原本都是用 Firefox 來測試,一切都是那麼完美,前幾天忽然想到,應該開 IE 起來測試才對,這時卻發現,線畫不出來,甚至連整個地圖的行為都怪怪的,我苦思不解,明明都是按照著文件的範例寫的啊,為什麼 Google 網頁上的範例可以正常運作,我寫的就不行,連續追了兩三天的臭蟲,最後終於在文件的一開始看到這段話:
XHTML and VML
We recommend that you use standards-compliant XHTML on pages that
contain maps. When browsers see the XHTML DOCTYPE at the
top of the page, they execute the page in "standards compliant mode," which
makes layout and behaviors much more predictable across browsers.
Likewise, if you include Polylines on your map, you need to include the VML namespace in your XHTML document for IE browsers. Your HTML document should begin like this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<style type="text/css">
v\:* {
behavior:url(#default#VML);
}
</style>
<script src="http://maps.google.com/maps?file=api&v=1&key=abcdefg" type="text/javascript"></script>
</head>
See Microsoft's VML workshop for more information.
原來是我自己沒一開始就把文件看仔細。:P
不過這樣一來就有點傷腦筋了,如果要讓 IE 也能正常顯示,那我就沒辦法在我自己的 blog 中安插一個 Google Maps 並在上面畫圖了,有辦法在 html tag 之外的地方安插 namespaces 嗎?
引用URL
http://cgi.blog.roodo.com/trackback/340618
回應文章 
我注意到就算你加了這些還不一定可以跑...
| 檢舉 |
Posted by Andy
at August 20,2005 08:02
