Google驱动器中包含的KML文件无法识别 [英] The KML file included in google drive that does not recognize

查看:49
本文介绍了Google驱动器中包含的KML文件无法识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Google Maps应用程序中显示KML文件.我使用了 Google Map api文档.

I have tried Displaying KML files in my google Maps application. I used google map api documentation for that.

当我加载HTML文件时,它仅显示google map.我认为有关KML文件的问题.我如何解决它 ..?我已将KML文件上传到我的Google驱动器中,并以知道链接的任何人都可以编辑"的方式共享.但是Google Maps API的示例正在运行... !!

when I load my HTML file, it show only google map. I think this problem about KML file. How do i fix it ..? I have upload KML file into my google drive and I share it as "anyone with the link can edit". However Google Maps API's example is working...!!

这是代码:-

<script>
var map;
var src = 'https://drive.google.com/open?id=0B5oAxCVEQK5uZ0tJcFBDaGRfajg';

 function initialize() {
 map = new google.maps.Map(document.getElementById('map'), {
     center: new google.maps.LatLng(7.742291, 80.529785),
     zoom: 7,
     mapTypeId: google.maps.MapTypeId.TERRAIN
 });
 loadKmlLayer(src, map);
 }

  var kmlUrl = 'https://drive.google.com/open?id=0B5oAxCVEQK5uZ0tJcFBDaGRfajg';
 var kmlOptions = {
 suppressInfoWindows: true,
 preserveViewport: false,
 map: map
  };
 var kmlLayer = new google.maps.KmlLayer(kmlUrl, kmlOptions);

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;
    });}
     google.maps.event.addDomListener(window, 'load', initialize);
 </script>

推荐答案

这是该问题的解决方案.整个代码正确,而且kml文件正确.关键是,我们无法将kml文件放入Google Drive或Dropbox中.您必须将KML文件托管在服务器上.为此,您可以使用 Google协作平台托管您的KML .

This is the solution for the question. This whole code is correct, and also kml file is correct. The point is, we are unable to put kml file in google Drive or Dropbox. you must host the KML file on a server. for that you can use Google Sites to host Your KML.

可能有用:-在Google地图中显示KML 和google api以下

May be useful :- Display KML in a Google Map and below google api

https://developers.google.com/maps/documentation/javascript/tutorials/kml#overview

这篇关于Google驱动器中包含的KML文件无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆