Fix for My OpenLayers

  1. // This is the JS to create the main layers and add controls.
  2.  
  3.         function setHTML(response) {
  4.                 document.getElementById('nodeList').innerHTML = response.responseText;
  5.         }
  6.  
  7.         function init() {
  8.                 // Create new map object.
  9.  
  10.                 // Set options
  11.                
  12.                 var lat         = 38.890000;
  13.                 var long        = -77.020000;
  14.                 var zoom        = 3;
  15.                
  16.                 var options     = {
  17.                         minResolution   : "auto",
  18.                         minExtent       : new OpenLayers.Bounds(-1,-1,1,1),
  19.                         maxResolution   : "auto",
  20.                         maxExtent       : new OpenLayers.Bounds(-180, -90, 180,90),
  21.                 };
  22.        
  23.                 var map = new OpenLayers.Map('map',options);
  24.                
  25.                 // Create new WMS base layer
  26.        
  27.                 var wms = new OpenLayers.Layer.WMS(
  28.                         "Metacarta Basic Map - No Borders",
  29.                         "http://labs.metacarta.com/wms/vmap0",
  30.                         {
  31.                                 layers          : 'basic',
  32.                                 isBaseLayer     :  true,
  33.                                 }
  34.                                 );
  35.  
  36.                 // Create new NASA JPL WMS base layer.
  37.  
  38.                 var jpl_wms = new OpenLayers.Layer.WMS(
  39.                         "NASA JPL's Satellite",
  40.                         "http://wms.jpl.nasa.gov/wms.cgi?",
  41.                         {
  42.                                 layers          : 'BMNG',
  43.                                 format          : 'image/png',
  44.                                 isBaseLayer     :  false,
  45.                                 }
  46.                                 );
  47.                                
  48.                 // Create a new base layer of Google Hybrid
  49.                
  50.                 var google = new OpenLayers.Layer.Google(
  51.                         "Google Hybrid",
  52.                         {
  53.                                 type: G_HYBRID_MAP
  54.                                 },
  55.                         {
  56.                                 isBaseLayer: true
  57.                                 }
  58.                         );
  59.                
  60.                 // Create an overlay of US boundaries
  61.                
  62.                 var USGSwms = new OpenLayers.Layer.WMS(
  63.                         "USGS US Political Boundaries",
  64.                         "http://toposervices.cr.usgs.gov/wmsconnector/com.esri.wms.Esrimap/USGS_EDNA_geo?",
  65.                         {
  66.                                 layers          : 'States_Generalized',
  67.                                 format          : 'image/png',
  68.                                 isBaseLayer     : false,
  69.                                 transparent     : true,
  70.                                 },
  71.                         {
  72.                                 reproject       : true,
  73.                         }
  74.                         );
  75.                                                
  76.                 // Create an overlay of courts in the US with proprietary data
  77.                
  78.                 var courts = new OpenLayers.Layer.WMS(
  79.                         "Courts in the United States",
  80.                         "http://goblin.c30:8080/geoserver/wms",
  81.                         {
  82.                                 layers          : 'dheeraj_court:courts',
  83.                                 format          : 'image/png',
  84.                                 isBaselayer     : false,
  85.                                 transparent     : true,
  86.                         },
  87.                         {
  88.                                 reproject       : true,
  89.                                 }
  90.                         );
  91.                
  92.                
  93.                 // Creating popup information for courts
  94.  
  95.         courtsInfo = new OpenLayers.Control.WMSGetFeatureInfo({
  96.             url: 'http://goblin.c30:8080/geoserver/wms',
  97.             title: 'Click for more info',
  98.             queryVisible: true,
  99.             eventListeners: {
  100.                 getfeatureinfo: function(event) {
  101.                     map.addPopup(new OpenLayers.Popup.FramedCloud(
  102.                         "Courts in The United States",
  103.                         map.getLonLatFromPixel(event.xy),
  104.                         null,
  105.                         event.text,
  106.                         null,
  107.                         true
  108.                     ));
  109.                 }
  110.             }
  111.         });
  112.         map.addControl(courtsInfo);
  113.         courtsInfo.activate();
  114.  
  115.  
  116.                                                
  117.                 // Add base layers     
  118.    
  119.                 map.addLayers([wms, jpl_wms, google]);
  120.  
  121.                 // Add transparent overlays
  122.                
  123.                 map.addLayer(USGSwms);
  124.                 map.addLayer(courts);
  125.                
  126.                 // Set the centre and zoom
  127.                
  128.                 map.setCenter(new OpenLayers.LonLat(long,lat), zoom);
  129.                        
  130.                 // Settings for the map object
  131.        
  132.                 var panelControls = [
  133.                         new OpenLayers.Control.Navigation(),
  134.                         new OpenLayers.Control.DrawFeature(wms,OpenLayers.Handler.Path,
  135.                         new OpenLayers.Control.LayerSwitcher(),
  136.                                 {
  137.                                         'displayClass'          : 'olControlDrawFeaturePath'
  138.                                 }
  139.                                 )
  140.                                 ];
  141.                
  142.                 var toolbar = new OpenLayers.Control.Panel(
  143.                         {
  144.                                 displayClass    : 'olControlEditingToolbar',
  145.                                 defaultControl  : panelControls[0]
  146.                         }
  147.                         );
  148.                        
  149.                 toolbar.addControls(panelControls);
  150.                 map.addControl(toolbar);       
  151.        
  152.  
  153.                 var toolbar = new OpenLayers.Control.Panel(
  154.                         {})
  155.        
  156.        
  157.        
  158.        
  159.        
  160.        
  161.         }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.