Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
6.9 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. /**
  16. * @class Ext.ux.GMapPanel
  17. * @extends Ext.Panel
  18. * @author Shea Frederick
  19. */
  20. Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
  21. initComponent : function(){
  22. var defConfig = {
  23. plain: true,
  24. zoomLevel: 3,
  25. yaw: 180,
  26. pitch: 0,
  27. zoom: 0,
  28. gmapType: 'map',
  29. border: false
  30. };
  31. Ext.applyIf(this,defConfig);
  32. Ext.ux.GMapPanel.superclass.initComponent.call(this);
  33. },
  34. afterRender : function(){
  35. var wh = this.ownerCt.getSize();
  36. Ext.applyIf(this, wh);
  37. Ext.ux.GMapPanel.superclass.afterRender.call(this);
  38. if (this.gmapType === 'map'){
  39. this.gmap = new GMap2(this.body.dom);
  40. }
  41. if (this.gmapType === 'panorama'){
  42. this.gmap = new GStreetviewPanorama(this.body.dom);
  43. }
  44. if (typeof this.addControl == 'object' && this.gmapType === 'map') {
  45. this.gmap.addControl(this.addControl);
  46. }
  47. if (typeof this.setCenter === 'object') {
  48. if (typeof this.setCenter.geoCodeAddr === 'string'){
  49. this.geoCodeLookup(this.setCenter.geoCodeAddr);
  50. }else{
  51. if (this.gmapType === 'map'){
  52. var point = new GLatLng(this.setCenter.lat,this.setCenter.lng);
  53. this.gmap.setCenter(point, this.zoomLevel);
  54. }
  55. if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
  56. this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear);
  57. }
  58. }
  59. if (this.gmapType === 'panorama'){
  60. this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng), {yaw: this.yaw, pitch: this.pitch, zoom: this.zoom});
  61. }
  62. }
  63. GEvent.bind(this.gmap, 'load', this, function(){
  64. this.onMapReady();
  65. });
  66. },
  67. onMapReady : function(){
  68. this.addMarkers(this.markers);
  69. this.addMapControls();
  70. this.addOptions();
  71. },
  72. onResize : function(w, h){
  73. if (typeof this.getMap() == 'object') {
  74. this.gmap.checkResize();
  75. }
  76. Ext.ux.GMapPanel.superclass.onResize.call(this, w, h);
  77. },
  78. setSize : function(width, height, animate){
  79. if (typeof this.getMap() == 'object') {
  80. this.gmap.checkResize();
  81. }
  82. Ext.ux.GMapPanel.superclass.setSize.call(this, width, height, animate);
  83. },
  84. getMap : function(){
  85. return this.gmap;
  86. },
  87. getCenter : function(){
  88. return this.getMap().getCenter();
  89. },
  90. getCenterLatLng : function(){
  91. var ll = this.getCenter();
  92. return {lat: ll.lat(), lng: ll.lng()};
  93. },
  94. addMarkers : function(markers) {
  95. if (Ext.isArray(markers)){
  96. for (var i = 0; i < markers.length; i++) {
  97. var mkr_point = new GLatLng(markers[i].lat,markers[i].lng);
  98. this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter, markers[i].listeners);
  99. }
  100. }
  101. },
  102. addMarker : function(point, marker, clear, center, listeners){
  103. Ext.applyIf(marker,G_DEFAULT_ICON);
  104. if (clear === true){
  105. this.getMap().clearOverlays();
  106. }
  107. if (center === true) {
  108. this.getMap().setCenter(point, this.zoomLevel);
  109. }
  110. var mark = new GMarker(point,marker);
  111. if (typeof listeners === 'object'){
  112. for (evt in listeners) {
  113. GEvent.bind(mark, evt, this, listeners[evt]);
  114. }
  115. }
  116. this.getMap().addOverlay(mark);
  117. },
  118. addMapControls : function(){
  119. if (this.gmapType === 'map') {
  120. if (Ext.isArray(this.mapControls)) {
  121. for(i=0;i<this.mapControls.length;i++){
  122. this.addMapControl(this.mapControls[i]);
  123. }
  124. }else if(typeof this.mapControls === 'string'){
  125. this.addMapControl(this.mapControls);
  126. }else if(typeof this.mapControls === 'object'){
  127. this.getMap().addControl(this.mapControls);
  128. }
  129. }
  130. },
  131. addMapControl : function(mc){
  132. var mcf = window[mc];
  133. if (typeof mcf === 'function') {
  134. this.getMap().addControl(new mcf());
  135. }
  136. },
  137. addOptions : function(){
  138. if (Ext.isArray(this.mapConfOpts)) {
  139. var mc;
  140. for(i=0;i<this.mapConfOpts.length;i++){
  141. this.addOption(this.mapConfOpts[i]);
  142. }
  143. }else if(typeof this.mapConfOpts === 'string'){
  144. this.addOption(this.mapConfOpts);
  145. }
  146. },
  147. addOption : function(mc){
  148. var mcf = this.getMap()[mc];
  149. if (typeof mcf === 'function') {
  150. this.getMap()[mc]();
  151. }
  152. },
  153. geoCodeLookup : function(addr) {
  154. this.geocoder = new GClientGeocoder();
  155. this.geocoder.getLocations(addr, this.addAddressToMap.createDelegate(this));
  156. },
  157. addAddressToMap : function(response) {
  158. if (!response || response.Status.code != 200) {
  159. Ext.MessageBox.alert('Error', 'Code '+response.Status.code+' Error Returned');
  160. }else{
  161. place = response.Placemark[0];
  162. addressinfo = place.AddressDetails;
  163. accuracy = addressinfo.Accuracy;
  164. if (accuracy === 0) {
  165. Ext.MessageBox.alert('Unable to Locate Address', 'Unable to Locate the Address you provided');
  166. }else{
  167. if (accuracy < 7) {
  168. Ext.MessageBox.alert('Address Accuracy', 'The address provided has a low accuracy.<br><br>Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)');
  169. }else{
  170. point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
  171. if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
  172. this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true, this.setCenter.listeners);
  173. }
  174. }
  175. }
  176. }
  177. }
  178. });
  179. Ext.reg('gmappanel', Ext.ux.GMapPanel); </pre>
  180. </body>
  181. </html>