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

JavaScript API

Rainer Simon edited this page Oct 16, 2012 · 51 revisions

JavaScript API (Work in Progress!)

Yuma provides a JavaScript API. You can use it to programmatically add/remove/change annotations, hook into Yuma's lifecycle events, etc. All functionality is exposed via a global yuma object.

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