Click here to Skip to main content
15,033,215 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am able select geojson layers from geoserver in dropdown selection but i want to add wms layers in the same how i am select the geojson layers . This code working for geojson layers...but i want add wms layers . thank you help..

What I have tried:

JavaScript
var map, layerControl;

var dropdownlayers = {};
dropdownlayers["04"] = {
  name: "Cluster Bahraich ",
  layer: L.geoJson(),
  url:"http://localhost:8080/geoserver/nird/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=nird:cluster_bahraich&maxFeatures=50&outputFormat=application%2Fjson",

    
};
dropdownlayers["4"] = {
	name: "Cluster Bahraich GM",
	layer: L.geoJson(),
	url:"http://127.0.0.1:8080/geoserver/nird/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=nird:Cluster_Bahraich_GM&maxFeatures=50&outputFormat=application%2Fjson",
	style:style
    
};
function load_layer(dropdownchoice) {
  $.ajax({
     dataType: "json",
    
	url: dropdownchoice.url,
    success: function(data) {
      var layer = dropdownchoice.layer;
      layer.clearLayers();
      layer.addTo(map);
       
      $(data.features).each(function(key, data) {
        layer.addData(data);
      });
function getstates(choice) {
  load_layer(dropdownlayers[choice.value]);
            var text = choice.options[choice.selectedIndex].text
            var ddl2 = document.querySelectorAll("#choice option");
           
            for (var i = 1; i < ddl2.length; i++) {
                var option = ddl2[i];
                option.style.display = 'none'; 
            /* state*/

                if (text == 'Uttar Pradesh') {
                    if (['Bahraich'].indexOf(option.text) > -1)
                        option.style.display = 'block'



                }
                if (text == 'Jharkhand') {
                    if (['Gumla', 'Hazirabagh'].indexOf(option.text) > -1)
                        option.style.display = 'block'
                }
			}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900