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

后端 未结 5 856
时光说笑
时光说笑 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:59

    If you don't want to touch maplabel.js, you can add this function to change the z-index of the parent of the labels (although if you have other canvas elements, you may need to alter the function):

    //change the z-index of the canvas elements parents to move them above polygon layer
    google.maps.event.addListenerOnce(map, 'idle', function(){
    //var canvasElements = document.getElementsByTagName('canvas');//plain js to get the elements
    var canvasElements = jQuery('canvas'); //jquery for easy cross-browser support
        for(var i=0; i

提交回复
热议问题