我正在尝试使用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>根据我从I need API Key获得启动信息的网站,我使用的是他们在网站上给出的测试API密钥。
发布于 2019-12-31 23:43:14
要使用该小部件,您必须对域(sampleDomain.com)拥有授权,并从附属机构检索API。这些可以通过联系提供API或小部件的分支机构或组织来获得。
https://stackoverflow.com/questions/59533041
复制相似问题