有没有办法让我的底图在Google Map API V3中亮起

时间:2019-07-11 09:15:48

标签: google-maps-api-3

Google的底图非常重,因为它具有所有图层。 我想通过在渲染时清除一些图层来使其轻量化,以便快速加载,并且在将对象添加到地图中(例如标记或线条)时,它也清晰可见。我有一个用例,其中客户不需要详细的地图,因为它的重要性较低。客户希望对象清晰美观。

我试图通过关闭某些图层来摆脱某些图层,但是更改没有得到反映。

函数initialize() {

  var roadAtlasStyles = [
                         {
                           featureType: 'road.highway',
                           elementType: 'geometry',
                           stylers: [
                             { visibility: 'on' }
                           ]
                         },{
                           featureType: 'road.arterial',
                           elementType: 'all',
                           stylers: [
                                     { visibility: 'on' }
                                   ]
                         },{
                           featureType: 'road.local',
                           elementType: 'all',
                           stylers: [
                                     { visibility: 'off' }
                                   ]
                         },{
                           featureType: 'water',
                           elementType: 'geometry',
                           stylers: [
                                     { visibility: 'on' }
                                   ]
                         },{
                           featureType: 'road.highway',
                           elementType: 'labels',
                           stylers: [
                                     { visibility: 'on' }
                                   ]
                         },
                         {
                               featureType: 'poi',
                               elementType: 'labels',
                               stylers: [
                                         { visibility: 'off' }
                                       ]
                          },{
                           featureType: 'administrative',
                           elementType: 'labels',
                           stylers: [
                                     { visibility: 'on' }
                                   ]
                         },{
                           featureType: 'transit.station.rail',
                           elementType: 'geometry',
                           stylers: [
                                     { visibility: 'off' }
                                   ]
                         }
                       ];



                    var mapOptions ={
                    center:new google.maps.LatLng(28.6139,77.2090),
                    mapTypeControlOptions: {
                        mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'usroadatlas']
                      },
                    streetViewControl: true,
                    panControl: false,
                    zoomControlOptions: {
                        style: google.maps.ZoomControlStyle.SMALL,
                        position: google.maps.ControlPosition.RIGHT_BOTTOM
                    },
                    zoom:16
                };

        map = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);    
        var styledMapOptions = { name: 'Netran' };

        var usRoadMapType = new google.maps.StyledMapType(
          roadAtlasStyles, styledMapOptions);

          map.mapTypes.set('usroadatlas', usRoadMapType);             

var homeControlDiv = document.createElement('div');
var homeControl = new HomeControl(homeControlDiv, map);

homeControlDiv.index = 1;
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);

}

1 个答案:

答案 0 :(得分:0)

我建议您玩Maps Platform Styling Wizard。它使您可以根据需要快速自定义地图,然后生成JSON样式对象。