[OpenLayers-Users] Mouse.Default help

Christopher Schmidt crschmidt at metacarta.com
Sun Mar 4 19:05:42 EST 2007


On Mon, Mar 05, 2007 at 09:56:40AM +1100, bradleyspencer wrote:
> Christopher,
> 
> Sorry to do this but I am unable to get this working.
> 
> I am using the following code to make double click work as a getFeatuerInfo
> request but double click on the map still re-centres the map?

You're doing the defaultDblClick change after adding the control to the
map. Try it before instead.

-- Chris

> OpenLayers.Control.MouseDefaults.prototype.defaultDblClick = function(e)
> {
> var getFeatureInfoRequest =  landuse.getFullRequestString
> 	({
> 		REQUEST: "GetFeatureInfo",
>                 	//EXCEPTIONS: "application/vnd.ogc.se_xml",
> 		EXCEPTIONS: "bxfs",
>                 	BBOX: landuse.map.getExtent().toBBOX(),
>                 	X: e.xy.x,
>                 	Y: e.xy.y,
> 		INFO_FORMAT: 'text/html',
> 		QUERY_LAYERS: landuse.params.LAYERS,
> 		QUERY_LAYERS: queryLayers ,
>                	WIDTH: landuse.map.size.w,
>                	HEIGHT: landuse.map.size.h
> 	});
> 	makePopup(getFeatureInfoRequest,'1200','480','both');
>         	Event.stop(e);
> }
> 
> FF is not objecting to this code. Is there something I am doing obviously
> wrong here?
> 
> The application can be tested at http://demo.cubewerx.com.au/DemoDrapes.html
> 
> Thanks in advance.
> 
> Cheers,
> 
> Brad Spencer
> General Manager
> CubeWerx Australia Pty Ltd
> ABN: 37 115 163 285
> Mob: +61 (0)404 841 131
> Tel/Fax: +61 (0)2 9481 7024
> mailto:brad at cubewerx.com.au
> http://www.cubewerx.com.au
> 
> -----Original Message-----
> From: Christopher Schmidt [mailto:crschmidt at metacarta.com]
> Sent: Sunday, 4 March 2007 1:27 PM
> To: bradleyspencer
> Cc: openlayers users
> Subject: Re: [OpenLayers-Users] Mouse.Default help
> 
> On Sun, Mar 04, 2007 at 12:47:48PM +1100, bradleyspencer wrote:
> > I am not a trained Object Oriented programmer so I apologise for this dumb
> > question.
> >
> > I want to suppress the use of doubleClick on the map as a re-centre
> > operation and use it as a getFeatureInfo operation instead.
> >
> > To do this the doco says I need to ?create a subclass of MouseDefaults,
> > replacing the functions whose behavior you wish to change?.
> >
> > There are no examples of this and whilst I have made an event listener to
> do
> > the getFeatureInfo quite successfully, I am not at all sure how to make a
> > new subclassof MouseDefaults as stated and link this event into that
> > subclass.
> 
> If you only want to do it for one control (for example, when you only
> have one map in the page):
> 
>  control = new OpenLayers.Control.MouseDefaults();
>  control.defaultDblClick = function(evt) {
>    var point = this.map.getLonLatFromViewPortPx( evt.xy );
>    alert("Got point:" + point);
>    OpenLayers.Event.stop(evt);
>    return false;
>  }
> 
> If you have multiple maps, or don't want to change the default controls
> when creating the map:
> 
>  OpenLayers.Control.MouseDefaults.prototype.defaultDblClick = function(evt)
> {
>    var point = this.map.getLonLatFromViewPortPx( evt.xy );
>    alert("Got point:" + point);
>    OpenLayers.Event.stop(evt);
>    return false;
>  }
> 
> Regards,
> --
> Christopher Schmidt
> MetaCarta
> 
> 

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list