Commit 48c2893f629ecd6e4f875547f3fc08863bc9c50a
1 parent
1179eb82
地图覆盖物
Showing
2 changed files
with
39 additions
and
35 deletions
src/styles/reset.css
... | ... | @@ -127,4 +127,28 @@ table { |
127 | 127 | color:rgba(255,255,255,1); |
128 | 128 | background:rgba(68,182,255,.6); |
129 | 129 | } |
130 | +.dislog-body{ | |
131 | + display: flex; | |
132 | + background:rgba(1,172,254,.2); | |
133 | +} | |
134 | +.dislog-body li{ | |
135 | + text-align: center; | |
136 | + color: #fff; | |
137 | +} | |
138 | +.dislog-body li:nth-of-type(1),.dislog-body li:nth-of-type(3){ | |
139 | + flex: 1; | |
140 | +} | |
141 | +.dislog-body li:nth-of-type(2){ | |
142 | + width: 12px; | |
143 | +} | |
144 | +.dislog-body li:nth-of-type(1) div:nth-of-type(1){ | |
145 | + font-size: 14px; | |
146 | + color: #32F532; | |
147 | +} | |
148 | +.dislog-body li:nth-of-type(3) div:nth-of-type(1){ | |
149 | + font-size: 14px; | |
150 | + color: #fff; | |
151 | +} | |
152 | + | |
153 | + | |
130 | 154 | ... | ... |
src/views/mapsection.vue
... | ... | @@ -90,9 +90,9 @@ export default { |
90 | 90 | }) |
91 | 91 | let data = { |
92 | 92 | nurseryInfo: [ |
93 | - {Name:'万达停车场1',MapPointX:'111.742579',MapPointY:'40.818675',status:0}, | |
94 | - {Name:'万达停车场2',MapPointX:'111.722579',MapPointY:'40.878675',status:1}, | |
95 | - {Name:'万达停车场333333',MapPointX:'111.782579',MapPointY:'40.818675',status:2} | |
93 | + {Name:'万达停车场1',MapPointX:'111.742579',MapPointY:'40.818675',status:0,free:30,total:1000}, | |
94 | + {Name:'万达停车场2',MapPointX:'111.722579',MapPointY:'40.878675',status:1,free:40,total:800}, | |
95 | + {Name:'万达停车场333333',MapPointX:'111.782579',MapPointY:'40.818675',status:2,free:300,total:500} | |
96 | 96 | ] |
97 | 97 | } |
98 | 98 | this.baiduMap(data) |
... | ... | @@ -103,9 +103,9 @@ export default { |
103 | 103 | this.currentIndex = index |
104 | 104 | let data = { |
105 | 105 | nurseryInfo: [ |
106 | - {Name:'万达停车场1',MapPointX:'111.742579',MapPointY:'40.818675',status:2}, | |
107 | - {Name:'万达停车场2',MapPointX:'111.722579',MapPointY:'40.878675',status:0}, | |
108 | - {Name:'万达停车场333333',MapPointX:'111.782579',MapPointY:'40.818675',status:1} | |
106 | + {Name:'万达停车场11111',MapPointX:'111.742579',MapPointY:'40.818675',status:2,free:300,total:500}, | |
107 | + {Name:'万达停车场22222',MapPointX:'111.722579',MapPointY:'40.878675',status:0,free:30,total:1000}, | |
108 | + {Name:'万达停车场333333',MapPointX:'111.782579',MapPointY:'40.818675',status:1,free:40,total:800} | |
109 | 109 | ] |
110 | 110 | } |
111 | 111 | this.baiduMap(data) |
... | ... | @@ -122,6 +122,7 @@ export default { |
122 | 122 | var points = []; |
123 | 123 | for (var item in data.nurseryInfo) { |
124 | 124 | (function (x) { |
125 | + var itemthat = item; | |
125 | 126 | //创建标注 |
126 | 127 | var pt = new BMap.Point(data.nurseryInfo[item].MapPointX, data.nurseryInfo[item].MapPointY); |
127 | 128 | points[i] = pt; |
... | ... | @@ -150,56 +151,35 @@ export default { |
150 | 151 | console.log(data) |
151 | 152 | map.addOverlay(marker); |
152 | 153 | var myLabel; |
154 | + | |
153 | 155 | marker.addEventListener("mouseover", function (e) { |
154 | 156 | console.log(e) |
155 | 157 | myLabel = new BMap.Label( |
156 | 158 | `<div class="dislog-wrap"> |
157 | - <div class="dialog-header" title="${data.nurseryInfo[item].Name}">${data.nurseryInfo[item].Name}</div> | |
159 | + <div class="dialog-header" title="${data.nurseryInfo[itemthat].Name}">${data.nurseryInfo[itemthat].Name}</div> | |
158 | 160 | <ul class="dislog-body"> |
161 | + <li><div>${data.nurseryInfo[itemthat].free}</div><div>空闲</div></li> | |
162 | + <li><div>/</div><div></div></li> | |
163 | + <li><div>${data.nurseryInfo[itemthat].total}</div><div>总数</div></li> | |
159 | 164 | </ul> |
160 | 165 | </div>`, |
161 | 166 | { |
162 | - offset: new BMap.Size(30, -85), //label的偏移量,为了让label的中心显示在点上 | |
167 | + offset: new BMap.Size(25, -35), //label的偏移量,为了让label的中心显示在点上 | |
163 | 168 | position: pt |
164 | 169 | }); |
165 | 170 | |
166 | 171 | myLabel.setStyle({ |
167 | 172 | // color: "#0f0", |
168 | 173 | // fontSize: "12px", |
169 | - padding: "0px", | |
174 | + padding: "0", | |
170 | 175 | // whiteSpace: "normal", |
171 | - // backgroundColor: "#f00", | |
176 | + backgroundColor: "", | |
172 | 177 | border: "0px", |
173 | 178 | // zIndex: "1000" |
174 | 179 | } |
175 | 180 | ); |
176 | - console.log('1') | |
177 | 181 | map.addOverlay(myLabel); |
178 | 182 | }); |
179 | - // marker.addEventListener("mouseout", function () { | |
180 | - // map.removeOverlay(myLabel); | |
181 | - // }) | |
182 | - | |
183 | - // //创建信息窗口 | |
184 | - // var opts = { | |
185 | - // width: 400, // 信息窗口宽度 | |
186 | - // height: 120, // 信息窗口高度 | |
187 | - // title: "<strong style=\"font-size:16px;font-weight:bold\">" + data.nurseryInfo[item].Name + "</strong>", // 信息窗口标题 | |
188 | - // enableMessage: true, //设置允许信息窗发送短息 | |
189 | - // message: "" | |
190 | - // } | |
191 | - // var showInfo = "地址:" + data.nurseryInfo[item].Addresss + "<br/>" + "描述:" + data.nurseryInfo[item].BasicFacts + "<br/>面积:" + data.nurseryInfo[item].HouseArea + "<br/>地块个数:" + data.nurseryInfo[item].nurseryBlockCount; | |
192 | - // var infoWindow = new BMap.InfoWindow(showInfo, opts); // 创建信息窗口对象 | |
193 | - // marker.addEventListener("mouseover", function (e) { | |
194 | - // console.log('1') | |
195 | - // //map.centerAndZoom(pt, 12); | |
196 | - // marker.openInfoWindow(infoWindow, pt); //开启信息窗口 | |
197 | - // }); | |
198 | - // marker.addEventListener("mouseout", function () { | |
199 | - // marker.closeInfoWindow(); | |
200 | - // }) | |
201 | - // console.log('1') | |
202 | - // map.addOverlay(marker); | |
203 | 183 | i++; |
204 | 184 | })(i); |
205 | 185 | } | ... | ... |