2011-04-21 47 views
2

我有一個谷歌地圖,我在地圖上插入自定義圖層,然後在其上添加谷歌街道和標籤。我一直在四處搜尋,看看是否有任何方式像路線圖一樣將街道和標籤重疊。谷歌地圖磚 - 街道和標籤覆蓋着風格?

所以我有這樣的:

var myStyle = [ 
{ 
    featureType: "road.arterial", 
    elementType: "all", 
    stylers: [ 
    { visibility: "simplified" } 
    ] 
},{ 
    featureType: "road.highway", 
    elementType: "all", 
    stylers: [ 
     { visibility: "simplified" } 
    ] 
} 
]; 

var myTileLayer = { 
    getTileUrl: function(coord, zoom) { 
     return "myTiles.php?" + 
     "z=" + zoom + "&x=" + coord.x + "&y=" + coord.y + "&client=api"; 
    }, 
    tileSize: new google.maps.Size(256, 256), 
    isPng: true 
}; 

var labelTiles = { 
    getTileUrl: function(coord, zoom) { 
     return "http://mt0.google.com/vt/v=apt.116&hl=en-US&" + 
     "z=" + zoom + "&x=" + coord.x + "&y=" + coord.y + "&client=api"; 
    }, 
    tileSize: new google.maps.Size(256, 256), 
    isPng: true 
}; 

var googleLabelLayer = new google.maps.ImageMapType(labelTiles); 

var mapOptions = { 
    mapTypeControlOptions: { 
    mapTypeIds: ['mystyle', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.TERRAIN] 
    }, 
    zoom: 9, 
    center: map_center, 
    mapTypeId: 'mystyle' 
}; 
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 
map.mapTypes.set('mystyle', new google.maps.StyledMapType(myStyle, { name: 'My Style' })); 
map.overlayMapTypes.insertAt(0, myTileLayer); 
map.overlayMapTypes.insertAt(1, googleLabelLayer); 

有人知道嗎?

回答

1

是的,您可以設計街道和標籤,至少在有限的範圍內。例如,您可以更改道路綠化是這樣的:

[ 
    { 
    featureType: "road", 
    elementType: "geometry", 
    stylers: [ 
     { visibility: "simplified" }, 
     { hue: "#3bff00" } 
    ] 
    } 
] 

使用谷歌地圖API樣式地圖精靈在http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html玩弄不同的設置。它會產生你需要複製風格的代碼。它也可以幫助你識別API不支持的事情。例如,我不認爲現在有一種方法可以使標籤斜體。 (如果有的話,沒問題,但你明白我的意思。)

另一件事:Maps API v3.5在不久前推出。您可能想要查看發行說明或通告或其他任何內容,以防現在出現的功能無法顯示在嚮導中,無論出於何種原因。