Commit 5b095e2d3cc318dba8bcc4d61283f908f9b81441
1 parent
f1105655
地图
Showing
4 changed files
with
122 additions
and
18 deletions
src/components/VMap.vue
| ... | ... | @@ -15,9 +15,9 @@ export default { |
| 15 | 15 | methods:{ |
| 16 | 16 | drawMap(){ |
| 17 | 17 | let data = [ |
| 18 | - {Name:'万达停车场1',lonId:'111.742579',latId:'40.818675',status:0,free:30,total:1000}, | |
| 19 | - {Name:'万达停车场2',lonId:'111.622579',latId:'40.878675',status:1,free:40,total:800}, | |
| 20 | - {Name:'万达停车场333333',lonId:'111.782579',latId:'40.778675',status:2,free:300,total:500} | |
| 18 | + {Name:'万达停车场1',lonId:'111.742579',latId:'40.818675',status:0,freeBrethNum:0,plBerthNum:1000,plName:'万达广场停车场1',plAddress:'北京万达广场1'}, | |
| 19 | + {Name:'万达停车场2',lonId:'111.622579',latId:'40.878675',status:1,freeBrethNum:100,plBerthNum:800,plName:'万达广场停车场2',plAddress:'北京万达广场2'}, | |
| 20 | + {Name:'万达停车场333333',lonId:'111.782579',latId:'40.778675',status:2,freeBrethNum:300,plBerthNum:500,plName:'万达广场停车场3',plAddress:'北京万达广场3'} | |
| 21 | 21 | ]; |
| 22 | 22 | var map = new BMap.Map('map', {enableMapClick: false}) |
| 23 | 23 | var point = new BMap.Point(data[0].lonId, data[0].latId) |
| ... | ... | @@ -38,7 +38,7 @@ export default { |
| 38 | 38 | var pt = new BMap.Point(data[item].lonId, data[item].latId); |
| 39 | 39 | points[i] = pt; |
| 40 | 40 | if(data[item].freeBrethNum/data[item].plBerthNum == 0){ |
| 41 | - var myIcon = new BMap.Icon(busyCar, | |
| 41 | + var myIcon = new BMap.Icon(idleCar, | |
| 42 | 42 | new BMap.Size(29, 40), { |
| 43 | 43 | offset: new BMap.Size(10, 40), |
| 44 | 44 | textColor: '#fff' |
| ... | ... | @@ -52,7 +52,7 @@ export default { |
| 52 | 52 | }); |
| 53 | 53 | var marker = new BMap.Marker(pt,{icon:myIcon}); |
| 54 | 54 | } else { |
| 55 | - var myIcon = new BMap.Icon(idleCar, | |
| 55 | + var myIcon = new BMap.Icon(busyCar, | |
| 56 | 56 | new BMap.Size(29, 40), { |
| 57 | 57 | offset: new BMap.Size(10, 40), |
| 58 | 58 | textColor: '#fff' |
| ... | ... | @@ -68,21 +68,37 @@ export default { |
| 68 | 68 | marker.setTop(true,27000000); |
| 69 | 69 | map.addOverlay(marker); |
| 70 | 70 | var myLabel; |
| 71 | + map.removeOverlay(myLabel); | |
| 71 | 72 | |
| 72 | - marker.addEventListener("mouseover", (e)=> { | |
| 73 | - map.removeOverlay(myLabel); | |
| 74 | - var that = this; | |
| 75 | - let tmpHtml = ''; | |
| 76 | - for(let i=0;i<JSON.parse(data[itemthat].plRate).length;i++){ | |
| 77 | - //console.log(data[itemthat].plRate) | |
| 78 | - tmpHtml += "<li>"+JSON.parse(data[itemthat].plRate)[i].standard+"</li>" | |
| 73 | + // map.removeOverlay(myLabel); | |
| 74 | + myLabel = new BMap.Label( | |
| 75 | + `<div class="dialog-wrap"> | |
| 76 | + <div class="dialog-header" title="${data[item].plAddress}">${data[item].plName}</div> | |
| 77 | + <div class="dialog-address" title="${data[item].plAddress}">${data[item].plAddress}</div> | |
| 78 | + <ul class="dislog-body"> | |
| 79 | + <li><div>${data[item].freeBrethNum}</div><div>空闲</div></li> | |
| 80 | + <li></li> | |
| 81 | + <li><div>${data[item].plBerthNum}</div><div>总数</div></li> | |
| 82 | + </ul> | |
| 83 | + <div class="dislog-footer">停车场收入:1293847.00元</div> | |
| 84 | + <div class="dislog-footer">停车场收入:1293847.00元</div> | |
| 85 | + </div>`, | |
| 86 | + { | |
| 87 | + offset: new BMap.Size(-225, -55), //label的偏移量,为了让label的中心显示在点上 | |
| 88 | + position: pt | |
| 89 | + }); | |
| 90 | + myLabel.setStyle({ | |
| 91 | + // color: "#0f0", | |
| 92 | + // fontSize: "12px", | |
| 93 | + padding: "0", | |
| 94 | + // whiteSpace: "normal", | |
| 95 | + backgroundColor: "", | |
| 96 | + border: "0px", | |
| 97 | + zIndex: "1000" | |
| 79 | 98 | } |
| 80 | - | |
| 81 | - | |
| 82 | - }); | |
| 83 | - marker.addEventListener("mouseout", function (e) { | |
| 84 | - map.removeOverlay(myLabel); | |
| 85 | - }); | |
| 99 | + ); | |
| 100 | + marker.setLabel(myLabel) | |
| 101 | + marker.setTop(true,27000000); | |
| 86 | 102 | i++; |
| 87 | 103 | })(i); |
| 88 | 104 | } |
| ... | ... | @@ -99,4 +115,6 @@ export default { |
| 99 | 115 | width: 100%; |
| 100 | 116 | height: 100%; |
| 101 | 117 | } |
| 118 | + | |
| 119 | + | |
| 102 | 120 | </style> | ... | ... |
src/images/content/dialog-address.png
0 → 100644
769 Bytes
src/images/content/sectionsmall.png
0 → 100644
1.58 KB
src/style/reset.css
| ... | ... | @@ -130,4 +130,90 @@ table { |
| 130 | 130 | |
| 131 | 131 | .anchorBL{display:none;} /*去掉百度地图logo*/ |
| 132 | 132 | |
| 133 | +.dialog-wrap{ | |
| 134 | + width:220px; | |
| 135 | + height: 160px; | |
| 136 | + padding:0 15px 15px 15px; | |
| 137 | + background:rgba(3,38,116,.7) url("../images/content/sectionsmall.png") no-repeat; | |
| 138 | + background-size: 100% 100%; | |
| 139 | +} | |
| 140 | +.dialog-header{ | |
| 141 | + width: 220px; | |
| 142 | + height:34px; | |
| 143 | + line-height: 34px; | |
| 144 | + font-size: 14px; | |
| 145 | + font-weight:500; | |
| 146 | + overflow: hidden; | |
| 147 | + white-space: nowrap; | |
| 148 | + text-overflow: ellipsis; | |
| 149 | + color:rgba(255,255,255,.8); | |
| 150 | +} | |
| 151 | +.dialog-address{ | |
| 152 | + height:22px; | |
| 153 | + font-size:12px; | |
| 154 | + padding-left: 20px; | |
| 155 | + font-family:PingFang-SC-Medium; | |
| 156 | + font-weight:500; | |
| 157 | + color:rgba(255,255,255,.4); | |
| 158 | + background: url("../images/content/dialog-address.png") no-repeat 0 3px; | |
| 159 | + background-size: 12px 12px | |
| 160 | +} | |
| 161 | +.dislog-body{ | |
| 162 | + display: flex; | |
| 163 | + height: 50px; | |
| 164 | + background:#2577F5; | |
| 165 | +} | |
| 166 | +.dislog-body li{ | |
| 167 | + text-align: center; | |
| 168 | + color: #fff; | |
| 169 | +} | |
| 170 | +.dislog-body li:nth-of-type(1),.dislog-body li:nth-of-type(3){ | |
| 171 | + flex: 1; | |
| 172 | +} | |
| 173 | +.dislog-body li:nth-of-type(2){ | |
| 174 | + width:1px; | |
| 175 | + height:31px; | |
| 176 | + margin-top: 9px; | |
| 177 | + background:rgba(5,41,112,.6); | |
| 178 | +} | |
| 179 | +.dislog-body li:nth-of-type(1) div:nth-of-type(1){ | |
| 180 | + height: 25px; | |
| 181 | + line-height: 30px; | |
| 182 | + font-size: 24px; | |
| 183 | + color: #0ECF0E; | |
| 184 | +} | |
| 185 | +.dislog-body li:nth-of-type(1) div:nth-of-type(2),.dislog-body li:nth-of-type(3) div:nth-of-type(2){ | |
| 186 | + height: 25px; | |
| 187 | + line-height: 25px; | |
| 188 | + color:rgba(69,195,243,1) | |
| 189 | +} | |
| 190 | + | |
| 191 | +.dislog-body li:nth-of-type(3) div:nth-of-type(1){ | |
| 192 | + height: 25px; | |
| 193 | + line-height: 30px; | |
| 194 | + font-size: 24px; | |
| 195 | + color: #fff; | |
| 196 | +} | |
| 197 | +.dislog-footer{ | |
| 198 | + height:25px; | |
| 199 | + line-height: 25px; | |
| 200 | + font-size:12px; | |
| 201 | + font-family:PingFang-SC-Regular; | |
| 202 | + font-weight:400; | |
| 203 | + color:rgba(7,179,245,1); | |
| 204 | +} | |
| 205 | +.dislog-footer-main{ | |
| 206 | + height:34px ; | |
| 207 | + overflow-y: auto; | |
| 208 | +} | |
| 209 | +.dislog-footer-main li { | |
| 210 | + font-size:12px; | |
| 211 | + font-family:PingFang-SC-Regular; | |
| 212 | + font-weight:400; | |
| 213 | + color:rgba(7,179,245,1); | |
| 214 | + overflow: hidden; | |
| 215 | + white-space: nowrap; | |
| 216 | + text-overflow: ellipsis; | |
| 217 | +} | |
| 218 | + | |
| 133 | 219 | ... | ... |