Select to view content in your preferred language

How to simulate mouse click

7633
4
Jump to solution
06-02-2016 05:26 AM
RobinChappatte
Emerging Contributor

(Please excuse my english)

I need to simulate a user mouse click on the map.

I tried with this kind of method but it seem not to work: http://stackoverflow.com/questions/6157929/how-to-simulate-a-mouse-click-using-javascript

I think it's because a script-lauched mouse click is an untrusted event and ArcGIS only listen to the trusted event (launched by an user).

I need it because my map is in an invisible iframe, and i send the click coords to it from the main page.

How could I do this ?

(nativ method ? JS hack ? I looked for it but found nothing...)

Thank you in advance for yours answers,

Robin Chappatte

1 Solution

Accepted Solutions
FC_Basson
MVP Regular Contributor

This also works (from Programmatically fire map's click event 😞

map.emit('click', {mapPoint: new esri.geometry.Point(myLong,myLat, esri.SpatialReference({wkid:102100}))});

View solution in original post

4 Replies
FC_Basson
MVP Regular Contributor

What is the click event in the invisible map used for?  If it is to trigger a seperate identify or query, then rather just use the query or identify task directly from the REST endpoint.

RobinChappatte
Emerging Contributor

Thanks for your answer !

In my case, the maps layers can change very often, so I could handle every cases and query the right thing, but in a sens, it duplicate the code that is already writted in the ArcGIS API.

Anyway it would have been a good way in an other case than mine, so thanks !

0 Kudos
FC_Basson
MVP Regular Contributor

This also works (from Programmatically fire map's click event 😞

map.emit('click', {mapPoint: new esri.geometry.Point(myLong,myLat, esri.SpatialReference({wkid:102100}))});

RobinChappatte
Emerging Contributor

I'll try it monday, thank-you very much !!

EDIT: It work just fine, thank you !

0 Kudos