The HTML annotations in qgis2 seem to fit the bill of what I'd like to do: have a full-custom data-based drawing in a callout. Problem: I can't find documentation anywhere on how to write the html file to incorporate placeholders to take data values from the annotated object. Web searching shows a few discussions that say something about placeholders, which is the only evidence so far that it could actually do the trick. Can someone please point me to documentation on writing the html file used by html annotations? Maybe I'm just missing something obvious?


  • Did anyone get this working? I was really hoping to be able to generate these HTML annotations for all my vector points and then just move them around. Would be great for displaying photos and their location on map.. – Kapanther Feb 17 '14 at 4:29
  • I think Nathan W is the author of the feature, but hasn't been able to follow up - how would we get in touch with him? – Tom Grundy Feb 17 '14 at 14:57

The HTML annotations will evaluate anything inside [% %] as a QGIS expression and return the result.

<b> [% "name" %] </b>

Would render the name value bold.

Expressions can be as simple or complex as you need. If you can do it in a label you can do it here.

  • So, how do you 'attach' the annotation object to an existing vector layer object like a point which has the data value in question? It seems like the annotation tool doesn't "annotate an existing object", instead it just "creates a new annotation object in space, which has a point and a callout box, but doesn't appear to have its own data values." I saw some references online that you need to have an 'active layer' when you make the annotation, but, it still doesn't appear to link it to any object, selected or not. ?? – Tom Grundy Feb 3 '14 at 4:23
  • PS I stumbled across your blog post here: nathanw.net/2012/09/04/five-new-awesomely-awesome-qgis-features - this looks very promising - really hoping to be able to get the link / attachment working to the 'underlying feature' - I tried for point and for area, no luck, so I must be missing something obvious. – Tom Grundy Feb 3 '14 at 4:43
  • Do you have a layer selected in the layer panel? – Nathan W Feb 3 '14 at 4:50
  • yes I do - probably the quickest way to send a test case would be a screen capture video, let me know if you want that. – Tom Grundy Feb 3 '14 at 5:18
  • here's a screen capture video showing the problem: youtu.be/gkwwJIhZFQA – Tom Grundy Feb 3 '14 at 16:11

This may be about the coordinate system the html annotation uses to recognize the linked feature.

I've had the same problem for awhile. I decided to start from scratch and create a new, very basic QGIS project and try to get HTML annotations to work with it. To my surprise they did, so I compared the working QGIS project to my old one in a text editor. I noticed some lines in the HtmlAnnotationItem block were different...


   <HtmlAnnotationItem hasFeature="0" feature="0"


   <HtmlAnnotationItem hasFeature="1" feature="52196" 

In both cases I had added the html annotation in the same way, making sure to have the layer selected in the layer panel when I did so. I tried editing the original file to look like the other by putting hasFeature=”1” and feature=”52196”----which is just the feature ID of where I had put the annotation. That didn't work.

Another discrepancy in the HtmlAnnotationItem block was…





I’m not sure what the srsid is, but the srid I recognize as being the geographic and projected coordinate systems I use. The new project I created defaulted to the srid of the first layer I added, which was 4267.

My feature layer in QGIS is a postgis view where the geometry srid is 4267, in QGIS I have it transformed ‘on the fly’ to 26714. I edited my view in postgis to transform my geometry to 26714, and html annotations now work fine. Apparently the annotation was trying to use the project coordinate system to link features but was not connecting to underlying view in this case, because it had a different srid and thus different coordinates. I noticed your project was srid 26710, if the datasets you were using are in a geographic coordinate system I think our problems were probably the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.