我怎样才能在他们的面具中转换KML多边形'等效实体?

时间:2016-11-29 08:55:39

标签: google-maps kml

我有KML文件,我想和我想让世界其他地方变得灰暗,只能看到我的国家。但是KML也没有显示,我怎么能这样做http://www.vasile.ch/hacks/ft-mask/

KML File



function initMap() {
   var myLatLng = {lat: 19.0760, lng: 72.8777};    
   var map = new google.maps.Map(document.getElementById('map-canvas'), {
       zoom: 5,
       center: new google.maps.LatLng(22.4913, 78.9000),
       mapTypeId: google.maps.MapTypeId.ROADMAP,
       disableDefaultUI: true      
   }); 
   var geocoder = new google.maps.Geocoder();
   var geoXml = new geoXML3.parser({
       map: map,
       singleInfoWindow: false,        
   });
   geoXml.parse('India_KML.kml'); 
   google.maps.event.addListener(geoXml,'parsed', function() {
       geocoder.geocode( { 'address': "India"},function(results, status) {
           if (status == google.maps.GeocoderStatus.OK) {
               map.fitBounds(results[0].geometry.viewport);
           } else {
               alert("Geocode was not successful for the following reason: " + status);
           }
       });    
   })
}
window.onload = initMap;

#map-canvas { 
  height: 100%; 
  width: 100%; 
  position:absolute; 
  top: 0; 
  left: 0; 
  z-index: 0;
  zoom:0.8;
}		

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?region=IN&libraries=places"></script>

<div id="map-canvas"></div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

来自链接的副本:How to invert KML so that area outside of polygon is highlighted

  

更改您的KML。为覆盖整个世界的多边形添加外边界。确保外多边形的缠绕方向与内多边形的缠绕方向相反。

<kml xmlns='http://www.opengis.net/kml/2.2'>
    <Document>      
        <Folder>            
            <Placemark>             
                <styleUrl>#poly-A52714-1-77</styleUrl>

                <Polygon>
<outerBoundaryIs><LinearRing><coordinates>180,85 180,0 180,-85 90,-85 0,-85 -90,-85 -180,-85 -180,0 -180,85 -90, 85 0,85 90, 85 180,85
<!--
180,85 90,85 0,85 -90,85 -180,85 -180,0 -180,-85 -90,-85 0,-85 90,-85 180,-85 180,0 180,85 
-->
</coordinates></LinearRing></outerBoundaryIs>
<innerBoundaryIs>
                        <LinearRing>                            
                            <coordinates>
                               73.6523438,36.8796206,0.0 73.125,36.7036596,0.0 <!-- ... snip -->
                            </coordinates>
                        </LinearRing>
</innerBoundaryIs>
                </Polygon>
            </Placemark>
        </Folder>
<!-- snip -->
    </Document>
</kml>

example with "fixed" KML

enter image description here