Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1178 from geoadmin/fix_hostname
Browse files Browse the repository at this point in the history
admin.ch domain doesn't require a confirmation message for WMS and KML
  • Loading branch information
cedricmoullet committed Mar 5, 2014
2 parents 122d23e + c74e9d3 commit d867896
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/components/map/MapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,9 +855,9 @@
});

var deregister = scope.$on('gaLayersChange', function() {
var allowThirdData = (angular.isDefined(layersParamValue) &&
layersParamValue.match(/(KML\|\||WMS\|\|)/g) &&
confirm($translate('third_party_data_warning')));

var allowThirdData = false;
var confirmedOnce = false;

angular.forEach(layerSpecs, function(layerSpec, index) {
var layer;
Expand All @@ -867,6 +867,26 @@
layerVisibilities[index] == 'false') ?
false : true;

if (isKmlLayer(layerSpec) || isWmsLayer(layerSpec)) {
var url = '';
if (isKmlLayer(layerSpec)) {
url = layerSpec.replace('KML||', '');
}
if (isWmsLayer(layerSpec)) {
url = layerSpec.split('||')[2];
}
if (!confirmedOnce &&
!/(admin|bgdi)\.ch$/.test(gaUrlUtils.getHostname(url))) {
allowThirdData =
confirm($translate('third_party_data_warning'));
if (allowThirdData) {
confirmedOnce = true;
}
} else {
allowThirdData = true;
}
}

if (gaLayers.getLayer(layerSpec)) {
// BOD layer.
// Do not consider BOD layers that are already in the map.
Expand All @@ -883,7 +903,6 @@

} else if (allowThirdData && isKmlLayer(layerSpec)) {
// KML layer
var url = layerSpec.replace('KML||', '');
try {
gaKml.addKmlToMapForUrl(map, url,
{
Expand All @@ -905,7 +924,7 @@
LAYERS: infos[3]
},
{
url: infos[2],
url: url,
label: infos[1],
opacity: opacity,
visible: visible,
Expand Down

0 comments on commit d867896

Please sign in to comment.