Google 地图 API 中特定国家/地区的缩放级别

Country specific zoom level in Google Maps API

我正在尝试制作只显示荷兰的 Google 地图。但是,当我使用缩放级别 6 时,它也会显示比利时和德国,而当我使用缩放级别 7 时,它会放大太多,无法显示完整的国家/地区。

如何让荷兰只显示,而不显示德国和比利时(或至少是其中的一小部分)。

目前看起来像这样:

  1. 转到http://www.gadm.org/download, download the adm0 file for the Netherlands

  2. 将该多边形(作为内环)与覆盖整个地球的多边形合并

  3. 使用 winding reversal tool 反转任何不与外环相对的内部多边形。

  4. 压缩生成的 kml,重命名为 kmz。使用 geoxml3

  5. 在地图上显示

代码:

function initialize() {
    var map = new google.maps.Map(
    document.getElementById("map_canvas"), {
        center: new google.maps.LatLng(85.4419, -122.1419),
        zoom: 13,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    var geocoder = new google.maps.Geocoder();
    var geoXml = new geoXML3.parser({
                    map: map,
                    zoom: false, 
                 });
    geoXml.parse("http://www.geocodezip.com/geoxml3_test/kmz/nld_adm0_inverted.kmz");
    google.maps.event.addListener(geoXml,'parsed', function() {
      geocoder.geocode( { 'address': "Netherlands"}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          map.fitBounds(results[0].geometry.viewport);
        } else {
          alert("Geocode was not successful for the following reason: " + status);
        }
      });    
    })
}
google.maps.event.addDomListener(window, "load", initialize);

Working example

要限制它始终显示在地图上,请参阅this page from Mike Williams' v2 tutorial

working example