Skip to content
This repository was archived by the owner on Apr 2, 2023. It is now read-only.

JavaScript API

rsimon edited this page Oct 17, 2012 · 51 revisions

JavaScript API (Work in Progress!)

Yuma provides a JavaScript API you can use to add/remove/change annotations, hook into Yuma's event lifecycle, etc. All functionality is exposed via a global YUMA object. (Upper-case is important!)

Getting, Adding and Removing Annotations

YUMA.getAnnotations(opt_image_src);

Returns the annotations currently on the page. The return type is an array of annotations. Use the optional opt_image_src parameter to get only the annotations for the image with the specified URL.

YUMA.addAnnotation({
  /** The URL of the image where the annotation should go **/
  src : 'http://www.example.com/myimage.jpg',
 
  /** The annotation text **/
  text : 'My annotation',
 
  /** The annotation shape **/
  shape : {
    /** The shape type: 'Rectangle', 'Point' or 'Polygon' **/
    type : 'Rectangle',
   
    /** The shape geometry **/
    geometry : { x : 10, y: 10, width : 40, height: 60 }
 }

});

Creates a new annotation and adds it to the page.

YUMA.removeAnnotation(annotation);

Removes an annotation from the page.

Yuma Lifecycle Events

TODO

Clone this wiki locally