【问题标题】:how to set the center of map in kml file如何在kml文件中设置地图的中心
【发布时间】:2011-02-06 21:56:42
【问题描述】:

http://code.google.com/intl/en/apis/kml/documentation/kml_tut.html

我想创建一个 kml 文件,但我找不到如何使用 google-maps-v3 设置地图中心

那么如何设置。

谢谢

【问题讨论】:

    标签: kml google-maps-api-3


    【解决方案1】:

    Maps API V3 目前不支持 KML 叠加层。然而,这是一个计划中的功能。

    【讨论】:

      【解决方案2】:

      请尝试我在 OpenLayers 中使用的这个简短示例,这是一个供专业程序员使用的 JavaScript 地图库。

      <html>
      <head>
      <title>My OpenLayers: Google Layer</title>
      <link rel="shortcut icon" href="http://www.gis.com.my/logo.ico" type="image/x-icon"/>
      <link rel="stylesheet" href="http://openlayers.org/api/theme/default/style.css" type="text/css" />
      <link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css" />
      <!-- this gmaps key generated for http://localhost:8080/geoserver/ -->
      <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAl9RMqSzhPUXAfeBCXOussRTQDbvAygy0cfGJr8dEMAYKf3RWNBQqP9mjKIsqTfmAlz5LOJ3Xpy5s4w'></script>
      <script src="http://openlayers.org/api/OpenLayers.js"></script>
      <script type="text/javascript">
      var map;
      function init() {
      // Create the map object
      map = new OpenLayers.Map('map');
      // Create a Google layer
      var gmap = new OpenLayers.Layer.Google(
      "Google Streets", // the default
      {numZoomLevels: 20}
      );
      // Add layer to map
      map.addLayer(gmap);
      // Zoom to Kuala Lumpur, Malaysia
      map.setCenter(new OpenLayers.LonLat(101.686855,3.139003), 13);         
      }
      </script>
      </head>
      <body onload="init()">
      <h1 id="title">My OpenLayers: Google Layer</h1>
      <div id="map" style='width: 700px; height: 700px'></div>
      </body>
      </html>
      

      请注意,google-maps-v3 被强制居中。正如您在我制作的以下代码中看到的那样: map.setCenter(new OpenLayers.LonLat(101.686855,3.139003), 13);

      The LonLat 位于吉隆坡。请记住,它与您学生时代的地理科目完全不同,因为经度是 x 坐标。纬度是y坐标。请参考笛卡尔坐标原理。

      祝你好运。


      问候,

      zearth

      【讨论】:

        猜你喜欢
        • 2016-03-03
        • 2019-03-06
        • 1970-01-01
        • 1970-01-01
        • 2010-12-05
        • 1970-01-01
        • 2016-01-16
        • 1970-01-01
        • 2020-03-04
        相关资源
        最近更新 更多