美文网首页
百度地图

百度地图

作者: 罗宏宇 | 来源:发表于2018-12-06 09:25 被阅读0次

    //去除底图中的图标,防止干扰

        var styleJson =[
              {
                    "featureType": "poilabel",
                    "elementType": "labels.icon",
                    "stylers": {
                              "visibility": "off"
                    }
              },
              {
                    "featureType": "subway",
                    "elementType": "labels.icon",
                    "stylers": {
                              "visibility": "off"
                    }
              }
            ];
        map.setMapStyle({styleJson:styleJson});
    

    效果:


    image.png

    添加自定义标注

    var label =new BMap.Label(name,{offset:new BMap.Size(38,5)});
            if(tbdz==""){
                tbdz="icon_c1.png";
            }
            var myIcon = new BMap.Icon("${base}/include/css/mapstyle/img/"+tbdz, new BMap.Size(36,36));
            var marker = new BMap.Marker(point,{icon:myIcon});
                //marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
            label.setStyle({
                color : color,
                fontSize : "12px",
                height : "20px",
                //lineHeight : "20px",
                fontFamily:"微软雅黑",
                backgroundColor:"rgba(255,255,255,0)",
                border:"none"
            });
            label.setTitle(nameAll); //为label添加鼠标提示    
            map.addOverlay(marker);
            marker.setLabel(label);
    
            marker.addEventListener("touchstart", function () {
                map.disableDragging();  //禁用地图拖拽功能
            });
    

    相关文章

      网友评论

          本文标题:百度地图

          本文链接:https://www.haomeiwen.com/subject/htowzftx.html