开发者

Problem in Overlaying KML files on google Map displayed in Browser

We are in the process of overlaying some KML files on Google Map displayed in Browser. The KML files when displayed on the normal Google Maps works as expected. But, when displayed in the google Map displayed in the browser the KML files are not getting displayed as expected. The KML files are generated by converting the Shape files开发者_运维问答 using an online converter tool.

We used the original shape files and retrieved county information from US Census Bureau Site.

Need Help in resolving the issue.


It would be helpful if you've provided the code that you're using, or the .kml file, so I can see where it goes wrong.

Anyway, you can add a kml to your map like this:

<html> 
<head> 
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
    <script type="text/javascript"> 
        function initialize() {
          new google.maps.KmlLayer('http://api.flickr.com/services/feeds/geo/?g=322338@N20&lang=en-us&format=feed-georss').setMap(
            new google.maps.Map(document.getElementById("map_canvas"), {mapTypeId: google.maps.MapTypeId.ROADMAP})
          );
        }
    </script> 
</head> 

<body onload="initialize()"> 
  <div id="map_canvas" style="position:absolute;bottom:0;left:0;right:0;top:0"></div> 
</body> 
</html> 


How are you creating your KmlLayer?

The URL passed into the constructor of the KmlLayer must be a publicly accessible one so that Google's server can retrieve the KML/KMZ then render it on the tile which it returns to you.

var layer = new google.maps.KmlLayer('http://this/must/not/be/localhost/file.kmz');

As seen in Google Maps v3 API Reference:

A KmlLayer adds geographic markup to the map from a KML, KMZ or GeoRSS file that is hosted on a publicly accessible web server.

Keep in mind there are also limits imposed on the KML and KMZ files. Information on this can be found here: http://code.google.com/apis/kml/documentation/mapsSupport.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜