Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. function findLayerClick(event) {
  2. mouseLoc = map.getLonLatFromPixel(event.xy);
  3. layerlist = 'mylayer';
  4. //GetCoverage
  5. var url = sec.getFullRequestString({
  6. REQUEST: "GetFeatureInfo",
  7. EXCEPTIONS: "application/vnd.ogc.se_xml",
  8. BBOX: map.getExtent().toBBOX(),
  9. X: event.xy.x,
  10. Y: event.xy.y,
  11. INFO_FORMAT: 'text/plain',
  12. QUERY_LAYERS: layerlist,
  13. FEATURE_COUNT: 50,
  14. WIDTH: map.size.w,
  15. HEIGHT: map.size.h},
  16. "http://localhost:8080/geoserver/wms");
  17.  
  18. var request = OpenLayers.Request.GET({
  19. url: url,
  20. callback: extractFeatures
  21. });
  22. }
  23.  
  24. function extractFeatures(e) {
  25. console.log(e);
  26. }
  27.  
  28. function init() {
  29. wgs84 = new OpenLayers.Projection('EPSG:4326');
  30. googleProjection = new OpenLayers.Projection('EPSG:900913');var options = {
  31. controls: [
  32. new OpenLayers.Control.LayerSwitcher(),
  33. new OpenLayers.Control.Navigation({zoomWheelEnabled: true, handleRightClicks: true}),
  34. new OpenLayers.Control.PanZoom(),
  35. new OpenLayers.Control.DragPan(),
  36. new OpenLayers.Control.ScaleLine({maxWidth:200})
  37. ],
  38.  
  39. div: 'map-canvas',
  40. theme: null,
  41. units: 'm',
  42. projection: googleProjection,
  43. displayProjection: wgs84,
  44. maxResolution: 'auto',
  45.  
  46. eventListeners: {
  47. 'movestart': function(e) {
  48. },
  49. 'zoomend': function(e) {
  50. zoomBoxControl.deactivate();
  51. }
  52. }
  53. };
  54.  
  55. map = new OpenLayers.Map(options);
  56.  
  57. var ghyb = new OpenLayers.Layer.Google(
  58. "Google Physical",
  59. {
  60. type: google.maps.MapTypeId.TERRAIN,
  61. minZoomLevel: 1,
  62. numZoomLevels: 11,
  63. sphericalMercator: true,
  64. projection: 'EPSG:900913'
  65. }
  66. );
  67.  
  68. //this is the raster layer
  69. sec = new OpenLayers.Layer.WMS(
  70. "mylayer",
  71. "http://localhost:8080/geoserver/wms",
  72. {layers: 'mylayer', format:'image/png', transparent:'true'},
  73. {opacity: 1.0, visibility: true, displayInLayerSwitcher: true, isBaseLayer: false}
  74. );
  75.  
  76. OpenLayers.Util.extend(control, {
  77. draw: function () {
  78. this.drag = new OpenLayers.Handler.Box( control,
  79. {"done": this.notice},
  80. {keyMask: OpenLayers.Handler.MOD_CTRL});
  81. this.drag.activate();
  82. },
  83.  
  84. notice: function (bounds) {
  85. mybounds = bounds;
  86.  
  87.  
  88. console.log(mybounds);
  89.  
  90. var lowerLeft = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.left, mybounds.bottom));
  91. var upperRight = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.right, mybounds.top));
  92.  
  93. mybounds = new OpenLayers.Bounds();
  94. mybounds.extend(lowerLeft);
  95. mybounds.extend(upperRight);
  96.  
  97. //findLayerClick(mybounds);
  98. return(true);
  99. }
  100. });
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement