i have selected feature(feature layer) from combobox and it zoom to the feature . now i want to clear combobox slection and map . and zoom map to its default zoom.
here is my code
function clearall()
{
//combobox selection clear dijit.byId("A1").reset(); dijit.byId("A2").reset(); dijit.byId("A3").reset(); dijit.byId("A4").reset(); dijit.byId("A5").reset(); //layer selection clear document.getElementById('A1_layer').clearSelection(); document.getElementById('A2_layerC').clearSelection(); document.getElementById('A3_layerC').clearSelection(); document.getElementById('A4_layerC').clearSelection(); document.getElementById('A5_layerC').clearSelection(); } //cascading code app = { zoomRow: function(id, which){ var query = new Query(); //var thePoly, theExtent; if(which == "Land"){ query.where = "Name='" + (id).toString() + "'"; console.info(query.where); query.returnGeometry = true; A1_layer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) { thePoly = features[0].geometry; theExtent = thePoly.getExtent().expand(2); //Zoom out slightly from the polygon's extent map.setExtent(theExtent); }); esriRequest({ url: "http://localhost:6080/arcgis/rest/services/........", content:{ f:'json' }, handleAs:'json', callbackParamName:'callback', timeout:15000 }).then(lang.hitch(this,function(response){ var store2 = new Memory({data:[]}); dijit.byId("A2").set('store',store2); var data = array.map(response.features,lang.hitch(this,function(feat, index){ var name = feat.attributes.nam; var dataItem = { id:index, name:name }; return dataItem; })); store2 = new Memory({data:data}); dijit.byId("A2").set('store',store2); document.getElementById('A2').value = "Select Room"; })); }
// combobox<input id="A1" data-dojo-type="dijit/form/ComboBox" value="Select landing" onchange="app.zoomRow(document.getElementById('A1').value, 'Land');" data-dojo-props="maxHeight: 200" style="overflow:auto; width:200px; background-color: #E7FCCA "/ ><br></br> <input id="A2" data-dojo-type="dijit/form/ComboBox" value="Select room onchange="app.zoomRow(document.getElementById('A2').value, 'Room');"style="overflow:auto; width:200px ;background-color: #E7FCCA" /> <br></br>
but i got error "Cannot read property 'geometry' of undefined" at thePoly = features[0].geometry;
Solved! Go to Solution.
Faryal,
So you should just simply check for a null in an if block before proceeding:
A1_layer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
if(features[0]){
thePoly = features[0].geometry;
theExtent = thePoly.getExtent().expand(2);
//Zoom out slightly from the polygon's extent
map.setExtent(theExtent);
}
});
Faryal,
So you should just simply check for a null in an if block before proceeding:
A1_layer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
if(features[0]){
thePoly = features[0].geometry;
theExtent = thePoly.getExtent().expand(2);
//Zoom out slightly from the polygon's extent
map.setExtent(theExtent);
}
});
thanks for your reply but as i mentioned it is cascading filtering. if i use if condition it does not zoom to the next feature in the combobox.
Faryal,
So you allow then to select a room before they select a landing? Why would selecting a landing not return any geometry results?