diff --git a/src/gui/qgshtmlannotationitem.cpp b/src/gui/qgshtmlannotationitem.cpp
index b04a5aa7bdf2..168e07757610 100644
--- a/src/gui/qgshtmlannotationitem.cpp
+++ b/src/gui/qgshtmlannotationitem.cpp
@@ -229,6 +229,7 @@ void QgsHtmlAnnotationItem::javascript()
{
QWebFrame *frame = mWebView->page()->mainFrame();
frame->addToJavaScriptWindowObject( "canvas", mMapCanvas );
+ frame->addToJavaScriptWindowObject( "layer", mVectorLayer );
}