From 69e3681b1d44050df4b4213afc113710d3634332 Mon Sep 17 00:00:00 2001 From: iskore Date: Tue, 15 Jan 2019 14:13:19 -0500 Subject: [PATCH] ui: showing previous annotations per image Fixes: https://github.com/ossimlabs/tlv/issues/31 --- .../javascripts/menus/annotations-map.js | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/tlv-app/grails-app/assets/javascripts/menus/annotations-map.js b/apps/tlv-app/grails-app/assets/javascripts/menus/annotations-map.js index 9a554fd5..f089bb8a 100644 --- a/apps/tlv-app/grails-app/assets/javascripts/menus/annotations-map.js +++ b/apps/tlv-app/grails-app/assets/javascripts/menus/annotations-map.js @@ -501,7 +501,7 @@ function saveAnnotations() { $( pre ).css( 'color', '#c8c8c8' ); $( pre ).html( JSON.stringify( data, null, 2 ) ); $( '#dragoMetadata' ).prepend( pre ); - + if( json.response ) { displayData.push( data ); $( '#dragoMetadata' ) @@ -672,8 +672,10 @@ function generateRandomStyle( min, max ) { function searchForAnnotations() { var usernames = {}; - - $.each( tlv.layers, function( index, layer ) { + + tlv.layers.forEach( function( layer ) { + console.log( layer ); + $.ajax( { url: '/annotation/imageAnnotations' + '?' + $.param( { imgId: layer.imageId } ) } ) @@ -693,28 +695,28 @@ function searchForAnnotations() { } } }; - + data.forEach( function( annotation ) { var geoJSON = { id: 'annotation.' + annotation.id, type: 'Feature', properties: annotation }; - + if( !usernames.hasOwnProperty( annotation.username ) ) { usernames[ annotation.username ] = generateRandomStyle( 140, 255 ); } - + geoJSON.properties.style = usernames[ annotation.username ]; - + geoJSON.properties.geometry_ortho = annotation.geometryOrtho; geoJSON.properties.geometry_pixel = annotation.geometryPixel; geoJSON.properties.image_id = annotation.imageId; geoJSON.properties.saved = true; - + collection.features.push( geoJSON ); } ); - + layer.annotations = collection; if( collection.features.length > 0 ) { try { @@ -728,8 +730,7 @@ function searchForAnnotations() { .fail( function( e ) { console.error( e ); } ); - - refreshLayer(); + return false; } ); } @@ -737,7 +738,7 @@ function searchForAnnotations() { function bindWindowUnload() { window.addEventListener( 'beforeunload', function( e ) { e.preventDefault(); - + var unsaved = tlv.layers[ tlv.currentLayer ] .annotationsLayer .getSource() @@ -745,7 +746,7 @@ function bindWindowUnload() { .filter( function( feature ) { return !feature.getProperties().saved; } ); - + if( unsaved.length ) { var message = 'Important: You have unsaved changes!'; e.returnValue = message; @@ -757,9 +758,9 @@ function bindWindowUnload() { var setupTimeLapseAnnotations = setupTimeLapse; setupTimeLapse = function() { setupTimeLapseAnnotations(); - + searchForAnnotations(); - annotationsLayerToggle(); - + // annotationsLayerToggle(); + bindWindowUnload(); };