Revision cb961f9d
Added by Andreas Kohlbecker almost 7 years ago
modules/cdm_dataportal/js/map/openlayers_map.js | ||
---|---|---|
17 | 17 |
|
18 | 18 |
return this.each(function(){ |
19 | 19 |
this.cdmOpenlayersMap = new CdmOpenLayers.Map($(this), mapserverBaseUrl, mapserverVersion, opts); |
20 |
this.cdmOpenlayersMap.init();
|
|
20 |
this.cdmOpenlayersMap.create();
|
|
21 | 21 |
}); // END each |
22 | 22 |
|
23 | 23 |
}; // END cdm_openlayers_map |
... | ... | |
57 | 57 |
url: null, |
58 | 58 |
params: null, |
59 | 59 |
projection: null, |
60 |
proj4js_def: null, |
|
60 | 61 |
max_extent: null, |
61 | 62 |
units: null |
62 | 63 |
}, |
64 |
wmsOverlayLayerData: { |
|
65 |
name: null, |
|
66 |
url: null, |
|
67 |
params: null |
|
68 |
}, |
|
63 | 69 |
/** |
64 | 70 |
* when true the map is made resizable by adding the jQueryUI widget resizable |
65 | 71 |
* to the map container. This feature requires that the jQueryUI is loaded |
... | ... | |
222 | 228 |
/** |
223 | 229 |
* |
224 | 230 |
*/ |
225 |
this.init = function(){ // public function
|
|
231 |
this.create = function(){ // public function
|
|
226 | 232 |
|
227 | 233 |
// set the height of the container element |
228 | 234 |
adjustHeight(); |
... | ... | |
249 | 255 |
|
250 | 256 |
if(distributionQuery !== undefined){ |
251 | 257 |
distributionQuery = mergeQueryStrings(distributionQuery, '&recalculate=false'); |
252 |
if(typeof legendPosition == 'number'){ |
|
258 |
if(typeof legendPosition === 'number'){
|
|
253 | 259 |
distributionQuery = mergeQueryStrings(distributionQuery, 'legend=1&mlp=' + opts.legendPosition); |
254 | 260 |
} |
255 | 261 |
if(opts.boundingBox){ |
... | ... | |
308 | 314 |
}); |
309 | 315 |
} |
310 | 316 |
|
311 |
if(LAYER_DATA_CNT == 0) { |
|
312 |
// a map only with base layer |
|
313 |
initPostDataLoaded(); |
|
317 |
if(LAYER_DATA_CNT === 0) { |
|
318 |
// a map only with base layer |
|
319 |
initPostDataLoaded(); |
|
320 |
} |
|
321 |
|
|
322 |
// -- Overlay Layer -- |
|
323 |
if(opts.wmsOverlayLayerData.params){ |
|
324 |
overlay_layer_params = opts.wmsOverlayLayerData.params; |
|
325 |
overlay_layer_params.transparent=true; |
|
326 |
wmsOverlay = createWMSLayer( |
|
327 |
opts.wmsOverlayLayerData.name, |
|
328 |
opts.wmsOverlayLayerData.url, |
|
329 |
overlay_layer_params, |
|
330 |
null, |
|
331 |
null, |
|
332 |
null, |
|
333 |
null |
|
334 |
); |
|
335 |
|
|
336 |
if(map.addLayer(wmsOverlay)){ |
|
337 |
// map.setLayerZIndex(wmsOverlay, 100); |
|
338 |
wmsOverlay.setVisibility(true); |
|
339 |
log("Overlay wms added"); |
|
340 |
} else { |
|
341 |
log("ERROR adding overlay wms layer") |
|
314 | 342 |
} |
343 |
} |
|
344 |
|
|
345 |
log("Map viewer creation complete."); |
|
315 | 346 |
|
316 | 347 |
}; |
317 | 348 |
|
318 | 349 |
var layerDataLoaded = function() { |
319 | 350 |
LAYER_DATA_CNT--; |
320 |
if(LAYER_DATA_CNT == 0){ |
|
351 |
if(LAYER_DATA_CNT === 0){
|
|
321 | 352 |
initPostDataLoaded(); |
322 | 353 |
} |
323 | 354 |
}; |
... | ... | |
327 | 358 |
map.layers.forEach(function(layer){ |
328 | 359 |
|
329 | 360 |
// hack for cuba |
330 |
if(layer.name == "flora_cuba_2016_regions"){ |
|
361 |
if(layer.name === "flora_cuba_2016_regions"){
|
|
331 | 362 |
map.setLayerZIndex(layer, 5); |
332 | 363 |
} |
333 |
if(layer.name == "flora_cuba_2016_provinces"){ |
|
364 |
if(layer.name === "flora_cuba_2016_provinces"){
|
|
334 | 365 |
map.setLayerZIndex(layer, 6); |
335 | 366 |
} |
336 |
if(layer.name == "flora_cuba_2016_world"){ |
|
367 |
if(layer.name === "flora_cuba_2016_world"){
|
|
337 | 368 |
map.setLayerZIndex(layer, 4); |
338 | 369 |
} |
339 | 370 |
|
... | ... | |
702 | 733 |
|
703 | 734 |
for(var i = 0; i < baseLayerNames.length; i++) { |
704 | 735 |
// create the layer |
705 |
if (baseLayerNames[i] == "custom_wms_base_layer_1"){ |
|
706 |
baseLayers[i] = createWMSBaseLayer(
|
|
736 |
if (baseLayerNames[i] === "custom_wms_base_layer_1"){
|
|
737 |
wmsBaseLayer =createWMSLayer(
|
|
707 | 738 |
customWMSBaseLayerData.name, |
708 | 739 |
customWMSBaseLayerData.url, |
709 | 740 |
customWMSBaseLayerData.params, |
... | ... | |
712 | 743 |
customWMSBaseLayerData.units, |
713 | 744 |
customWMSBaseLayerData.max_extent |
714 | 745 |
); |
746 |
wmsBaseLayer.setIsBaseLayer(true); |
|
747 |
baseLayers[i] = wmsBaseLayer; |
|
715 | 748 |
} else { |
716 | 749 |
baseLayers[i] = window.CdmOpenLayers.getLayerByName(baseLayerNames[i]); |
717 | 750 |
} |
718 | 751 |
// set default baselayer |
719 |
if(baseLayerNames[i] == defaultBaseLayerName){ |
|
752 |
if(baseLayerNames[i] === defaultBaseLayerName){
|
|
720 | 753 |
defaultBaseLayer = baseLayers[i]; |
721 | 754 |
} |
722 | 755 |
|
... | ... | |
850 | 883 |
* @param Object projection |
851 | 884 |
* A OpenLayers.Projection object |
852 | 885 |
*/ |
853 |
var createWMSBaseLayer= function(name, url, params, projection, proj4js_def, units, maxExtent){
|
|
886 |
var createWMSLayer= function(name, url, params, projection, proj4js_def, units, maxExtent){ |
|
854 | 887 |
|
855 |
console.log("creating WMSBaseLayer");
|
|
888 |
console.log("creating WMS Layer " + name);
|
|
856 | 889 |
|
857 | 890 |
if(projection && proj4js_def){ |
858 | 891 |
// in case projection has been defined for the layer and if there is also |
... | ... | |
860 | 893 |
Proj4js.defs[projection] = proj4js_def; |
861 | 894 |
} |
862 | 895 |
|
863 |
if(maxExtent == null){ |
|
896 |
if(maxExtent === null){
|
|
864 | 897 |
maxExtent = CdmOpenLayers.mapExtends.epsg_4326.clone(); |
865 | 898 |
maxExtent.transform(CdmOpenLayers.projections.epsg_4326, projection); |
866 | 899 |
} |
... | ... | |
873 | 906 |
maxExtent: maxExtent, |
874 | 907 |
projection: projection, |
875 | 908 |
units: units, |
876 |
isBaseLayer: true,
|
|
909 |
isBaseLayer: false,
|
|
877 | 910 |
displayInLayerSwitcher: true |
878 | 911 |
} |
879 | 912 |
); |
880 | 913 |
|
881 |
if(wmsLayer == null){ |
|
882 |
console.log("Error creating WMSBaseLayer");
|
|
914 |
if(wmsLayer === null){
|
|
915 |
console.log("Error creating WMS Layer");
|
|
883 | 916 |
} |
884 | 917 |
|
885 | 918 |
return wmsLayer; |
Also available in: Unified diff
fix #6573 wms overlay layer and some bugfixes: