Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Set Map Extent

Hello,

I am trying to set the extent in the mapviewer (RCP example) programatically after adding some layers with no luck. If I put a button in the toolbar to execute the following action when clicked:

    class SetExtentAction extends Action {
        public SetExtentAction() {
            super("Set Extent"); //$NON-NLS-1$
        }
        public void run() {
		ReferencedEnvelope bounds = new ReferencedEnvelope(new Envelope (2000000, 8669445.545, -3334722.765, 3334722.78), DefaultGeographicCRS.WGS84);
		map.sendCommandASync(new SetViewportBBoxCommand(bounds));
        }
    }

It works, but I need to click a button and I would prefer to set the bounds from the code so I dont have to click a button.

If I use this:
	map.getViewportModelInternal().setBounds(new ReferencedEnvelope(new Envelope (2000000, 8669445.545, -3334722.765, 3334722.78),DefaultGeographicCRS.WGS84));
After creating the map, it works if I dont add layers, but it seems like everytime a layer is added the map is zoomed to the layer extent.
Since the layers are added using 
       map.sendCommandASync(new AddLayersCommand(dataHandles));
I dont know where to place the code for setting the extent, and which method to use (map.getViewportModelInternal().setBounds or SetViewportBBoxCommand), where would be a good place??

Thank you!!

Joaquín Rodríguez-Guerra Urcelay

______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.

______________________



Back to the top