高德地图——移动端请帖

不问归期 提交于 2019-11-29 02:41:08

 

 

 

<!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.Driving,AMap.Autocomplete"></script>
        <title>高德地图案例——移动端请帖</title>
        <meta name="viewport" content="initial-scale=1.0,user-scaleble=no,width=device-width" />
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            #container{
                position: absolute;
                top: 10%;
                left: 0;
                width: 100%;
                height: 80%;
            }
            #panel{
                position: fixed;
                background: white;
                top: 10px;
                right: 10px;
                width: 280px;
            }
            #search{
                width: 100%;
                height: 10%;
                position: absolute;
                left: 0px;
                top: 0px;
                background: white;
            }
            body{
                background: lightcoral;
            }
        </style>
    </head>
    <body>
        <div id="container"></div>
        <div id="search">
            <input type="" id="ipt" />
            <button id="btn">导航</button>
        </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:'ipt'
            })
            
            btn.onclick = function(){
                new AMap.Driving({
                    map:map
                }).search([
                    {keyword:ipt.value,city:'北京'},
                    {keyword:'天宫院',city:'北京'}
                ],function(status,data){
                    console.log(data);
                })
            };
            
            
        </script>
    </body>
</html>

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!