Commit fdddb2fef59814925f2db080757554be7174484e
1 parent
c421e638
地图覆盖物
Showing
4 changed files
with
87 additions
and
26 deletions
src/views/busy-status.png deleted
1.06 KB
src/views/idle-status.png deleted
1.2 KB
src/views/mapsection.vue
... | ... | @@ -47,7 +47,9 @@ |
47 | 47 | |
48 | 48 | <script> |
49 | 49 | import BScroll from 'better-scroll' |
50 | -import iconCar from '../assets/img/busy-status.png'; //以import的方式导入图片文件 | |
50 | +import busyCar from '../assets/img/busy-status.png'; //以import的方式导入图片文件 | |
51 | +import normalCar from '../assets/img/normal-status.png'; //以import的方式导入图片文件 | |
52 | +import idleCar from '../assets/img/idle-status.png'; //以import的方式导入图片文件 | |
51 | 53 | |
52 | 54 | export default { |
53 | 55 | name: 'mapsection', |
... | ... | @@ -83,26 +85,35 @@ export default { |
83 | 85 | bounce:true,//取消达到边界的缓冲效果 |
84 | 86 | }) |
85 | 87 | }) |
86 | - this.baiduMap() | |
88 | + let data = { | |
89 | + nurseryInfo: [ | |
90 | + {MapPointX:'111.742579',MapPointY:'40.818675',status:0}, | |
91 | + {MapPointX:'111.722579',MapPointY:'40.878675',status:1}, | |
92 | + {MapPointX:'111.782579',MapPointY:'40.818675',status:2} | |
93 | + ] | |
94 | + } | |
95 | + this.baiduMap(data) | |
87 | 96 | }, |
88 | 97 | methods: { |
89 | 98 | currentPark(item, index) { |
90 | 99 | console.log(item) |
91 | 100 | this.currentIndex = index |
101 | + let data = { | |
102 | + nurseryInfo: [ | |
103 | + {Name:'万达停车场1',MapPointX:'111.742579',MapPointY:'40.818675',status:2}, | |
104 | + {Name:'万达停车场2',MapPointX:'111.722579',MapPointY:'40.878675',status:0}, | |
105 | + {Name:'万达停车场3',MapPointX:'111.782579',MapPointY:'40.818675',status:1} | |
106 | + ] | |
107 | + } | |
108 | + this.baiduMap(data) | |
92 | 109 | }, |
93 | - baiduMap () { | |
110 | + baiduMap (data) { | |
94 | 111 | var map = new BMap.Map('allmap') |
95 | 112 | var point = new BMap.Point(111.742579, 40.818675) |
96 | 113 | map.centerAndZoom(point, 12) |
97 | 114 | // var marker = new BMap.Marker(point) // 创建标注 |
98 | 115 | // map.addOverlay(marker) // 将标注添加到地图中 |
99 | - let data = { | |
100 | - nurseryInfo: [ | |
101 | - {MapPointX:'111.742579',MapPointY:'40.818675'}, | |
102 | - {MapPointX:'111.722579',MapPointY:'40.818675'}, | |
103 | - {MapPointX:'111.732579',MapPointY:'40.818675'} | |
104 | - ] | |
105 | - } | |
116 | + | |
106 | 117 | map.clearOverlays(); |
107 | 118 | var i = 0; |
108 | 119 | var points = []; |
... | ... | @@ -111,21 +122,63 @@ export default { |
111 | 122 | //创建标注 |
112 | 123 | var pt = new BMap.Point(data.nurseryInfo[item].MapPointX, data.nurseryInfo[item].MapPointY); |
113 | 124 | points[i] = pt; |
114 | - var myIcon = new BMap.Icon(iconCar, | |
115 | - new BMap.Size(29, 40), { | |
116 | - offset: new BMap.Size(10, 40), | |
117 | - textColor: '#fff' | |
118 | - }); | |
119 | - var marker = new BMap.Marker(pt,{icon:myIcon}); | |
125 | + if(data.nurseryInfo[item].status === 0){ | |
126 | + var myIcon = new BMap.Icon(busyCar, | |
127 | + new BMap.Size(29, 40), { | |
128 | + offset: new BMap.Size(10, 40), | |
129 | + textColor: '#fff' | |
130 | + }); | |
131 | + var marker = new BMap.Marker(pt,{icon:myIcon}); | |
132 | + } else if(data.nurseryInfo[item].status === 1){ | |
133 | + var myIcon = new BMap.Icon(normalCar, | |
134 | + new BMap.Size(29, 40), { | |
135 | + offset: new BMap.Size(10, 40), | |
136 | + textColor: '#fff' | |
137 | + }); | |
138 | + var marker = new BMap.Marker(pt,{icon:myIcon}); | |
139 | + } else { | |
140 | + var myIcon = new BMap.Icon(idleCar, | |
141 | + new BMap.Size(29, 40), { | |
142 | + offset: new BMap.Size(10, 40), | |
143 | + textColor: '#fff' | |
144 | + }); | |
145 | + var marker = new BMap.Marker(pt,{icon:myIcon}); | |
146 | + } | |
147 | + | |
120 | 148 | map.addOverlay(marker); |
121 | - // var label = new BMap.Label(data.nurseryInfo[item].Name, { offset: new BMap.Size(30, -10) }); | |
122 | - // marker.setLabel(label); | |
123 | - // label.setStyle({ | |
124 | - // color: "White", | |
125 | - // fontSize: "14px", | |
126 | - // backgroundColor: "#5CACEE", | |
127 | - // border: "0" | |
128 | - // }); | |
149 | + var myLabel; | |
150 | + marker.addEventListener("mouseover", function (e) { | |
151 | + myLabel = new BMap.Label( | |
152 | + '<div class="parkpop-content"> ' + | |
153 | + '<div class="parkpop-tit">112321312312</div> ' + | |
154 | + '<div class="parkpop-cont"> ' + | |
155 | + '<div class="parkpop-freecont"> ' + | |
156 | + | |
157 | + '<div class="allspace-tit">总车位</div> ' + | |
158 | + '</div> ' + | |
159 | + '</div></div>', | |
160 | + { | |
161 | + offset: new BMap.Size(30, -85), //label的偏移量,为了让label的中心显示在点上 | |
162 | + position: point | |
163 | + }); | |
164 | + | |
165 | + myLabel.setStyle({ | |
166 | + color: "#F0F0F0", | |
167 | + fontSize: "12px", | |
168 | + padding: "5px", | |
169 | + whiteSpace: "normal", | |
170 | + backgroundColor: "#f00", | |
171 | + border: "0px", | |
172 | + zIndex: "1000" | |
173 | + } | |
174 | + ); | |
175 | + console.log('1') | |
176 | + map.addOverlay(myLabel); | |
177 | + }); | |
178 | + marker.addEventListener("mouseout", function () { | |
179 | + map.removeOverlay(myLabel); | |
180 | + }) | |
181 | + | |
129 | 182 | // //创建信息窗口 |
130 | 183 | // var opts = { |
131 | 184 | // width: 400, // 信息窗口宽度 |
... | ... | @@ -136,12 +189,17 @@ export default { |
136 | 189 | // } |
137 | 190 | // var showInfo = "地址:" + data.nurseryInfo[item].Addresss + "<br/>" + "描述:" + data.nurseryInfo[item].BasicFacts + "<br/>面积:" + data.nurseryInfo[item].HouseArea + "<br/>地块个数:" + data.nurseryInfo[item].nurseryBlockCount; |
138 | 191 | // var infoWindow = new BMap.InfoWindow(showInfo, opts); // 创建信息窗口对象 |
139 | - // marker.addEventListener("click", function (e) { | |
192 | + // marker.addEventListener("mouseover", function (e) { | |
193 | + // console.log('1') | |
140 | 194 | // //map.centerAndZoom(pt, 12); |
141 | 195 | // marker.openInfoWindow(infoWindow, pt); //开启信息窗口 |
142 | 196 | // }); |
197 | + // marker.addEventListener("mouseout", function () { | |
198 | + // marker.closeInfoWindow(); | |
199 | + // }) | |
200 | + // console.log('1') | |
143 | 201 | // map.addOverlay(marker); |
144 | - // i++; | |
202 | + i++; | |
145 | 203 | })(i); |
146 | 204 | } |
147 | 205 | |
... | ... | @@ -158,6 +216,9 @@ export default { |
158 | 216 | right: 0; |
159 | 217 | bottom: 0; |
160 | 218 | } |
219 | + .parkpop-tit{ | |
220 | + color: #000; | |
221 | + } | |
161 | 222 | .title-wrap{ |
162 | 223 | display: flex; |
163 | 224 | padding-top: 17px; | ... | ... |
src/views/normal-status.png deleted
1.17 KB