Skip to content

Commit

Permalink
removing legend code
Browse files Browse the repository at this point in the history
  • Loading branch information
rduivenvoorde committed Apr 14, 2015
1 parent fbf0685 commit 45332b5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 131 deletions.
115 changes: 1 addition & 114 deletions api/js/OpenLayersPdokKaartExtenders.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
OpenLayers.Format.KMLv2_2
Symbology support for the OpenLayers class for reading/writing KML 2.2
OpenLayers.Control.LegendControl
The LegendControl control adds a legend for WMS layers.
OpenLayers.Control.GeocoderControl
The GeocoderControl control adds pdok search functionality.
Expand Down Expand Up @@ -220,116 +217,6 @@ OpenLayers.Format.KMLv2_2 = OpenLayers.Class(OpenLayers.Format.KML, {
}
});



/**
* @requires OpenLayers/Control.js
*/

/**
* Class: OpenLayers.Control.LegendControl
* The LegendControl control adds a legend for WMS layers.
*
* Inherits from:
* - <OpenLayers.Control>
*/
OpenLayers.Control.LegendControl =
OpenLayers.Class(OpenLayers.Control, {
dynamic: true,
/**
* Constructor:
*
* Parameters:
* @param options - {Object} Options for control.
*/
initialize: function(options) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
// we create the div ourselves, to be able to put it outside the map-div
// if we let OpenLayers create it, and let it be part of the map-div
// then OpenLayers steals the cursor from our input
if (!this.div){
this.div = document.createElement("div");
this.div.className = OpenLayers.Util.createUniqueID("lg_");
this.div.id = this.div.className+'_'+this.id;
}

// deferred event delegation:
// http://davidwalsh.name/event-delegate
var me = this;
var clickFunc = function(e) {
var target;
e.target?target=e.target:target=e.srcElement;
if(target && target.className === "hideWindow") {
me.hideLegend();
} else if (target && target.className === "hideWindow"){
me.showLegend();
}
};
if (this.div.addEventListener) {
this.div.addEventListener("click", clickFunc);
} else{
// IE8
this.div.attachEvent("onclick", clickFunc);
}
//me.draw();
},

/**
* Method: destroy
* Destroy control.
*/
destroy: function() {
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},

activate: function() {
OpenLayers.Control.prototype.activate.apply(this, arguments);
this.map.events.register('addlayer', this, this.draw);
this.map.events.register('removelayer', this, this.draw);
this.map.events.register('changelayer', this, this.draw);
},

deactivate: function() {
OpenLayers.Control.prototype.deactivate.apply(this, arguments);
this.map.events.unregister('addlayer', this, this.draw);
this.map.events.unregister('removelayer', this, this.draw);
this.map.events.unregister('changelayer', this, this.draw);
},

/**
* Method: draw
* Initialize control.
*
* Returns:
* {DOMElement} A reference to the DIV DOMElement containing the control
*/
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
if(this.dynamic==false){
return;
}
var html = '<h2>Legenda</h2>';
// for every WMS add a P + IMG tag to legendgraphic image
for (var i = 0;i< this.map.layers.length;i++){
var layer = this.map.layers[i];
if (layer.CLASS_NAME == "OpenLayers.Layer.WMS" && layer.visibility) {
var legend = layer.url +
"?TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2F" +
"vnd.ogc.se_xml&FORMAT=image%2Fpng&LAYER=" + layer.params["LAYERS"];
html += '<h4>' + layer.name + '</h4><p><img src=' + legend + ' alt="' + layer.name + '" title="' + layer.name + '" /></p>';
}
}
this.div.innerHTML = html;
return this.div;
},
hideResults: function() {
document.getElementById(this.div.id).style.display = 'none';
},
showResults: function() {
document.getElementById(this.div.id).style.display = 'block';
},
CLASS_NAME: "OpenLayers.Control.LegendControl"
});
/**
* @requires OpenLayers/Control.js
*/
Expand Down
4 changes: 2 additions & 2 deletions api/js/pdok-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ OpenLayers.ProxyHost = "http://"+window.location.host+"/proxy.php?url="; // kaar
//OpenLayers.ProxyHost = window.location.protocol + "//" + window.location.host + "/proxy?url="; // Rijkswaterstaat proxy

// PDOK LOKET DEV
//Pdok.ApiUrl = 'http://pdokserver/pdokkaart/api';
//OpenLayers.ProxyHost = "http://pdokserver/proxy?url="; // kaart.pdok.nl
Pdok.ApiUrl = 'http://pdokserver/pdokkaart/api';
OpenLayers.ProxyHost = "http://pdokserver/proxy?url="; // kaart.pdok.nl



Expand Down
4 changes: 0 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ <h2>
<input type="checkbox" name="mapsearch" id="mapsearch" />
<label for="mapsearch"> Toon zoekfunctie in de kaart</label>
</div>
<div class="row">
<input type="checkbox" name="maplegend" id="maplegend" />
<label for="maplegend"> Toon legenda in de kaart</label>
</div>
</div>
</form>
</div>
Expand Down
11 changes: 0 additions & 11 deletions js/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ function createOnClickEvents() {
$('#mapscaleline').click( function() { setScaleLineVisible($('#mapscaleline').is(':checked')); } );
$('#mapmouseposition').click( function() { setMousePositionVisible($('#mapmouseposition').is(':checked')); } );
$('#mapsearch').click( function() { setMapsearchVisible($('#mapsearch').is(':checked')); } );
$('#maplegend').click( function() { setLegendVisible($('#maplegend').is(':checked')); } );
$('#addpdoklayerbutton').click( function() { addPdokLayer();return false; } );
$('#addwmslayerbutton').click( function() { addWmsLayer();return false; } );
$('#addwmtslayerbutton').click( function() { addWmtsLayer();return false; } );
Expand Down Expand Up @@ -648,15 +647,6 @@ function setMapsearchVisible(isVisible){
}
api.setMapsearchVisible(isVisible);
}
function setLegendVisible(isVisible){
if (isVisible){
api.activateLegend({div:'legendonthemap'});
$('#legendonthemap').show();
} else {
$('#legendonthemap').hide();
}
api.setLegendVisible(isVisible);
}
function reload_wizard_based_on_url(){
strUrl = $('#pdokkaartUrl').val();
if (strUrl.substr(0,4).toUpperCase() === 'HTTP'){
Expand Down Expand Up @@ -684,5 +674,4 @@ function setGuiToApiState(api) {
setCheckbox('#mapscaleline', config.showscaleline);
setCheckbox('#mapmouseposition', config.showmouseposition);
setCheckbox('#mapsearch', config.geocoder);
setCheckbox('#maplegend', config.legend);
}

0 comments on commit 45332b5

Please sign in to comment.