[我试图在这里获取示例代码:https://docs.microsoft.com/en-us/azure/azure-maps/how-to-use-map-control仅显示地图,然后将代码复制并粘贴到运行IIS的便携式计算机上的本地虚拟目录中。
两个位置的代码错误。首先,至少可以说非常令人困惑:
第1行,第1列:default.html:1:1XML分析错误:语法错误位置:http://localhost/azuremaps/default.html
第二个错误是:
TypeError:atlas.map不是构造函数
直接从示例中复制的HTML代码:
<html>
<head>
<!-- Load in the Azure Maps Web SDK - Using CSS and JS -->
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css" />
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
<!-- Add a reference to the Azure Maps Services Module JavaScript file. -->
<script src="https://atlas.microsoft.com/sdk/javascript/service/2/atlas-service.min.js"></script>
</head>
<body>
<div id="theMap"></div>
<script type="text/javascript">
map = new atlas.map('theMap', {
// Only allow one copy of the world be rendered when zoomed out.
renderWorldCopies: false,
language: 'en-US',
center: [-122.3353, 47.6038],
zoom: 12,
view: 'auto',
style: 'road',
authOptions: {
authType: 'subscriptionKey',
subscriptionKey: 'mySubKey',
getToken: function(resolve, reject, map) {
fetch(url).then(function(response) {
return response.text();
}).then(function(token) {
resolve(token);
});
}
}
});
// Wait until the map resources are ready.
map.events.add('ready', function () {
});
</script>
</body>
</html>
错字,使用map = new atlas.Map('theMap'
,此处M
用大写字母表示