Dear Geoext users,<br><br>I'm trying to develop a functionality that will allow the user to change the base map projection. The initial map is using the spherical mercator projection so that OSM and Google/Yahoo/Bing layers can be displayed. Because the users will need to edit features at specific scales (1:25.000; 1:10.000) i need to develop a function that will change the projection from spherical mercator to ETRS PTM06 (EPSG:3763). I think i'm almost there but somehow, after reprojection the base map i get my map full extent much higher in latitude (so, more to the north) and much smaller in longitude (more to the west).<br>
<br>My steps are:<br>1. Remove all OSM/Google/Yahoo/Bing layers from the map.<br>2. Add new options to the map<br>3. Merge new options (projection) to a blank layer and set it as basellayer<br>4. Loop the remaining layers and add new options.<br>
<br>The relevant part of the code is below:<br><br>//Map options<br>var mapOptions = {<br> maxExtent: bBox,<br> maxResolution: 305.74811309814453,<br> minResolution: 0.29858214169740677,<br> resolutions: mapResolutions,<br>
units: 'm',<br> projection: baseMercator,<br> displayProjection: wgs,<br> restrictedExtent: bBox,<br> panMethod: OpenLayers.Easing.Quad.easeOut,<br> numZoomLevels: 20,<br> controls: []<br>};<br>
<br>var mapOptionsEtrs = {<br> maxExtent: bBoxEtrs,<br> maxResolution: 282.2220698223045,<br> minResolution: 0.35277758727788067,<br> resolutions: mapResolutionsEtrs,<br> units: 'm',<br> projection: etrs,<br>
displayProjection: etrs,<br> restrictedExtent: bBoxEtrs,<br> panMethod: OpenLayers.Easing.Quad.easeOut,<br> numZoomLevels: 10,<br>};<br><br><br>//Reprojection logic<br>var radioValue = Ext.getCmp('srsradiogroup').getValue().getGroupValue();<br>
var mapProj = map.getProjection();<br>var baseCart = treePanel.getNodeById('basecartography');<br>if (radioValue != mapProj && radioValue == 'EPSG:3763') {<br> baseCart.cascade(function () {<br>
var childNodes = this.childNodes;<br> for (i = 0; i < childNodes.length; i++) {<br> switch (childNodes[i].text) {<br> case 'OpenStreetMap':<br> childNodes[i].disable();<br>
map.removeLayer(osm);<br> break;<br> case 'Google Streets':<br> childNodes[i].disable();<br> map.removeLayer(gstreets);<br> break;<br>
// and so on...<br> }<br> }<br> });<br><br> map.setOptions(mapOptionsEtrs);<br> map.layerContainerOrigin.transform(baseMercator, etrs);<br><br> blankLayer.addOptions({<br> projection: etrs<br>
});<br> map.setBaseLayer(blankLayer);<br><br> for (i = 0; i < mapPanel.map.layers.length; i++) {<br> var className = mapPanel.map.layers[i].CLASS_NAME;<br> if (className == 'OpenLayers.Layer.WMS') {<br>
mapPanel.map.layers[i].addOptions({<br> srs: etrs<br> });<br> } else if (className == 'OpenLayers.Layer.Vector') {<br> mapPanel.map.layers[i].projection = etrs;<br>
} else {<br> //here i will control other types of layers like tilecache<br> }<br> }<br>}<br><br>Checking the map and layers projection through firebug, it seems everything is correct.<br>I've also tried to get the initial extent of the map, reproject it and zoom to it after the reprojection but the it still goes to the same place.<br>
<br>What might be the issues here?? Am i doing something completely wrong?<br>Cheers,<br><br>Hugo<br> <br><br clear="all"><br>-- <br>Hugo Martins<br>LabNT - ISEGI UNL<br>Campus de Campolide<br>1070-312 Lisboa<br>
N 38°43'56.84", W 9°9'35.74"<br>