Making points on a visible layer, clickable with a popup

789
6
06-15-2011 05:54 AM
AlistairDorman-Smith
New Contributor
Hi

I want to do something which appears to be more complicated than I first thought, although it's probably simple for someone who knows what they're doing.

I have a map, with some vectors that you can click on to find out information about. Which is fine, but in another layer of my MSD, I have some points - just markers that indicate locations of facilities.

At the moment when I make the points layer visible (using the standard buildLayerList/updateLayerVisibility function from the ESRI examples) they markers appear on top of the vectors - which is exaclty right.

I want to make the markers clickable, so that when you click on them, you get a popup about the facility's name etc. I'm not sure how to do this!!!

Do I need to actually do a small buffer search on the specific points layer?

As the vectors will be clickable, and I want the facilities to be too, I'm not sure how to handle that without having a seperate tool, but that's a seperate issue - the major issue I have is being able to make them clickable once they are visible.

Hope that makes sense and grateful for any help you can give.
Thanks
0 Kudos
6 Replies
HemingZhu
Occasional Contributor III
Hi

I want to do something which appears to be more complicated than I first thought, although it's probably simple for someone who knows what they're doing.

I have a map, with some vectors that you can click on to find out information about. Which is fine, but in another layer of my MSD, I have some points - just markers that indicate locations of facilities.

At the moment when I make the points layer visible (using the standard buildLayerList/updateLayerVisibility function from the ESRI examples) they markers appear on top of the vectors - which is exaclty right.

I want to make the markers clickable, so that when you click on them, you get a popup about the facility's name etc. I'm not sure how to do this!!!

Do I need to actually do a small buffer search on the specific points layer?

As the vectors will be clickable, and I want the facilities to be too, I'm not sure how to handle that without having a seperate tool, but that's a seperate issue - the major issue I have is being able to make them clickable once they are visible.

Hope that makes sense and grateful for any help you can give.
Thanks


one feasible approach would be doing a identify task (with layerOption LAYER_OPTION_VISIBLE) on your MSD. The result is an array of IdentifyResult which will tell you the info of the feature (layer id, layer name, attributes etc) you clicked. Then you can associate the feature with infowindow.
0 Kudos
AlistairDorman-Smith
New Contributor
Hi

I have had a go with the identify task, and it works. I haven't tried to integrate it into my main project yet, just a modified version of the ESRI example.

However, it turns out you have to click EXACTLY on the precise pixel of the little map marker for the identify tool to work. It really needs to work like google map markers, where you can click anywhere on the marker icon itself and it will identify ok.

The map markers I'm using are defined in the MSD.

What can you suggest?

Thanks.
0 Kudos
HemingZhu
Occasional Contributor III
ali7789v4;110414 wrote:
Hi


I have had a go with the identify task, and it works. I haven't tried to integrate it into my main project yet, just a modified version of the ESRI example.

However, it turns out you have to click EXACTLY on the precise pixel of the little map marker for the identify tool to work. It really needs to work like google map markers, where you can click anywhere on the marker icon itself and it will identify ok.

The map markers I'm using are defined in the MSD.

What can you suggest?

you could set IdentifyParameters.tolerance =2 or more(pixel distance) to give your identify point a wider searching area.
0 Kudos
derekswingley1
Frequent Contributor
Hzhu is right, you want to look at the tolerance property of identifyParameters.
0 Kudos
BrettLord-Castillo
Occasional Contributor
You could try using a feature layer to display the data instead.
Or use a simple transparent graphics layer.
Those would be clickable with a popup, and would be based on the marker being clicked rather than hitting the exact pixel.

The bigger plus is that there would be no xhr round trip like there is with identify; the actions would all happen client side. The disadvantage is longer loading time for the data (use feature class rather than graphics if you have a large number of features).
0 Kudos
AlistairDorman-Smith
New Contributor
Hi Thanks for your comments.

I have got this working with the identify task and increased the tolerance.

It works, but your idea about using a Feature Layer sounds worth exploring. Please excuse my lack of knowledge as I don't quite know what a feature layer is compared to what I currently have. I would be grateful if you could explain.

I currently have a layer with points on which I simply just make visible and then I use the identify task with it. How would I use a feature layer?

It would be nice to have custom icons for the points, but the examples I have seen seem to use the Graphics object to achieve this, and I'm yet to work out how to integrate this into my current setup. Perhaps using a feature layer might solve this.

Grateful for any advice.
0 Kudos