重庆市地图json数据下载链接https://pan.baidu.com/s/19eZfuGGRY6JOrH9WnZJ5iw 密码h5f9
D3.js下载链接:https://pan.baidu.com/s/13wKelQUjueTY-pP4zUEkww 密码15te

由于JSON文件中的地图数据,都是经度和纬度的信息。他们都是三维的,而要在网页上显示的为二维,所以需要设定一个投影函数来转换经纬度。
1.center()设定地图的中心位置[107,31]指的是经度和纬度。
2.scale()设定放大的比例。
3.translate()设定平移。

使用d3.geo.path(),来深成svg中path元素的路径值
projection()是设定生成器的投影函数,把上面定义的投影传入即可。
实现代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/d3.v3.js" ></script>
</head>
<body&