POST
|
Thanks stevel With outfields populated i get a "dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"error":{"code":400,"message":"Unable to complete operation.","details":["Unable to complete Query operation."]}});" error with outfields empty i get "TypeError: Cannot read property 'geometry' of undefined {}" regardless, the map errors and doesn't draw <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.tasks.query"); function init() { map = new esri.Map("mapDiv"); var basemapURL= "http://<myserver>/ArcGIS/rest/services/<myservice>/MapServer" var basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapURL); map.addLayer(basemap); // sample Query Task // define variables var queryTask, query; //Define a new Query and QueryTask queryTask = new esri.tasks.QueryTask("http://<myserver>/ArcGIS/rest/services/<myservice>/MapServer/7"); query = new esri.tasks.Query(); query.returnGeometry = true; query.outFields = ["BUILDNG_NO","ADDRESS_ID"]; //The query's where clause will be attribute query to find the feature query.where = "OBJECTID=6742"; //Run the query. Its results are returned in the function showResults queryTask.execute(query,showResults); //results is an array of any found features. Assuming you only want the first feature: function showResults(results) { var result = results[0]; var extent = result.geometry.getExtent().expand(5.0); map.setExtent(extent); } // end of Query Task } dojo.addOnLoad(init); </script>
... View more
01-09-2012
04:08 PM
|
0
|
0
|
610
|
POST
|
Unfortunately, our server is on our intranet. I'm passing the objectid value to js Is a query task really needed? there is no other way to pass the value? the query tasks i have seen seem to be more related to the data table and i can't seem to find a simple example of passing a variable to the query task to pan and zoom i did find this: function zoomRow(id){ selectionLayer.clear(); dojo.some(map.graphics.graphics,function(graphic){ if (graphic.attributes.ObjectID.toString() === id) { var selectedState = new esri.Graphic(graphic.geometry).setAttributes( graphic.attributes); selectionLayer.add(selectedState); var stateExtent = selectedState.geometry.getExtent().expand(5.0); map.setExtent(stateExtent); return true; } }); here http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/12/14/Add-a-Zoom-button-to-a-DataGrid.aspx which basically does what i want, i just need to do an onload, i think
... View more
01-09-2012
09:26 AM
|
0
|
0
|
610
|
POST
|
I've searched here and the rest forums and can't seem to find an answer. I have a php page that when a value is click, a fancybox iframe opens with data, a floor plan, and a map of the building. i have passed the variable to javascript but am unable to see how to pass the variable to the map to zoom to the feature(QueryTask?). i've tried using query?where= but i seem to be way off. i've looked into the QueryTask, but have been unable to find an example of what i'm trying to accomplish. Does anyone have an example i can look at?
... View more
01-06-2012
02:05 PM
|
0
|
12
|
3004
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|