function hidePreview() {
        if (!popoverState) {
            return;
        }

        if (popoverState.visible) {
            popoverState.marker.clear();

            $previewContent.empty();
            $previewContainer.hide();
            $previewContainer.removeClass("active");
        } else {
            window.clearTimeout(popoverState.hoverTimer);
        }
        popoverState = null;
    }
Cancels whatever popoverState was currently pending and sets it back to null. If the popover was visible,
hides it; if the popover was invisible and still pending, cancels hoverTimer so it will never be shown.