地图将不显示在屏幕上,svg标签被插入

Map will not display on screen, svg tag is inserted

本文关键字:svg 标签 插入 屏幕 显示 地图      更新时间:2023-09-26

我从地图网站上获取了教程,并将其放在一个html页面中。当地图。write被调用,SVG标签被插入到它应该在的地方,但是我从来没有在浏览器中看到任何东西。我已经检查过了,JS文件正在加载,并以正确的顺序。我在控制台中也没有得到任何错误。下面你会发现我使用的代码:

<html>
<head>
    <style>
        #chartdiv {
            width   : 100%;
            height  : 500px;
        }               
    </style>
</head>
<body>
    <div id = "mapdiv" style="width: 600px; height: 400px;">
    </div>
    <script src="../libs/jquery-1.10.2.min.js"></script>
    <script src="../libs/ammaps/ammap.js"></script>
    <script src="../libs/ammaps/maps/js/worldLow.js"></script>
    <script>
        AmCharts.ready(function() {
            console.log("AmCharts.ready");
            var map = new AmCharts.AmMap();
            map.pathToImages = "ammap/images/";
            var dataProvider = {
                //map: "worldLow",
                        mapVar: "worldLow",
                getAreasFromMap:true              
            }; 
            map.dataProvider = dataProvider;
            map.areasSettings = {
                autoZoom: true,
                selectedColor: "#CC0000"
            };
            map.smallMap = new AmCharts.SmallMap();
            map.write("mapdiv");
        });
    </script>
</body>
</html>

更新:我发现通过将dataProvider对象的map属性从map更改为mapVar导致我看到地图导航控件,但仍然没有地图

要显示地图,我必须将mapVar属性的值从"worldLow"更改为AmCharts.maps.worldLow。