-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCoordinates.js
40 lines (28 loc) · 982 Bytes
/
getCoordinates.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var counter=0;
var array = [];
/* Will run as soon as HTML doc is loaded */
$(document).ready(function() {
console.log("First landmark is:", landmarks[0]);
});
/* Lil script runs as soon as user clicks left mouse button... */
$(function() {
$("#test").click(function(e) {
var offset = $(this).offset();
var relativeX = (e.pageX - offset.left);
var relativeY = (e.pageY - offset.top);
console.log("Name = ",landmarks[counter],
relativeX, relativeY,
" next landmark is ", landmarks[counter+1]);
counter++;
array.push([landmarks[counter],relativeX, relativeY]);
});
});
/* This should executed when user press "e" in the keyboard to
erase a X and Y coordinate from being stored in the array */
$(function() {
$("#erase").click(function(events) {
console.log("removing coordinates " + array.pop() + "... done!" );
counter--;
console.log("Please repin landmark", landmarks[counter]);
});
});