Skip to content

Commit

Permalink
Added picking to ScreenText example.
Browse files Browse the repository at this point in the history
  • Loading branch information
tag3 committed Nov 9, 2015
1 parent ade9f85 commit ea653cc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/ScreenText.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,27 @@ requirejs(['../src/WorldWind',

// Create a layer manager for controlling layer visibility.
var layerManger = new LayerManager(wwd);

// Set up to handle picking.
var handlePick = (function (o) {
var pickPoint = wwd.canvasCoordinates(o.clientX, o.clientY);

var pickList = wwd.pick(pickPoint);
if (pickList.objects.length > 0) {
for (var p = 0; p < pickList.objects.length; p++) {
var pickedObject = pickList.objects[p];
if (!pickedObject.isTerrain) {
if (pickedObject.userObject instanceof WorldWind.ScreenText) {
console.log(pickedObject.userObject.text);
}
}
}
}
}).bind(this);

// Listen for mouse moves and highlight text that the cursor rolls over.
wwd.addEventListener("mousemove", handlePick);

// Listen for taps on mobile devices and highlight text that the user taps.
var tapRecognizer = new WorldWind.TapRecognizer(wwd, handlePick);
});

0 comments on commit ea653cc

Please sign in to comment.