Skip to content

Commit

Permalink
ui: annotations loading on first image
Browse files Browse the repository at this point in the history
  • Loading branch information
iSkore committed Jan 14, 2019
1 parent c012f30 commit cee0a5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 19 additions & 21 deletions apps/tlv-app/grails-app/assets/javascripts/menus/annotations-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,11 @@ function saveAnnotations() {
$( pre ).css( 'color', '#c8c8c8' );
$( pre ).html( JSON.stringify( data, null, 2 ) );
$( '#dragoMetadata' ).prepend( pre );

if( json.response ) {
displayData.push( data );
$( '#dragoMetadata' ).prepend( 'Saved ' + displayData.length + ' of ' + features.length + '...' );
$( '#dragoMetadata' )
.prepend( 'Saved ' + displayData.length + ' of ' + features.length + '...' );
} else {
$( '#dragoMetadata' ).prepend( 'Not Saved ...' );
}
Expand Down Expand Up @@ -670,11 +671,9 @@ function generateRandomStyle( min, max ) {
}

function searchForAnnotations() {
console.log( tlv.layers );

var usernames = {};
tlv.layers.forEach( function( layer ) {

$.each( tlv.layers, function( index, layer ) {
$.ajax( {
url: '/annotation/imageAnnotations' + '?' + $.param( { imgId: layer.imageId } )
} )
Expand All @@ -694,31 +693,32 @@ 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 {
// annotationsLayerToggle();
addSavedAnnotations( collection, layer );
} catch( e ) {
console.error( e );
Expand All @@ -728,8 +728,7 @@ function searchForAnnotations() {
.fail( function( e ) {
console.error( e );
} );

// annotationsLayerToggle();

refreshLayer();
return false;
} );
Expand All @@ -738,15 +737,15 @@ function searchForAnnotations() {
function bindWindowUnload() {
window.addEventListener( 'beforeunload', function( e ) {
e.preventDefault();

var unsaved = tlv.layers[ tlv.currentLayer ]
.annotationsLayer
.getSource()
.getFeatures()
.filter( function( feature ) {
return !feature.getProperties().saved;
} );

if( unsaved.length ) {
var message = 'Important: You have unsaved changes!';
e.returnValue = message;
Expand All @@ -758,10 +757,9 @@ function bindWindowUnload() {
var setupTimeLapseAnnotations = setupTimeLapse;
setupTimeLapse = function() {
setupTimeLapseAnnotations();

setTimeout( function() {
searchForAnnotations();
}, 1 );


searchForAnnotations();
annotationsLayerToggle();

bindWindowUnload();
};
2 changes: 2 additions & 0 deletions apps/tlv-app/test.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@
}
}
}

31.92, -102.28

0 comments on commit cee0a5c

Please sign in to comment.