Created
April 17, 2012 21:46
-
-
Save zuk/2409286 to your computer and use it in GitHub Desktop.
VEOS Photo capture and upload examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var photo = new veos.model.Photo(); | |
| // called when photo.upload() succeeds | |
| function photoUploaded() { | |
| console.log("Photo ID is: " + photo.id); | |
| } | |
| // called when photo.captureFromCamera() succeeds | |
| function imageCaptured () { | |
| // upload the captured image to the server | |
| photo.upload(); | |
| } | |
| photo.on('image_upload', imageUploaded); | |
| photo.on('image_capture', imageCaptured); | |
| photo.captureFromCamera(); | |
| // At this point we assume the user has successfully uploaded the photo. | |
| // We now need to associate it with a Report (via a Camera or Sign). | |
| var report = new veos.model.Report(); | |
| report.set('loc_lat_from_gps', 45.88); | |
| report.set('loc_lng_from_gps', -38.88); | |
| // There are other ways to create a Sign or Camera... the advantage of | |
| // doing it this way is that the Sign object will get created in one | |
| // save() call together with the Report (as opposed to instantiating the | |
| // Report and Sign separately). | |
| report.set('sign', {text: "Something something", visibility: "hidden"}) | |
| report.save(); | |
| // Attach the photo we created earlier to this report. | |
| report.attachPhoto(photo); | |
| // Note that the photo can't be attached until after the report | |
| // has been saved, so if you're doing both things at the same time, | |
| // you'll have to wrap the attachPhoto call in a sync event handler: | |
| report.on('sync', function () { | |
| report.attachPhoto(photo); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment