﻿var map; var mapcanvas = null; var mapwidth = null; var mapheight = null; var Bounds = null; var Geocoder = null; var Geofence = null; var BaseGeofence = null; var Report = false; var FleetReport = false; var MoveListener = null; var overmap = null; var LandmarkManager; var AddressMarker; var ShowLandmarks = true; var UnitManager; var OverManager; var UnitMarkers = new Array(); var LandmarkMarkers = new Array(); var SelectedInfoWindow = null; var whtml = null; var UpdateTimer = null; var SelectedUnit = null; var FollowUnit = null; var TrackPan = null; var GeofenceMode = false; var Menus = new Array(); var ControlLeader = "TravlMaster_BodyContent_"; Menus[0] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuUnits'); Menus[1] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuLocations'); Menus[2] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuLocationsAddress'); Menus[3] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuLocationsLandmark'); Menus[4] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuUnitSettings'); Menus[5] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuMapSettings'); Menus[6] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuMapSettingsSize'); Menus[7] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuMapSettingsTimeZone'); Menus[8] = new TravlMenu(false, ControlLeader + 'colpnlextSubMenuGeofence'); var settings9 = { tl: { radius: 9 }, tr: { radius: 9 }, bl: { radius: 9 }, br: { radius: 9 }, antiAlias: true, autoPad: true, validTags: ["div"] }; var settings6bottom = { tl: { radius: 0 }, tr: { radius: 0 }, bl: { radius: 6 }, br: { radius: 6 }, antiAlias: true, autoPad: true, validTags: ["div"] }; var settings6 = { tl: { radius: 6 }, tr: { radius: 6 }, bl: { radius: 6 }, br: { radius: 6 }, antiAlias: true, autoPad: false, validTags: ["div", "span"] }; var settings8 = { tl: { radius: 8 }, tr: { radius: 8 }, bl: { radius: 8 }, br: { radius: 8 }, antiAlias: true, autoPad: true, validTags: ["div"] }; var settings5 = { tl: { radius: 5 }, tr: { radius: 5 }, bl: { radius: 5 }, br: { radius: 5 }, antiAlias: true, autoPad: true, validTags: ["div", "span", "table"] }; var settings15 = { tl: { radius: 15 }, tr: { radius: 15 }, bl: { radius: 15 }, br: { radius: 15 }, antiAlias: true, autoPad: true, validTags: ["div"] }; var settings12 = { tl: { radius: 12 }, tr: { radius: 12 }, bl: { radius: 12 }, br: { radius: 12 }, antiAlias: true, autoPad: true, validTags: ["div"] };var settings10 = { tl: { radius: 10 }, tr: { radius: 10 }, bl: { radius: 10 }, br: { radius: 10 }, antiAlias: true, autoPad: true, validTags: ["div", "span"] };
function TravlMenu(open, extender) { this.Open = open; this.Extender = extender; return this; }
window.onunload = function() { if (map != null) GUnload(); }
window.onload = function() { var unitSettings = document.getElementById(ControlLeader + "tblUnitSettings"); if (unitSettings != null) unitSettings.style.visibility = "hidden"; if (document.getElementById(ControlLeader + "pnlMap") != null || document.getElementById(ControlLeader + "pnlReportMap") != null) { if (GBrowserIsCompatible()) { mapcanvas = document.getElementById(ControlLeader + "pnlMap"); if (mapcanvas == null) { mapcanvas = document.getElementById(ControlLeader + "pnlReportMap"); Report = true; } map = new GMap2(mapcanvas); Bounds = new GLatLngBounds(); Geocoder = new GClientGeocoder(); GEvent.addListener(map, "zoomend", function(oldLevel, newLevel) { map.getCurrentMapType().getMaxZoomAtLatLng(map.getCenter(), function(response) { if (response && response['status'] == G_GEO_SUCCESS && response['zoom'] < newLevel) { map.setCenter(map.getCenter(), response['zoom']); } }); if (SelectedUnit != null) { SelectPoint(SelectedUnit + 1, true); } }); GEvent.addListener(map, "maptypechanged", function() { map.getCurrentMapType().getMaxZoomAtLatLng(map.getCenter(), function(response) { if (response && response['status'] == G_GEO_SUCCESS && response['zoom'] < map.getZoom()) { map.setCenter(map.getCenter(), response['zoom']); } }); }); if (!Report) { GEvent.addListener(map, "singlerightclick", function(point, src, overlay) { if (!overlay) { var latlng = map.fromContainerPixelToLatLng(point); var whtml = "<input id=\"hiddenLandmarkLocation\" type=\"hidden\" value=\"" + latlng.lat() + "_:_" + latlng.lng() + "\">"; whtml += "<input id=\"hiddenLandmarkDescription\" type=\"hidden\" value=\"" + latlng.lat() + ", " + latlng.lng() + "\">"; whtml += "<input id=\"txtLandmarkName\" type=\"text\" value=\"Landmark Name\" maxlength=\"20\">"; whtml += "<br />"; whtml += "<input type=\"submit\" class=\"MenuButton\" value=\"Save Landmark\" onclick=\"SaveLandmark(); return false;\">"; MoveListener = GEvent.bind(map, "moveend", this, function() { this.openInfoWindowHtml(latlng, whtml); GEvent.removeListener(MoveListener) }); this.panTo(latlng); } }); } map.setCenter(new GLatLng(35.4683341083781, -82.5808576198583), 13); SizeMap(); if (!Report) { LandmarkManager = new MarkerManager(map, { trackMarkers: false }); } if (UnitManager == null) UnitManager = new MarkerManager(map, { trackMarkers: true }); map.setUIToDefault(); } } if (!Report) FollowUnit = setInterval('TrackUnit()', 2500); var bnr = document.getElementById("TravlMaster_pnlBanner"); var mnu = document.getElementById("TravlMaster_MenuBarPanel"); var bdy = document.getElementById("TravlMaster_BodyPanel"); bnr.style.visibility = "visible"; mnu.style.visibility = "visible"; bdy.style.visibility = "visible"; }
function CreateGeofence() {var sv = document.getElementById(ControlLeader + "btnSaveGeofence");sv.style.visibility = "visible";  var el = document.getElementById(ControlLeader + "btnRevertGeofence");el.value = "Cancel";  el.style.visibility = "visible"; var gd = document.getElementById(ControlLeader + "btnDeleteGeofence"); gd.style.visibility = "hidden"; var gn = document.getElementById(ControlLeader + "txtGeofenceName");gn.value = "";  gn.style.visibility = "visible"; if (Geofence != null) { Geofence.disableEditing(); map.removeOverlay(Geofence); } Geofence = new GPolygon(new Array(), "#0000FF", 1, 0.75, "#0000FF", 0.25); Geofence.id = "00000000-0000-0000-0000-000000000000"; map.addOverlay(Geofence); Geofence.enableDrawing(); GEvent.addListener(Geofence, "endline", function() { GEvent.addListener(Geofence, "mouseover", function() { this.enableEditing(); }); GEvent.addListener(Geofence, "mouseout", function() { this.disableEditing(); }); GEvent.addListener(Geofence, "click", function(latlng, index) { if (typeof index == "number") { this.deleteVertex(index); } }); this.complete = true; }); }
function ShowHideMenus(auto, open) { if (map == null) { setTimeout("ShowHideMenus('" + auto + "', '" + open + "')", 25); return; } if (AddressMarker != null) { map.removeOverlay(AddressMarker); } var menuOpen = false; var subMenu = document.getElementById(ControlLeader + "pnlSubMenu"); if (subMenu != null) { subMenu.style.visibility = "visible"; } var sgf = document.getElementById(ControlLeader + "fieldShowGeofence"); var gfl = document.getElementById(ControlLeader + "ddlGeofenceList"); if (sgf != null) { var selGeo = sgf.value; } if (gfl != null) { for (var i = 0; i < gfl.options.length; i++) { if (gfl.options[i].selected) { selGeo = gfl.options[i].value; } } } for (var i = 0; i < Menus.length; i++) { if (Menus[i] != null) { var autoMenu = false; var openMenu = false; var ii = 0; if (auto != null) { for (ii = 0; ii < auto.length; ii++) { if (Menus[i].Extender == auto[ii]) { autoMenu = true; break; } } } if (open != null) { for (ii = 0; ii < open.length; ii++) { if (Menus[i].Extender == open[ii]) { openMenu = true; break; } } } if (autoMenu) { if (Menus[i].Open) { if ($find(Menus[i].Extender) != null) { $find(Menus[i].Extender)._doClose(); } Menus[i].Open = false; if (Menus[i].Extender == ControlLeader + "colpnlextSubMenuGeofence") { if (sgf.value != "00000000-0000-0000-0000-000000000000") { sgf.value = "00000000-0000-0000-0000-000000000000"; } GeofenceMode = false; SizeMap(); DisplayGeofence(); if (Geofence != null) { map.removeOverlay(Geofence); } } } else { if ($find(Menus[i].Extender) != null) { $find(Menus[i].Extender)._doOpen(); } Menus[i].Open = true; if (Menus[i].Extender != ControlLeader + "colpnlextSubMenuUnits" && Menus[i].Extender != ControlLeader + "colpnlextSubMenuMapSettings") { menuOpen = true; } if (Menus[i].Extender == ControlLeader + "colpnlextSubMenuMapSettingsTimeZone") { mapcanvas.style.top = "59px"; mapcanvas.style.height = (mapheight - 59) + "px"; map.checkResize(); } if (Menus[i].Extender == ControlLeader + "colpnlextSubMenuUnitSettings") { mapcanvas.style.top = "89px"; mapcanvas.style.height = (mapheight - 89) + "px"; map.checkResize(); } if (Menus[i].Extender == ControlLeader + "colpnlextSubMenuLocations") { mapcanvas.style.top = "59px"; mapcanvas.style.height = (mapheight - 59) + "px"; map.checkResize(); } if (Menus[i].Extender == ControlLeader + "colpnlextSubMenuGeofence") { GeofenceMode = true; mapcanvas.style.top = "59px"; mapcanvas.style.height = (mapheight - 59) + "px"; map.checkResize(); map.enableDragging(); if (sgf.value == "00000000-0000-0000-0000-000000000000") { sgf.value = selGeo; } DisplayGeofence(); } } } else if (openMenu) { if ($find(Menus[i].Extender) != null) { $find(Menus[i].Extender)._doOpen(); } Menus[i].Open = true; if (Menus[i].Extender != ControlLeader + "colpnlextSubMenuUnits" && Menus[i].Extender != ControlLeader + "colpnlextSubMenuMapSettings") { menuOpen = true; } } else { if ($find(Menus[i].Extender) != null) { $find(Menus[i].Extender)._doClose(); } Menus[i].Open = false; if (Menus[i].Extender == ControlLeader + "colpnlextSubMenuGeofence") { GeofenceMode = false; if (sgf != null) { sgf.value = "00000000-0000-0000-0000-000000000000"; } if (Geofence != null) { map.removeOverlay(Geofence); } __doPostBack(ControlLeader + 'fieldShowGeofence', 'OnValueChanged'); } } } } if (!menuOpen) { SizeMap(); } }
function ShowUnitsMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuUnits']); }
function ShowLocationsMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuLocations']); }
function ShowLocationsAddressMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuLocationsAddress'], [ControlLeader + 'colpnlextSubMenuLocations']); }
function ShowLocationsLandmarkMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuLocationsAddress'], [ControlLeader + 'colpnlextSubMenuLocations', ControlLeader + 'colpnlextSubMenuLocationsLandmark']); }
function ShowUnitSettingsMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuUnitSettings']); }
function ShowMapSettingsMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuMapSettings']); }
function ShowMapSizeMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuMapSettingsSize']); }
function ShowGeofenceMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuGeofence']); }
function ShowTimeZoneMenu() { ShowHideMenus([ControlLeader + 'colpnlextSubMenuMapSettingsTimeZone']); }
function PanToLandmark() { var el = document.getElementById(ControlLeader + 'LandmarksDropdown'); var landmarkinfo = document.getElementById(ControlLeader + 'LandmarkLocation-' + el.value); if (landmarkinfo == null) { alert("You must select a landmark first."); return; } var position = landmarkinfo.value.split(':'); TridentMap.PanToWorldCoordinate(position[0], position[1]); }
function GotoLandmark() { var ddl = document.getElementById(ControlLeader + "ddlLandmarks"); for (var i = 0; i < LandmarkMarkers.length; i++) { if (LandmarkMarkers[i].id == ddl.value) { map.panTo(LandmarkMarkers[i].position); break; } } }
function MapUpdate(timestamp) { var lmu = document.getElementById(ControlLeader + "cellMapUpdate"); lmu.innerHTML = timestamp; }
function ShowHideLandmarks(el) { ShowLandmarks = !ShowLandmarks; if (el == null) { return; } if (ShowLandmarks) { el.value = "Hide Landmarks"; for (var i = 0; i < LandmarkMarkers.length; i++) { LandmarkManager.addMarker(LandmarkMarkers[i], 0); } } else { el.value = "Show Landmarks"; LandmarkManager.clearMarkers(); } }
function SelectFleet(key) { UnitManager.clearMarkers(); if (UnitMarkers[(key)].length > 0) { UnitManager.addMarkers(UnitMarkers[(key)], 0); } UnitManager.refresh(); }
function SelectPoint(key, nopan) { for (var i = 0; i < UnitMarkers.length; i++) { if (UnitMarkers[i].id == key) { SelectedUnit = i; if (map.getCenter() != UnitMarkers[SelectedUnit].position) { if (!nopan) { map.panTo(UnitMarkers[SelectedUnit].position); } MoveListener = GEvent.bind(map, "moveend", this, function() { setTimeout("ShowHidePoints(" + nopan + ");", 10); GEvent.removeListener(MoveListener) }); } else { setTimeout("ShowHidePoints(" + nopan + ");", 10); } break; } } }
function ShowHidePoints(nopan) { if (SelectedUnit != null) { for (var i = 0; i < UnitMarkers.length; i++) { if (i != SelectedUnit) { UnitMarkers[i].hide(); UnitMarkers[i].closeInfoWindow(); } } UnitMarkers[SelectedUnit].show(); UnitMarkers[SelectedUnit].setImage(window.location.protocol + "//" + window.location.host + UnitMarkers[SelectedUnit].image); if (!nopan) { Geocoder.getLocations(UnitMarkers[SelectedUnit].position, AddAddressFromPoint); } else { map.openInfoWindow(UnitMarkers[SelectedUnit].position, whtml); } } }
function GetAddressFromPoint(response) { if (!response || response.Status.code != 200) { } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); var address = ""; if (place.AddressDetails.Country == null) { address = place.address; } else { var adminarea = place.AddressDetails.Country.AdministrativeArea; if (adminarea != null) { if (adminarea.Locality != null) { if (adminarea.Locality.Thoroughfare != null) { address += adminarea.Locality.Thoroughfare.ThoroughfareName + "<br />"; } address += adminarea.Locality.LocalityName + ", "; address += adminarea.AdministrativeAreaName; if (adminarea.Locality != null) { if (adminarea.Locality.PostalCode != null) { address += "  " + adminarea.Locality.PostalCode.PostalCodeNumber; } } html = address; } else { html = place.address; } } } var coords = response.name.split(","); var foundunit = false; for (var i = 0; i < UnitMarkers.length; i++) { if (UnitMarkers[i].position.lat().toFixed(6) == coords[0] && UnitMarkers[i].position.lng().toFixed(6) == coords[1]) { UnitMarkers[i].address = html; var ai = document.getElementById(UnitMarkers[i].id + "-addressinfo"); if (ai != null) { ai.innerHTML = UnitMarkers[i].address; } foundunit = true; break; } } for (var i = 0; i < LandmarkMarkers.length; i++) { if (LandmarkMarkers[i].position.lat().toFixed(6) == coords[0] && LandmarkMarkers[i].position.lng().toFixed(6) == coords[1]) { LandmarkMarkers[i].address = html; var ai = document.getElementById(LandmarkMarkers[i].id + "-addressinfo"); if (ai != null) { ai.innerHTML = LandmarkMarkers[i].address; } foundunit = true; break; } } } }
function AddAddressFromPoint(response) { var marker = UnitMarkers[SelectedUnit]; whtml = "Point: " + (SelectedUnit + 1) + "<br />"; whtml += marker.alias + " [" + marker.hsid + "-" + marker.min + "]<br />"; whtml += marker.timestamp + "<br />"; whtml += "Direction: " + ConvertDirection(marker.heading) + "<br />"; whtml += "<br />"; whtml += "<span id='" + marker.id + "-addressinfo'>"; if (!response || response.Status.code != 200) { var head = document.getElementById(ControlLeader + "lblAlertHeading"); var txt = document.getElementById(ControlLeader + "lblAlertText"); var btn = document.getElementById(ControlLeader + "btnAlert"); whtml += "No detailed address information is available."; } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); var address = ""; if (place.AddressDetails.Country == null) { address = place.address; } else { var adminarea = place.AddressDetails.Country.AdministrativeArea; if (adminarea != null) { if (adminarea.Locality != null) { if (adminarea.Locality.Thoroughfare != null) { address += adminarea.Locality.Thoroughfare.ThoroughfareName + "<br />"; } address += adminarea.Locality.LocalityName + ", "; address += adminarea.AdministrativeAreaName; if (adminarea.Locality != null) { if (adminarea.Locality.PostalCode != null) { address += "  " + adminarea.Locality.PostalCode.PostalCodeNumber; } } } else { } } } whtml += place.address; whtml += "</span>"; } UnitMarkers[SelectedUnit].openInfoWindowHtml(whtml); }
function SelectUnit(el) { SelectedUnit = el.id; var chk = document.getElementById(ControlLeader + "chkFollowUnit"); if (chk.checked) { if (SelectedUnit != null) { map.disableDragging(); } } else { map.enableDragging(); } var lmu = document.getElementById(ControlLeader + "tblUnitInfo"); lmu.style.visibility = "visible"; var lus = document.getElementById(ControlLeader + "cellUnit"); lus.innerHTML = el.innerHTML; MoveListener = GEvent.bind(map, "moveend", this, function() { ShowHideMenus(); GEvent.removeListener(MoveListener) }); for (var i = 0; i < UnitMarkers.length; i++) { if (SelectedUnit == UnitMarkers[i].id) { UnitManager.removeMarker(UnitMarkers[i]); UnitManager.addMarker(UnitMarkers[i], 0); break; } } PanToUnit(SelectedUnit); }
function ShowUnitSettings(speedlimit, speedunits, geofence, alertrecipients) { var spdLimit = document.getElementById(ControlLeader + "txtUnitSettingsSpeedLimit"); var spdUnits = document.getElementById(ControlLeader + "ddlUnitSettingsSpeedUnit"); var geo = document.getElementById(ControlLeader + "ddlUnitSettingsGeofence"); var alrt = document.getElementById(ControlLeader + "txtUnitSettingsAlertRecipients"); spdLimit.value = speedlimit; for (var i = 0; i < spdUnits.options.length; i++) { if (spdUnits.options[i].text == spdUnits) { spdUnits.options[i].selected = true; break; } } for (var i = 0; i < geo.options.length; i++) { if (geo.options[i].value == geofence) { geo.options[i].selected = true; break; } } alrt.value = alertrecipients; var subMenu = document.getElementById(ControlLeader + "pnlSubMenu"); if (subMenu != null) { var tmp = document.getElementById(ControlLeader + "tblUnitSettings"); tmp.style.visibility = subMenu.style.visibility; } }
function EditUnit(el) { var sel = document.getElementById(ControlLeader + "fieldShowUnitSettings"); for (var i = 0; i < el.options.length; i++) { if (el.options[i].selected) { var tmp = document.getElementById(ControlLeader + "tblUnitSettings"); tmp.style.visibility = 'hidden'; sel.value = el.options[i].value; __doPostBack(ControlLeader + 'fieldShowUnitSettings', 'OnValueChanged'); } } }
function EditedUnit(heading, text, button) { ShowAlert(heading, text, button); }
function UpdatedTimeZone(heading, text, button) { ShowAlert(heading, text, button); }
function TrackUnit() { if (map == null) { return; } if (!GeofenceMode) { var chk = document.getElementById(ControlLeader + "chkFollowUnit"); if (chk.checked) { map.disableDragging(); for (var i = 0; i < UnitMarkers.length; i++) { if (UnitMarkers[i].id == SelectedUnit) { break; } } PanToUnit(SelectedUnit); } else { } } }
function PanToUnit(guid) { for (var i = 0; i < UnitMarkers.length; i++) { if (UnitMarkers[i].id == guid) { var lur = document.getElementById(ControlLeader + "cellUnitUpdate"); if (UnitMarkers[i].position.lat() != 0 && UnitMarkers[i].position.lng() != 0) { map.panTo(UnitMarkers[i].position); lur.innerHTML = UnitMarkers[i].timestamp; lur.style.color = ""; } else { lur.innerHTML = "No Valid Report"; lur.style.color = "Salmon"; } break; } } }
function UpdateUnitSettings() { var uus = document.getElementById(ControlLeader + "fieldUpdateUnitSettings"); var sus = document.getElementById(ControlLeader + "fieldShowUnitSettings"); var spdLimit = document.getElementById(ControlLeader + "txtUnitSettingsSpeedLimit"); var spdUnits = document.getElementById(ControlLeader + "ddlUnitSettingsSpeedUnit"); var geo = document.getElementById(ControlLeader + "ddlUnitSettingsGeofence"); var alrt = document.getElementById(ControlLeader + "txtUnitSettingsAlertRecipients"); uus.value = sus.value + "_:_" + spdLimit.value + "_:_" + spdUnits.value + "_:_" + geo.value + "_:_" + alrt.value; __doPostBack(ControlLeader + 'fieldUpdateUnitSettings', 'OnValueChanged'); }
function ConvertDirection(heading) { if (heading == 0) { return "N"; } else if (heading == 360) { return "N"; } else if (heading == 45) { return "NE"; } else if (heading == 90) { return "E"; } else if (heading == 135) { return "SE"; } else if (heading == 180) { return "S"; } else if (heading == 225) { return "SW"; } else if (heading == 270) { return "W"; } else if (heading == 315) { return "NE"; } else if (heading < 45) { return "NNE"; } else if (heading < 90) { return "ENE"; } else if (heading < 135) { return "ESE"; } else if (heading < 180) { return "SSE"; } else if (heading < 225) { return "SSW"; } else if (heading < 270) { return "WSW"; } else if (heading < 315) { return "WNW"; } else if (heading < 360) { return "NNW"; } }
function SetMarkerOrder(marker, b) { if (SelectedUnit == marker.id || SelectedInfoWindow == marker.id) { return 200; } else { return 100; } }
function ReverseGeocode(latitude, longitude) { Geocoder.getLocations(new GLatLng(latitude, longitude), GetAddressFromPoint); }
function UpdateUnit(guid, hsid, id, alias, geofence, infence, speedlimit, inrange, heading, longitude, latitude, imageinfo, timestamp, pan) { if (map == null) { setTimeout("UpdateUnit('" + guid + "', '" + hsid + "', '" + id + "', '" + alias + "', '" + geofence + "', '" + infence + "', '" + speedlimit + "', '" + inrange + "', '" + heading + "', '" + longitude + "', '" + latitude + "', '" + imageinfo + "', '" + timestamp + "', " + pan + ")", 50); return; } alias = alias.replace("%^%", "'"); var imageDetails = imageinfo.split("_$_"); var imageInfo = imageDetails[2].split("-"); var imgOpacity = 100; if (inrange == "0") { imgOpacity = 25; } var unitIcon = new GIcon(G_DEFAULT_ICON); unitIcon.shadow = ""; unitIcon.iconSize = new GSize(imageDetails[0], imageDetails[1]); unitIcon.iconAnchor = new GPoint(imageDetails[0] / 2, imageDetails[1] / 2); unitIcon.infoWindowAnchor = new GPoint(imageDetails[0] / 2, imageDetails[1] / 2); unitIcon.image = window.location.protocol + "//" + window.location.host + imageDetails[2]; markerOptions = { icon: unitIcon, zIndexProcess: SetMarkerOrder }; var position = new GLatLng(latitude, longitude); var marker = new GMarker(position, markerOptions); marker.id = guid; marker.alias = alias; marker.hsid = hsid; marker.min = id; marker.heading = heading; marker.image = imageInfo[1]; marker.timestamp = timestamp; marker.position = position; var foundMarker = false; for (var i = 0; i < UnitMarkers.length; i++) { if (UnitMarkers[i].id == guid) { foundMarker = true; if (position.lat() != 0 && position.lng() != 0) { UnitMarkers[i].alias = alias; UnitMarkers[i].hsid = hsid; UnitMarkers[i].min = id; UnitMarkers[i].heading = heading; UnitMarkers[i].position = position; UnitMarkers[i].timestamp = timestamp; UnitMarkers[i].setLatLng(position); } } } if (!foundMarker) { UnitMarkers.push(marker); if (position.lat() != 0 && position.lng() != 0) { UnitManager.addMarker(marker, 0); } } var selectwindow = SelectedInfoWindow; UnitManager.refresh(); marker.address = "Latitude: " + marker.position.lat() + "<br />"; marker.address += "Longitude: " + marker.position.lng(); if (marker.position.lat() != 0 && marker.position.lng() != 0) { ReverseGeocode(marker.position.lat(), marker.position.lng()); } if (selectwindow == marker.id) { var ihtml = marker.alias + " [" + marker.hsid + "-" + marker.min + "]<br />"; ihtml += marker.timestamp + "<br />"; ihtml += "Direction: " + ConvertDirection(marker.heading) + "<br />"; ihtml += "<br />"; ihtml += "<span id='" + marker.id + "-addressinfo'>"; ihtml += marker.address; ihtml += "</span>"; map.openInfoWindowHtml(marker.position, ihtml, { noCloseOnClick: true, onCloseFn: function() { SelectedInfoWindow = null; } }); SelectedInfoWindow = marker.id; } if (Report || pan) { if (position.lat() != 0 && position.lng() != 0) { Bounds.extend(position); var newzoom = map.getBoundsZoomLevel(Bounds); var newcenter = Bounds.getCenter(); map.setCenter(newcenter, newzoom); map.savePosition(); } } if (!Report) { GEvent.addListener(marker, "click", function() { if (SelectedInfoWindow != this.id) { var ihtml = this.alias + " [" + this.hsid + "-" + this.min + "]<br />"; ihtml += this.timestamp + "<br />"; ihtml += "Direction: " + ConvertDirection(this.heading) + "<br />"; ihtml += "<br />"; ihtml += "<span id='" + marker.id + "-addressinfo'>"; ihtml += this.address; ihtml += "</span>"; map.openInfoWindowHtml(this.position, ihtml, { noCloseOnClick: true, onCloseFn: function() { SelectedInfoWindow = null; } }); SelectedInfoWindow = this.id; UnitManager.removeMarker(this); UnitManager.addMarker(this, 0); } }); GEvent.addListener(marker, "dblclick", function(latlng) { if (latlng) { map.zoomIn(); map.setCenter(latlng); } }); var chk = document.getElementById(ControlLeader + "chkFollowUnit"); if (SelectedUnit == guid && chk.checked && !GeofenceMode) { PanToUnit(guid); } else { if (SelectedUnit == guid) { var lur = document.getElementById(ControlLeader + "cellUnitUpdate"); if (position.lat() != 0 && position.lng() != 0) { lur.innerHTML = timestamp; lur.style.color = ""; } else { lur.innerHTML = "No Valid Report"; lur.style.color = "Salmon"; } } } var unitsTable = document.getElementById(ControlLeader + "tblSubMenuUnits"); var bodyTable = unitsTable.getElementsByTagName("tbody"); var tableBody = document.createElement("tbody"); if (bodyTable.length > 0) { tableBody = bodyTable[0]; } var unitsRows = unitsTable.getElementsByTagName("tr"); var found = false; for (var ii = 0; ii < unitsRows.length; ii++) { var rowId = unitsRows[ii].id.split("_"); if (rowId[1] == guid) { found = true; var cells = unitsRows[ii].getElementsByTagName("td"); cells[0].innerHTML = alias; var newImg = cells[1].getElementsByTagName("img"); newImg[0].src = imageDetails[2]; newImg[0].style.filter = "alpha(opacity=" + imgOpacity + ")"; newImg[0].style.opacity = imgOpacity / 100; var geoImage = cells[2].getElementsByTagName("img"); if (geoImage.length > 0) { if (geofence == 0) { cells[2].removeChild(geoImage[0]); } } else { if (geofence > 0) { var geofenceImage = document.createElement("img"); geofenceImage.src = "/images/geofence.png"; cells[2].appendChild(geofenceImage); } } var speedImage = cells[3].getElementsByTagName("img"); if (speedImage.length > 0) { if (speedlimit == 0) { cells[3].removeChild(speedImage[0]); } } else { if (speedlimit > 0) { var speedlimitImage = document.createElement("img"); speedlimitImage.src = "/images/speedlimit.png"; cells[3].appendChild(speedlimitImage); } } } } if (!found) { var row = document.createElement("tr"); row.id = "UNITROW_" + guid; row.className = "UnitListRow"; var aliasCell = document.createElement("td"); aliasCell.id = guid; aliasCell.className = "UnitListAliasCell"; aliasCell.innerHTML = alias.replace("&", "&amp;"); aliasCell.onclick = function() { SelectUnit(this); }; var vehicleimageCell = document.createElement("td"); vehicleimageCell.onclick = function() { SelectUnit(aliasCell) }; vehicleimageCell.className = "UnitListVehicleImageCell"; var vehicleimageImage = document.createElement("img"); vehicleimageImage.src = imageDetails[2]; vehicleimageImage.style.filter = "alpha(opacity=" + imgOpacity + ")"; vehicleimageImage.style.opacity = imgOpacity / 100; vehicleimageCell.appendChild(vehicleimageImage); var geofenceCell = document.createElement("td"); geofenceCell.onclick = function() { SelectUnit(aliasCell) }; if (geofence > 0) { var geofenceImage = document.createElement("img"); geofenceImage.src = "/images/geofence.png"; geofenceCell.appendChild(geofenceImage); } geofenceCell.className = "UnitListGeofenceCell"; var speedlimitCell = document.createElement("td"); speedlimitCell.onclick = function() { SelectUnit(aliasCell) }; if (speedlimit > 0) { var speedlimitImage = document.createElement("img"); speedlimitImage.src = "/images/speedlimit.png"; speedlimitCell.appendChild(speedlimitImage); } speedlimitCell.className = "UnitListSpeedLimitCell"; var infoCell = document.createElement("td"); infoCell.className = "UnitListInfoCell"; infoCell.innerHTML = "Alert Message Here"; row.appendChild(aliasCell); row.appendChild(vehicleimageCell); row.appendChild(geofenceCell); row.appendChild(speedlimitCell); row.appendChild(infoCell); tableBody.appendChild(row); } if (bodyTable.length == 0) { unitsTable.appendChild(tableBody); } UpdateDropdownOption(ControlLeader + "ddlUnitSettingsUnits", alias, guid); var sel = document.getElementById(ControlLeader + "ddlUnitSettingsUnits"); var selu = document.getElementById(ControlLeader + "fieldShowUnitSettings"); if (selu.value == "") { EditUnit(sel); } } }
function UpdateUnitIcons() { for (var i = 0; i < UnitMarkers.length; i++) { UnitMarkers[i].setImage(UnitMarkers[i].icon); } }
function PanTo(latitude, longitude) { TrackPan = new GLatLng(latitude, longitude); map.panTo(new GLatLng(latitude, longitude)); }
function UpdateFleetUnits(fleetInfo) { if (map == null) { setTimeout("UpdateFleetUnits('" + fleetInfo + "')", 25); return; } FleetReport = true; var fleetData = fleetInfo.split("_!_"); for (var f = 0; f < fleetData.length; f++) { var unitInfo = fleetData[f].split("_#_"); var tempArray = new Array(); for (var i = 0; i < unitInfo.length; i++) { if (unitInfo[i] != "") { var unitDetails = unitInfo[i].split("_^_"); var unitPosition = unitDetails[1].split(","); var imageDetails = unitDetails[2].split("_$_"); var unitIcon = new GIcon(G_DEFAULT_ICON); unitIcon.shadow = ""; unitIcon.iconSize = new GSize(imageDetails[0], imageDetails[1]); unitIcon.iconAnchor = new GPoint(imageDetails[0] / 2, imageDetails[1] / 2); unitIcon.infoWindowAnchor = new GPoint(imageDetails[0] / 2, imageDetails[1] / 2); unitIcon.image = imageDetails[2].replace("markers/", "markers/transparent-"); markerOptions = { icon: unitIcon }; var position = new GLatLng(unitPosition[0], unitPosition[1]); var marker = new GMarker(position, markerOptions); marker.id = unitDetails[0]; marker.image = imageDetails[2]; marker.position = position; var foundMarker = false; tempArray.push(marker); GEvent.addListener(marker, "mouseover", function() { this.setImage(this.image); }); GEvent.addListener(marker, "mouseout", function() { if ((this.id - 1) != SelectedUnit) { this.setImage(this.image.replace("markers/", "markers/transparent-")); } }); Bounds.extend(position); } } UnitMarkers.push(tempArray); var newzoom = map.getBoundsZoomLevel(Bounds); var newcenter = Bounds.getCenter(); map.setCenter(newcenter, newzoom); map.savePosition(); } }
function UpdateUnits(unitsInfo) { if (map == null) { setTimeout("UpdateUnits('" + unitsInfo + "')", 25); return; } var unitInfo = unitsInfo.split("_#_"); for (var i = 0; i < unitInfo.length; i++) { var unitDetails = unitInfo[i].split("_^_"); var unitPosition = unitDetails[1].split(","); var imageDetails = unitDetails[2].split("_$_"); var unitIcon = new GIcon(G_DEFAULT_ICON); unitIcon.shadow = ""; unitIcon.iconSize = new GSize(imageDetails[0], imageDetails[1]); unitIcon.iconAnchor = new GPoint(imageDetails[0] / 2, imageDetails[1] / 2); unitIcon.infoWindowAnchor = new GPoint(imageDetails[0] / 2, imageDetails[1] / 2); unitIcon.image = imageDetails[2].replace("markers/", "markers/transparent-"); markerOptions = { icon: unitIcon }; var position = new GLatLng(unitPosition[0], unitPosition[1]); var marker = new GMarker(position, markerOptions); marker.hsid = unitDetails[3]; marker.min = unitDetails[4]; marker.alias = unitDetails[5]; marker.heading = unitDetails[6]; marker.timestamp = unitDetails[7]; marker.id = unitDetails[0]; marker.image = imageDetails[2]; marker.position = position; var foundMarker = false; UnitMarkers.push(marker); GEvent.addListener(marker, "click", function() { var el = document.getElementById(ControlLeader + "gridReport"); var className = "ReportDisplayAlternatingRowStyle"; for (var ii = 1; ii < el.rows.length; ii++) { el.rows[ii].className = className; if (className == "ReportDisplayRowStyle") { className = "ReportDisplayAlternatingRowStyle"; } else { className = "ReportDisplayRowStyle"; } el.rows[ii].className = className; var cols = el.rows[ii].getElementsByTagName("TD"); if (cols[0].innerHTML == this.id) { el.rows[ii].className = "ReportDisplaySelectedRowStyle"; } } SelectPoint(this.id); }); GEvent.addListener(marker, "mouseover", function() { this.setImage(this.image); }); GEvent.addListener(marker, "mouseout", function() { if ((this.id - 1) != SelectedUnit) { this.setImage(this.image.replace("markers/", "markers/transparent-")); } }); Bounds.extend(position); } UnitManager.addMarkers(UnitMarkers, 0); var newzoom = map.getBoundsZoomLevel(Bounds); var newcenter = Bounds.getCenter(); map.setCenter(newcenter, newzoom); map.savePosition(); UnitManager.refresh(); }
function RemoveLandmark(guid) { if (map == null) { setTimeout("RemoveLandmark('" + guid + "')", 50); return; } var removeId; for (var i = LandmarkMarkers.length - 1; i >= 0; i--) { if (LandmarkMarkers[i].id == guid) { removeId = i; LandmarkManager.removeMarker(LandmarkMarkers[i]); var sel = document.getElementById(ControlLeader + "ddlLandmarks"); for (var ii = sel.options.length - 1; ii >= 0; ii--) { var found = false; if (sel.options[ii] != null) { if (sel.options[ii].value == guid) { found = true; } } if (found) { sel.remove(ii); } } } } if (removeId != null) { LandmarkMarkers.splice(removeId, 1); } }
function UpdateLandmark(guid, alias, description, longitude, latitude, pan) { if (map == null) { setTimeout("UpdateLandmark(\"" + guid + "\", \"" + alias + "\", \"" + description + "\", \"" + longitude + "\", \"" + latitude + "\", " + pan + ")", 50); return; } var position = new GLatLng(latitude, longitude); var marker = new GMarker(position); marker.id = guid; marker.alias = alias; marker.position = position; marker.address = "Latitude: " + latitude + "<br />"; marker.address += "Longitude: " + longitude + "<br />"; if (marker.position.lat() != 0 && marker.position.lng() != 0) ReverseGeocode(marker.position.lat(), marker.position.lng()); var foundMarker = false; for (var i = 0; i < LandmarkMarkers.length; i++) { if (LandmarkMarkers[i].id == guid) { foundMarker = true; LandmarkMarkers[i].alias = alias; LandmarkMarkers[i].position = position; LandmarkMarkers[i].setLatLng(position); } } if (!foundMarker) { LandmarkMarkers.push(marker); LandmarkManager.addMarker(marker, 0); } GEvent.addListener(marker, "click", function(latlng) { if (latlng) { var ihtml = marker.alias + "<br />"; ihtml += "<br />"; ihtml += "<span id='" + marker.id + "-addressinfo'>"; ihtml += marker.address; ihtml += "</span>"; map.openInfoWindowHtml(this.position, ihtml, { pixelOffset: new GSize(0, -20) }); } }); GEvent.addListener(marker, "dblclick", function(latlng) { if (latlng) { map.zoomIn(); map.setCenter(latlng); } }); UpdateDropdownOption(ControlLeader + "ddlLandmarks", alias, guid); var sel = document.getElementById(ControlLeader + "ddlLandmarks"); }
function ShowAlert(heading, text, button) { var hed = document.getElementById(ControlLeader + "lblAlertHeading"); var txt = document.getElementById(ControlLeader + "lblAlertText"); var btn = document.getElementById(ControlLeader + "btnAlert"); hed.innerHTML = heading; txt.innerHTML = text; btn.value = button; var alt = document.getElementById(ControlLeader + "pnlAlert"); if (alt != null) { alt.style.visibility = "visible"; } $find("AlertPopup").show(); btn.focus(); }
function LandmarkSaved(heading, text, button, timestamp) { ShowAlert(heading, text, button); UpdateMap(timestamp); }
function LandmarkDeleted(heading, text, button, timestamp) { ShowAlert(heading, text, button); UpdateMap(timestamp); }
function GotoAddressFail(heading, text, button, timestamp) { ShowAlert(heading, text, button); UpdateMap(timestamp); }
function GotoAddress() { var street = document.getElementById(ControlLeader + "txtLocationsAddress"); var city = document.getElementById(ControlLeader + "txtLocationsCity"); var state = document.getElementById(ControlLeader + "ddlLocationsState"); var zip = document.getElementById(ControlLeader + "txtLocationsZip"); var address = street.value + ", " + city.value + ", " + state.value + " " + zip.value; Geocoder.getLocations(address, addAddressToMap); }
function addAddressToMap(response) { if (!response || response.Status.code != 200) { ShowAlert("FAILURE!", "Unable to locate address provided.  Please try again.", "OK"); btn.focus(); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); if (AddressMarker != null) { map.removeOverlay(AddressMarker); } AddressMarker = new GMarker(point); map.addOverlay(AddressMarker); var address = ""; if (place.AddressDetails.Country == null) { address = place.address; } else { var adminarea = place.AddressDetails.Country.AdministrativeArea; if (adminarea != null) { if (adminarea.Locality != null) { if (adminarea.Locality.Thoroughfare != null) { address += adminarea.Locality.Thoroughfare.ThoroughfareName + "<br />"; } address += " " + adminarea.Locality.LocalityName + ","; } address += " " + adminarea.AdministrativeAreaName; if (adminarea.Locality != null) { if (adminarea.Locality.PostalCode != null) { address += "  " + adminarea.Locality.PostalCode.PostalCodeNumber; } } } } var whtml = "<input id=\"hiddenLandmarkLocation\" type=\"hidden\" value=\"" + place.Point.coordinates[1] + "_:_" + place.Point.coordinates[0] + "\">"; whtml += "<input id=\"hiddenLandmarkDescription\" type=\"hidden\" value=\"" + address + "\">"; whtml += "<input id=\"txtLandmarkName\" type=\"text\" value=\"Landmark Name\" maxlength=\"20\">"; whtml += "<br />"; whtml += "<input type=\"submit\" class=\"MenuButton\" value=\"Save Landmark\" onclick=\"SaveLandmark(); return false;\">"; whtml += "<br />"; whtml += "<br />"; whtml += address; MoveListener = GEvent.bind(map, "moveend", this, function() { AddressMarker.openInfoWindowHtml(whtml); GEvent.removeListener(MoveListener) }); map.panTo(point); } }
function SaveLandmark() { var loc = document.getElementById("hiddenLandmarkLocation"); var des = document.getElementById("hiddenLandmarkDescription"); var name = document.getElementById("txtLandmarkName"); var el = document.getElementById(ControlLeader + "fieldSaveLandmark"); el.value = loc.value + "_:_" + name.value + "_:_" + des.value; __doPostBack(ControlLeader + 'fieldSaveLandmark', 'OnValueChanged'); }
function DeleteLandmark() { var ddl = document.getElementById(ControlLeader + "ddlLandmarks"); var el = document.getElementById(ControlLeader + "fieldDeleteLandmark"); el.value = ddl.value; __doPostBack(ControlLeader + 'fieldDeleteLandmark', 'OnValueChanged'); }
function SavedLandmark(heading, text, button) { ShowAlert(heading, text, button); if (heading.indexOf("SUCCESS") != -1) { if (AddressMarker != null) { map.removeOverlay(AddressMarker); } map.closeInfoWindow(); } }
function UpdateDropdownOption(dropdown, text, value) { var sel = document.getElementById(dropdown); var found = false; for (var i = 0; i < sel.options.length; i++) { if (sel.options[i].value == value) { sel.options[i].text = text; found = true; break; } } if (!found) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; sel.options.add(optn); } }
function RemoveGeofence(guid) { var sel = document.getElementById(ControlLeader + "ddlUnitSettingsGeofence"); var el = document.getElementById(ControlLeader + "ddlGeofenceList"); for (var i = sel.options.length - 1; i >= 0; i--) { var found = false; if (sel.options[i] != null) { if (sel.options[i].value == guid) { found = true; } } if (found) { sel.remove(i); } } var isSelected = false; for (var i = el.options.length - 1; i >= 0; i--) { var found = false; if (el.options[i] != null) { if (el.options[i].value == guid) { isSelected = el.options[i].selected; found = true; } } if (found) { el.remove(i); } } if (isSelected) { DisplayGeofence(); } }
function UpdateGeofence(guid, alias) { UpdateDropdownOption(ControlLeader + "ddlUnitSettingsGeofence", alias, guid); UpdateDropdownOption(ControlLeader + "ddlGeofenceList", alias, guid); }
function DeleteGeofencePrompt() { var el = document.getElementById(ControlLeader + "ddlGeofenceList"); var geoName = ""; var geoGuid = ""; for (var i = 0; i < el.options.length; i++) { if (el.options[i].selected) { geoGuid = el.options[i].value; geoName = el.options[i].text; break; } } ShowConfirmation("CONFIRM", "Are you sure you want to delete the geofence: " + geoName, "Yes", "No", function() { DeleteGeofence(geoGuid); return false; }); }
function DeleteGeofence(guid) { var el = document.getElementById(ControlLeader + "fieldDeleteGeofence"); el.value = guid; __doPostBack(ControlLeader + 'fieldDeleteGeofence', 'OnValueChanged'); $find("ConfirmationPopup").hide(); }
function DeletedGeofence(heading, text, button) { ShowAlert(heading, text, button); }
function ShowConfirmation(heading, text, yesbutton, nobutton, yesaction) { var lblHead = document.getElementById(ControlLeader + "lblConfirmationHeading"); var lblText = document.getElementById(ControlLeader + "lblConfirmationText"); var btnYes = document.getElementById(ControlLeader + "btnConfirmationYes"); var btnNo = document.getElementById(ControlLeader + "btnConfirmationNo"); lblHead.innerHTML = heading; lblText.innerHTML = text; btnYes.value = yesbutton; btnYes.onclick = yesaction; btnNo.value = nobutton; var alt = document.getElementById(ControlLeader + "pnlConfirmation"); if (alt != null) alt.style.visibility = "visible"; $find("ConfirmationPopup").show(); }
function SaveGeofence() { var gn = document.getElementById(ControlLeader + "txtGeofenceName"); if (!Geofence.complete) { ShowAlert("INFORMATION!", "You must complete drawing the geofence.  Please try again.", "OK"); return; } var tmp = gn.value; while (tmp.indexOf(" ") != -1) { tmp = tmp.replace(" ", ""); } if (tmp == "") { ShowAlert("INFORMATION!", "You must specify a name for the geofence.  Please try again.", "OK"); return; } var test = Geofence.id; test += "_$_"; test += gn.value; test += "_$_"; for (var i = 0; i < Geofence.getVertexCount() - 1; i++) { if (i > 0) { test += "_^_"; } test += Geofence.getVertex(i).lat() + "," + Geofence.getVertex(i).lng(); } var sg = document.getElementById(ControlLeader + "fieldSaveGeofence"); sg.value = test; __doPostBack(ControlLeader + "fieldSaveGeofence", "OnValueChanged"); }
function SavedGeofence(guid, heading, text, button, update) { ShowAlert(heading, text, button); var el = document.getElementById(ControlLeader + "ddlGeofenceList"); for (var i = 0; i < el.options.length; i++) { if (el.options[i].value == guid) { el.options[i].selected = true; break; } } if (update == "true") { var gi = document.getElementById(ControlLeader + "tblMapSubMenuGeofenceInfo"); gi.style.visibility = "visible"; } else { DisplayGeofence(); } }
function RevertGeofence() { if (Geofence != null) { Geofence.disableEditing(); map.removeOverlay(Geofence); } if (BaseGeofence != null) { var latlonArray = new Array(); for (var i = 0; i < BaseGeofence.getVertexCount(); i++) { latlonArray.push(BaseGeofence.getVertex(i)); } Geofence = new GPolygon(latlonArray, "#0000FF", 1, 0.75, "#0000FF", 0.25); Geofence.id = BaseGeofence.id; Geofence.complete = true; Geofence.alias = BaseGeofence.alias; GEvent.addListener(Geofence, "mouseover", function() { Geofence.enableEditing(); }); GEvent.addListener(Geofence, "mouseout", function() { Geofence.disableEditing(); }); GEvent.addListener(Geofence, "click", function(latlng, index) { if (typeof index == "number") { Geofence.deleteVertex(index); } }); var gr = document.getElementById(ControlLeader + "btnRevertGeofence"); gr.value = "Revert"; var gn = document.getElementById(ControlLeader + "txtGeofenceName"); gn.value = Geofence.alias; map.addOverlay(Geofence); } else { var sv = document.getElementById(ControlLeader + "btnSaveGeofence"); sv.style.visibility = "hidden"; var gfr = document.getElementById(ControlLeader + "btnRevertGeofence"); gfr.value = "Revert"; gfr.style.visibility = "hidden"; var gfn = document.getElementById(ControlLeader + "txtGeofenceName"); gfn.value = ""; gfn.style.visibility = "hidden"; var gfd = document.getElementById(ControlLeader + "btnDeleteGeofence"); gfd.style.visibility = "hidden"; } }
function ShowGeofence(guid, alias, points) { if (map == null) { setTimeout("ShowGeofence(\"" + guid + "\", \"" + alias + "\", \"" + points + "\")", 25); return; } else { var areas = points.split("_&_"); for (var ii = 0; ii < areas.length; ii++) { var point = areas[ii].split("_^_"); if (point.length > 0) { var latlonArray = new Array(); if (Geofence != null) { map.removeOverlay(Geofence); } var bounds = new GLatLngBounds(); for (var i = 0; i < point.length; i++) { var position = point[i].split(","); var thisPoint = new GLatLng(position[0], position[1]); latlonArray.push(thisPoint); if (i != (point.length - 1)) { if (!Report) { bounds.extend(thisPoint); } else { Bounds.extend(thisPoint); } } } if (!Report) { var newzoom = map.getBoundsZoomLevel(bounds); var newcenter = bounds.getCenter(); map.setCenter(newcenter, newzoom); } else { var newzoom = map.getBoundsZoomLevel(Bounds); var newcenter = Bounds.getCenter(); map.setCenter(newcenter, newzoom); } var firstGeofence = false; if (Geofence == null) { firstGeofence = true; } if (!firstGeofence) { Geofence.disableEditing(); map.removeOverlay(Geofence); } BaseGeofence = new GPolygon(latlonArray, "#0000FF", 1, .75, "#0000FF", 0.25); Geofence = new GPolygon(latlonArray, "#0000FF", 1, .75, "#0000FF", 0.25); if (!Report) { GEvent.addListener(Geofence, "mouseover", function() { Geofence.enableEditing(); }); GEvent.addListener(Geofence, "mouseout", function() { Geofence.disableEditing(); }); GEvent.addListener(Geofence, "click", function(latlng, index) { if (typeof index == "number") { Geofence.deleteVertex(index); } }); } BaseGeofence.id = guid; BaseGeofence.alias = alias; Geofence.id = guid; Geofence.alias = alias; Geofence.complete = true; map.addOverlay(Geofence); if (!Report) { var gr = document.getElementById(ControlLeader + "btnRevertGeofence"); gr.value = "Revert"; var gd = document.getElementById(ControlLeader + "btnDeleteGeofence"); gd.style.visibility = "visible"; var gn = document.getElementById(ControlLeader + "txtGeofenceName"); gn.value = Geofence.alias; var gi = document.getElementById(ControlLeader + "tblMapSubMenuGeofenceInfo"); gi.style.visibility = "visible"; var el = document.getElementById(ControlLeader + "ddlGeofenceList"); for (var i = 0; i < el.options.length; i++) { if (el.options[i].value == guid) { el.options[i].selected = true; break; } } } } } } }
function DisplayGeofence() { var el = document.getElementById(ControlLeader + "ddlGeofenceList"); if (el.value != "") { var gi = document.getElementById(ControlLeader + "tblMapSubMenuGeofenceInfo"); var sg = document.getElementById(ControlLeader + "fieldShowGeofence"); gi.style.visibility = "hidden"; for (var i = 0; i < el.options.length; i++) { if (el.options[i].selected) { sg.value = el.options[i].value; break; } } __doPostBack(ControlLeader + "fieldShowGeofence", "OnValueChanged"); } else { var msg = document.getElementById(ControlLeader + "tblMapSubMenuGeofenceInfo"); msg.style.visibility = "hidden"; if (Geofence != null) { Geofence.disableEditing(); map.removeOverlay(Geofence); } } }
function ModifyGeofence() { var eg = document.getElementById("EditGeofence"); var sg = document.getElementById("SelectedGeofence"); eg.value = ""; eg.value = sg.value; __doPostBack('EditGeofence', 'OnValueChanged'); }
function MapClicked() { if (!GeofenceMode) { ShowHideMenus(); } }
function SetTrackMode(el) { if (el.checked) { if (SelectedUnit != null) { map.disableDragging(); PanToUnit(SelectedUnit); } } else { map.enableDragging(); } }
function SetMapSize(el) { var dimensions = el.id.split("x"); set_cookie('MapSize', el.id.replace(ControlLeader + "rdo", "")); SizeMap(); }
function SizeMap() { if (map == null) { setTimeout("SizeMap()", 10); return; } var size = get_cookie("MapSize"); if (Report) { size = "468x538"; } if (size == null) { set_cookie("MapSize", "1236x617"); setTimeout("SizeMap();", 10); return; } var chk = document.getElementById(ControlLeader + "rdo" + size); if (chk != null) { chk.checked = true; } var mapdiv = document.getElementById(ControlLeader + "pnlMapContainer"); var mapinfo = document.getElementById(ControlLeader + "pnlMapInfo"); var dimensions = size.split("x"); var mapmove = false; var resize = false; var justHeight = false; if (mapcanvas.style.top != "0px") { mapcanvas.style.top = "0px"; mapmove = true; } if (mapcanvas.style.width != dimensions[0] + "px" && mapcanvas.style.height != dimensions[1] + "px") { resize = true; } else if (mapcanvas.style.width == dimensions[0] + "px" && mapcanvas.style.height != dimensions[1] + "px") { justHeight = true; } mapcanvas.style.width = dimensions[0] + "px"; mapcanvas.style.height = dimensions[1] + "px"; mapwidth = dimensions[0]; mapheight = dimensions[1]; if (mapdiv != null) mapdiv.style.height = dimensions[1] + "px"; var top = parseInt(dimensions[1]); top += 5; if (mapinfo != null) { mapinfo.style.top = top + "px"; } var center = map.getCenter(); map.checkResize(); map.panTo(center); if (!Report) { if (!justHeight) { } } }
function HideAllUnits() { if (map == null) { setTimeout("HideAllUnits()", 25); return; } if (!FleetReport) { for (var i = 0; i < UnitMarkers.length; i++) { UnitMarkers[i].hide(); UnitMarkers[i].closeInfoWindow(); } var el = document.getElementById(ControlLeader + "gridReport"); var className = "ReportDisplayRowStyle"; for (var i = 1; i < el.rows.length; i++) { el.rows[i].className = className; if (className == "ReportDisplayRowStyle") { className = "ReportDisplayAlternatingRowStyle"; } else { className = "ReportDisplayRowStyle"; } } SelectedUnit = null; } }
function ShowAllUnits() { if (map == null) { setTimeout("ShowAllUnits()", 25); return; } if (!FleetReport) { var el = document.getElementById(ControlLeader + "gridReport"); var className = "ReportDisplayRowStyle"; for (var i = 1; i < el.rows.length; i++) { el.rows[i].className = className; if (className == "ReportDisplayRowStyle") { className = "ReportDisplayAlternatingRowStyle"; } else { className = "ReportDisplayRowStyle"; } } SelectedUnit = null; for (var i = 0; i < UnitMarkers.length; i++) { UnitMarkers[i].show(); UnitMarkers[i].closeInfoWindow(); } map.returnToSavedPosition(); } }
function get_cookie(cookie_name) { var results = document.cookie.match(cookie_name + '=(.*?)(;|$)'); if (results) { return (unescape(results[1])); } else { return null; } }
function set_cookie(name, value) { var cookie_string = name + "=" + escape(value); var expires = new Date(2099, 12, 31); cookie_string += "; expires=" + expires.toGMTString(); cookie_string += "; path=/"; document.cookie = cookie_string; }
