Select to view content in your preferred language

How to extract xmin, xmax, etc from a selected feature?

3756
3
Jump to solution
12-09-2015 12:18 PM
JohnAdams
Occasional Contributor

Hello, I've got a pesky problem I'm trying to figure out.

I've got a dual webpage arrangement. Both have web maps on them. The map on the 2nd page (a child of the first) will be a zoomed-in map of the feature selected by the user (via clicking) on the first (parent) page and map.

In the first page I've got a handler for the click event. The code is like this, standard stuff: The user clicks on a parcel on a Feature layer which fires the handler:

                return dojo.map(response, function (result)

                {

                    var feature = result.feature;

                    feature.attributes.layerName = result.layerName;

                    if (result.layerName === 'Parcels')

                    {

                        feature.setInfoTemplate(ParcelTemplate);

                    }

                    return feature;

                }

The above is in an executeIdentifyTask function. What I want to do is extract the xmin, xmax, ymin and ymax attributes from the selected feature and store them each in a separate variable. That way I can pass them into the URL of the 2nd web page and use them to set the extent of the map in the 2nd page. I know how to do that, I just can't figure out how to extract the xmin, xmax, etc from the selected feature.

I've looked at the specs of the Feature layer and Geometry classes but it's not clear to me how they're arranged. I'm thinking something like (before "return feature"):

     xmin=feature.Extent.xmin;

          or

     xmin=feature.Geometry.xmin

After declaring "var xmin" at the top of the script. But all the different combinations I've tried either crash the page or give me an "undefined" result.

Assistance would be appreciated.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

John,

   It would be more like:

xmin = feature.geometry.getExtent().xmin

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

John,

   It would be more like:

xmin = feature.geometry.getExtent().xmin

0 Kudos
JohnAdams
Occasional Contributor

It worked! Thanks!!!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

John,

   Glad to help. Don't forget to mark this thread as answered. To do this you have to open the thread (you can not see the correct answer link from inside your inbox) and then you will see the green star with correct answer link. Just click that link on the thread that answered your question.

0 Kudos