Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. function addPlaceGraphic(item, symbol) {
  2. map.graphics.clear();
  3. var place = {};
  4. var attributes, infoTemplate, pt, graphic;
  5. pt = item.feature.geometry;
  6. place.address = item.name;
  7. place.score = item.feature.attributes.score;
  8.  
  9. var trashQuery = runPWQuery(pt, trashLayer, "trash");
  10. var yardQuery = runPWQuery(pt, yardWasteLayer, "yardwaste");
  11. var recycleQuery = runPWQuery(pt, recyclingLayer, "recycling");
  12.  
  13. all([trashQuery, yardQuery, recycleQuery]).then(function (results) {
  14.  
  15. //receive query responses, update attributes and add graphics
  16.  
  17. attributes = { trashQuery: pt.trashLayer, recycleQuery: pt.recyclingLayer, yardQuery: pt.yardWasteLayer };
  18.  
  19. infoTemplate = new InfoTemplate();
  20. infoTemplate.setTitle("Scheduling Information");
  21. infoTemplate.setContent("Trash: ${trashQuery}<br/>Recycling: ${recycleQuery}<br/>Mixed Bulk: ${yardQuery}");
  22. graphic = new Graphic(pt, symbol, attributes, infoTemplate);
  23.  
  24. //add to map
  25. map.graphics.add(graphic);
  26. map.centerAt(pt);
  27. });
  28. }
  29.  
  30. function runPWQuery(in_geometry , in_fl , in_container_id) {
  31. var query = new esri.tasks.Query();
  32. query.returnGeometry = true;
  33. query.outFields = ["*"];
  34. query.geometry = in_geometry;
  35.  
  36. var promise = in_fl.queryFeatures(query, function(myresponse, io) {
  37. var temp_val;
  38. var values = [];
  39. var tstr;
  40. for (var il = 0; il < myresponse.features.length; il++) {
  41. if (myresponse.features[il].attributes["MONDAY"] == "Yes") {
  42. temp_val = "Monday";
  43. }
  44. else if (myresponse.features[il].attributes["TUESDAY"] == "Yes") {
  45. temp_val = "Tuesday";
  46. }
  47. else if (myresponse.features[il].attributes["WEDNESDAY"] == "Yes") {
  48. temp_val = "Wednesday";
  49. }
  50. else if (myresponse.features[il].attributes["THURSDAY"] == "Yes") {
  51. temp_val = "Thursday";
  52. }
  53. else if (myresponse.features[il].attributes["FRIDAY"] == "Yes") {
  54. temp_val = "Friday";
  55. }
  56. else {
  57. //temp_val = "Other";
  58. temp_val = myresponse.features[il].attributes["DESCRIPT"];
  59. }
  60. }
  61.  
  62.  
  63. var statCount = myresponse.features.length;
  64. if (statCount >= 1) {
  65. $("#" + in_container_id).html(temp_val);
  66. }
  67. else {
  68. $("#" + in_container_id).html("");
  69. }
  70.  
  71. return temp_val;
  72.  
  73. }, function (error) {
  74. console.log(dojo.toJson(error, true));
  75. });
  76.  
  77. //return promise
  78. return promise;
  79.  
  80. }
  81.  
  82. function renderPWQuery() {
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement