如何在node.js里调用高德地图的js sdk?

cragsman 发布于 2017/09/23 12:58
阅读 415
收藏 0

想在node.js里引用高德js sdk,不知道怎么引用,功能在客户端已经实现了,代码是这样的:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>点是否在多边形内</title>
 <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.0&key=您申请的key值"></script>
</head>
<body>
<script type="text/javascript">
    //初始化地图对象,加载地图
    var myMarker = new AMap.Marker({
        position: [116.442621,39.799892]
    });
    var path = [
[116.169465,39.932670],
[116.160260,39.924492], 
[116.186138,39.879817], 
[116.150625,39.710019],
[116.183198,39.709920], 
[116.226950,39.777616], 
[116.421078,39.810771],
[116.442621,39.799892],
[116.463478,39.790066], 
[116.588276,39.809551],
[116.536091,39.808859],
[116.573856,39.839643], 
[116.706380,39.916740],
[116.657285,39.934545],
[116.600293,39.937770],
[116.540039,39.937968],
[116.514805,39.982375],
[116.499935,40.013710],
[116.546520,40.030443], 
[116.687668,40.129961], 
[116.539697,40.080659],
[116.503390,40.058474],
[116.468800,40.052578]
];
    var polygon = new AMap.Polygon({
        path: path
    });
   alert('点是否在多边形内:' + polygon.contains(myMarker.getPosition()));
</script>
</body>
</html>

 

需求很简单,前台传一个地址到后台,然后在node.js里调用高德js sdk,然后返回这个地址是否在定义的范围内。

 

加载中
0
阿假克斯
阿假克斯
高德没有Node的sdk吗?
cragsman
cragsman
没有呢,高德的js sdk能在node.js里使用么?
0
阿假克斯
阿假克斯
高德应该有后台可用的api吧,没用过
0
艾恩
艾恩
前端js跟后段node有啥关系。。。 后端输出html代码,前端处理就好了
cragsman
cragsman
我要在后台调用高德地图的js sdk,不知道怎么用
0
孤单的不同世界
孤单的不同世界
。我好像在公司代码里看到过,
cragsman
cragsman
呵呵,能否偷偷帮我看下呢
返回顶部
顶部