+
+
Richard Süselbeck
Developer Evangelist
HERE Technologies
@sueselbeck
@heredev
The world‘s leading location technology company
Determine user‘s location
Find and display nearby sights, user can scroll through sights
Find route to sight, user can scroll through instructions
Expectations
Where am I?
https://github.com/leopectus/connectiq-workshop
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)
How did we get the location?
How did we get the location?
GPS
How did we get the location?
GPS, GLONASS
GNSS
How did we get the location?
GPS, GLONASS, GALILEO, BeiDou, NAVIC, QZSS
GNSS
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];
}
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
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
Where am I?
By themselves a latitude and longitude aren‘t always helpful.
Often their power is in placing us on a map.
Maps
Making Maps is hard.
Maps
Making Maps is hard.
Maps
Maps
https://github.com/leopectus/connectiq-workshop
Map Image API
https://developer.here.com/documentation/map-image/
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
Example: Map Image API
Communications.makeWebRequest(url,
parameters,
options,
listener);
Communications.makeImageRequest(url,
parameters,
options,
listener);
Example: Map Image API
url = "https://image.maps.cit.api.here.com/mia/1.6/mapview";
parameters = {
"app_id" => Ui.loadResource(Rez.Strings.app_id),
"app_code" => Ui.loadResource(Rez.Strings.app_code),
"c" => 37.37774,-121.92186,
"h" => "210",
"w" => "210",
"z" => "14",
};
options = {
:dithering => Communications.IMAGE_DITHERING_FLOYD_STEINBERG
};
Example: Map Image API
Comm.makeImageRequest(url,parameters,options,method(:onReceive));
function onReceive(responseCode, data) {
if (responseCode == 200) {
mapImage = data;
} else {
System.println("Error: " + responseCode);
}
}
Where am I?
1200 E. 151st St.,
Olathe, Kansas 66062-3426
Where am I?
Invalidenstraße 116
10245 Berlin
1200 E. 151st St.,
Olathe, Kansas 66062-3426
Geocoder API
https://developer.here.com/documentation/geocoder/
Geocoder API
38.85689,-94.79921
Invalidenstraße 116
10245 Berlin52.530861,13.38474
1200 E. 151st St.,
Olathe, Kansas 66062-3426
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?
&mode=retrieveAddresses
&prox=52.530861,13.38474
Example: HERE Geocoder API
https://geocoder.api.here.com/6.2/geocode.json
?searchtext=1200+E+151st+St+Olathe+Kansas
return the closest street address
location (and radius)
search
string
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
};
Example: Geocoder in Monkey C
Comm.makeWebRequest(url,parameters,options,method(:onReceive));
function onReceive(responseCode, data) {
if (responseCode == 200) {
parseResponse(data);
} else {
addressText = responseCode;
}
}
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");
}
16K
16K
maximum size of JSON response
What‘s around us?
Maps provide context for a location.
Places (points of interest) are another type of context.
Where do I want to go?
Location isn‘t just about where you are. It‘s about where you‘re going.
Places API
https://developer.here.com/documentation/places/
Example: HERE Places API
https://places.demo.api.here.com/places/v1/discover/here?
at=52.530861,13.38474 center of search
How do I get there?
Find your way using the Routing API.
Routing API
https://developer.here.com/documentation/routing/
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
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
https://developer.here.com
+
After the break: Workshop Session!
Hands-on, bring your laptop!
Resources
https://developer.here.comFree Trial:
https://developer.here.com/documentationDocs:
https://www.slideshare.net/heretechSlides:
https://github.com/heremapsCode:
https://stackoverflow.com/questions/tagged/here-apiHelp:
@sueselbeckTwitter: @heredev

Garmin Developer Summit 2018 - Talk