<template>
  <div class="mapTransitContainer">
      <div  @click =  'normalClick' class = 'mapTypeCarod' :class="{ 'selMapTypeCarod': isNormalMap }" style = 'background-image:url("./shiliangmap.png"); right:200px;'>
         <span>标准</span>
      </div>  
      <div  @click =  'imageClick'  class = 'mapTypeCarod' :class="{ 'selMapTypeCarod': !isNormalMap }" style = 'background-image:url("./yingxiangmap.png")'>
         <span>影像</span>
      </div>
  </div>
</template>

<script>
export default {
  name: 'MapTransit',
  data() {
      return { 
        mapType: 'normal',
        isImage: 0,
        isNormalMap: true,
        map:null
    }
  },
  props:{
    poiMap:{
        type:Object,
        default:null
    }
  },
  methods:{
      normalClick(){
        this.isNormalMap = true
        let options = {
            'type':4,
            'config': {'url': 'http://172.20.32.161:8080/qptiles/{z}/{x}/{y}.jpg',id:'normaltile'},
            'isBaseMap': false
        };  
        this.clearSpatial('basetile',this.poiMap)
        this.clearSpatial('yingxiangtile',this.poiMap)
        this.createLayer(this.poiMap, options);
		let getCheckedNodes = this.$parent.$children[8].$children[0].$refs.tree.getCheckedNodes();
        if(getCheckedNodes.length!=0){//勾选的显示
                 for(let i = 0;i<getCheckedNodes.length;i++){
                    if(getCheckedNodes[i].id=='instantRoad'){//说明此时为实时路况
                            this.createLayer(this.poiMap, {isBaseMap:false, type:4, config:{id:'trafficLayerId',url: "http://tm.amap.com/trafficengine/mapabc/traffictile?v=1.0&;t=1&x={x}&y={y}&z={z}&&t='+longTime+'"}})
                    }
                }
        }
    
      },
      imageClick(){
        this.isNormalMap = false
        let options = {
            'type':4,
            'config': {'url': 'http://172.20.36.100:8081/googleimage/{z}/{x}/{y}.png'}, id:'yingxiangtile',
            'isBaseMap': false
        };
        
        this.clearSpatial('basetile',this.poiMap)
        this.clearSpatial('normaltile',this.poiMap)
        this.createLayer(this.poiMap, options);
        let getCheckedNodes = this.$parent.$children[8].$children[0].$refs.tree.getCheckedNodes();
        if(getCheckedNodes.length!=0){//勾选的显示
                 for(let i = 0;i<getCheckedNodes.length;i++){
                    if(getCheckedNodes[i].id=='instantRoad'){//说明此时为实时路况
                            this.createLayer(this.poiMap, {isBaseMap:false, type:4, config:{id:'trafficLayerId',url: "http://tm.amap.com/trafficengine/mapabc/traffictile?v=1.0&;t=1&x={x}&y={y}&z={z}&&t='+longTime+'"}})
                    }
                }
        }
      }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.mapTransitContainer{
    position: absolute;
    background-color: rgba(255,255,255,.5);;
    bottom: 0;
    right: 0;
    width:200px;
    height: 80px;
    cursor: pointer;
}
.mapTypeCarod{
    position:absolute;
    height: 70px;
    width: 86px;
    
    margin: 5px;
    display: inline-block;
    box-sizing: border-box;
   
    border: 1px solid #ffffff;
}
.selMapTypeCarod{
    border: 1px solid #3385FF;
}


.mapTypeCarod:hover{
    border: 1px solid #3385FF;
}

.selMapTypeCarod > span{
    position: absolute;
    bottom: 0;
    right: 0;
    display: inline-block;
    padding: 3px 3px 2px 4px;
    font-size: 12px;
    height: 16px;
    line-height: 12px;
    color: #FFF;
    border-top-left-radius: 2px;
     background-color:#3385FF ;
}
 
.mapTypeCarod > span{
    position: absolute;
    bottom: 0;
    right: 0;
    display: inline-block;
    padding: 3px 3px 2px 4px;
    font-size: 12px;
    height: 16px;
    line-height: 12px;
    color: #FFF;
    border-top-left-radius: 2px;
}
.mapTypeCarod:hover > span{
    background-color:#3385FF ;
}

 
</style>
