[OpenLayers-Users] OpenLayers.Class withOpenLayers.Control.GetFeature

Gery . gamejihou at hotmail.com
Wed Jan 30 15:01:17 PST 2013


thanks Arnd, I added your suggestion and it still complains about the same but after some a couple of clicks or boxes it sends the request, however the sent bbox is still in UTM, where could the problem be? here you can take a look at the code:
var mycontrol = function(){
            var protocol = new OpenLayers.Protocol.HTTP({
                url: 'http://www.r2d2.starwars/',
                format: new OpenLayers.Format.GeoJSON({
                    ignoreExtraDims: true,
                    'internalProjection': new OpenLayers.Projection('EPSG:900913'),
                    'externalProjection': new OpenLayers.Projection('EPSG:4326')
                })
            });

            OpenLayers.Control.myGetFeature = OpenLayers.Class(OpenLayers.Control.GetFeature,{
                selectBox: function(position){
                    var opts = OpenLayers.Control.GetFeature(position);
                    var baseSRSutm = this.map.getprojectionObject();
                    console.log('this is the baseSRSutm' + baseSRSutm);                     <--- this console.log doesnt appear in firebug
                    var layerSRSdd = new OpenLayers.Projection('EPSG:4326');
                    opts.params.bbox = this.map.getExtent().transform(baseSRSutm,layerSRSdd).toBBOX(null,firstLayer.reverseAxisOrder());
                    console.log('this is the opts.params.bbox' + opts.params.bbox);      <--- this console.log doesnt appear in firebug
                    return opts;
                },
                CLASS_NAME: "OpenLayers.Control.myGetFeature"
            });
 
          return new OpenLayers.Control.myGetFeature({
                protocol: protocol,
                box: true,
                click: true,
                single: false,
                clickTolerance: 10,
                eventListeners:{
                    // May the Force be with you
                }
            });
        };

because the console.log doesnt appear in firebug, I think the problem is in the OpenLayers.Control.myGetFeature and OpenLayers.Class. It seems to me that the "selectBox" function is the one I need, but the subclass itself is not read by the return.

Gery 




__________________________________________________________________________________________
Piensa en el medio ambiente - mantenlo en la pantalla. NO lo imprimas si NO es necesario.
Think green - keep it on the screen. Do NOT print if it is NOT necessary.
Denken Sie an die Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie es NICHT, wenn es NICHT notwendig ist.


From: arnd.wippermann at web.de
To: gamejihou at hotmail.com
CC: openlayers-users at lists.osgeo.org
Subject: AW: [OpenLayers-Users] OpenLayers.Class withOpenLayers.Control.GetFeature
Date: Wed, 30 Jan 2013 23:34:13 +0100








try 
this:
...
opts.params.bbox = 
...
return opts;
},
CLASS_NAME: 
"OpenLayers.myGetFeature"
});

It seems, that a class needs a CLASS_NAME.
 
Arnd



Von: Gery . [mailto:gamejihou at hotmail.com] 

Gesendet: Mittwoch, 30. Januar 2013 18:53
An: 
arnd.wippermann at web.de
Cc: 
openlayers-users at lists.osgeo.org
Betreff: RE: AW: [OpenLayers-Users] 
OpenLayers.Class withOpenLayers.Control.GetFeature



Thanks for that Arnd, now it 
stops complaining about the missing "}", but now it appears 
"TypeError: 
this.CLASS_NAME is undefined", what and where should I put 
there?

__________________________________________________________________________________________
Piensa 
en el medio ambiente - mantenlo en la pantalla. NO lo imprimas 
si NO es necesario.
Think green - keep it on the screen. Do NOT print if it is NOT 
necessary.
Denken Sie an die 
Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie es 
NICHT, wenn es NICHT notwendig 
ist.






From: arnd.wippermann at web.de
To: gamejihou at hotmail.com
CC: 
openlayers-users at lists.osgeo.org
Subject: AW: [OpenLayers-Users] 
OpenLayers.Class withOpenLayers.Control.GetFeature
Date: Wed, 30 Jan 2013 
18:13:50 +0100




Hi,
 
move 'return opts;' into the function 
body:
...
opts.params.bbox = ...
return opts;
}
 
to get rid of 
the error.
 
Arnd
 



Von: openlayers-users-bounces at lists.osgeo.org 
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Gery 
.
Gesendet: Mittwoch, 30. Januar 2013 16:52
An: 
openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] 
OpenLayers.Class withOpenLayers.Control.GetFeature




Hi 
all,

I'm wondering if someone could point me in the right 
direction to force the BBOX 
of OpenLayers.Control.GetFeature to be always in long/lat coordinates. I'm trying 
to get this with OpenLayers.Class, so 
the new control will inherit 
OpenLayers.Control.GetFeature with just the small modification in BBOX. This is what I've 
done:

OpenLayers.Control.myGetFeature = 
OpenLayers.Class(OpenLayers.Control.GetFeature,{ 
        
    selectBox: function(position){ 
        
        var opts = OpenLayers.Control.GetFeature(position); 

                var baseSRSutm = 
this.map.getprojectionObject(); 
            
    var layerSRSdd = new OpenLayers.Projection('EPSG:4326'); 

                opts.params.bbox = 
this.map.getExtent().transform(baseSRSutm,layerSRSdd).toBBOX(null,firstLayer.reverseAxisOrder()); 

            }
        
    return opts; 
        }); 

 
but I'm getting that some "}" are missing. Is this the right way to use OpenLayers.Class to do what I want?

Any help is much appreciated.

Gery


__________________________________________________________________________________________
Piensa 
en el medio ambiente - mantenlo en la pantalla. NO lo imprimas 
si NO es necesario.
Think green - keep it on the screen. Do NOT print if it is NOT 
necessary.
Denken Sie an die 
Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie es 
NICHT, wenn es NICHT notwendig 
ist.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130130/bc1f3ac8/attachment-0001.html>


More information about the Users mailing list