我试图显示基于Datamaps插件的法国地图。经过我尝试的所有尝试,我无法成功。
这是我的 HTML:
<div id="container"></div>
这是我的 js:
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/topojson/1.6.9/topojson.min.js"></script>
<script src="../../../node_modules/datamaps/dist/datamaps.fra.min.js"></script>
<script>
var map = new Datamap({
element: document.getElementById('container'),
geographyConfig: {
dataUrl: null,
//dataUrl: "../../assets/script/fra.topo.json",
popupOnHover: true,
highlightOnHover: true,
borderColor: '#444',
borderWidth: 0.5,
},
scope: 'fra',
fills: {
'MAJOR': '#306596',
'MEDIUM': '#0fa0fa',
'MINOR': '#bada55',
defaultFill: '#dddddd'
},
setProjection: function (element) {
var projection = d3.geo.mercator()
.center([78.9629, 23.5937]) // always in [East Latitude, North Longitude]
.scale(1000);
var path = d3.geo.path().projection(projection);
return {
path: path,
projection: projection
};
}
});
</script>
当我检查页面并检查它时,我看到一个 svg wut 页面是空的(下图) 在此处输入图像描述