polyline that not drawed - android

I have a problem with polyline in android
as you can see in the picture above, it has a line that drawn long to the bottom of my map, but that line is not supposed to be there
but when I follow that line to the bottom or I zoom out the map like the picture above, the line is gone
is there anyone can help me?

For each vertex (location) in polyline. You can specified the level which will indicate the location that will appear on that level. For example decrease in zoom. If a location does not appear on a given level, then the line will go from the last visible location to the next visible location. Note that the first and last locations must be Level 3 points, otherwise the polyline won't display on all levels.
Check this page for more information.
You can use polyline's properties such as points which is the vertices of the line. This line segments are drawn between consecutive points. A polyline is not closed by default; to form a closed polyline, the start and end points must be the same.
Check this page for the other properties.

Related

Polyline points are not accurate while moving

When you draw a polyline, those points near the turns are not accurate while moving they are placed on the top of the buildings and sometimes instead of a proper polyline there is a line from the source to destination.What I want to do is a polyline must stick on to the road.So how do I fix this?
I am following this link:
Please find the screenshots for more clarification.

Adding markers to google map 2 depending on the zoom level

I have multiple markers set around on the map. What I want to know is how can I show only a few markers depending on the zoom level. For example: I have a zoom on the map with radius: the length between the center of the map and the bounds of the screen (lets say this is like 2km in real life not sure if this is true) so I want to show only the markers that are inside the radius. And of course if the user zooms out the radius will be recalculated again from the center point of the map to the bound of the screen. And again include markers that are inside the new radius. How can I achieve this?
I have thought about this problem and here could be an approach.
you can loop through your available markers and find distance from the center of your given circle (since we're talking about a radius) to the marker; this can be done using computeDistanceBetween(); for more info see link
If the marker lies within your radius, show, otherwise, hide using the setVisible() method. For more information, see link
Hope this gives you some idea.

Drawing on the MapFragment, while keeping some elements visible

I'm developing an application that has the following goal:
Using the google maps android API 2 I get my current position, and as I start walking the application starts drawing the route I take
The twist is that the map is a "blind" map. Meaning the map is hidden, only the Marker of my current position and a dotted line of my route is shown.
Keep in mind I'm a novice developing to Android, so please be specific. (Thank you)
I managed to create the map, get my current position and zoom in to it (Had no sens to see the whole planet while i want only my current position). And it's pretty accurate so far.
The thing is I don't know what should I do from this point on.
Basicly I need a white View between the Marker and the real map. Also as I advance that View should always be on, over the MapFragment/MapView. Also I wish to keep the zoom and drag functionality's of the MapFragment.
How can I achieve this?
At this point I'm opened to any solutions.
(Been browsing for a few days now the developers site, I have seen that with the ViewOverlay class I can put messages over the map, but I'm not sure what would the correct aproach be in my case...)
To hide the whole map behind the white view I would use Polygon class Polygon Even if you specify Polygon to cover the whole map Markers will be still displayed in front of it and as so user's current position marker will be visible. You also will be able to zoom and drag.
To draw line on map use Polyline class Polyline It will draw users path as a polyline. If you want to stick with dotted line you can use Circle objects to create it. Circle

Android google maps zoom to fit mark and current position

I'm trying to create a custom "my location" button for my app using Google Maps.
What I'm trying to do is to center the map around the location of the user, which is already done and working flawlessly, but also want to zoom in just enough to see a marker of my choice (this is actually the closest of a set of markers I have in memory, but that's not important now).
I haven't been able to find how the zoom variable works here. If I know the marker I want to show is 0.5 GPS units away from me, how can I center the map around me in a way that includes that marker on its boundaries? I'd also use a padding to make sure it perfectly fits in the map.
LatLng my_coordinates = ...;
LatLng closest_mark = ...;
map.animateCamera(CameraUpdateFactory.newLatLng(my_coordinates));
So now I want to modify that code to not only center the position to my_coordinates but also make sure zoom will make closest_mark fit in the viewport
CameraUpdateFactory.newLatLngBounds( ?? , /*padding*/);
I don't think there is a specific zoom variable in the api you can control along with the points in the map. (And LatLngBounds just takes in the upper right and lower left bounds and gets you a view accordingly).
I believe what you could do is with a little geometry. If your marker is very close to your location (you can consider it a rectangle), get the distance between the two and extrapolate that on the opposite direction with the same distance (multiple by a small factor if you want some padding) to get the other coordinates, and then you can get the upper right and lower left coordinates (simple geometry).
If your marker is quite far and the surface of the earth comes into picture, you may have to use the haversine formula (great circle distance).
Hope this helps.

Can I alter the order that points in an Maps Overlay are drawn on the Map

I have an Maps Overlay which contains multiple points, each with its own numbered marker. The points are in the overlay in the order I would like them to be drawn (ie from Marker 0 to 10 - with 10 being the latest point). When the map is displayed it appears that points are drawn in the order of increasing Latitude. This means than in my case the marker for point 7 may be drawn on top of the marker for point 10. Is there any way of controlling the order in which the markers will be laid out on the map?
I found it - I have added the following code and it seems to work. This forces the items to be drawn in the same order as they are in the Overlay and not in order of increasing Latitude.
Interestingly, if you choose a different order (e.g. reversed) then the map will display as you ask it with earlier entries overlaying later ones. i.e. point 7 will be drawn on top of point 10 if they both have the same map coordinates. However when you tap on a what is displayed as point 7, the onTap method will give you the index for point 10 (presumably because it was drawn 10th in the sequence) which may cause you some confusion. It is then up to you to remember the sequence you asked points to be displayed and work out which entry is actually on top.
#Override
protected int getIndexToDraw(int drawingOrder) {
// Log.d("getIndexToDraw", "drawing order: " + drawingOrder); //just my debug
return drawingOrder; // forces order to follow overlay item sequence
// return super.getIndexToDraw(drawingOrder); // default code - ie Latitude order
}

Categories

Resources