【问题标题】:How to remove the international date line (IDL) and equator from Google Maps API v3?如何从 Google Maps API v3 中删除国际日期变更线 (IDL) 和赤道?
【发布时间】:2014-02-20 15:38:48
【问题描述】:

根据标题,我想从我的地图中删除 IDL 和赤道线。我正在使用以下代码:

<script src="https://maps.googleapis.com/maps/api/js?key=KEY&sensor=false"></script>
<script>
var locations = [
['<p>Location 1<br/> <a href="http://example.com/location1">Click here for more info</a></p>', 64.8436, -147.7231, 1],
['<p>Location 2<br/> <a href="http://example.com/location2">Click here for more info</a></p>', 33.4500, -112.0667, 2],
['<p>Location 3<br/> <a href="http://example.com/location3">Click here for more info</a></p>', 34.0500, -118.2500, 3],
['<p>Location 4<br/> <a href="http://example.com/location4">Click here for more info</a></p>', 32.7150, -117.1625, 4],
];

var map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: new google.maps.LatLng(19.4328, -99.1333),
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
overviewMapControl: false
});

var infowindow = new google.maps.InfoWindow();

var marker, i;

for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
    position: new google.maps.LatLng(locations[i][1], locations[i][2]),
    map: map
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
    return function() {
        infowindow.setContent(locations[i][0]);
        infowindow.open(map, marker);
    }
})(marker, i));
}

</script>

我对此很陌生,任何帮助将不胜感激。

【问题讨论】:

    标签: google-maps google-maps-api-3 google-maps-styled


    【解决方案1】:

    根据this post,您需要在风格化地图上设置一些未记录的属性。这可能会移除 IDL 和赤道以外的其他要素。

     var map = new google.maps.Map(document.getElementById('map'), {
     zoom: 2,
     center: new google.maps.LatLng(19.4328, -99.1333),
     mapTypeControl: false,
     scaleControl: false,
     streetViewControl: false,
     overviewMapControl: false
     });
    
     var mapStyle = [
          {
             featureType: "administrative",
             elementType: "geometry.fill",
             stylers: [
                { visibility: "off" }
             ]
           }
      ];
     var styledMap = new google.maps.StyledMapType(mapStyle);
     map.mapTypes.set('myCustomMap', styledMap);
     map.setMapTypeId('myCustomMap');
    

    http://jsfiddle.net/stevejansen/pBh6p/

    【讨论】:

    • 它并不是真正的无证。有documentation here。然而,我们不知道每种功能类型的确切内容。但这似乎有效!这里的答案很好。
    • 嗨@MrUpsidown,你是对的。也许“记录不充分”更公平。 geometry.fill 的文档为“将规则应用于特征几何的填充”。这让我很困惑。我很难将其翻译为“显示/隐藏 IDL 和赤道特征”。
    猜你喜欢
    • 1970-01-01
    • 2021-11-28
    • 2011-02-25
    • 1970-01-01
    • 2012-03-19
    • 2015-07-16
    • 1970-01-01
    • 2011-12-19
    • 2011-10-07
    相关资源
    最近更新 更多