Revision 62371108
Added by Andreas Kohlbecker almost 14 years ago
modules/cdm_dataportal/js/openlayers_map.js | ||
---|---|---|
21 | 21 |
controls: |
22 | 22 |
[ |
23 | 23 |
new OpenLayers.Control.PanZoom(), |
24 |
// new OpenLayers.Control.LayerSwitcher(), |
|
24 | 25 |
new OpenLayers.Control.Navigation({zoomWheelEnabled: false, handleRightClicks:true, zoomBoxKeyMask: OpenLayers.Handler.MOD_CTRL}) |
25 | 26 |
], |
26 | 27 |
maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90), |
... | ... | |
96 | 97 |
|
97 | 98 |
} |
98 | 99 |
|
100 |
map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false})); |
|
101 |
|
|
102 |
|
|
99 | 103 |
// zoom to the required area |
100 | 104 |
var boundsStr = (options.boundingBox !== undefined ? options.boundingBox : (mapResponseObj.bbox ? mapResponseObj.bbox : '-180, -90, 180, 90') ); |
101 | 105 |
var zoomToBounds = OpenLayers.Bounds.fromString( boundsStr ); |
... | ... | |
106 | 110 |
mapResponseObj.legend = "http://edit.br.fgov.be/" + mapResponseObj.legend.substr(hack.length - 1); |
107 | 111 |
// END OF HACK |
108 | 112 |
if(options.legendPosition !== undefined){ |
109 |
addLegend(mapResponseObj.geoserver + legendImgSrc + mapResponseObj.legend); |
|
113 |
var legendSrcUrl = mapResponseObj.geoserver + legendImgSrc + mapResponseObj.legend; |
|
114 |
addLegendAsElement(legendSrcUrl); |
|
115 |
//addLegendAsLayer(legendSrcUrl, map); |
|
110 | 116 |
} |
111 | 117 |
} |
112 | 118 |
|
113 | 119 |
|
114 | 120 |
}; |
115 | 121 |
|
116 |
var addLegend= function(legendSrcUrl){ |
|
122 |
var addLegendAsElement= function(legendSrcUrl){
|
|
117 | 123 |
mapElement.after('<div class="openlayers_legend"><img src="' + legendSrcUrl + '"></div>'); |
118 | 124 |
mapElement.next('.openlayers_legend').find('img').load(function () { |
119 | 125 |
$(this).parent() |
... | ... | |
124 | 130 |
}); |
125 | 131 |
}; |
126 | 132 |
|
133 |
|
|
134 |
var addLegendAsLayer= function(legendSrcUrl, map){ |
|
135 |
var w, h; |
|
136 |
|
|
137 |
// 1. download imge to find height and width |
|
138 |
mapElement.after('<div class="openlayers_legend"><img src="' + legendSrcUrl + '"></div>'); |
|
139 |
mapElement.next('.openlayers_legend').css('display', 'none').find('img').load(function () { |
|
140 |
|
|
141 |
w = mapElement.next('.openlayers_legend').find('img').width(); |
|
142 |
h = mapElement.next('.openlayers_legend').find('img').height(); |
|
143 |
mapElement.next('.openlayers_legend').remove(); |
|
144 |
|
|
145 |
createLegendLayer(); |
|
146 |
}); |
|
147 |
|
|
148 |
// 2. create the Legend Layer |
|
149 |
var createLegendLayer = function(){ |
|
150 |
|
|
151 |
|
|
152 |
var legendLayerOptions={ |
|
153 |
maxResolution: '.$maxRes.', |
|
154 |
maxExtent: new OpenLayers.Bounds(0, 0, w, h) |
|
155 |
}; |
|
156 |
|
|
157 |
var legendLayer = new OpenLayers.Layer.Image( |
|
158 |
'Legend', |
|
159 |
legendSrcUrl, |
|
160 |
new OpenLayers.Bounds(0, 0, w, h), |
|
161 |
new OpenLayers.Size(w, h), |
|
162 |
imageLayerOptions |
|
163 |
); |
|
164 |
} |
|
165 |
|
|
166 |
}; |
|
167 |
|
|
127 | 168 |
/** |
128 | 169 |
* merge 2 Url query strings |
129 | 170 |
*/ |
Also available in: Unified diff
hot fix for annotations & map legend