annotorious / annotorious-openseadragon

An OpenSeadragon plugin for annotating high-res zoomable images
https://annotorious.github.io
BSD 3-Clause "New" or "Revised" License
124 stars 44 forks source link

How to set json data from database #82

Closed akashlondhe4 closed 3 years ago

akashlondhe4 commented 3 years ago

frappe.call({ method: "powerannotation.power_annotation.page.image_annotation.image_annotation.load_annotarious_json", args: { 'name': id, }, async: false, callback: function(r2) { // alert(r2.message) anno.loadAnnotations(r2.message); } });

// I got the JSON data from r2.massage -->

[{"type":"Annotation","body":[{"type":"TextualBody","value":"Damage Fiber","purpose":"tagging","creator":{"id":"http://www.example.com/rainer","name":"rainer"},"created":"2021-08-27T06:53:54.099Z","modified":"2021-08-27T06:53:55.867Z"}],"target":{"source":"http://0.0.0.0:8000/files/DJI_0766_R.JPG","selector":{"type":"FragmentSelector","conformsTo":"http://www.w3.org/TR/media-frags/","value":"xywh=pixel:177,43,250,40"}},"@context":"http://www.w3.org/ns/anno.jsonld","id":"#ca563799-d7b9-474d-8e27-bbc6fc67b26b"}]

But when I was in load data or using this code -->

anno.loadAnnotations(r2.message); I got error -->VM1623:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 What can I do plz provide any solution?

rsimon commented 3 years ago

See documentation at: https://recogito.github.io/annotorious/api-docs/annotorious/

Replacing loadAnnotations with setAnnnotations should do the trick.

akashlondhe4 commented 3 years ago

thanks, it working