我有一個層節點功能,我可能要顯示兩個圖像,主要和背景之一。本頁面:http://openlayers.org/dev/examples/marker-shadow.html顯示了我想要的:陰影在黃金項目下(當我們用開發工具移動png時,這一點更加明顯)。 爲此,他們使用:OpenLayers:如何獲得backgroundGraphic去下externalGraphic
// Set the external graphic and background graphic images.
externalGraphic: "../img/marker-gold.png",
backgroundGraphic: "./img/marker_shadow.png",
// Makes sure the background graphic is placed correctly relative
// to the external graphic.
backgroundXOffset: 0,
backgroundYOffset: -7,
// Set the z-indexes of both graphics to make sure the background
// graphics stay in the background (shadows on top of markers looks
// odd; let's not do that).
graphicZIndex: MARKER_Z_INDEX, //11
backgroundGraphicZIndex: SHADOW_Z_INDEX, //10
顯然,這不是真正的CSS的z-index因爲DOM元素都有到底z-index: auto
。但不管,我想這個嘗試我自己(而不是在層結構但事後):顯示
style["backgroundGraphic"] = './img/marker-shadow.png';
style["externalGraphic"] ='./img/marker-gold.png';
style['graphicZIndex'] = 1;
style['backgroundGraphicZIndex'] = style['graphicZIndex']-1;
的圖像。但是,當人們可以認爲背景圖形會自動進入外部圖形時,實際上會發生相反的情況。好吧,我只是添加Z指數的東西:
style['graphicZIndex'] = 1;
style['backgroundGraphicZIndex'] = style['graphicZIndex']-1;
但它絕對沒有改變。我如何獲得我的背景?
我很想看到這個演示/例子。 – Joel