2013-10-24 51 views
-1

我可以完美地繪製地圖的樣式,使其不飽和。我也可以對地圖進行樣式設置,使其具有自定義標記。不過,我無法將代碼與定製標記製作成不飽和地圖。有人可以看看我的腳本,並檢查我是否在正確的位置有正確的位。感謝您的幫助球員 - 非常感謝:風格Google地圖

<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> 
+0

你的 「劇本」 是不完整的。 – geocodezip

回答

0

你忘了應用風格。

將這個線的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 
          } 
          ] 
       } 
       ] 
}; 
+0

謝謝莫爾先生。第二個選項是一種享受! – dmt