Guest User

Untitled

a guest
Jul 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. var shapeConfigurationCallback = function(attributes, record) {
  2. var configuration = {};
  3. configuration.name =
  4. attributes.values.name ||
  5. attributes.values.Name ||
  6. attributes.values.NAME;
  7.  
  8. // count++;
  9. // console.log(count);
  10.  
  11. if (record.isPointType()) {
  12. configuration.name =
  13. attributes.values.name ||
  14. attributes.values.Name ||
  15. attributes.values.NAME;
  16.  
  17. configuration.attributes = new WorldWind.PlacemarkAttributes(
  18. placemarkAttributes
  19. );
  20.  
  21. if (attributes.values.pop_max) {
  22. var population = attributes.values.pop_max;
  23. configuration.attributes.imageScale = 0.01 * Math.log(population);
  24. }
  25. } else if (record.isPolygonType()) {
  26. // configuration.attributes = new WorldWind.ShapeAttributes(null);
  27. //
  28. // // Fill the polygon with a random pastel color.
  29. // configuration.attributes.interiorColor = new WorldWind.Color(
  30. // 0.375 + 0.5 * Math.random(),
  31. // 0.375 + 0.5 * Math.random(),
  32. // 0.375 + 0.5 * Math.random(),
  33. // 1.0
  34. // );
  35. //
  36. // // Paint the outline in a darker variant of the interior color.
  37. // configuration.attributes.outlineColor = new WorldWind.Color(
  38. // 0.5 * configuration.attributes.interiorColor.red,
  39. // 0.5 * configuration.attributes.interiorColor.green,
  40. // 0.5 * configuration.attributes.interiorColor.blue,
  41. // 1.0
  42. );
  43.  
  44. getAqi(configuration.name).then(res => {
  45. console.log(res);
  46. configuration.attributes = new WorldWind.ShapeAttributes(null);
  47. switch (res) {
  48. case res < 50:
  49. configuration.attributes.interiorColor = greenColor;
  50. break;
  51. case res < 100 && res >= 50:
  52. configuration.attributes.interiorColor = yellowColor;
  53. break;
  54. case res < 150 && res >= 100:
  55. configuration.attributes.interiorColor = orangeColor;
  56. break;
  57. case res > 200:
  58. configuration.attributes.interiorColor = redColor;
  59. break;
  60. default:
  61. configuration.attributes.interiorColor = purpleColor;
  62. }
  63. });
  64.  
  65. return configuration;
  66. }
  67. };
Add Comment
Please, Sign In to add comment