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

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

    I sketched up this CodePen example utilizing the gmaps-labels class. It is based on the fiddle in the Q above and adds the ose of a LabelOverlay class. The class requires a new google.maps.LatLng, dimensions (in LatLng units) of a box centered around the label's point (If the label would overflow this box, hide it, and some CSS. Heres a code stub, check out the demo in the CodePen.

    var MIN_BOX_H = 0.0346, 
        MIN_BOX_W = 0.121,
        MAX_BOX_H = 0.001, 
        MAX_BOX_W = 0.03;
    
    
    
    var overlay1 = new LabelOverlay({
        ll      : myLatlng,
    
        minBoxH     : MIN_BOX_H,
        minBoxW     : MIN_BOX_W,
    
        maxBoxH     : MAX_BOX_H,
        maxBoxW     : MAX_BOX_W,
    
       ...
    
       label        : "I want on top",
       map      : map
    });
    

提交回复
热议问题