Baidu map api, click on the label, changing the label marker icons link address

Change the selected icon style

1  // Select image highlight label 
2 the let mapIcon = './ icon.png';  
 . 3  
. 4  // label points 
. 5 the let markerArrs = [{}, {}, ....]; 
 . 6  
. 7  
. 8  // click denoted point 
. 9 marker.addEventListener ( " the Click " , (EVT) => {
 10      for (the let J = 0 ; J <markerArrs.length; J ++ ) {
 . 11                const Element = markerArrs [J];
 12 is                 // initialize o'clock tie given CustomID 
13                  the let IDS = evt.target? evt.target.id: evt.customId;
14                 IF (IDS === element.id) {
 15                   element.setIcon ( new new BMap.Icon (mapIcon, new new BMap.Size ( 24 , 39 )));
 16                 } the else {
 . 17                 // initialization initialization binding site iconSrc address label 
18 is                 element.setIcon ( new new BMap.Icon (element.iconSrc, new new BMap.Size ( 24 , 39 )));
 . 19         }
 20 is     }
 21 is }                                

  A simple example

1 //简单点说明
2 var pointAIcon2= new BMap.Icon(url2, new BMap.Size(28,28));
3  
4 markerArm.addEventListener("click",function () {
5       this.setIcon(pointAIcon2);
6  });

 

 

 

Guess you like

Origin www.cnblogs.com/ajaxlu/p/12074314.html