I've extended the JavaScript OnAnnotationClicked( ) function to allow a distinction of the annotation type clicked as such:
function OnAnnotationClicked(e)
{
var clickedAnno = e.annotation;
switch( clickedAnno.getType() )
{
case "TextData":
alert("TextData annotation clicked");
break;
default:
alert("unknown annotation type");
break;
}
}
But other than checking the .Text of the TextAnnotation, I can't think how to distinguish between which has been clicked. For example if 10 of them say "Click Here", how could I tell which is being clicked? I would have e.annotation, but is there anything in there to distinguish between the 10?
My next issue is with image annotations (my end intention is to overlay image annotations as clickable markers on an image). However, when I try (on the server-side) to use the same style as TextAnnotation and RubberStampAnnotation with ReferencedImageAnnotation, all annotations stop working.
For example, in the following code... if I remove anything to do with imgAnn, the code will display the stamp and text annotations. But including the imgAnn code (or isolating it to just the imgAnn code), no annotations are displayed.
(Code is in Page_Load)
wav.ImageUrl =
"chloe.jpg";
// Make sure we have a layer to add the annotation
if (wav.Annotations.Layers.Count == 0)
wav.Annotations.Layers.Add(new LayerAnnotation());
// Make sure that CurrentLayer is set
if (wav.Annotations.CurrentLayer == null)
wav.Annotations.CurrentLayer = wav.Annotations.Layers[0];
// Create TextAnnotation
TextAnnotation textAnn = new TextAnnotation("This is an annotation created on the server side.");
textAnn.Size = new System.Drawing.SizeF(300, 50);
textAnn.FontBrush.Color = Color.White;
textAnn.Visible = true;
// Create RubberStamp Annotation
RubberStampAnnotation stampAnn = new RubberStampAnnotation("This is an annotation created on the server side.");
stampAnn.Size = new System.Drawing.SizeF(300, 50);
stampAnn.FontBrush.Color = Color.White;
stampAnn.Visible = true;
// Create Image Annotation
ReferencedImageAnnotation imgAnn = new ReferencedImageAnnotation();
imgAnn.FileName = "prinny.jpg";
imgAnn.Visible = true;
wav.Annotations.CurrentLayer.Items.Add(stampAnn);
wav.Annotations.CurrentLayer.Items.Add(textAnn);
wav.Annotations.CurrentLayer.Items.Add(imgAnn);
wav.UpdateAnnotations();
Moo!