7
ProjPane = Class.create();
13
initialize: function(pane, code) {
15
if (code) this.setProj(code);
18
updateCoords: function(coords) {
19
document.getElementById(this.id+'_coords').innerHTML = coords.toString();
20
var pt = this.map.getLayerPxFromLonLat(coords);
21
this.marker.moveTo(pt);
24
setProj: function(code) {
25
document.getElementById(this.id+'_proj').value = code;
27
this.proj = new Proj4js.Proj(code);
28
var mapDef = Proj4js.maps[this.proj.srsCode];
30
if (this.map) this.map.destroy();
31
this.map = new OpenLayers.Map(this.id, mapDef.mapOptions);
32
this.mapLayer = new OpenLayers.Layer.WMS(mapDef.layerName, mapDef.layerUrl, mapDef.layerParams, mapDef.layerOptions);
33
this.map.addLayer(this.mapLayer);
35
this.map.addLayer(new OpenLayers.Layer.Markers(''));
36
this.marker = new OpenLayers.Marker(new OpenLayers.LonLat(0,0));
37
this.map.layers[1].addMarker(this.marker);
38
this.marker.map = this.map;
40
this.map.addLayer(new OpenLayers.Layer.Boxes());
41
this.map.layers[2].addMarker(new OpenLayers.Marker.Box(bounds));
42
this.map.setCenter(bounds.getCenterLonLat());
44
this.map.zoomToMaxExtent();
46
this.map.events.register('click', this.map, this.mapClicked.bind(this));
48
document.getElementById(this.id+'_units').innerHTML = this.proj.units;
49
document.getElementById(this.id+'_title').innerHTML = this.proj.title;
50
document.getElementById(this.id+'_class').innerHTML = this.proj.projName;
53
mapClicked: function(ev) {
54
var olc = this.map.getLonLatFromViewPortPx(ev.xy);
55
c = new Proj4js.Point(olc.lon, olc.lat);
58
if (this.opposite && this.opposite.proj) {
59
var newCoords = this.proj.transform(c, this.opposite.proj);
60
this.opposite.updateCoords(newCoords);
63
var newCoords = this.proj.inverse(c);
64
this.common.updateCoords(newCoords);
66
if (this.projected1 && this.projected1.proj) {
67
var newCoords = this.projected1.proj.forward(c);
68
this.projected1.updateCoords(newCoords);
70
if (this.projected2 && this.projected2.proj) {
71
var newCoords = this.projected2.proj.forward(c);
72
this.projected2.updateCoords(newCoords);
79
panes['mapLL'] = new ProjPane('mapLL',Proj4js.defaultDatum);
80
panes['mapL'] = new ProjPane('mapL');
81
panes['mapR'] = new ProjPane('mapR');
83
panes['mapLL'].projected1 = panes['mapL'];
84
panes['mapLL'].projected2 = panes['mapR'];
85
panes['mapL'].opposite = panes['mapR'];
86
panes['mapR'].opposite = panes['mapL'];
87
panes['mapL'].common = panes['mapLL'];
88
panes['mapR'].common = panes['mapLL'];