JoyceWu12
JoyceWu12
  • 发布:2020-07-17 10:39
  • 更新:2020-07-17 10:39
  • 阅读:867

百度地图js 浏览器开F12,web页面正常,切换到移动端页面disableMassClear无效

分类:HTML5+

测试代码如下,具体操作见截图

<!DOCTYPE html>  
<html>  
    <head>  
        <meta charset="utf-8">  
        <title></title>  
    </head>  
    <body>  
    </body>  
</html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />  
    <style type="text/css">  
        body, html {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}  
        #l-map{height:100%;width:100%;}  
        #r-result{width:100%; font-size:14px; height:50px;top:30px}  
    </style>  
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=密钥"></script>  
    <!-- <script type="text/javascript" src="js/convertor.js"></script> -->  
    <title>驾车导航的数据接口</title>  
</head>  
<body>  
    <div id="l-map"></div>  
    <!-- <div id="r-result"></div> -->  
    <div id="r-result">  
            <input type="button" onclick="remove_overlay();" value="删除覆盖物" />  
        </div>  
</body>  
</html>  
<script type="text/javascript">  
    // 百度地图API功能  
    var map = new BMap.Map("l-map");  
    map.centerAndZoom(new BMap.Point(116.404, 39.915), 15);  

    var marker = new BMap.Marker(new BMap.Point(116.404, 39.915)); // 创建点  
        var polyline = new BMap.Polyline([  
            new BMap.Point(116.399, 39.910),  
            new BMap.Point(116.405, 39.920),  
            new BMap.Point(116.425, 39.900)  
        ], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});   //创建折线  
      polyline.disableMassClear();  
      map.addOverlay(polyline);   
     polyline = new BMap.Polyline([  
            new BMap.Point(116.398, 39.910),  
            new BMap.Point(116.404, 39.920),  
            new BMap.Point(116.424, 39.900)  
        ], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});      
       map.addOverlay(polyline);  

        //清除覆盖物  
        function remove_overlay(){  
            /*  var allOverlay = map.getOverlays();  
                for (var i = 0; i < allOverlay.length; i++) {  
                    if (allOverlay[i].toString() == "[object Polyline]") {  
                        map.removeOverlay(allOverlay[i]);  
                    }  
                }  */   
          map.clearOverlays();  
        }  
</script>  

2020-07-17 10:39 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复