clay-core
Version:
Provide a more friendly web-side drawing interface!
40 lines (36 loc) • 1.5 kB
HTML
<html lang="zh-cn">
<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" href="../../libs/easycss-1.3.1.min.css">
<link rel="stylesheet" href="../../libs/prettify.css">
<link rel="stylesheet" href="../../doc.css">
<script src="../../libs/prettify.js"></script>
</head>
<body onload="prettyPrint()">
<header>
地球坐标映射
</header>
<p>
把地球看成一个半径为100px的圆球,采用等角斜方位投影,计算出经纬度分别为longitude和latitude的点对应的(x, y, z)坐标值。
</p>
<pre class='prettyprint lang-js'>var map=$$.map();</pre>
<p>
首先,你需要获取map对象,默认的参数适合绘制中国地图,当然,你可以修改他们:
</p>
<pre class='prettyprint lang-js'>map.center(longitude, latitude);</pre>
<p>
上面的方法用于设置旋转中心,你可以把你绘制的部分的中心的经纬度设置为中心。返回map对象。
</p>
<pre class='prettyprint lang-js'>map.scale(scale);</pre>
<p>
设置缩放比例,默认1。返回map对象。
</p>
<p>
经过上面简单的配置,你就可以直接调用map对象获取一个经纬度对应的坐标:
</p>
<pre class='prettyprint lang-js'>var xyz=map(longitude, latitude);</pre>
</body>
</html>