Clip Google Maps JS API ImageMapType to a polygon

后端 未结 6 1699
梦毁少年i
梦毁少年i 2021-02-04 23:21

How can I clip a MapType in Google Maps to an arbitrary polygon. For example, if I have a custom ImageMapType that covers a large area (i.e. all the world), but I want to show i

6条回答
  •  春和景丽
    2021-02-05 00:03

    You could use an svg clippath, together with the foreignobject svg tag to put a html document within the svg then clip it to the desired shape like this code taken from codepen.io/yoksel/pen/oggRwR:

    @import url(http://fonts.googleapis.com/css?family=Arvo:700);
    
    .svg {
      display: block;
      width: 853px;
      height: 480px;
      margin: 2em auto;
    	}
    
    text {
      font: bold 5.3em/1 Arvo, Arial sans-serif;
    	}
    
        
          
          Soldier Of Fortune
        
      
           
       	
          
            
          
        
       	
    

    http://codepen.io/yoksel/pen/oggRwR

提交回复
热议问题