[英]DTN weather widget not showing up on page?
我正在嘗試使用 DTN 的天氣小部件來希望在背景圖像之上創建一個小部件。 但是,我至少無法讓小部件顯示出來。 下面是我的代碼:
<HTML>
<head>
<script src="https://content-services.dtn.com/ui-widgets/local-weather-widget/local-weather-widget-1.0-latest.js">
</script>
</head>
<body>
<p>This is a weather widget:</p>
<div class="widget" id="local-weather-widget" style="background: rgb(255, 255, 255); padding: 10px;">
</div>
<script>
window.dtn.localWeather.createLocalWeatherWidget({
"apiKey": "oViXqthDGFNVw3IvAsnKrFG1AcfPyA6b",
"container": "#local-weather-widget",
"units": "Imperial",
"defaultLocation": {
"postalCode": "68033"
},
"stations": [
{
"id": "KTPH",
"displayName": "Station 1"
},
{
"id": "KSNA",
"displayName": "Station 2"
}
],
"showStationsSelect": true,
"showPostalCodeInput": true,
"showForecast": true,
"showCurrentConditions": true,
"showWeatherDetails": true,
"callbacks": {
"onStationChange": "",
"onPostalCodeChange": "",
"onWeatherChange": ""
}
});
</script>
</body>
</HTML>
根據我從我需要 API 密鑰獲取啟動信息的網站,我使用的是他們在網站上提供的測試 API 密鑰。
要使用小部件,您必須獲得域 (sampleDomain.com) 的授權並從附屬機構檢索 API 密鑰。 這些可以通過聯系提供 API 或小部件的附屬機構或組織來獲得。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.