Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string symbol = "";
- string value = "";
- string alarm = "";
- foreach (var userSensor in Model)
- {
- <text>
- var pin = { lat: @userSensor.Latitude, lng: @userSensor.Longtitude };
- </text>
- value = userSensor.Value.ToString();
- alarm = userSensor.Alarm.ToString();
- alarm = userSensor.Alarm ? "On" : "Off";
- if (userSensor.Tag.StartsWith("Temperature"))
- {
- symbol = "°C";
- }
- else if (userSensor.Tag.StartsWith("Humidity"))
- {
- symbol = "%";
- }
- else if (userSensor.Tag.StartsWith("Electric"))
- {
- symbol = "W";
- }
- else if (userSensor.Tag.StartsWith("Occupancy"))
- {
- symbol = "";
- value = value == "0" ? "false" : "true";
- }
- else if (userSensor.Tag.StartsWith("Door"))
- {
- symbol = "";
- value = value == "0" ? "close" : "open";
- }
- else if (userSensor.Tag.StartsWith("Noise"))
- {
- symbol = "dB";
- }
- <text>
- var contentString = '<div id="content">' +
- '<div id="siteNotice">' +
- '</div>' +
- '<h5 id="firstHeading" class="firstHeading">@userSensor.Name</h5>' +
- '<div id="bodyContent">' +
- '<div><b>Username:</b> @userSensor.UserName</div>' +
- '<div><b>Description:</b> @userSensor.Description</div>' +
- '<div><b>Tag:</b> @userSensor.Tag</div>' +
- '<div><b>Alarm:</b> @alarm</div>' +
- '<div><b>Value:</b> @value @symbol</div>' +
- '<div><b>ModifiedOn:</b> @userSensor.ModifiedOn</div>' +
- '<div><b>Latitude:</b> @userSensor.Latitude</div>' +
- '<div><b>Longitude:</b> @userSensor.Longtitude</div>' +
- '</div>' +
- '</div>';
- var infowindow = new google.maps.InfoWindow({
- content: contentString,
- disableAutoPan: true
- });
- var marker = new google.maps.Marker({
- position: pin, animation: google.maps.Animation.DROP, map: map, title: '@userSensor.Tag'
- });
- markers.push(marker);
- google.maps.event.addListener(marker, 'click', (function (marker, contentString, infowindow) {
- return function () {
- infowindow.setContent(contentString);
- infowindow.open(map, marker);
- google.maps.event.addListener(map, 'click', function () {
- infowindow.close(map, marker);
- });
- setTimeout(function () { infowindow.close(); }, 5000);
- };
- })(marker, contentString, infowindow));
- </text>
- }
- }
- console.log(markers);
- var markerCluster = new MarkerClusterer(map, markers,);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement