Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get feature info for each layer - L.TileLayer.BetterWMS.js

Get feature info for each layer - L.TileLayer.BetterWMS.js

showGetFeatureInfo: function(err, latlng, content){
    // alert(this.wmsParams.layers);
    var lyr=this.wmsParams.layers;
    if(lyr=='sinhthai:rung_1980' || lyr=='sinhthai:rung_1990' || lyr=='sinhthai:rung_2000' || lyr=='sinhthai:rung_2010' || lyr=='sinhthai:rung_2018'){
      var res_obj = JSON.parse(content);
      var code=res_obj.features[0].properties.PALETTE_INDEX;
      // raster2info(code,this.wmsParams.layers);
      // console.log(code, raster2info);

      if(code!=9){        
        var info=raster2info(code,lyr);
        var info_frm='<h3>'+info['ten']+'</h3>'+'<img src="upload/images/raster_info_rung/'+info['img']+'" width="440" height="280"></img>';
      }else{
        // Giá trị 9 là background
        var info_frm=''
      }

    }else{
      var info_frm='';
    }

    if(info_frm!=''){
      L.popup({ maxWidth: 800})
              .setLatLng(latlng)
              .setContent(info_frm)
              .openOn(this._map);
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment