将 openweather 数据添加到 Mapbox 地图

问题描述 投票:0回答:1

所以我尝试将天气数据添加到我的 Mapbox 地图中。我使用 openweather api 来获取数据。我尝试通过添加带有天气数据图块的图层来添加数据。这是我当前的代码: ` var map1 = "https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=e7fef929605b6a73c6921e4fec83f6ce"

map.on('load', function(){
  map.addLayer({
    "id": "simple-tiles",
    "type": "raster",
    "source": {
      "type": "raster",
      "tiles": ["https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=e7fef929605b6a73c6921e4fec83f6ce"],
    "tileSize": 256
},
"minzoom": 0,
"maxzoom": 22

}); });`

所以,如果我这样做,它工作得很好,但如果我尝试通过 openweather 网站 上提供的链接添加天气图块集,它就不起作用。而且链接也很不同。例如我想添加此地图: http://maps.openweathermap.org/maps/2.0/weather/PA0/{z}/{x}/{y}?date=1527811200&appid={API key} 它不起作用。是的,我用我的 api 密钥更改了 api 密钥占位符。因此,任何建议为什么它不能与其他链接一起使用以及如何解决该问题。也许我只是愚蠢,但提前谢谢。

mapbox openweathermap
1个回答
0
投票

您使用的第二个链接是 OpenWeatherMap 2.0 API,仅适用于付费用户。您可能需要升级您的帐户。

气象图1.0只有一层降水。气象图 2.0 具有以下功能:

{Op}    Meaning                             Units
PAC0    Convective precipitation            mm
PR0     Precipitation intensity             mm/s
PARAIN  Accumulated precipitation - rain    mm
PASNOW  Accumulated precipitation - snow    mm
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.