我创建了一个自定义样式马普图案, 并将其插入 Google.maps.overlayMapType 中, 以便在另一层上绘制此自定义地图 。 不幸的是, 我有一个 javascript 错误信息 :
Uncaught TypeError: Cannot call method apply of undefined main.js:9
(anonymous function) main.js:9
d
L main.js:9
du
H.$
(anonymous function)
这是我在浏览器里执行的代码:
function initialize() {
var pinkParksStyles = [
{
featureType: "all",
stylers: [
{ saturation: -80 }
]
},
{
featureType: "poi.park",
stylers: [
{ hue: "#ff0023" },
{ saturation: 40 }
]
}
];
var pinkMapType = new google.maps.StyledMapType(pinkParksStyles,
{name: "Pink Parks"});
var mapOptions = {
zoom: 11,
center: new google.maps.LatLng(55.6468, 37.581),
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP]
}
};
var map = new google.maps.Map(document.getElementById( map_canvas ),
mapOptions);
//Insert styled map in overlayMapTypes.
map.overlayMapTypes.insertAt(0, pinkMapType);
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
}
To see a full example, here is a link on jsfiddle code: http://jsfiddle.net/X5r8r/460/ You can notice in this example that the styled map works as a mapType but not as an overlayMapType.
Thanks, François