Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findLayerClick(event) {
- mouseLoc = map.getLonLatFromPixel(event.xy);
- layerlist = 'mylayer';
- //GetCoverage
- var url = sec.getFullRequestString({
- REQUEST: "GetFeatureInfo",
- EXCEPTIONS: "application/vnd.ogc.se_xml",
- BBOX: map.getExtent().toBBOX(),
- X: event.xy.x,
- Y: event.xy.y,
- INFO_FORMAT: 'text/plain',
- QUERY_LAYERS: layerlist,
- FEATURE_COUNT: 50,
- WIDTH: map.size.w,
- HEIGHT: map.size.h},
- "http://localhost:8080/geoserver/wms");
- var request = OpenLayers.Request.GET({
- url: url,
- callback: extractFeatures
- });
- }
- function extractFeatures(e) {
- console.log(e);
- }
- function init() {
- wgs84 = new OpenLayers.Projection('EPSG:4326');
- googleProjection = new OpenLayers.Projection('EPSG:900913');var options = {
- controls: [
- new OpenLayers.Control.LayerSwitcher(),
- new OpenLayers.Control.Navigation({zoomWheelEnabled: true, handleRightClicks: true}),
- new OpenLayers.Control.PanZoom(),
- new OpenLayers.Control.DragPan(),
- new OpenLayers.Control.ScaleLine({maxWidth:200})
- ],
- div: 'map-canvas',
- theme: null,
- units: 'm',
- projection: googleProjection,
- displayProjection: wgs84,
- maxResolution: 'auto',
- eventListeners: {
- 'movestart': function(e) {
- },
- 'zoomend': function(e) {
- zoomBoxControl.deactivate();
- }
- }
- };
- map = new OpenLayers.Map(options);
- var ghyb = new OpenLayers.Layer.Google(
- "Google Physical",
- {
- type: google.maps.MapTypeId.TERRAIN,
- minZoomLevel: 1,
- numZoomLevels: 11,
- sphericalMercator: true,
- projection: 'EPSG:900913'
- }
- );
- //this is the raster layer
- sec = new OpenLayers.Layer.WMS(
- "mylayer",
- "http://localhost:8080/geoserver/wms",
- {layers: 'mylayer', format:'image/png', transparent:'true'},
- {opacity: 1.0, visibility: true, displayInLayerSwitcher: true, isBaseLayer: false}
- );
- OpenLayers.Util.extend(control, {
- draw: function () {
- this.drag = new OpenLayers.Handler.Box( control,
- {"done": this.notice},
- {keyMask: OpenLayers.Handler.MOD_CTRL});
- this.drag.activate();
- },
- notice: function (bounds) {
- mybounds = bounds;
- console.log(mybounds);
- var lowerLeft = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.left, mybounds.bottom));
- var upperRight = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.right, mybounds.top));
- mybounds = new OpenLayers.Bounds();
- mybounds.extend(lowerLeft);
- mybounds.extend(upperRight);
- //findLayerClick(mybounds);
- return(true);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement