I'm need to use GoogleMaps for an android app
I need to build an android app that sends request to GoogleMaps API and recive only the list of directions (Turn right in 400meters at the next..) without showing any map
How to I update the list by user movement ?
(You currently passed first turn, heading to second turn.. 800 meters to next turn.. 400 meters to next turn)
If in answer 2 I get only String with "Left,Right,North.." How do I get the turn angle ?
(45-125 will be right, 90 will be absolute right)
I would like to hear about how to optimize the update ( There are 4 ways to use threads in android so I've heard )
Listen for Location Updates using requestLocationUpdates().
http://developer.android.com/training/location/receive-location-updates.html#StartUpdates
Related
is it possible to follow a path on google map android (Programmatically) if my android device getting away from the path it notify or show alert that your not following your path
Help will be appriciated,
Thank's :)
Yes, it's possible by several ways. For example you can use PolyUtil.isLocationOnPath(LatLng point, java.util.List<LatLng> polyline, boolean geodesic, double tolerance) from Google Maps Android API Utility Library. In this case you need to check (with isLocationOnPath()) if user location laying on segment of the polyline of your path. Something like that:
if (!PolyUtil.isLocationOnPath(userLocationPoint, pathPolyline.getPoints(), true, 50)) {
// user away of pathPolyline more than 50 meters
// show your alert here
...
}
}
where 50 - is tolerance (in meters).
NB! It's not a complete solution - just approach.
Also you can use geofence monitoring for several waypoints (with a limit of 100 per device user).
I want some functionality in my Android/iOS application i.e. U user is travelling to L location, So when the U is 15 minute away from the L location he/she will get some Notification.
What i tried so far:
Calling google API and get travel time from the current location to the L location on a particular time interval, when i found it to very close from the 15 minute, i triggered notification to the user(U) and stop calling the API.
Geo-fence L location in such a way that travel time from enter the fence to the L location, should be very close to 15 minutes. When user(U) enter into the Geo-fence i triggered notification to the user(U) and remove the Geo-fence.
But for 1st methods Calling google API is not the right way to achieve that.
In second method the problem is My locations are not fixed they may vary. So the radius of Geo-fence should be different for every location because travel time is different for the location.
According to to me Geo-fence is a good solution but its dynamic radius are creating the problem.
So is there any other way to achieve that? Or we can fix the dynamic radius issue of Geo-fence in any way?
For geofence "dynamic radius" you can use workaround like that: set geofence radius to maximum possible, than test user location on GEOFENCE_TRANSITION_ENTER handler and do what you need only if actual radius less than you need. Something like that:
...
// Get the transition type.
int geofenceTransition = geofencingEvent.getGeofenceTransition();
// Test that the reported transition was of interest.
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {
// start continuously calculate actual radius here
// actualRadius = calcActualRadius();
// if (actualRadius < RADIUS_FOR_YOUR_CONDITION) {
// // do what you need
// }
}
...
I am drawing navigation routes with via points. I want navigation should follow exactly the same route as via points provided. To achieve this what type of Route Mode should i set?
Right now i am setting SKRouteMode.EFFICIENT, but somehow route drawn is different many times.
I dont want any fastest or shortest route but the route which exactly follow my via points.
Please help(I am using SDK 2.5)
Following are the coordinates:
Start Point: -104.98036489999998,39.7435209
End Point: -104.98036489999998,39.7435209
Via Point:
-104.97252523899078,39.74324265487236
-104.96009051799774,39.74316428375109
-104.95895862579346,39.74350251637351
-104.95895862579346,39.74350251637351
-104.94109511375427,39.74377062667071
-104.94064809999998,39.707593
-104.94056940078735,39.71219659344454
-104.94062304496765,39.73016169331405
-104.94062036275864,39.73711087652619
-104.94078397750854,39.74018611509486
-104.9781499,39.7401722
-104.99110221862793,39.74328802758604
-104.99050829999999,39.7428701
-104.98829126358032,39.74547413202817
-104.99693870544434,39.75225473927719
-105.00033380000002,39.7506546
-104.9958872795105,39.754481800432515
-104.99119210000003,39.7543157
-104.98791575431824,39.751256662580026
-104.98734712600708,39.75011009381583
-104.98737931251526,39.74344476945796
-104.98623132705688,39.74330865153693
Here is the configuration:
prefSpeedInTown- 0
prefSpeedOutTown- 0
tollRoads- false
avoidFerries- false
highWays- false
Route Mode: RouteMode.EFFICIENT
I have an example route that I've tested using the Skobbler SDK.
Start Point: around 820 S MacArthur Blvd
Irving, TX 75063
End Point: Bass Performance Hall, Fort Worth, TX
Via Point #1: Shell Gas Station, 1224 Oakland Blvd Fort Worth, TX
The code that's used to calculate the route is as follows:
SKRouteSettings route = new SKRouteSettings();
// set start and destination points
route.setStartCoordinate(start);
route.setDestinationCoordinate(end);
route.setNoOfRoutes(1);
// set the route mode
route.setRouteMode(SKRouteSettings.SKRouteMode.CAR_FASTEST);
// Traffic enabled
route.setUseLiveTraffic(true);
route.setUseLiveTrafficETA(true);
route.setTollRoadsAvoided(true);
route.setAvoidFerries(true);
route.setHighWaysAvoided(true);
ArrayList<SKViaPoint> viaPoints = new ArrayList<SKViaPoint>();
viaPoints.add(new SKViaPoint(VIA_POINT_ID_OTW_DEST, viaPoint));
route.setViaPoints(viaPoints);
// set whether the route should be shown on the map after it's computed
route.setRouteExposed(true);
// Set traffic routing mode
SKRouteManager.getInstance().setTrafficRoutingMode(SKMapSettings.SKTrafficMode.FLOW_AND_INCIDENTS);
// set the route listener to be notified of route calculation
// events
SKRouteManager.getInstance().setRouteListener(this);
// pass the route to the calculation routine
SKRouteManager.getInstance().calculateRoute(route);
When I compute this route via the Skobbler SDK and display the calculated route on the SKMapView, I sometimes get a route that doesn't make sense.
This route calculated on one of our test devices shows the calculated route taking us off the freeway, turning right onto a street and then making a u-turn at the end of the street, before turning right again into the Shell gas station. For some reason, the routing algorithm is not realizing that the route can go straight off the freeway and then turn right, or alternatively, turn right at the street off the freeway and then make an immediate left.
This is not the only instance of incorrect routing that we have witnessed, but it is the most recent. In the past, we have been able to make slight modifications to the coordinate passed for the via point to make the routing algorithm return a sensible route, and then were able to go back to recalculating the original route correctly without the long detours.
In this case, in order to view the corrected route below, we simply try routing the same route again some time later:
Has anyone experienced an issue similar to this and is there something that can be done on the client side to prevent it? Or perhaps a request setting that can be made while requesting a route calculation to the server that might help?
Thanks for any feedback on the matter!
-Keith
Hypothetical question. I'm building an augmented reality app using Google Maps API for Android. I'm wondering if there's any data that I can use to determine whether a building lies between me and a specified location. I ask this because when sufficiently zoomed-in, there is clearly 3D data on the shape of buildings included on the map. I was wondering if there was a method like:
boolean buildingInTheWay(myLocation, destinationLocation);
if (buildingInTheWay) {
//Do something
} else {
//Do something else
}
Perhaps there's also something that could be done where if the route to a location is much longer than the birds-eye path to a location, there must be an obstacle in the way (imagine two parallel streets like so:
- = street
X = buildings
A = start location
B = destination location
---------C----A-------
xxxxxxxx | xxxxxxxxx
---------D----B-------
Here, A to B would return true, as the route around the buildings is a lot longer than the direct distance. But C to D would return false, as the route following a road is almost exactly the same distance.
However, that's not very accurate - what about between buildings? I wonder if each building on Google Maps has lat/lng points for each of its corners?
Any thoughts, anyone?