[GIS] How to query all points within the current map extent

arcgis-javascript-apijavascript

First post – apologies if it's a simple question!

I am basically looking to have a JS API service which will populate a datagrid with all of the points visible in the current map extent. As a user zooms in or out, the number of records returned will change to reflect what is in the current extent.

I have been looking at the findPointsInExtent examples in the esri JavaScript examples, but am not sure how to edit the these examples to go from a user defined rectangle to the map extent as described above.

Many thanks,

Best Answer

When you create map object, you can specify the extends as below:

 map = new esri.Map("map", {
          extent: esri.geometry.geographicToWebMercator(new esri.geometry.Extent(-125.90, 44.60, -114.65, 50.22, new esri.SpatialReference({wkid:4326}))),
          showInfoWindowOnClick:false
        });

Then latter you can change the map extends values as below:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/map.htm#setExtent

map.setExtent(taxLotExtent);
Related Question