I can’t seem to get atlas maps weather overlays to work on my map.
I have tried api versions 2.0, 2.1, and 2022-08-01 and I keep getting the same error:
enter image description here
My code (from the example https://github.com/Azure-Samples/AzureMapsCodeSamples/blob/main/Samples/Weather/Show%20weather%20overlays%20on%20a%20map/Show%20weather%20overlays%20on%20a%20map.html#L16):
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" type="text/css" />
<div>
<div id="map" style="position:relative;width:100%;min-width:290px;height:600px;"></div>
</div>
@section Scripts{
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script>
<script src="https://atlas.microsoft.com/sdk/javascript/spatial/0/atlas-spatial.min.js"></script>
<script src="https://atlas.microsoft.com/sdk/javascript/service/2/atlas-service.min.js"></script>
<script>
$(function() {
var map, tileLayer;
var weatherTileUrl = 'https://atlas.microsoft.com/map/tile?api-version=2022-08-01&tilesetId=microsoft.weather.radar.main&zoom=2&x=2&y=1';
map = new atlas.Map('map', {
style: 'satellite_road_labels',
center: [-99.47, 40.75],
zoom: 2,
language: 'en-US',
view: 'Auto',
authOptions: {
authType: 'subscriptionKey',
subscriptionKey: 'key'
}
});
map.events.add('ready', function () {
map.controls.add(new atlas.control.StyleControl({
mapStyles: 'all'
}), {
position: 'top-right'
});
updateTileLayer();
});
function updateTileLayer() {
if (!tileLayer) {
tileLayer = new atlas.layer.TileLayer({
tileUrl: weatherTileUrl,
opacity: 0.9,
tileSize: 256
});
map.layers.add(tileLayer, 'labels');
} else {
tileLayer.setOptions({
tileUrl: weatherTileUrl
});
}
}
})
</script>
}
cherrys26 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.