Multipoint Coordinate Index Array/getPoint

34
3
06-02-2020 11:43 AM
Highlighted
New Contributor II

So I am currently able to select multiple parcels with Multipoint and it's currently populating my InfoWindow with the correct information, but I'm wanting the InfoWindow to move to the corresponding parcel when it is highlighted using the location that the user clicked for that particular parcel.

Currently I have a variable in a for loop that is housing the coordinate array called multi:

var multi = evt.geometry.points;

This array has the coordinates as [0] and [1], but of course the InfoWindow wants them as X and Y.

I've attempted to use the getPoint method to push these coordinates to the X and Y properties so that the InfoWindow can use them, but I can't seem to figure out how to use it properly in this instance.

I've tried it like this, but it throws an error saying the property [0] is undefined:

var infoloc = evt.geometry.getPoint(multi);

I assumed since it just needed an index in the brackets that this would work, but I am mistaken. Can anyone point me in the right direction?

Thank you.

Reply
0 Kudos
3 Replies
Highlighted
MVP Esteemed Contributor

Kevin,

   The getPoint method of a multipoint is wanting a index (number) of the point that you are trying to get.

var infoloc = evt.geometry.getPoint(0);

Reply
0 Kudos
Highlighted
New Contributor II

That makes sense. Thank you.

My problem now is that it only seems to be placing the InfoWindow at one of the locations. If I use evt.geometry.getPoint(0) it places it at the location of the first parcel I click. If I use evt.geometry.getPoint(i) it places it at the last parcel I click.

Is there a proper way to do this when using multipoint?

Here is the full function, for reference:

function showFeatureSetMulti(fset,evt, infoTemplate) {

map.graphics.clear();
featureSet = fset;
var numFeatures = featureSet.features.length;
var features = fset.features;

var content = "";

for (var i=0; i<numFeatures; i++) {
var graphic = featureSet.features;
content = graphic.attributes.OWNER_NAME;

infoTemplate = new InfoTemplate("${PIN_DSP}","<b>${OWNER_NAME}<br>${ADDRESS_1}<br>${ADDRESS_2}<br>${CITY_NAME}, ${ST}<br>${ZIPCODE}</b>");

graphic.setInfoTemplate(infoTemplate);
document.getElementById("doMultiSela").className = "none";

var array = fset.features;
map.infoWindow.setFeatures(array);
map.infoWindow.show();
}
var point = evt.geometry.getPoint(i);
map.infoWindow.show(point);
}

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Kevin,

    Why are you using a multipoint? You do know that the map can only have one popup visible at a time right?

Reply
0 Kudos