谷歌地图的风格不起作用?

时间:2013-08-02 12:48:34

标签: google-maps

我需要对谷歌地图进行去饱和处理。我使用stylers但它们不起作用。这是我的代码:

            <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
            <script type="text/javascript">
                document.write('<div id="gmap" style="width:960px; height:360px;"></div>');
                var map_center = new google.maps.LatLng(xxx, xxx);
                var map = new google.maps.Map( document.getElementById("gmap"),  {
                    zoom: 11,
                    center: map_center,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    panControl: false,
                    streetViewControl: false,
                    mapTypeControl: false,
                    stylers: [
                        { visibility: "on" },
                        { saturation: -100 }
                    ]
                });

                var pos;
                var marker;
                for(var i = 0 ; i < 10 ; i++) {
                    pos = new google.maps.LatLng(xxx, xxx);
                    marker = new google.maps.Marker({
                        position: pos,
                        map: map,
                        title: 'Tu jesteśmy',
                        icon: 'pointer.png'
                    });
                }

            </script>

请注意,我还需要使用自定义指针。

1 个答案:

答案 0 :(得分:1)

没有MapOption样式。它是风格。

            var map = new google.maps.Map( document.getElementById("gmap"),  {
                zoom: 11,
                center: map_center,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                panControl: false,
                streetViewControl: false,
                mapTypeControl: false,
                styles: [
                {
                   featureType: 'all',
                   elementType: 'all',
                   stylers: [
                     { visibility: "on" },
                     { saturation: -100 }
                  ]
                }]
            });

working example