Help with InfoTemplate when selecting multiple parcels using Extent

117
2
Jump to solution
05-08-2020 12:55 PM
KevinHanley2
New Contributor II

So I'm using an InfoTemplate to display info on parcels. When clicking on a parcel the InfoTemplate knows exactly where to go since there is a defined coordinate with the mouse click.

I also have a selection that allows you to click and drag an extent to select multiple parcels and I'm having trouble controlling where the InfoWindow is popping up. I found some xmin/xmax, ymin/ymax coordinates in some of the geometry properties, so I figured I'd try finding the "middle" of these and displaying the InfoWindow there, but it doesn't seem to be working. I'm sure there's an easier way to do this, or to find the middle of a parcel to display the window, but I wanted to see if I am on the right track.

var coordxmin = evt.geometry.xmin;
var coordxmax = evt.geometry.xmax;
var coordx = coordxmax + coordxmin;
var coordxhalf = coordx / 2.0;

var coordymin = evt.geometry.ymin;
var coordymax = evt.geometry.ymax;
var coordy = coordymax + coordymin;
var coordyhalf = coordy / 2.0;

var fcoords = {
x: coordxhalf,
y: coordyhalf,
};

map.infoWindow.show(fcoords)

I'm basically trying to create a variable and force the x/y coordinates into the properties of it so that map.infoWindow.show pops up there, but it seems to be overwriting my X value with something else and I'm confused as to why it's doing that.

Let me know if there's an easier way to accomplish what I'm trying to do, as always. I'm very new to this! Thank you in advance.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Kevin,

  It would be much easier to get the center of the extent using the getcenter method.

https://developers.arcgis.com/javascript/3/jsapi/extent-amd.html#getcenter 

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Kevin,

  It would be much easier to get the center of the extent using the getcenter method.

https://developers.arcgis.com/javascript/3/jsapi/extent-amd.html#getcenter 

KevinHanley2
New Contributor II

As usual I was over-complicating it. Thank you!

0 Kudos