2017-03-22 11 views
0

Google Maps APIをGoogle Mapsプラットフォームで直接作成し、.kmlファイルにエクスポートして使用しようとしています。使用されたガイドはGoogle Developerのポータルで利用可能な主要なものでした。GoogleマップでのKMLファイルのインポートと解析

ただし、KMLファイルが正しく読み込まれない可能性があります。 http://1c.1contact.ch/mandats/map1.html

(それはhttps://developers.google.com/maps/documentation/javascript/kmllayerから適応された)マップが怒鳴るで接続し、ロードするコードは:

<script> 
    var map; 
    var src = 'http://1c.1contact.ch/file/2573/GE.kml'; 

    /** 
    * Initializes the map and calls the function that loads the KML layer. 
    */ 
    function initMap() { 
    map = new google.maps.Map(document.getElementById('map'), { 
    center: new google.maps.LatLng(-19.257753, 146.823688), 
    zoom: 2, 
    mapTypeId: 'terrain' 
    }); 
    loadKmlLayer(src, map); 
    } 

    /** 
    * Adds a KMLLayer based on the URL passed. Clicking on a marker 
    * results in the balloon content being loaded into the right-hand div. 
    * @param {string} src A URL for a KML file. 
    */ 
    function loadKmlLayer(src, map) { 
    var kmlLayer = new google.maps.KmlLayer(src, { 
    suppressInfoWindows: true, 
    preserveViewport: false, 
    map: map 
    }); 
    google.maps.event.addListener(kmlLayer, 'click', function(event) { 
    var content = event.featureData.infoWindowHtml; 
    var testimonial = document.getElementById('capture'); 
    testimonial.innerHTML = content; 
    }); 
    } 
</script> 

この.KMLの使用を達成するために適切な方法は何ですか?

幸運を祈り、

答えて

0

KMLは、指定しますファイル(http://1c.1contact.ch/file/2573/GE.kml)それはウェブ上で公的にアクセスできないため、ロードされません。そのサーバー上のログインページの後ろに表示されます。ブラウザでログインしていても、Googleマップのコードとレンダリングシステムはそのファイルにアクセスできないため、一般のユーザーがアクセスできる場所に置く必要があります。

関連する問題