会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132358个问题
WEB前端全系列/第九阶段:HTML5新特性模块/HTML5新特性 17楼
WEB前端全系列/第九阶段:HTML5新特性模块/HTML5新特性 21楼

index.zip

老师这个整体画布跟着在旋转颜色还都变成秒针的颜色了

WEB前端全系列/第九阶段:HTML5新特性模块/HTML5新特性 22楼
WEB前端全系列/第九阶段:HTML5新特性模块/HTML5新特性 23楼
WEB前端全系列/第九阶段:HTML5新特性模块/HTML5新特性 25楼
WEB前端全系列/第九阶段:HTML5新特性模块/(旧)H5新特性 28楼

<!DOCTYPE html>
<html lang="en">

<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" />
    <script type="text/javascript"
        src="https://api.map.baidu.com/api?v=2.0&ak=FbonyatSbRvrD6W2ApVIpz5BGT9wE18a"></script>

    <title>Document</title>
    <style type="text/css">
        html {
            height: 100%
        }

        body {
            height: 100%;
            margin: 0px;
            padding: 0px
        }

        #container {
            height: 500px;
            width: 700px;
            border: 1px solid black;
            margin: 30px;
        }
    </style>
</head>

<body>
    <div id="container"></div> <br>
    <label for="startPoint">
        起点:<input type="text" id="startPoint" value="广东省广州市越秀区环市西路179号">
    </label>
    <label for="endPoint">
        终点:<input type="text" id="endPoint" value="广东省广州市白云区广园西路133号">
    </label>
    <select>
        <option value="bus">公交</option>
        <option value="car">自驾</option>
        <option value="step">不行</option>
    </select><br>
    <button class="route">规划路线</button>
    <button class="load">加载</button>
    <script>
        var startPoint_input = document.querySelector('#startPoint');
        var endPoint_input = document.querySelector('#endPoint');
        var routeBtn = document.querySelector('.route')
        var map = null;
        document.querySelector('.load').onclick = function () {
            map = new BMap.Map("container");
            var point = new BMap.Point(113.26512290418745, 23.154485582798717);//设置中心点 经纬度
            map.centerAndZoom(point, 15);//地图初始化,同时设置地图展示级别 登记1-21  数值越大 
            map.addControl(new BMap.NavigationControl());//平移缩放
            //加载时所在地点标注
            var centerMarker = new BMap.Marker(point);
            map.addOverlay(centerMarker);
            centerMarker.addEventListener('click', function (eve) {
                var opts = {
                    width: 250,     // 信息窗口宽度    
                    height: 100,     // 信息窗口高度    
                    title: '你现在地址在:'  // 信息窗口标题   
                }

                var geoc = new BMap.Geocoder()
                geoc.getLocation(eve.point, function (info) {
                    var addressStr = info.address;
                    var infoWindow = new BMap.InfoWindow(addressStr, opts);  // 创建信息窗口对象    
                    map.openInfoWindow(infoWindow, map.getCenter());
                    event.stopPropagation();
                })

            })

            map.addEventListener('click', function (eve) {
                var geoc = new BMap.Geocoder()
                geoc.getLocation(eve.point, function (info) {
                    console.log(info);
                })

                var Marker = new BMap.Marker(eve.point);
                map.addOverlay(Marker);

            })
        }
        routeBtn.onclick = function () {
            startPoint_input_value = startPoint_input.value;
            endPoint_input_value = endPoint_input.value;
            var router_value = document.querySelector('select').value;
            switch (router_value) {
                case'bus':
                    {
                        var transit = new BMap.TransitRoute(map, {
                            renderOptions: {
                                map: map,
                                autoViewport: true
                            }
                        });
                        transit.search(startPoint_input_value, endPoint_input_value)
                    }

                    break;
                case 'car': {
                    var driving = new BMap.DrivingRoute(map, {
                        renderOptions: {
                            map: map,
                            autoViewport: true//自动切换视野
                        }
                    });
                    driving.search(startPoint_input_value, endPoint_input_value);//绘制路线图
                }
                    break;
                case 'step': {
                    var walk = new BMap.WalkingRoute(map, {
                        renderOptions: { map: map }
                    });
                    walk.search(startPoint_input_value, endPoint_input_value);//绘制路线图
                }
                    break;
            }

        }
    </script>
</body>

</html>

老师  我为啥公交那个方案不会显示   为啥汇报这些错 

image.png

WEB前端全系列/第九阶段:HTML5新特性模块/(旧)H5新特性 29楼

<!DOCTYPE html>
<html lang="en">
<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" /> 
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=FbonyatSbRvrD6W2ApVIpz5BGT9wE18a"></script>

    <title>Document</title>
    <style type="text/css">  
        html{height:100%}    
        body{height:100%;margin:0px;padding:0px}    
        #container{height:500px;width: 700px; border: 1px solid black;}    
    </style> 
</head>
<body>
    <div id="container"></div> 
    <button>加载</button>
    <script>
        var btn=document.querySelector('button');
        btn.onclick=function(){
            var map = new BMap.Map("container");    
var point = new BMap.Point(113.26512290418745, 23.154485582798717);    
map.centerAndZoom(point, 15);    
map.addControl(new BMap.NavigationControl());//平移缩放
//默认标注
// map.addEventListener('click',function(eve){
//     var tempMarker = new BMap.Marker(eve.point);        // 创建标注    
// map.addOverlay(tempMarker);  
// }


//------------------------自定义图标-------------------
var temPoint = new BMap.Point(113.26552290418745, 23.154485582798717);
var myIcon = new BMap.Icon("imgs/标注.gif", new BMap.Size(50, 50), {    
        // 指定定位位置。   
        // 当标注显示在地图上时,其所指向的地理位置距离图标左上    
        // 角各偏移10像素和25像素。您可以看到在本例中该位置即是   
        // 图标中央下端的尖角位置。    
        anchor: new BMap.Size(10, 25),    
        // 设置图片偏移。   
        // 当您需要从一幅较大的图片中截取某部分作为标注图标时,您   
        // 需要指定大图的偏移位置,此做法与css sprites技术类似。    
        imageOffset: new BMap.Size(-30, 10)   // 设置图片偏移    
    });      
    // 创建标注对象并添加到地图   
    var Mymarker = new BMap.Marker(temPoint, {icon: myIcon});    
    map.addOverlay(Mymarker);    
        }
    </script>
</body>
</html>

我的自定义图片怎么加载不了出来

WEB前端全系列/第九阶段:HTML5新特性模块/(旧)H5新特性 30楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637