Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var legendHTML = ""; // ni letak atas sekali as global pastu add kt HTML ko
- function createLegend(){
- var legend_query = '?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=';
- var layerList = map.frameState_.layerStatesArray;
- for(var i=0; i<layerList.length; i++){
- //console.log(map.frameState_.layerStatesArray[i]);
- if(layerList[i].visible){
- // console.log(layerList[i].layer.values_);
- // console.log(sourceLayer.params_);
- var sourceLayer= layerList[i].layer.values_.source;
- if(typeof sourceLayer.url_ === 'undefined' ){
- }else{
- var legendtitle = layerList[i].layer.values_.title;
- var layerurl = sourceLayer.url_;
- var layerparam = sourceLayer.params_;
- // console.log(layerparam);
- var imglegend = encodeURI(layerurl+legend_query+layerparam.LAYERS);
- legendHTML += "<div class='imglegend'><span>"+legendtitle+"</span>";
- // sini ko boleh control css die guna .imglegend>span or yg mana ko rase senang
- legendHTML += "<img src='"+imglegend+"'>";
- legendHTML += "</div>";
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment