Skip to content

Instantly share code, notes, and snippets.

View here-devblog-gists's full-sized avatar

here-devblog-gists

  • HERE Technologies
View GitHub Profile
public void findPlaces(View view) {
// collect data to set options
GeoCoordinate myLocation = posManager.getPosition().getCoordinate();
EditText editSteps = (EditText)findViewById(R.id.editSteps);
int noOfSteps;
try {
noOfSteps = Integer.valueOf(editSteps.getText().toString());
} catch (NumberFormatException e) {
// if input is not a number set to default of 2500
private PositioningManager posManager;
...
private void onMapFragmentInitializationCompleted() {
// retrieve a reference of the map from the map fragment
map = mapFragment.getMap();
// start the position manager
posManager = PositioningManager.getInstance();
class SearchRequestListener implements ResultListener<DiscoveryResultPage> {
@Override
public void onCompleted(DiscoveryResultPage data, ErrorCode error) {
if (error != ErrorCode.NONE) {
// Handle error
} else {
// results can be of different types
// we are only interested in PlaceLinks
List<PlaceLink> results = data.getPlaceLinks();
if (results.size() > 0) {
MapGesture.OnGestureListener listener = new MapGesture.OnGestureListener.OnGestureListenerAdapter() {
@Override
public boolean onMapObjectsSelected(List<ViewObject> objects) {
// There are various types of map objects, but we only want
// to handle the MapMarkers we have added
for (ViewObject viewObj : objects) {
if (viewObj.getBaseType() == ViewObject.Type.USER_OBJECT) {
if (((MapObject)viewObj).getType() == MapObject.Type.MARKER) {
// save the selected marker to use during route calculation
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == OnEngineInitListener.Error.NONE) {
mapFragment.getMapGesture().addOnGestureListener(listener);
onMapFragmentInitializationCompleted();
} else {
System.out.println("ERROR: Cannot initialize Map Fragment: " + error);
}
}
private class RouteListener implements RouteManager.Listener {
public void onProgress(int percentage) {
// You can use this to display the progress of the route calculation
}
public void onCalculateRouteFinished(RouteManager.Error error, List<RouteResult> routeResult) {
// If the route was calculated successfully
if (error == RouteManager.Error.NONE) {
// Render the route on the map
public class BasicMapActivity extends Activity {
// map embedded in the map fragment
private Map map = null;
// map fragment embedded in this activity
private MapFragment mapFragment = null;
private PositioningManager posManager;
// markers and containers
route.cit.api.here.com/routing/7.2/calculateroute.json
?app_id={id}
&app_code={code}
&waypoint0=geo!{start point}
&waypoint1=geo!{end point}
&mode={mode}
String basicAuth = "/routing/7.2/calculateroute.json" +
"?app_id=[my_id]" +
"&app_code=[my_code]" +
"&waypoint0=geo!37.7825295,-122.4056341" +
"&waypoint1=geo!37.7837775,-122.3989785";
client.print("GET " + basicAuth + "&mode=shortest;car;traffic:enabled HTTP/1.1\r\n")
client.print("Host: route.cit.api.here.com\r\n");
client.print("Connection: close\r\n");
client.println();