我最終的工作解決方案。但我仍然不明白MapTypeStyle接口在哪裏以及如何使用。
HTML添加添加public customStyle = [{ "JSON style declaration goes here" }]
export class GmapComponent implements OnInit {
public customStyle = [
{
"elementType": "geometry",
"stylers": [
{
"hue": "#ff4400"
},
{
"saturation": -100
},
{
"lightness": -4
},
{
"gamma": 0.72
}
]
},
{
"featureType": "road",
"elementType": "labels.icon"
},
{
"featureType": "landscape.man_made",
"elementType": "geometry",
"stylers": [
{
"hue": "#0077ff"
},
{
"gamma": 3.1
}
]
},
{
"featureType": "water",
"stylers": [
{
"hue": "#00ccff"
},
{
"gamma": 0.44
},
{
"saturation": -33
}
]
},
{
"featureType": "poi.park",
"stylers": [
{
"hue": "#44ff00"
},
{
"saturation": -23
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"hue": "#007fff"
},
{
"gamma": 0.77
},
{
"saturation": 65
},
{
"lightness": 99
}
]
},
{
"featureType": "water",
"elementType": "labels.text.stroke",
"stylers": [
{
"gamma": 0.11
},
{
"weight": 5.6
},
{
"saturation": 99
},
{
"hue": "#0091ff"
},
{
"lightness": -86
}
]
},
{
"featureType": "transit.line",
"elementType": "geometry",
"stylers": [
{
"lightness": -48
},
{
"hue": "#ff5e00"
},
{
"gamma": 1.2
},
{
"saturation": -23
}
]
},
{
"featureType": "transit",
"elementType": "labels.text.stroke",
"stylers": [
{
"saturation": -64
},
{
"hue": "#ff9100"
},
{
"lightness": 16
},
{
"gamma": 0.47
},
{
"weight": 2.7
}
]
}
];
title: string = 'Current Location';
lat: number = 50.937531;
lng: number = 6.960278600000038;
constructor() {
}
ngOnInit() {
}
}
你試圖應用什麼風格? [入門指南](https://angular-maps.com/docs/getting-started.html)只是說在組件聲明中使用'styleUrls:['app.component.css']'。您的示例沒有提供有關您嘗試應用的樣式的詳細信息。 – Adam
在組件css中,我只向組件本身添加樣式,例如地圖的寬度和高度。我想實現的目標是將JASON格式化的樣式應用於https://mapstyle.withgoogle.com/的示例,並且從我的未確認的需要通過api添加(?) –