4 var selectedNetworkOverlay;
9 var loadingAnimationDiv;
15 function novaMapInit() {
16 if (GBrowserIsCompatible()) {
17 var dmap = document.getElementById("map");
18 map = new GMap2(dmap);
19 var defaultCenterLongitude = document.getElementById("defaultCenterLongitude").value;
20 var defaultCenterLatitude = document.getElementById("defaultCenterLatitude").value;
21 var defaultZoomLevel = document.getElementById("defaultZoomLevel").value * 1;
23 map.setCenter(new GLatLng(defaultCenterLatitude, defaultCenterLongitude), defaultZoomLevel);
25 map.enableScrollWheelZoom();
26 map.enableContinuousZoom();
27 map.addControl(new GLargeMapControl());
28 map.addControl(new GMapTypeControl());
30 geocoder = new GClientGeocoder();
32 GEvent.addListener(map, "dragend", mapDragEnd);
33 GEvent.addListener(map, "zoomend", mapZoomChanged);
34 GEvent.addListener(map, "click", mapClicked);
35 GEvent.addListener(map, "moveend", mapMoveEnd)
36 GEvent.addListener(map, "singlerightclick", mapRightClicked);
37 GEvent.addListener(map, "mousemove", function(latlng) {
38 locationInfoDiv.innerHTML = latlng.lng().toFixed(3) + ", " + latlng.lat().toFixed(3);
41 var n = document.getElementById("popupmenudiv2");
42 popupDiv = n.cloneNode(true);
43 map.getContainer().appendChild(popupDiv);
45 popupTable = document.getElementById("popupmenudivtb");
48 /*infoDiv = document.createElement("div");
49 infoDiv.style.display = "none";
50 infoDiv.style.position = "absolute";
51 infoDiv.style.overflow = "auto";
52 infoDiv.style.top = "0px";
53 infoDiv.style.left = "0px";
54 infoDiv.style.zIndex = "1001";
55 infoDiv.style.border = "1px outset #000";
56 infoDiv.style.background = "#C6DEFF";
57 infoDiv.style.height = "150px";
58 infoDiv.style.width = "300px";
59 infoDiv.align = "center";*/
61 mainInfoDiv = document.createElement("div");
62 mainInfoDiv.style.display = "none";
63 mainInfoDiv.style.position = "absolute";
64 mainInfoDiv.style.overflow = "auto";
65 mainInfoDiv.style.top = "0px";
66 mainInfoDiv.style.left = "0px";
67 mainInfoDiv.style.zIndex = "1001";
68 mainInfoDiv.style.border = "1px outset #000";
69 mainInfoDiv.style.background = "#C6DEFF";
70 mainInfoDiv.style.height = "150px";
71 mainInfoDiv.style.width = "300px";
72 mainInfoDiv.align = "center";
74 //mainInfoDiv = infoDiv.appendChild(document.createElement("div"));
75 mainInfoDiv.style.overflow = "auto";
76 mainInfoDiv.style.height = "150px";
77 mainInfoDiv.style.width = "300px";
78 //mainInfoDiv.align = "center";
80 /*var closeInfoDiv = infoDiv.appendChild(document.createElement("div"));
81 closeInfoDiv.appendChild(document.createTextNode("Close"));
83 closeInfoDiv.style.background = "#FFFFF0";
84 closeInfoDiv.style.color = "black";
85 closeInfoDiv.style.fontFamily = "Verdana";
86 closeInfoDiv.style.fontSize = "12px";
87 closeInfoDiv.style.fontWeight= "bold";
88 closeInfoDiv.style.border = "2px solid black";
89 closeInfoDiv.style.padding = "0px";
90 closeInfoDiv.style.marginBottom = "0px";
91 closeInfoDiv.style.textAlign = "center";
92 closeInfoDiv.style.width = "80px";
93 closeInfoDiv.style.height = "15px";
94 closeInfoDiv.style.cursor = "pointer";
96 GEvent.addDomListener(closeInfoDiv, "click", function() {
97 infoDiv.style.display = "none";
100 // longitude latitude div
101 var locationInfoWidth = 200;
102 var locationInfoHeight = 15;
103 locationInfoDiv = document.createElement("div");
104 locationInfoDiv.style.display = "inline";
105 locationInfoDiv.style.position = "absolute";
106 locationInfoDiv.style.zIndex = "1";
107 locationInfoDiv.style.height = locationInfoHeight + "px";
108 locationInfoDiv.style.width = locationInfoWidth + "px";
109 locationInfoDiv.align = "center";
110 locationInfoDiv.style.color = "#4CC417";
111 locationInfoDiv.style.fontWeight = "bold";
112 locationInfoDiv.appendChild(document.createTextNode("Longitude Latitude"));
114 var mapWidth = map.getSize().width;
115 var mapHeight = map.getSize().height;
117 locationInfoDiv.style.top = (mapHeight - locationInfoHeight - 5) + "px";
118 locationInfoDiv.style.left = (mapWidth / 2 - locationInfoWidth / 2) + "px";
120 // loading image animation
121 loadingAnimationDiv = document.createElement("div");
122 loadingAnimationDiv.style.position = "absolute";
123 loadingAnimationDiv.style.zIndex = "100000";
124 loadingAnimationDiv.style.display = "none";
125 loadingAnimationDiv.style.width = "50px";
126 loadingAnimationDiv.style.height = "50px";
127 loadingAnimationDiv.style.top = (mapHeight / 2 - 50 / 2) + "px";
128 loadingAnimationDiv.style.left = (mapWidth / 2 - 50 / 2) + "px";
129 var imgDiv = loadingAnimationDiv.appendChild(document.createElement("img"));
130 imgDiv.src = document.getElementById("imgFolder").value + "loading.gif";
133 //map.getContainer().appendChild(infoDiv);
134 map.getContainer().appendChild(mainInfoDiv);
135 map.getContainer().appendChild(locationInfoDiv);
136 map.getContainer().appendChild(loadingAnimationDiv);
141 function mapRightClicked(point, src) {
142 var latlng = map.fromContainerPixelToLatLng(new GPoint(point.x , point.y));
143 alert(latlng.lng() + ", " + latlng.lat());
146 function searchObject(searchInput, searchType, exactMatch, clickX, clickY) {
147 loadingAnimationDiv.style.display = "inline";
148 var baseURL = document.getElementById("baseURL").value;
149 //var url = baseURL + "/gmap_controller.htm?action=searchObject";
150 //var url = baseURL + "report.gmap.search_object";
151 var url = baseURL + "/gmapservlet?action=searchObject&nextpage=report.gmap.search_object";
152 url += "&search_input=" + searchInput;
153 url += "&search_type=" + searchType;
154 url += "&exact_match=" + exactMatch;
155 url += "&object_type=CELLSITE";
157 if (clickX == null || clickY == null) {
158 var mapWidth = map.getSize().width;
159 var mapHeight = map.getSize().height;
160 clickX = mapWidth / 2;
161 clickY = mapHeight / 2;
164 url += "&client_x=" + clickX;
165 url += "&client_y=" + clickY;
167 new Ajax.Request(url, {
169 onSuccess: function(transport) {
170 loadingAnimationDiv.style.display = "none";
171 var jsonData = transport.responseText.evalJSON();
172 var list = jsonData.list;
178 if (list.length == 1) {
179 var longitude = list[0].longitude;
180 var latitude = list[0].latitude;
181 map.setCenter(new GLatLng(latitude, longitude));
185 for (var i = popupTable.childNodes.length - 1; i >= 0; i--) {
186 popupTable.removeChild(popupTable.lastChild);
189 for (var i = 0; i < list.length; i++) {
190 var tr = popupTable.appendChild(document.createElement("tr"));
191 var td = tr.appendChild(document.createElement("td"));
192 td.appendChild(document.createTextNode(list[i].type + "(" + list[i].numberOfT1 +
193 "): " + list[i].id));
194 td.style.border = "solid";
195 td.style.borderWidth = "thin";
196 td.style.borderRight = "none";
197 td.style.borderLeft = "none";
200 td.style.borderTop = "none";
203 if (i == list.length - 1) {
204 td.style.borderBottom = "none";
207 td.style.color = "#0000FF";
208 td.style.background = "#FFFFF0";
209 td.style.fontSize = "12px";
210 td.font = "Arial,Helvetica,sans-serif";
211 td.id = list[i].latitude + ">>" + list[i].longitude;
213 td.onmouseover = function(e) {
214 this.style.background = "#0000FF";
215 this.style.color = "#FFFFF0";
218 td.onmouseout = function(e) {
219 this.style.background = "#FFFFF0";
220 this.style.color = "#0000FF";
223 td.onclick = function(e) {
224 //var popupDiv = document.getElementById("popupmenudiv");
225 popupDiv.style.display = "none";
226 var latitudeLongitude = this.id.split(">>");
227 var latlng = new GLatLng(latitudeLongitude[0], latitudeLongitude[1]);
228 map.setCenter(latlng);
233 //var popupDiv = document.getElementById("popupmenudiv");
234 popupDiv.style.display = "";
236 var textWidth = popupDiv.offsetWidth;
237 var textHeight = popupDiv.offsetHeight;
239 if (textHeight >= 200) {
240 popupDiv.style.overflow = "auto";
241 popupDiv.style.height = "200px";
245 if (textWidth >= 250) {
246 popupDiv.style.width = "250px";
250 var clientX = jsonData.clientX;
251 var clientY = jsonData.clientY;
253 if ((clientX * 1 + textWidth + 20) >= screen.availWidth) {
254 clientX = clientX - textWidth - 20;
257 if ((clientY * 1 + textHeight) >= document.getElementById("map").offsetHeight) {
258 clientY = document.getElementById("map").offsetHeight - textHeight;
262 popupDiv.style.top = clientY + "px";
263 popupDiv.style.left = clientX + "px";
270 function getInfo(info, x, y) {
271 var baseURL = document.getElementById("baseURL").value;
272 //var url = baseURL + "/gmap_controller.htm?action=getInfo";
273 //var url = baseURL + "report.gmap.get_info";
274 var url = baseURL + "/gmapservlet?action=getInfo&nextpage=report.gmap.get_info";
275 url += "&info=" + info;
276 url += "&client_x=" + x;
277 url += "&client_y=" + y;
279 new Ajax.Request(url, {
281 onSuccess: function(transport) {
282 var jsonData = transport.responseText.evalJSON();
283 var clientX = jsonData.clientX;
284 var clientY = jsonData.clientY;
285 var attributes = jsonData.attributes;
287 for (var i = mainInfoDiv.childNodes.length - 1; i >= 0; i--) {
288 mainInfoDiv.removeChild(mainInfoDiv.lastChild);
291 mainInfoDiv.align="left";
292 var menuUL = mainInfoDiv.appendChild(document.createElement("ul"));
293 var menuItem = document.createElement("li");
294 menuItem.appendChild(document.createTextNode("Row : " + jsonData.id));
295 menuUL.appendChild(menuItem);
297 menuItem = document.createElement("li");
298 menuItem.appendChild(document.createTextNode("Longitude: " + jsonData.longitude));
299 menuUL.appendChild(menuItem);
301 menuItem = document.createElement("li");
302 menuItem.appendChild(document.createTextNode("Latitude: " + jsonData.latitude));
303 menuUL.appendChild(menuItem);
305 var table = mainInfoDiv.appendChild(document.createElement("table"));
308 var tbody = table.appendChild(document.createElement("tbody"));
309 //tbody.style.borderCollapse = "collapse";
310 //var tr = tbody.appendChild(document.createElement("tr"));
312 for (var i = 0; i < attributes.length ; i++) {
313 tr = tbody.appendChild(document.createElement("tr"));
314 td = tr.appendChild(document.createElement("td"));
317 td.style.padding = "2px";
318 td.appendChild(document.createTextNode(attributes[i].key));
319 td = tr.appendChild(document.createElement("td"));
320 td.style.padding = "2px";
321 td.appendChild(document.createTextNode(attributes[i].value));
325 var textHeight = 150 + 15;
327 if ((clientX * 1 + textWidth + 20) >= screen.availWidth) {
328 clientX = clientX - textWidth - 20;
331 if ((clientY * 1 + textHeight) >= document.getElementById("map").offsetHeight) {
332 clientY = document.getElementById("map").offsetHeight - textHeight;
335 mainInfoDiv.style.top = clientY + "px";
336 mainInfoDiv.style.left = clientX + "px";
337 mainInfoDiv.style.display = "inline";
342 function mapClicked(overlay, latlng, overlaylatlng) {
343 var baseURL = document.getElementById("baseURL").value;
344 //var url = baseURL + "/gmap_controller.htm?action=singleLeftClick";
345 //var url = baseURL + "report.gmap.single_left_click";
346 var url = baseURL + "/gmapservlet?action=singleLeftClick&nextpage=report.gmap.single_left_click";
347 var mapSize = map.getSize();
348 var mapBounds = map.getBounds();
349 var pointSW = mapBounds.getSouthWest();
350 var pointNE = mapBounds.getNorthEast();
351 url += "&click_longitude=" + latlng.lng();
352 url += "&click_latitude=" + latlng.lat();
353 url += "&zoom_level=" + map.getZoom();
354 url += "&map_size=" + mapSize.width + "," + mapSize.height;
355 url += "&map_bounds=" + pointSW.lng() + "," + pointSW.lat() + "," + pointNE.lng() + "," + pointNE.lat();
356 var point = map.fromLatLngToContainerPixel(latlng);
357 var clickX = point.x;
358 var clickY = point.y;
359 url += "&client_x=" + clickX;
360 url += "&client_y=" + clickY;
362 //document.getElementById("popupmenudiv").style.display = "none";
363 popupDiv.style.display="none";
364 mainInfoDiv.style.display="none";
365 new Ajax.Request(url, {
367 onSuccess: function(transport) {
368 var jsonData = transport.responseText.evalJSON();
369 var list = jsonData.list;
370 var selectedImageURL = jsonData.selectedImageURL;
371 var legendImageURL = jsonData.legendImageURL;
372 //alert(legendImageURL);
373 if (legendImageURL != null) {
374 repaintLegend(legendImageURL);
378 for (var i = popupTable.childNodes.length - 1; i >= 0; i--) {
379 popupTable.removeChild(popupTable.lastChild);
382 for (var i = 0; i < list.length; i++) {
383 var tr = popupTable.appendChild(document.createElement("tr"));
384 var td = tr.appendChild(document.createElement("td"));
385 td.appendChild(document.createTextNode("Row : " + list[i].id));
386 td.style.border = "solid";
387 td.style.borderWidth = "thin";
388 td.style.borderRight = "none";
389 td.style.borderLeft = "none";
392 td.style.borderTop = "none";
395 if (i == list.length - 1) {
396 td.style.borderBottom = "none";
399 td.style.color = "#0000FF";
400 td.style.background = "#FFFFF0";
401 td.style.fontSize = "12px";
402 td.font = "Arial,Helvetica,sans-serif";
403 td.id = jsonData.type + ">>" + list[i].id + ">>" + list[i].type;
405 td.onmouseover = function(e) {
406 this.style.background = "#0000FF";
407 this.style.color = "#FFFFF0";
410 td.onmouseout = function(e) {
411 this.style.background = "#FFFFF0";
412 this.style.color = "#0000FF";
415 td.onclick = function(e) {
416 //var popupDiv = document.getElementById("popupmenudiv");
417 getInfo(this.id, clickX, clickY);
419 popupDiv.style.display = "none";
423 //var popupDiv = document.getElementById("popupmenudiv");
424 popupDiv.style.display = "";
426 var textWidth = popupDiv.offsetWidth;
427 var textHeight = popupDiv.offsetHeight;
429 if (textHeight >= 200) {
430 popupDiv.style.overflow = "auto";
431 popupDiv.style.height = "200px";
435 if (textWidth >= 250) {
436 popupDiv.style.width = "250px";
440 var clientX = jsonData.clientX;
441 var clientY = jsonData.clientY;
443 if ((clientX * 1 + textWidth + 20) >= screen.availWidth) {
444 clientX = clientX - textWidth - 20;
447 if ((clientY * 1 + textHeight) >= document.getElementById("map").offsetHeight) {
448 clientY = document.getElementById("map").offsetHeight - textHeight;
452 popupDiv.style.top = clientY + "px";
453 popupDiv.style.left = clientX + "px";
455 else if (selectedImageURL != null) {
456 repaintSelected(selectedImageURL);
464 function mapMoveEnd() {
465 if (networkOverlay != null) {
466 map.removeOverlay(networkOverlay);
467 networkOverlay = null;
474 function mapDragEnd() {
477 function mapZoomChanged(oldZoomLevel, newZoomLevel) {
480 function updateSelectedImage() {
481 var baseURL = document.getElementById("baseURL").value;
482 var url = baseURL + "/gmap_controller.htm?action=nova.gmap.fetch.selected.image";
483 var mapSize = map.getSize();
484 var mapBounds = map.getBounds();
485 var pointSW = mapBounds.getSouthWest();
486 var pointNE = mapBounds.getNorthEast();
487 url += "&zoomLevel=" + map.getZoom();
488 url += "&mapSize=" + mapSize.width + "," + mapSize.height;
489 url += "&mapBounds=" + pointSW.lng() + "," + pointSW.lat() + "," + pointNE.lng() + "," + pointNE.lat();
491 new Ajax.Request(url, {
494 onSuccess: function(transport) {
495 var url = transport.responseXML.getElementsByTagName("image-url")[0].childNodes[0].nodeValue;
498 repaintSelected(url);
505 function updateImage(incDecValue) {
507 loadingAnimationDiv.style.display = "inline";
508 var baseURL = document.getElementById("baseURL").value;
509 //var url = baseURL + "/gmap_controller.htm?action=getImage";
510 //var url = baseURL + "report.gmap.get_image";
511 var url = baseURL + "/gmapservlet?action=getImage&nextpage=report.gmap.get_image";
512 var mapSize = map.getSize();
513 var mapBounds = map.getBounds();
514 var pointSW = mapBounds.getSouthWest();
515 var pointNE = mapBounds.getNorthEast();
516 url += "&zoom_level=" + map.getZoom();
517 url += "&map_size=" + mapSize.width + "," + mapSize.height;
518 url += "&map_bounds=" + pointSW.lng() + "," + pointSW.lat() + "," + pointNE.lng() + "," + pointNE.lat();
519 url += "&increment_decrement_value=" + incDecValue;
520 url += "&selected_layer_list=" + document.getElementById("selectedLayerList").value;
521 url += "&color_list=" + document.getElementById("colorList").value;
522 var randomNumber = Math.floor(Math.random() * 5000000)
523 url += "&dummy=" + randomNumber;
525 //disableUserInput();
526 new Ajax.Request(url, {
528 onSuccess: function(transport) {
530 loadingAnimationDiv.style.display = "none";
531 var jsonData = transport.responseText.evalJSON();
532 var imageURL = jsonData.imageURL;
533 var legendImageURL = jsonData.legendImageURL;
534 var selectedImageURL = jsonData.selectedImageURL;
535 var currentMonth = jsonData.currentMonth;
536 var colorList = jsonData.colorList;
537 var selectedLayerList = jsonData.selectedLayerList;
539 if (legendImageURL != null) {
540 repaintLegend(legendImageURL);
542 if (imageURL != null) {
546 if (selectedImageURL != null) {
547 repaintSelected(selectedImageURL);
550 if (currentMonth != null) {
551 document.getElementById("currentMonthDiv").innerHTML = currentMonth;
554 if (colorList != null) {
555 document.getElementById("colorList").value = colorList;
556 document.getElementById("selectedLayerList").value = selectedLayerList;
557 NovaButton.prototype.initializeLayerDiv(NovaButton.globals.layerOptionContainer);
565 function repaintLegend(url) {
566 var mapLegend = document.getElementById("mapLegend");
567 var legendImg = document.getElementById("legendImg");
569 mapLegend.removeChild(legendImg);
570 var newpic=document.createElement('img');
572 newpic.id="legendImg";
574 mapLegend.appendChild(newpic);
579 function repaint(url) {
580 if (networkOverlay != null) {
581 map.removeOverlay(networkOverlay);
584 networkOverlay = new ProjectedOverlay(url, map.getBounds()) ;
585 map.addOverlay(networkOverlay);
588 function repaintSelected(url) {
589 var mapBounds = map.getBounds();
590 var pointSW = mapBounds.getSouthWest();
591 var pointNE = mapBounds.getNorthEast();
593 if (selectedNetworkOverlay != null) {
594 map.removeOverlay(selectedNetworkOverlay);
597 selectedNetworkOverlay = new GGroundOverlay(url, new GLatLngBounds(pointSW, pointNE)) ;
598 map.addOverlay(selectedNetworkOverlay);
600 if (flashTimeout != null) {
601 clearTimeout(flashTimeout);
607 function flashImage() {
608 if (selectedNetworkOverlay.isHidden()) {
609 selectedNetworkOverlay.show();
612 selectedNetworkOverlay.hide();
615 flashTimeout = setTimeout(flashImage, 500);
618 function disableUserInput() {
619 map.disableDragging();
620 map.disableDoubleClickZoom();
621 map.disableScrollWheelZoom();
622 map.disableContinuousZoom();
625 function enableUserInput() {
626 map.enableDragging();
627 map.enableDoubleClickZoom();
628 map.enableScrollWheelZoom();
629 map.enableContinuousZoom();
632 String.prototype.trim = function() {
633 return this.replace(/^\s+|\s+$/g, "");