But this event keeps firing... If you add an alert in this event handler, you will know what I mean. How to fix this problem?Thanks
featureLayer.setDefinitionExpression("COUNTY='" + value + "'"); var query = new esri.tasks.Query(); query.where = "1=1"; query.outSpatialReference = map.spatialReference; featureLayer.queryFeatures(query, function (featureSet) { var data = []; if (featureSet && featureSet.features && featureSet.features.length > 0) { data = featureSet.features; } var zoomExtent = esri.graphicsExtent(data); map.setExtent(zoomExtent); });
I found out with an alert that my featurelayer.graphics.length was = 0 so I could not even access the graphics at all.I found a post titled "unable to draw graphic" which helped me solve this problem.If the layer isn't finished drawing before I try and zoom to the graphic extent, it simply won't zoom.What I did was move the zoom code to an event handler using the onUpdateEnd event of the feature layer.// Just after defining the featurelayer >dojo.connect(featureLayer, "onUpdateEnd", function() { var zoomExtent = esri.graphicsExtent(featureLayer.graphics); map.setExtent(zoomExtent);}); // now the zoom won't happen until map is updatedmap.addLayer(featureLayer);
I can't work out why my map is not zooming to the extent of graphics in my featurelayer.See at the bottom of this code where I try and use the esri.graphicextent method. function initOperationalLayer(map) { var content = "<b>Street: </b>${Street_Name}, ${Suburb}<br/>" + "<b>Pickup Time: </b>${Departure_Time}"; var infoTemplate = new esri.InfoTemplate("Route 1 Details", content); var featureLayer = new esri.layers.FeatureLayer("http://gsportenf/ArcGIS/rest/services/Public_Access/MapServer/12",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], infoTemplate: infoTemplate }); map.addLayer(featureLayer); var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,255,0.35]), 1); var renderer = new esri.renderer.SimpleRenderer(symbol); featureLayer.setRenderer(renderer); map.infoWindow.resize(300,100); var zoomExtent= esri.graphicsExtent(featureLayer.graphics); map.setExtent(zoomExtent); // THE MAP IS NOT CHANGING !!! }
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.