Wouldn't that be convenient if makeMarker(options) would construct a sidebar entry as well.
See it here.
A separate SidebarItem() constructor was written. It creates a button element and appends that to a div with id="sidebar" by default. makeMarker() calls the constructor if you have set an option property {sidebarItem: "My label"}
The basic button element needs some CSS cure. You can also style individual sidebar items by setting different CSS class names for them. {sidebarItemClassName: "important_item"}
The events are set to work bidirectionally.
- click on sidebar -> click on marker
- select on sidebar -> click on marker (select by [Tab])
- click on marker -> focus on sidebar
- mouseover on sidebar -> mouseover on marker
- mouseout on sidebar -> mouseout on marker
One of the reasons why I selected a button element was that it is 'focusable' and 'selectable'. You can open an info window by stepping the focus to a sidebar item by [Tab] or [Shift]+[Tab] and select the item by [Enter] or [Space] (some browsers). That is called accessibility.
Also you can use :hover and :focus CSS pseudoselectors. (:focus does not work with IE)
SidebarItem() instance has methods addIn() and remove(). We need addIn() to decide where to add the item. That helps to implement the categories.