Hi all,
I would like to talk about the "srs" listener (in context.setSRS()
method) which is linked to nothing.
I need this listener transform the actual BBOX and rebuild the map
Object with the new SRS.
I think this use case is logical because MVC , when we modify the model
, the MapPane must be redraw.
What do you thinking about this usecase? ideas or comments?
(I can commit the change on trunk and a add a temporary example , if you
want to test)
We have implemented this functionnality , we have just added a function
transformBBox() to Context.js :
/**
* Transform BoundingBox in the current SRS , use only when srs
listener is called
* @param model object reference .
*/
this.transformBbox=function(objRef) {
if (objRef.map.mbMapPane) {
//Transform the bbox with the new SRS
var bbox=objRef.getBoundingBox();
var srs = objRef.getSRS();
var srcProj = objRef.proj;
var destProj = new Proj4js.Proj(srs);
var bl=new Proj4js.Point(bbox[0],bbox[1]);
var tr=new Proj4js.Point(bbox[2],bbox[3]);
Proj4js.transform(srcProj,destProj,bl);
Proj4js.transform(srcProj,destProj,tr);
var
bboxNode=objRef.doc.selectSingleNode("/wmc:ViewContext/wmc:General/wmc:BoundingBox");
bboxNode.setAttribute("minx", bl.x);
bboxNode.setAttribute("miny", bl.y);
bboxNode.setAttribute("maxx", tr.x);
bboxNode.setAttribute("maxy", tr.y);
// Rebuild the OpenLayers.Map but does not reload the MapBuilder
model
// That code was copied from the destroy method on the
OpenLayers.Map object
// Everything is destroyed but the controls which are kept aside
and added to the new OpenLayers.Map
OpenLayers.Event.stopObserving(window,'unload',objRef.map.unloadDestroy);
objRef.map.unloadDestroy=null;
if(objRef.map.layers!=null){
for(var i=objRef.map.layers.length-1;i>=0;--i){
objRef.map.layers[i].destroy(false);
}
objRef.map.layers=null;
}
if(objRef.map.viewPortDiv){
objRef.map.div.removeChild(objRef.map.viewPortDiv);
}
objRef.map.viewPortDiv=null;
// End of the OpenLayers copy
// Keep the controls and the events aside
var events = objRef.map.events;
var controls = objRef.map.controls;
var activeControl = null;
for(var i=controls.length-1;i>=0;--i){
if (controls[i].active) {
activeControl = controls[i];
}
}
// Rebuild a OpenLayers.Map
objRef.map = null;
objRef.callListeners("refresh");
//mainMapWidget.paint(config.objects.mainMapWidget);
// Add the events and the controls to the new OpenLayers.Map
objRef.map.events = events;
for(var i=controls.length-1;i>=0;--i){
objRef.map.addControl(controls[i]);
}
activeControl.activate();
}
}
this.addFirstListener( "srs", this.transformBbox, this );
/**
* Set the Spatial Reference System for the context document.
* @param srs The Spatial Reference System.
*/
this.setSRS=function(srs) {
var
bbox=this.doc.selectSingleNode("/wmc:ViewContext/wmc:General/wmc:BoundingBox");
bbox.setAttribute("SRS",srs);
this.callListeners("srs");
}
begin:vcard
fn:Olivier Terral
n:Terral;Olivier
org:GEOMATYS
adr:;;24 rue Pierre Renaudel;Arles;;13200 ;France
email;internet:[EMAIL PROTECTED]
title:Developpeur
tel;work:04 67 54 87 30
tel;fax:04 67 54 87 00
url:http://demo.geomatys.fr/
version:2.1
end:vcard
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
mapbuilder-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-devel