Avoid specific point in android map - android

I have an issue with android Google Maps. I want find route between two locations but avoid specific points which given in input.
Can you help me with this ?

There is no specific feature of this kind yet. According to this SO thread, this is a feature request for the Maps API.
However,I can suggest possible alternatives like Using Waypoints in Routes.
Note: sample was done in Javascript
In this fiddle demo, you have 3 markers A, B & C.
A = origin, B = route, C = destination.
var directionsService = new google.maps.DirectionsService;
Let's say the initial point of B is blocked, drag it to other streets/points in the map (zoom-in to see other routes) and you have your alternative route. You can read more of waypoints in the DirectionService guide.

Related

How to pass custom coordinates to map box navigation launcher?

Mapbox provides good Navigation SDK for Android, and what I have been trying to do is pass custom lat and lng's to mapbox navigation launcher. But its taking current user location and i would like to pass the custom coordinates . Is that possible?
You need to build a DirectionsRoute and then eventually give it to the NavigationLauncherOptions.Builder.
You can build a route with a custom origin instead of the device location.
Also, you can add custom waypoints.
Create a waypoint via the Point class. Point wayPoint = Point.fromLngLat(longCoordinate, latCoordinate);
Once you get the route from the response, you can eventually give it to the options builder before starting the NavigationLauncher.

Can alternate routes be set up with different viapoints?

I am trying to create 3 alternate routes, as in the demo project. After the routes are calculated, I would like to insert different SKViaPoints along each route. Is this possible? SKViaPoint only seems editable at the SKRouteManager level, which would give all alternate routes the same via points.
Thanks in advance.
This is not supported - the alternative routes will use the same start, destination and via points as the original route. You can change the routing constraints used for alternatives but not the start/end/viaPoints.
If you need to calculate multiple routes with different settings, call the calculate route API with "setRouteExposed" to false

Is there a better way to do this? Plotting lots of map markers

I'm working on an android app.
I'm basically plotting a set of data to a map. They are camera locations. The map will shown a customised marker icon at the location, as well as contain a snippet of information when you click it.
I've a LOT of data to plot. It is Lat/Long coordinates.
I've just created an xml map fragment, id'd it, and dumped this into the MainActivity.
If you just want to avoid having a lot of similar variables, use a Collection. I tend to use ArrayLists.
This is how I would address your situation:
ArrayList<LatLng> cameraLatLngs = new ArrayList<LatLng>();
// You should use a loop to add the LatLngs to the ArrayList
cameraLatLngs.add(new LatLng(51.6167, -3.9500));
cameraLatLngs.add(new LatLng(51.581, -3.9550));
for (int i = 0; i < cameraLatLngs.size(); i++) {
map.addMarker(new MarkerOptions().title("camera" + i)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.cctv))
.snippet("<Camera Details>.").position(cameraLatLngs.get(0)));
I hope that answers your question!
One time I tried creating markers for all the bus stops in my city... all 2,200 of them. Needless to say, my phone would stumble a bit when I tried to pan around. And when I zoomed out, the markers completely obscured the map.
I haven't had a chance to apply this solution yet, but if I ever revisit my bus app, I'll probably use tile overlays. You can provide different levels of detail at different zoom levels. You could also detect map clicks near your camera locations to display your details.

Quadtree on android maps utils

I'm developing a android application with google maps v2 that draw polygons on the google maps. But now i have to identify a click on a certain polygon and popup a window.
I found this useful library on github
This library has the method containsLocation implemented. This method receives a LatLng (from click on the map) and a List (the polygon). This is fine but if i have 1 million polygon in the map i cant iterate all and test if a certain LatLng belongs to a certain Polygon. I remember that i can use a quadtree to get more performance and this library also implements a quadtree but it uses point. What is the best way of doing this? May i have to reimplement this quadtree for a quadtree of LatLng ? Or in each click i have to convert this click to a point and search on a point quadtree?
Regards
you cannot use a Point- Quadtree, you need an Object-Quadtree for your Polygons. An object quadree uses the bounding box of the polygon or any object for adding into the tree.
you dont need to consider latLong, use x,y with x= longitude, and y = Latitude.
Consider reading Hanan Sammet: Foundations of multidimensional data structures.
I think you need to implement a quadtree that stores the polygons, then query the tree to see which polygon (if any) contains the LatLng. If you search around I'm sure you can find a decent implementation.

Drawing an elevation profile between two markers in Maps API V2

I'm a novice so I apologize in advance if my code and/or understanding is simplistic. I am attempting to build an app that allows me to select different markers and show not only the distance to the selected marker from my current location, but an elevation profile as well. I saw something similar to this in a Google Labs option for Maps where it allowed you to draw a line between two points and then it would give you a graph that showed the elevations between those two points. I've tried to find some answers here, but it seems nobody is really talking about this at all so I thought I'd ask. The code I'm currently using to give me the distance is:
if (marker.equals(windy))
{
//handle click here
WINDYINFO.setVisibility(View.VISIBLE);
float[] results = new float[1];
Location.distanceBetween(myPosition.latitude, myPosition.longitude,
WDY.latitude, WDY.longitude, results);
TextView distanceView = (TextView) findViewById(R.id.windydistance);
results[0] *= 0.000621371192;
distanceView.setText(String.valueOf(results[0]));
}
myPosition will always be my location according to GPS, and WDY is the elevation for the windy marker. How would I go about doing what I mentioned above, here, so that I can take the data and display it in my activity?
You are looking for Evelation API from Google. Take a look at the chart at the bottom of this page.

Categories

Resources