33. So we are at 38.8565, -94.80069. What does that mean?
Latitude & Longitude
Latitude Longitude
Equator
Prime Meridian
+60
-30
-90 (South)
+90 (North) 180
-120 (West)
+30 (East)
36. How did we get the location?
GPS, GLONASS
GNSS
37. How did we get the location?
GPS, GLONASS, GALILEO, BeiDou, NAVIC, QZSS
GNSS
38. Example: Positioning in Monkey C
Position.enableLocationEvents(
Position.LOCATION_ONE_SHOT,
method(:onPosition));
function onPosition(info) {
var lat = info.position.toDegrees()[0];
var long = info.position.toDegrees()[1];
}
39. How did we get the location?
There are other ways to get location.
e.g. radio signals:
Cell towers, Wi-Fi, Bluetooth, etc
e.g. IP address
40.
41. Where am I?
Use a Positioning API.
Understand where the location comes from.
Choose the right API for the right task/device.
On your Connect IQ device: GPS/GLONASS
42. Where am I?
By themselves a latitude and longitude aren‘t always helpful.
Often their power is in placing us on a map.
49. Example: Map Image API
https://image.maps.api.here.com/mia/1.6/mapview?
&app_id=YOUR_APP_ID
&app_code=YOUR_APP_CODE
&c=37.37774,-121.92186
&z=14
&w=210
&h=110
center of the map
zoom level
image width and height
credentials
60. Example: Geocoder in Monkey C
url = "https://reverse.geocoder.api.here.com/6.2/reversegeocode.json";
parameters = {
"app_id" => Ui.loadResource(Rez.Strings.app_id),
"app_code" => Ui.loadResource(Rez.Strings.app_code),
"mode" => "retrieveAddress"
"prox" => lat + "," + long + ",250",
};
options = {
:responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_JSON
};
61. Example: Geocoder in Monkey C
Comm.makeWebRequest(url,parameters,options,method(:onReceive));
function onReceive(responseCode, data) {
if (responseCode == 200) {
parseResponse(data);
} else {
addressText = responseCode;
}
}
62. Example: Geocoder in Monkey C
function parseResponse(data) {
var response = data.get("Response");
var viewArray = response.get("View");
var view = viewArray[0];
var resultArray = view.get("Result");
var result = resultArray[0];
var location = result.get("Location");
var address = location.get("Address");
addressText = address.get("Label");
}
71. Example: HERE Routing API
https://route.api.here.com/routing/7.2/calculateroute.json?
waypoint0=38.92812,-94.70251
&waypoint1=37.615,122.393
&mode=fastest;car;traffic:enabled
start and end point
routing mode
72. EXAMPLE: Map Image with Route
https://image.maps.api.here.com/mia/1.6/route?
&r0=52.540867,13.262444,
52.536691,13.264561,
52.529172,13.268337,
52.528337,13.273144,
52.52583,13.27898,
52.518728,13.279667
&lc0=44ff00ff
waypoints
line color