forked from sspinnovations/esrijsapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NavigationHelper.js
73 lines (59 loc) · 2.07 KB
/
NavigationHelper.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* global $ */
var NavigationHelper = {
goToLatLong: function () {
var lat = $('#latNav').val();
var long = $('#longNav').val();
if (isNaN(lat))
return;
if (isNaN(long))
return;
var setPoint = new Site.point({
longitude: long,
latitude: lat
});
Site.mapView.center = setPoint;
},
tiltView: function () {
// Get the camera tilt and add a small number for numerical inaccuracies
var tilt = Site.mapView.camera.tilt + 1e-3;
// Switch between 3 levels of tilt
if (tilt >= 80) {
tilt = 0;
} else if (tilt >= 40) {
tilt = 80;
} else {
tilt = 40;
}
Site.mapView.animateTo({
tilt: tilt
});
},
rotateView: function(direction) {
var heading = Site.mapView.camera.heading;
// Set the heading of the view to the closest multiple of 90 degrees,
// depending on the direction of rotation
if (direction > 0) {
heading = Math.floor((heading + 1e-3) / 90) * 90 + 90;
} else {
heading = Math.ceil((heading - 1e-3) / 90) * 90 - 90;
}
Site.mapView.animateTo({
heading: heading
});
},
geocode: function() {
//http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?text=380+New+York+Street%2C+Redlands%2C+CA+92373&f=pjson
var find = new Site.locator({
url: "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
});
var addressString = $('#geocodeAddress').val();
var address = {"addresses" : [{"OBJECTID": 0, "Single Line Input": addressString}],
"countryCode": "US", categories: []};
find.addressesToLocations(address)
.then(function(response) {
console.log(response);
}).otherwise(function (error) {
console.log(error);
});
}
}