Demo entry 6746423

no

   

Submitted by anonymous on May 30, 2018 at 06:46
Language: HTML. Code size: 2.2 kB.

<body>
    <div id="container" tabindex="0"></div>

    <div id="panel">
    </div>
    <div id="tip">
        <input type="text" id="keyword" name="keyword" value="请输入起点:" onfocus='this.value=""' />
        <a href="search.html" class="button">已到B楼</a>
    </div>

    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.4&key=c8469b5a3f3e4b5e6644cdd964f48071"></script>
    <script type="text/javascript">
        //panel中是查询结果展示的标签元素
        var map = new AMap.Map('container', {
            pitch: 75, //地图的俯仰角度
            viewMode: '3D', //展示方式
            expandZoomRange: true,
            resizeEnable: true, //可缩放
            zoom: 16.5, //地图级别
            center: [108.833609, 34.123189],
        });
        map.setMapStyle('amap://styles/normal'); //设置地图的样式
        map.setFeatures(["building", "road", "point", "bg"]); //单一种类要素显示["building", "road", "point", "bg"]

        ////////////////////添加标记点
        marker = new AMap.Marker({
            position: [108.833609, 34.123189],
            title: "西安电子科技大学",
            map: map
        });
        ////////////////////

        AMap.plugin(['AMap.Autocomplete', 'AMap.PlaceSearch'], function() {
            var autoOptions = {
                city: "西安", //城市,默认全国
                input: "keyword" //使用联想输入的input的id
            };
            var autocomplete = new AMap.Autocomplete(autoOptions);
            var placeSearch = new AMap.PlaceSearch({
                pageSize: 1,
                city: '西安',
                map: map
            })
            AMap.event.addListener(autocomplete, "select", function(e) {
                placeSearch.setCity("西安");
                AMap.service('AMap.Walking', function() { //回调函数
                    walking = new AMap.Walking({
                        panel: "panel",
                        city: '西安',
                        map: map
                    });
                    walking.search([{
                        keyword: e.poi.name
                    }, {
                        keyword: '西安电子科技大学B栋教学楼'
                    }], function(status, result) {});
                })
            });
        });
    </script>
</body>

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).