问题描述
我试图在Google Maps V3中将MapLabel放置在Polygon的顶部。我试图将MapLabel zIndex设置为2,将Polygon zIndex设置为1,但没有任何运气。这是不可能的,因为Polygon并不真正遵循zIndex?
我为你们创建了一个jsFiddle来检查:
解决方案: strong>在 maplabel.js
更改:
mapPane.appendChild(canvas );
到:
floatPane.appendChild(画布);
原因是因为 floatPane
高于一切地图图层(面板6)
如果你不想使用 这可能是后期发现的,但希望有人会发现这有用。 / code>(John的解决方案),因为这将始终处于最佳状态,并且想要提供自定义zIndex。编辑 maplabel.js 。在 MapLabel.prototype.onAdd = function(){ 现在您可以传递 I'm trying to place a MapLabel on top of a Polygon in Google Maps V3. I've tried to set the MapLabel zIndex to 2 and the Polygon zIndex to 1 without any luck. Isn't this possible since the Polygon doesn't really follow zIndex? I've created a jsFiddle for you guys to check out: http://jsfiddle.net/7wLWe/1/ Solution: In to: The reason is because http://code.google.com/apis/maps/documentation/javascript/reference.html#OverlayView This is probably a late find.. but hope someone would find this useful. If you don't want to use Now you can pass 这篇关于在Google Maps V3中将MapLabel放置在Polygon的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! floatPane
结束之前添加以下行if(canvas.parentNode!= null){
canvas.parentNode.style.zIndex = style.zIndex;
zIndex $ c $创建一个 maplabel :
var mapLabel = new MapLabel({
text :abc,
位置:center,
map:map,
fontSize:8,
align:'left',
zIndex:15
});
maplabel.js
change:mapPane.appendChild(canvas);
floatPane.appendChild(canvas);
floatPane
is above all map layers (pane 6)floatPane
(John's Solution) as this will be always on top of everything, and want to give a custom zIndex.. Edit the maplabel.js. Add the following line just before the end of MapLabel.prototype.onAdd = function() {if (canvas.parentNode != null) {
canvas.parentNode.style.zIndex = style.zIndex;
}
zIndex
while creating a maplabel:var mapLabel = new MapLabel({
text: "abc",
position: center,
map: map,
fontSize: 8,
align: 'left',
zIndex: 15
});