This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |