&plugin=AMap.Riding
也是[]中放json, 包含keyword和city,不能有途经

1、骑行路线(关键字)

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.11&key=9de88a718781910c9a1c81230827d1ce&plugin=AMap.Riding,AMap.Autocomplete"></script>
<title>骑行路线</title>
<style>
*{
padding: 0;
margin: 0;
}
#container{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#panel{
position: fixed;
background: white;
top: 10px;
right: 10px;
width: 280px;
}
#search{
width: 200px;
height: 160px;
position: absolute;
left: 10px;
top: 10px;
background: white;
}
</style>
</head>
<body>
<div id="container"></div>
<div id="panel"></div>
<div id="search">
起点:<input type="text" name="" id="startNode"/><br /> 终点:<input type="text" name="" id="endNode"/><br />
<button id="btn">开始导航</button>
</div> <script>
var map = new AMap.Map('container',{
zoom:11,
center:[116.379391,39.861536], }); new AMap.Autocomplete({
input:'startNode'
}); new AMap.Autocomplete({
input:'endNode'
}); /* new AMap.Riding({
map:map,
panel:'panel',
}).search([
{keyword:'北京大学',city:'北京'},
{keyword:'清华大学',city:'北京'}
],function(){ }) */ btn.onclick = function(){
new AMap.Riding({
map:map,
panel:'panel'
}).search([
{keyword:startNode.value,city:'北京'},
{keyword:endNode.value,city:'北京'}
],function(status,data){
console.log(data);
})
}; </script>
</body>
</html>

2、骑行指定(坐标):点击地图任意两点

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.11&key=9de88a718781910c9a1c81230827d1ce&plugin=AMap.Riding,AMap.Autocomplete"></script>
<title>骑行路线——坐标指定</title>
<style>
*{
padding: 0;
margin: 0;
}
#container{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#panel{
position: fixed;
background: white;
top: 10px;
right: 10px;
width: 280px;
}
#search{
width: 200px;
height: 160px;
position: absolute;
left: 10px;
top: 10px;
background: white;
}
</style>
</head>
<body>
<div id="container"></div>
<div id="panel"></div>
<div id="search">
起点:<input type="text" name="" id="startNode"/><br /> 终点:<input type="text" name="" id="endNode"/><br />
<button id="btn">开始导航</button>
</div> <script>
var map = new AMap.Map('container',{
zoom:11,
center:[116.379391,39.861536], }); /* new AMap.Riding({
map:map,
panel:'panel'
}).search([116.379391,39.861536],[116.479391,39.961536],function(status,data){
console.log(data);
}) */ var num = 0,arr = [];
map.on('click',function(e){
num++;
if(num%2 ==1){
arr = [e.lnglat.R,e.lnglat.P];
}else{
new AMap.Riding({
map:map,
panel:'panel'
}).search(new AMap.LngLat(arr[0],arr[1]),new AMap.LngLat(e.lnglat.R,e.lnglat.P),function(status,data){
console.log(data);
})
}
}) </script>
</body>
</html>

最新文章

  1. 简单酷炫的canvas动画
  2. javascript判断数组中是否包含某个元素
  3. 使用CSS完美实现垂直居中的方法
  4. 关于Xcode7中添加不了libresolv.dylib等类似库的问题
  5. 使用Template控制Editor显示方式
  6. nginx安装pcre
  7. 微软职位内部推荐-SDEII
  8. 封装cookie.js、EventUtil.js、
  9. Linux下一个简单的日志系统的设计及其C代码实现
  10. Java多线程高并发学习笔记(一)——Thread&amp;Runnable
  11. SSH的jar包下载地址
  12. C# 《编写高质量代码改善建议》整理&amp;笔记 --(三)泛型&amp;委托&amp;事件
  13. OPPO A7x在哪里开启usb调试模式的详细经验
  14. koa2--delegates模块源码解读
  15. 高性能Mysql笔记 — 索引
  16. 三问助你Fundebug
  17. 学习 MeteoInfo二次开发教程(五)
  18. CentOS6.8安装配置sonarqube6.4
  19. 【整理】HTML5游戏开发学习笔记(3)- 抛物线运动
  20. Postman 网络调试工具

热门文章

  1. Leetcode:面试题 04.04. 检查平衡性
  2. Gos Log每次查询响应后自动清理临时文件,优化磁盘空间
  3. 监控实战之Prometheus
  4. markdown文档编写基础
  5. Maven项目思考&amp;实战
  6. 必备!一文掌握Wordpress插件
  7. CTF之隐写总结
  8. MobSF移动安全扫描平台本地化部署与简单汉化
  9. SpringMVC学习01(什么是SpringMVC)
  10. k8s之数据存储-高级存储