var identifyParams = new IdentifyParameters(); identifyParams.tolerance = this.identifyTolerance; identifyParams.returnGeometry = true; identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE; identifyParams.geometry = evt.mapPoint; identifyParams.mapExtent = this.map.extent; identifyParams.spatialReference = this.map.spatialReference; identifyParams.width = this.map.width; identifyParams.height = this.map.height;
Thanks for reporting this.
Seems like the workaround mentioned "fixes" this. We will also look at fixing it properly in the Javascript 3.12 version.
result.feature.geometry.spatialReference = this.map.spatialReference;
Unfortunately used identifyTask and spent the past several days to figure out what's wrong with this wkid:4326.
Same thing happened to one of my webmaps after we have updated our servers to 10.2.2 . That piece of code worked like a charm!
Indirectly, this is a Bug in the JSAPI as AJ Morris said. The problem is, that since ArcGIS for Server 10.2(.2) there is no spatial reference in the returning geometry of identify result. In ArcGIS for Server 10.1 the spatial reference still exists in identify result. So perhaps the JSAPI takes a default spatial reference for returning geometry which is 4326 (WGS84) and not the requested one.
So I thing there is a bug in ArcGIS for Server 10.2. But the solution described above works for me too and is a good workaround. So thanks !
Using the 3.10 JSAPI, I experienced the same problem, where the geometries being returned were in 4326 rather than the WKID of the map. Even when I set the SpatialReference of the IdentifyParams. Like M S , I resorted to manually setting the spatial reference of the returned geometries. Using Fiddler, I could see that no spatial ref was on the geometries coming back from server, so it seems like an issue with the JSAPI. Since it doesn't always happen, there's probably a special set of circumstances, like a map declared without a basemap, and then adding a non-webmercator basemap.
Just updating this now that I have it working. I had to set the spatial reference of each individual feature coming from the result set right before adding it to the infotemplate, ieresult.feature.geometry.spatialReference = this.map.spatialReference;Annoying that I have to do it as my map and all my layers are of the same wkid, but at least it now works!
What does map.graphics.spatialReference.wkid return in console?
map.graphics.spatialReference.wkid
For your second question, I performed a search through all of my code for '4326' and nothing was found. I also tried 'graphics.spatialReference' which came up with nothing as well.
Are you using map.graphics for your results? If so, does map.graphics.spatialReference = 4326?How are you setting the sr of the map? With an extent, center & zoom, or the first layer added?
define([ 'dojo/_base/declare', 'dijit/_WidgetBase', 'dojo/_base/lang', 'dojo/_base/array', 'esri/lang', 'esri/tasks/IdentifyTask', 'esri/tasks/IdentifyParameters', 'esri/dijit/PopupTemplate', 'dojo/on', 'dojo/promise/all', './Identify/config' ], function(declare, _WidgetBase, lang, array, esriLang, IdentifyTask, IdentifyParameters, PopupTemplate, on, all, config) { var Identify = declare([_WidgetBase], { declaredClass: 'gis.dijit.Identify', postCreate: function() { this.inherited(arguments); this.layers = []; array.forEach(this.map.layerIds, function(layerId) { var layer = this.map.getLayer(layerId); if (layer.declaredClass === 'esri.layers.ArcGISDynamicMapServiceLayer') { this.layers.push({ ref: layer, identifyTask: new IdentifyTask(layer.url) }); } }, this); this.map.on('click', lang.hitch(this, function(evt) { if (this.mapClickMode.current === 'identify') { this.executeIdentifyTask(evt); } })); }, executeIdentifyTask: function(evt) { this.map.infoWindow.hide(); this.map.infoWindow.clearFeatures(); this.map.infoWindow.setTitle('Identifing...'); this.map.infoWindow.setContent('<img src="images/loading.gif" style="height:20px;width:20px;margin-top:5px"></img>'); this.map.infoWindow.show(evt.mapPoint); var identifyParams = new IdentifyParameters(); identifyParams.tolerance = this.identifyTolerance; identifyParams.returnGeometry = true; identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE; identifyParams.geometry = evt.mapPoint; identifyParams.mapExtent = this.map.extent; identifyParams.width = this.map.width; identifyParams.height = this.map.height; var identifies = []; var identifiedlayers = []; array.forEach(this.layers, function(layer) { if (layer.ref.visible && layer.ref.visibleLayers.length !== 0 && layer.ref.visibleLayers[0] !== -1) { var params = lang.clone(identifyParams); params.layerIds = layer.ref.visibleLayers; identifies.push(layer.identifyTask.execute(params)); identifiedlayers.push(layer); } }); all(identifies).then(lang.hitch(this, 'identifyCallback', identifiedlayers), function(err) { console.log('identify tasks error: ', err); }); }, identifyCallback: function(identifiedlayers, responseArray) { var fSet = []; array.forEach(responseArray, function(response, i) { var layerId = identifiedlayers.ref.id; array.forEach(response, function(result) { // see if we have a Popup config defined for this layer if (config.hasOwnProperty(layerId)) { if (config[layerId].hasOwnProperty(result.layerId)) { result.feature.setInfoTemplate(new PopupTemplate(config[layerId][result.layerId])); } } // if no Popup defined output all attributes if (result.feature.infoTemplate === undefined) { result.feature.setInfoTemplate(new PopupTemplate({ title: result.layerName, description: esriLang.substitute(result.feature.attributes) })); } fSet.push(result.feature); }, this); }, this); this.map.infoWindow.setFeatures(fSet); } }); return Identify; });
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.