has been messing with Tencent Map recently, and then the product manager asked that there are two states of Marker, selected and unselected. When I click on one of the annotations, the style is replaced by the selected style, and if it was previously selected, it reverts to the unselected style.
tried several ways I thought of, but none of them worked; it wasn"t in the development documentation either. I have come to ask for help. If this can be achieved, how can it be achieved? I"d better have some code that I can refer to ~
.const latlngs = [];
const test = [];
let datas;
if (this.allProjects) {
datas = this.allProjects;
for (let j = 0; j < this.allProjects.length; jPP) {
latlngs.push(new qq.maps.LatLng(this.allProjects[j].maLat, this.allProjects[j].maLng));
test.push(new qq.maps.LatLng(this.allProjects[j].maLat, this.allProjects[j].maLng));
}
}
for (let i = 0; i < latlngs.length; iPP) {
// ,
if (this.allProjects[i].hasParkingLot()) {
let marker = new qq.maps.Marker({
icon: noSelectedIcon,
position: latlngs[i],
map: this.map
});
qq.maps.event.addListener(marker, "click", () => {
infoWin.open();
infoWin.setContent("<div style="text-align:center;white-space:" +
"nowrap;margin:10px;font-size:0.2rem;">" +
datas[i].maName + "</div>");
infoWin.setPosition(latlngs[i]);
this.map.panTo(latlngs[i]); //
this.selectedProject = datas[i];
// debugger
this.markerSelect = marker;
marker.setIcon(selectedIcon);
});
}
}
that"s it. According to the API given by Tencent Map and the example method, I looped out all the points in the coordinate group, so that each marker clicked is a single message clicked, not several contained in it. However, each time a change to the icon setting marker.setIcon is an one-time modification of all, speechless.
how to crack this?