Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. string symbol = "";
  2. string value = "";
  3. string alarm = "";
  4. foreach (var userSensor in Model)
  5. {
  6. <text>
  7. var pin = { lat: @userSensor.Latitude, lng: @userSensor.Longtitude };
  8. </text>
  9.  
  10. value = userSensor.Value.ToString();
  11. alarm = userSensor.Alarm.ToString();
  12. alarm = userSensor.Alarm ? "On" : "Off";
  13.  
  14. if (userSensor.Tag.StartsWith("Temperature"))
  15. {
  16. symbol = "°C";
  17. }
  18. else if (userSensor.Tag.StartsWith("Humidity"))
  19. {
  20. symbol = "%";
  21. }
  22. else if (userSensor.Tag.StartsWith("Electric"))
  23. {
  24. symbol = "W";
  25. }
  26. else if (userSensor.Tag.StartsWith("Occupancy"))
  27. {
  28. symbol = "";
  29. value = value == "0" ? "false" : "true";
  30. }
  31. else if (userSensor.Tag.StartsWith("Door"))
  32. {
  33. symbol = "";
  34. value = value == "0" ? "close" : "open";
  35. }
  36. else if (userSensor.Tag.StartsWith("Noise"))
  37. {
  38. symbol = "dB";
  39. }
  40.  
  41. <text>
  42. var contentString = '<div id="content">' +
  43. '<div id="siteNotice">' +
  44. '</div>' +
  45. '<h5 id="firstHeading" class="firstHeading">@userSensor.Name</h5>' +
  46. '<div id="bodyContent">' +
  47. '<div><b>Username:</b> @userSensor.UserName</div>' +
  48. '<div><b>Description:</b> @userSensor.Description</div>' +
  49. '<div><b>Tag:</b> @userSensor.Tag</div>' +
  50. '<div><b>Alarm:</b> @alarm</div>' +
  51. '<div><b>Value:</b> @value @symbol</div>' +
  52. '<div><b>ModifiedOn:</b> @userSensor.ModifiedOn</div>' +
  53. '<div><b>Latitude:</b> @userSensor.Latitude</div>' +
  54. '<div><b>Longitude:</b> @userSensor.Longtitude</div>' +
  55. '</div>' +
  56. '</div>';
  57.  
  58. var infowindow = new google.maps.InfoWindow({
  59. content: contentString,
  60. disableAutoPan: true
  61. });
  62.  
  63. var marker = new google.maps.Marker({
  64. position: pin, animation: google.maps.Animation.DROP, map: map, title: '@userSensor.Tag'
  65. });
  66. markers.push(marker);
  67. google.maps.event.addListener(marker, 'click', (function (marker, contentString, infowindow) {
  68. return function () {
  69. infowindow.setContent(contentString);
  70. infowindow.open(map, marker);
  71.  
  72. google.maps.event.addListener(map, 'click', function () {
  73. infowindow.close(map, marker);
  74. });
  75. setTimeout(function () { infowindow.close(); }, 5000);
  76. };
  77. })(marker, contentString, infowindow));
  78. </text>
  79. }
  80. }
  81. console.log(markers);
  82. var markerCluster = new MarkerClusterer(map, markers,);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement