Widgets 4x: Listening for pointer events on a MapView

974
3
Jump to solution
03-17-2017 03:34 PM
DirkVandervoort
Occasional Contributor II

I'm trying to figure out how to listen for pointer events on a MapView in my widget. I'm not getting very far... For example:

postInitialize() {
 watchUtils.on(this, "view", "pointer-down", () => this._onPointerDown());
}‍‍‍

will fire the _onPointerDown method when the MapView is clicked on. However, what I'm really interested in are the properties of the pointer-down event. e.g., x, y, etc. : MapView | API Reference | ArcGIS API for JavaScript 4.3 

Any advice is appreciated - I'm just looking for an opening  TIA

0 Kudos
1 Solution

Accepted Solutions
thejuskambi
Occasional Contributor III

You need to use the instance of MapView to add listener for the event like below.

mapView.on("pointer-down",() => this._onPointerDown());

View solution in original post

3 Replies
thejuskambi
Occasional Contributor III

You need to use the instance of MapView to add listener for the event like below.

mapView.on("pointer-down",() => this._onPointerDown());
DirkVandervoort
Occasional Contributor II

Yep!

this.view.on("pointer-down",(evt:PointerEvent) => this._onPointerDown(evt));

and

private _onPointerDown(evt:PointerEvent) {
 // do something with the evt
}

Brilliant!

0 Kudos
Travis_L_Riffle
New Contributor II

My "this" keyword is not available....  Am I the only one?  Using AngularJS.

0 Kudos