use of com.here.android.mpa.common.GeoCoordinate in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
/* Locate the mapFragment UI element */
m_mapFragment = getMapFragment();
m_mapFragmentContainer = m_activity.findViewById(R.id.mapfragment);
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.getExternalFilesDir(null), ".here-map-data").getAbsolutePath();
// This method will throw IllegalArgumentException if provided path is not writable
com.here.android.mpa.common.MapSettings.setDiskCacheRootPath(path);
if (m_mapFragment != null) {
/* Initialize the AndroidXMapFragment, results will be given via the called back. */
m_mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == Error.NONE) {
m_map = m_mapFragment.getMap();
m_map.setCenter(new GeoCoordinate(49.259149, -123.008555), Map.Animation.NONE);
m_map.setZoomLevel(13.2);
} else {
new android.app.AlertDialog.Builder(m_activity).setMessage("Error : " + error.name() + "\n\n" + error.getDetails()).setTitle(R.string.engine_init_error).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_activity.finish();
}
}).create().show();
}
}
});
}
}
use of com.here.android.mpa.common.GeoCoordinate in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
/* Locate the mapFragment UI element */
m_mapFragment = getMapFragment();
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.getExternalFilesDir(null), ".here-map-data").getAbsolutePath();
// This method will throw IllegalArgumentException if provided path is not writable
com.here.android.mpa.common.MapSettings.setDiskCacheRootPath(path);
if (m_mapFragment != null) {
/* Initialize the AndroidXMapFragment, results will be given via the called back. */
m_mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == Error.NONE) {
/*
* If no error returned from map fragment initialization, the map will be
* rendered on screen at this moment.Further actions on map can be provided
* by calling Map APIs.
*/
m_map = m_mapFragment.getMap();
/*
* Map center can be set to a desired location at this point.
* It also can be set to the current location ,which needs to be delivered
* by the PositioningManager.
* Please refer to the user guide for how to get the real-time location.
*/
m_map.setCenter(new GeoCoordinate(49.258576, -123.008268), Map.Animation.NONE);
} else {
new AlertDialog.Builder(m_activity).setMessage("Error : " + error.name() + "\n\n" + error.getDetails()).setTitle(R.string.engine_init_error).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_activity.finish();
}
}).create().show();
}
}
});
}
}
use of com.here.android.mpa.common.GeoCoordinate in project here-android-sdk-examples by heremaps.
the class NavigationController method onEgineInited.
private void onEgineInited() {
map = new Map();
mapView.setMap(map);
ftcrRouter = new FTCRRouter();
ftcrNavigationManager = new FTCRNavigationManager();
defeultCoreRouter = new CoreRouter();
defaultNavigationManager = NavigationManager.getInstance();
createRerouteListener();
createdefaultNavEventListener();
// Use STOP waypoint type in originalWaypointList.
// Stopover is waypoint that must be visited, it is used in SDK calbacks and during voice guidance.
// Via waypoint is only used in initial route calculation, during recalculation all via point will be removed.
originalWaypointList = Collections.unmodifiableList(Arrays.asList(new RouteWaypoint(new GeoCoordinate(52.516224, 13.376820), Type.STOP_WAYPOINT), new RouteWaypoint(new GeoCoordinate(52.513934, 13.382110), Type.STOP_WAYPOINT), new RouteWaypoint(new GeoCoordinate(52.512247, 13.391867), Type.STOP_WAYPOINT)));
buildRouteOptions();
calculateFTCRRoute(originalWaypointList);
showWaypointsOnMap();
}
use of com.here.android.mpa.common.GeoCoordinate in project here-android-sdk-examples by heremaps.
the class MapFragmentView method addFakeRoute.
// Sends the fake route into the server and displays on the map.
// Note, layer uploading functionality is not part of the Mobile SDK 3.X, this was added
// added for demo purposes.
// Refer to the official fleet telematics documentation to properly implement uploading
// layer on the server.
private void addFakeRoute() {
m_fakeRoute = new GeoCoordinate[] { new GeoCoordinate(52.51517456956208, 13.35019220598042), new GeoCoordinate(52.51693326048553, 13.350012330338359), new GeoCoordinate(52.51796909607947, 13.350633010268211), new GeoCoordinate(52.51875473186374, 13.351499531418085), new GeoCoordinate(52.519415309652686, 13.350413320586085), new GeoCoordinate(52.51992283388972, 13.351393081247807) };
m_startPoint = new GeoCoordinate(52.50920455902815, 13.351180600002408);
m_endPoint = new GeoCoordinate(52.521314984187484, 13.350122384727001);
uploadRouteGeometryOnServer();
GeoPolyline fakeRoutePolyLine = new GeoPolyline();
fakeRoutePolyLine.add(Arrays.asList(m_fakeRoute));
MapPolyline mapFakeRoutePolyline = new MapPolyline(fakeRoutePolyLine);
mapFakeRoutePolyline.setLineWidth(15);
mapFakeRoutePolyline.setLineColor(argb(255, 185, 63, 2));
mapFakeRoutePolyline.setPatternStyle(MapPolyline.PatternStyle.DASH_PATTERN);
m_map.addMapObject(mapFakeRoutePolyline);
MapMarker startMapMarker = new MapMarker(m_startPoint);
MapMarker endMapMarker = new MapMarker(m_endPoint);
m_map.addMapObject(startMapMarker);
m_map.addMapObject(endMapMarker);
}
use of com.here.android.mpa.common.GeoCoordinate in project here-android-sdk-examples by heremaps.
the class MainView method triggerGeocodeRequest.
private void triggerGeocodeRequest() {
m_resultTextView.setText("");
/*
* Create a GeocodeRequest object with the desired query string, then set the search area by
* providing a GeoCoordinate and radius before executing the request.
*/
String query = "4350 Still Creek Dr,Burnaby";
GeocodeRequest geocodeRequest = new GeocodeRequest(query);
GeoCoordinate coordinate = new GeoCoordinate(49.266787, -123.056640);
geocodeRequest.setSearchArea(coordinate, 5000);
geocodeRequest.execute(new ResultListener<List<GeocodeResult>>() {
@Override
public void onCompleted(List<GeocodeResult> results, ErrorCode errorCode) {
if (errorCode == ErrorCode.NONE) {
/*
* From the result object, we retrieve the location and its coordinate and
* display to the screen. Please refer to HERE Android SDK doc for other
* supported APIs.
*/
StringBuilder sb = new StringBuilder();
for (GeocodeResult result : results) {
sb.append(result.getLocation().getCoordinate().toString());
sb.append("\n");
}
updateTextView(sb.toString());
} else {
updateTextView("ERROR:Geocode Request returned error code:" + errorCode);
}
}
});
}
Aggregations