【问题标题】:Styled Google Maps风格化的谷歌地图
【发布时间】:2013-10-24 13:00:26
【问题描述】:

我能够完美地设置地图的样式,使其不饱和。我还可以设置地图样式,使其具有自定义标记。但是我不能结合代码来制作一个带有自定义标记的去饱和地图。有人可以看看我的脚本并检查我在正确的位置是否有正确的位。感谢你们的帮助 - 非常感谢:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>

<script>
var map;
var brooklyn = new google.maps.LatLng(53.798709, -1.550740); 

var MY_MAPTYPE_ID = 'custom_style';

function initialize() {

var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(53.798709, -1.550740),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map-canvas'),
                            mapOptions);

var image = 'images/marker.png';
var myLatLng = new google.maps.LatLng(53.798709, -1.550740);
var beachMarker = new google.maps.Marker({
  position: myLatLng,
  map: map,
  icon: image
});

var featureOpts = [
{
  stylers: [

    ]
},{
        featureType: "all",

        stylers: [{
            saturation: -100
        }]},

   {

    }]

    }

google.maps.event.addDomListener(window, 'load', initialize);

</script>

【问题讨论】:

  • 你的“脚本”不完整。

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


【解决方案1】:

你忘记应用样式了。

将此行放在initialize()的末尾:

map.setOptions({styles:featureOpts});

或者用mapOptions定义样式:

var mapOptions = {
  zoom:       14,
  center:     new google.maps.LatLng(53.798709, -1.550740),
  mapTypeId:  google.maps.MapTypeId.ROADMAP,
  styles:     [
                {
                  featureType: "all",
                  stylers: [
                            {
                              saturation: -100
                            }
                           ]
                }
              ]
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-28
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 2010-09-09
    • 2012-06-19
    相关资源
    最近更新 更多