【问题标题】:Basic KML with Google Map API not working带有 Google Map API 的基本 KML 不起作用
【发布时间】:2014-03-15 23:14:13
【问题描述】:

我尝试了我的第一个带有 KML 的 Google Map API,它轰炸了我。似乎只是一个非常基本的问题,但无法让它发挥作用。

这里是脚本标签:

 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> </script>

这里是 Javascript:

$(document).ready(function () {
 map_center = new google.maps.LatLng(-34.397, 150.644);
 var mapOptions = {
      zoom: 8,
      center: map_center
  };
  var kml_map = new google.maps.Map(document.getElementById('map_div'), mapOptions); 
  var kml_layer = new google.maps.KmlLayer({
          preserveViewport: true,
         url: 'http://someurl/mykml.kml' //Of course, I am using a valid URL here for "someurl" 
   }); 
  kml_layer.setMap(kml_map);
});

这是 KML 文件:

 <?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://www.opengis.net/kml/2.2">
  <Placemark>
 <name>My placemark!</name>
 <description>Some description of my placemark.</description>
 <Point>
 <coordinates>-34.397, 150.644</coordinates>
 </Point>
 </Placemark>
 </kml>

我没有看到地标。我看到整个星球的谷歌地图没有缩放……没有别的。我哪里错了?控制台中也没有错误。

【问题讨论】:

  • 如果您在 Google 地图上显示 KML 会发生什么?
  • 您的 KML 是否使用正确的 MIME type 提供服务?
  • 验证者说coordinates tuple is not within the valid latitude range of +/-90 [1].
  • KML坐标为经度、纬度;不允许有空格。
  • @geocodezip 如果您将“不允许空格”的评论作为答案,我会接受。

标签: javascript google-maps-api-3 kml


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-07
    • 2015-03-22
    • 2016-12-05
    • 1970-01-01
    • 2012-06-02
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多