2011-03-12 45 views
1

我知道如何嵌入一個公共GMAP:我可以試用一個公共GMap,然後通過編程修改它嗎?

 <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=207932289133051333830.000457f61fc6dcab1aff1&amp;ll=46.495556,11.359863&amp;spn=0.017726,0.025749&amp;z=14&amp;output=embed"></iframe> 

我也知道如何使用JavaScript創建和程序,我想一個。我試圖做的是結合兩種方法: 我嵌入公共gmap,但隨後以編程方式修改它(或(更好)在它的頂部添加覆蓋)。這可能嗎?任何例子?

+0

你說的 「修改」 究竟是什麼意思? – 2011-03-12 18:41:51

+0

相關:http://code.google.com/intl/zh-CN/apis/maps/documentation/javascript/demogallery.html – 2011-03-12 18:42:15

+0

相關:http://stackoverflow.com/questions/2199421/combine-google-maps -api-google-maps-data-api – simpatico 2011-03-12 19:13:26

回答

1

給它一個ID,然後你可以找到它並改變它。

<iframe id="MyFrame" width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=207932289133051333830.000457f61fc6dcab1aff1&amp;ll=46.495556,11.359863&amp;spn=0.017726,0.025749&amp;z=14&amp;output=embed"></iframe> 

然後使用:

document.getElementById("MyFrame") 

然後你就可以用一套setAttribute()

更多改變這個元素的屬性:Change HTML class attribute using javascript

+0

但我該如何創建一個覆蓋設置屬性?基本上我需要改變一些特定的標記圖標。 – simpatico 2011-03-12 18:55:51

0

你需要使用谷歌地圖API添加標記。

查看Google Maps V3 API demo gallery中的custom marker example。代碼太長,無法在此複製+粘貼,但它應該回答您的基本問題。

更多基本的東西,看一下將M aps API code samples.

+0

不,這不是。 http://gmaps-samples-v3.googlecode.com/svn/trunk/overlayview/custommarker.html – simpatico 2011-03-13 07:40:12

+0

@simpatico你能更詳細地描述你想要什麼嗎? – 2011-03-13 09:15:13

相關問題