Placing a MapLabel on top of a Polygon in Google Maps V3

后端 未结 5 854
时光说笑
时光说笑 2020-12-14 19:29

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

5条回答
  •  悲哀的现实
    2020-12-14 19:40

    This is probably a late find.. but hope someone would find this useful.

    If you don't want to use 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;
    }
    

    Now you can pass zIndex while creating a maplabel:

    var mapLabel = new MapLabel({
        text: "abc",
        position: center,
        map: map,
        fontSize: 8,
        align: 'left',
        zIndex: 15
    });
    

提交回复
热议问题