传单库错误
每当我试图在地图上添加一个地图标记时,我都会得到这个错误。
leaflet.js:5 Uncaught : t.addLayer不是i.addTo (leaflet.js:5)的一个函数。这个函数是库的一部分,我不知道为什么它不工作。我的代码来自tomtom的开发人员门户。这是我的密码。
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel='stylesheet' type='text/css' href='sdk/map.css'/>
<link rel="stylesheet" href="style.css">
<script src='sdk/tomtom.min.js'></script>
<title>Document</title>
</head>
<body>
<header class="name-header">
<div class="name-wrapper">
<nav class="container">
</nav>
</div>
</header>
<div class="img-wrapper">
<div class="svgbox">
</div>
</div>
<div id="map"> </div>
<script>
var storeLocation = [35.677512,-81.99855]
const map = tomtom.setProductInfo('KG\'s', '<your-product-
version>');
tomtom.L.map("map", {
key: 'myapikey',
source: 'vector',
center: storeLocation,
basePath: '/sdk',
zoom: 15
});
var marker = tomtom.L.marker(storeLocation).addTo(map);
marker.bindPopup("my business").openPopup();
</script>
</div>
</body>
</html>
我的地图大小在css中声明。
发布于 2019-02-26 11:29:18
您将映射分配给从setProductInfo方法返回的内容。它应该分配给tomtom.L.map。
const map = tomtom.L.map("map", {
key: 'myapikey',
source: 'vector',
center: storeLocation,
basePath: '/sdk',
zoom: 15
});发布于 2020-05-12 00:50:47
您可以使用类似的方法:
const map = tomtom.L.map("map", {
key: 'YOUR API KEY',
center: [0.0000, 00.0000],
basePath: 'tomtom',
zoom: 16
});
var marker = tomtom.L.marker([0.0000, 00.0000]).addTo(map);
marker.bindPopup('Flyover International').openPopup();
https://stackoverflow.com/questions/54877988
复制相似问题