When I select a feature on a map and use popup.getSelectedFeature() I get a great JSON object that has all kinds of information about the feature, including: feature attributes, the layer the feature is on, etc. That's great! Is it possible to get the same information when I don't have a map loaded?
I have a page in my application where I don't have a map at all. I just show information from my own custom database that relates to features. I want to be able to open the same custom info panel that I created for use on my map page on this other page. To do that, I need the following information for the feature:
I looked into using the ArcGIS REST API query, but it doesn't give me any information about the layer or the full geometry object.
I hoping there is a way to select a feature using its ObjectID without a map. Thanks!
Solved! Go to Solution.
I'm pretty sure you can get all the information you want via the Query operation against the REST endpoint. Here I just supplied the OBJECTID and set the outfields to * and returnGeometry to true. For example:
We also have a similar sample that uses the FindTask:
Just as a side note, if you want it to be a json you can replace the 'f=html' at the end of the url with 'f=pjson' like so:
I add it to a map, but you can just as easily access the json object instead.
Thanks to both of you for your responses. Yes, you can get some information about feature using the REST API, but not nearly as much as you can by selecting the graphic on the map. For example, you can see below, the geometry from the REST Endpoint contains X and Y. However, from the Graphic there is much more data including hasM, hasZ, latitude, longitude, spatialReference, type, X and Y. It's the same things with layer. I was hoping there was an easy way to get around it, but it sounds like I will still have to go ahead a create a layer and select a feature to get all the same data, even if there isn't a map loaded. Is that right?
I believe that you can still get all the relevant information from REST. If it's a feature that is hosted somewhere, all the pertinent information is there, it's really just a questions of formatting. For example, the hasM or hasZ is false for both in the image above. This means that there is no M-value or Z-value, so those values will not be returned from the REST endpoint (they would be returned if they existed). The x and y values are just converted lat/longs (or vice versa). The type is available from REST, just in a different format, e.g.:
Lastly, the spatial reference is available on the service itself.
Hi Ben and Noah,
Both great points. Noah, yes it's true, I'm sure it is all there using the REST API, it just would take a little bit of work. Ben, that is what I was looking for. The answer seems obvious now that you point it out. I don't need a map and layers and all that, just a quick query and create a graphic. Perfect! Thanks again!