0

我正在使用Google Maps API. 我来自南非,想展示一张南非地图,上面清楚地标明了各省的边界。我的南非网页上有地图,但我不知道如何让用户更容易看到各省的边界。有浅灰色的虚线,我假设是各省的边界线?

我的地图 HTML 容器:

<div id="map-canvas"></div>

我的 JavaScript:

<script type="text/javascript">
     var map;

     function initialize() {
          var mapOptions = {
               center: new google.maps.LatLng(-33.49559749315654, 20.93444836718755),
               zoom: 8,
               mapTypeId: google.maps.MapTypeId.ROADMAP
          };
          map = new google.maps.Map(document.getElementById("map-canvas"),
               mapOptions);
     }

     google.maps.event.addDomListener(window, 'load', initialize);
</script>

如何使南非各省的边界线更暗。

4

1 回答 1

0

您需要自己绘制边框。

最简单的方法:使用 FusionTableLayer,这是一个包含各省几何形状的 FusionTable:https ://www.google.com/fusiontables/DataSource?docid=16L-UK_1OZxGw6DlKR8V8yP4XZrtmNdOMugRRNrQ#map:id=3

用法:

<script type="text/javascript">
  function initialize() {
     var map = new google.maps.Map(document.getElementById('map-canvas'), {
      center: new google.maps.LatLng(-33.49559749315654, 20.93444836718755),
               zoom: 4,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    //create the layer
    layer = new google.maps.FusionTablesLayer({
      map: map,
      //the layer doesn't need to be clickable
      clickable:false,
      query: {
      //column with the geometry
        select: "col2",
      //table-ID
        from: "16L-UK_1OZxGw6DlKR8V8yP4XZrtmNdOMugRRNrQ",
        where: ""
      },
      styles: [{
        polygonOptions: {
        //border-color
        strokeColor: "#000000",
        //border-width
        strokeWeight: 2,
        //hide the fill
        fillOpacity:0.0001
      }}]
    });
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>
于 2013-10-21T13:39:14.250 回答