From 64562187a52594d668ea5de1473195d135ea321d Mon Sep 17 00:00:00 2001 From: Arvind Date: Tue, 16 Jul 2013 15:35:12 +0530 Subject: [PATCH] Bug fix - A hack for working around various data fields. --- static/myVector.js | 109 ++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/static/myVector.js b/static/myVector.js index deeab1b..f89b4c4 100644 --- a/static/myVector.js +++ b/static/myVector.js @@ -60,25 +60,25 @@ var handler={ }; function onFeatureSelect(feature) { - for(var i in ans.ans) + for(var i in ans.ans) { // if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom']) // { - str = {}; - if(ans.ans[i]['character']) - str['character'] = ans.ans[i]['character']; - else - { - str['material'] = ans.ans[i]['material']; - // str['jewellery'] = ans.ans[i]['jewellery'] - } + str = {}; + if(ans.ans[i]['character']) + str['character'] = ans.ans[i]['character']; + else + { + str['material'] = ans.ans[i]['material']; + // str['jewellery'] = ans.ans[i]['jewellery'] + } if(ans.ans[i]["how"]) { z = new OpenLayers.Popup.FramedCloud( "test", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(640,480), - '",null,true); + '",null,true); } else { @@ -86,27 +86,27 @@ function onFeatureSelect(feature) "test", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(640,480), - '",null,true); + '",null,true); } - feature.popup = z; - z.panMapIfOutOfView = true; - map.addPopup(z); - break; + feature.popup = z; + z.panMapIfOutOfView = true; + map.addPopup(z); + break; //} //else{ - // if(i == ans.count-1) - // { - // z = new OpenLayers.Popup.FramedCloud( - // "test", - // feature.geometry.getBounds().getCenterLonLat(), - // new OpenLayers.Size(640,480), - // '',null,true); - // feature.popup = z; - // z.panMapIfOutOfView = true; - // map.addPopup(z); - // } + // if(i == ans.count-1) + // { + // z = new OpenLayers.Popup.FramedCloud( + // "test", + // feature.geometry.getBounds().getCenterLonLat(), + // new OpenLayers.Size(640,480), + // '',null,true); + // feature.popup = z; + // z.panMapIfOutOfView = true; + // map.addPopup(z); + // } //} } @@ -196,7 +196,6 @@ function init(url){ $.get(config.indexer+"/fetch",{uri:"default"} , function(data){ if (data != undefined) { - console.log(data); ans.ans = data; for(var i in ans.ans) { @@ -230,23 +229,23 @@ function init(url){ /*addLabel('3759.0000','-1274.33337','Face'); - addLabel('3719','-1771','Jewelery'); - addLabel('4263.0000','-1345.33337', 'Video'); + addLabel('3719','-1771','Jewelery'); + addLabel('4263.0000','-1345.33337', 'Video'); - for (var i = 0; i < box_extents.length; i++) { - ext = box_extents[i]; - bounds = OpenLayers.Bounds.fromArray(ext); + for (var i = 0; i < box_extents.length; i++) { + ext = box_extents[i]; + bounds = OpenLayers.Bounds.fromArray(ext); - box = new OpenLayers.Feature.Vector(bounds.toGeometry()); - box2.addFeatures(box); - } - for (var i = 0; i < box_extents1.length; i++) { - ext = box_extents1[i]; - bounds = OpenLayers.Bounds.fromArray(ext); + box = new OpenLayers.Feature.Vector(bounds.toGeometry()); + box2.addFeatures(box); + } + for (var i = 0; i < box_extents1.length; i++) { + ext = box_extents1[i]; + bounds = OpenLayers.Bounds.fromArray(ext); - box = new OpenLayers.Feature.Vector(bounds.toGeometry()); - box3.addFeatures(box); - }*/ + box = new OpenLayers.Feature.Vector(bounds.toGeometry()); + box3.addFeatures(box); + }*/ } boxes = new OpenLayers.Layer.Vector( "Boxes" ); @@ -331,25 +330,27 @@ function makeBoxes(x) { if(x.left) { - bounds = new OpenLayers.Bounds(x['left'], x['bottom'], x['right'], x['top']); - box = new OpenLayers.Feature.Vector(bounds.toGeometry()); - box3.addFeatures(box); - addLabel(x['left'],x['top'],x['name']); + bounds = new OpenLayers.Bounds(x['left'], x['bottom'], x['right'], x['top']); + box = new OpenLayers.Feature.Vector(bounds.toGeometry()); + box3.addFeatures(box); + addLabel(x['left'],x['top'],x['name']); } else if(x.where) { - position = JSON.parse(x.where.split("#")[1]); - console.log(position); - bounds = new OpenLayers.Bounds(position[2], position[1], position[3], position[0]); - box = new OpenLayers.Feature.Vector(bounds.toGeometry()); - box3.addFeatures(box); - addLabel(position[2],position[0],x['name']); + try{ + position = JSON.parse(x.where.split("#")[1]); + bounds = new OpenLayers.Bounds(position[2], position[1], position[3], position[0]); + box = new OpenLayers.Feature.Vector(bounds.toGeometry()); + box3.addFeatures(box); + addLabel(position[2],position[0],x['name']); + } + catch(e){ //This is a hack for mixed up data fields. FIXME! + } } } -// function onmouse(data){ -// console.log(data); -// } + + function myfeatureadded(myObj) { var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; -- 1.7.10.4