我的当前谷歌地图代码正常工作,如果我点击侧边栏链接,会触发标记事件,然后打开信息窗口。单击标记时,我需要做什么来突出显示侧栏上的块?
function createMarkers(point, username, st) {
var html = '<b>' + username + '</b> <br/> ' + st;
var marker = new google.maps.Marker({
position: point,
map: map,
//zIndex: Math.round(point.lat()*-100000)<<5,
title: username
});
//Closes any open infowindow while clicking on another marker
infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'click', function() {
infowindow.close();
infowindow.setContent(html);
infowindow.open(map, marker);
});
markersArray.push(marker);
return marker;
}
创建标记时,我还创建了侧边栏条目:
sidebar.innerHTML += '<span id="sidebarTxt">'
+'<a href="javascript:sidebar_click(' + i + ')">'
+ '<b>' + name + '</b> </a> <br/> '
+ 'St: ' + st + '<br />'
+ 'St Preference: ' + location + '<br />'
+ 'Distance from me: ' + Number(distance).toFixed(2) + 'miles <br />'
+' </span>';
单击标记时,我需要做什么来突出显示侧栏上的块?
答案 0 :(得分:4)
像这样修改click
监听器:
google.maps.event.addListener(marker, 'click', function() {
infowindow.close();
infowindow.setContent(html);
infowindow.open(map, marker);
$("#sidebarTxt").toggleClass("new_style"); // this line adds the new_style to sidebarTxt span
});
哪里有一些风格
.new_style {
border: 1px solid red;
}