Check Z-index of map polygon - android

lets say I have a situation where I have a few polygons ontop of eachother like this
is there a way to know what polygon is on-top aka the z-index of it? I didn't see anything in the docs but I was hoping I just missed it somewhere

Here it is - http://developer.android.com/reference/com/google/android/gms/maps/model/Polygon.html#getZIndex()
StackOverflow wants 30 characters out of me, so here they are.

Related

Check if Point is located on(or close to) a convex polygon edges

So I'm loading KML files to my google map, they are shown as convex polygons on the map.
I also have the user location , basically i want to know if the user is located on one of the polygon's edges (which is a convex polygon).
and because location services aren't 100% accurate, if the location is close (the edge is 15m far)- that's good :)
My solution is to find the function y=f(x) that passes between 2 vertices, then check if the user location is below f(x)+a and above f(x)-a.
I feel like I'm missing something and there should be a better (and more accurate) way to solve my issue or even maybe a java library for android that already tackle this.
Thanks :)
You can use PolyUtil.isLocationOnEdge() which is exactly what you want.
You should implement a function that determines the distance from a point to a line segment. You can find code all over the web for this, e.g., here: "Shortest distance between a point and a line segment."
Then iterate over each segment of the polygon. This works even if the polygon is nonconvex.
You can actually achieve better time complexity for convex polygons, but likely that would not be worth the implementation effort.

Reducing Android Map shape overlapping draws

Forgive me if this is a duplicate, but the questions I find don't have an answer (I hope to simplify those questions).
Given two circles on a GoogleMap, how do I tell if they overlap and "smash" them into one image?
I have a lot of data points (~14K) and that many circles are not rendering well. Can they also be drawn just once, instead of 14k draw calls?
There is Google Maps API Clustering Utility. That should handle clustering your items for you.
And there is a SOF Question addressing the same issue and solutions as well.

Best way to draw tournament bracket in Android

I need to draw a tournament bracket in Android. I already calculated the positions for all games (i.e. an (x,y) tuple that defines where to place teams in a spreadsheet-like structure). However, I don't know the preferred way of drawing the bracket. I found an example that shows what I need:Example
My first idea was to programmatically create and fill a TableLayout. However, borders are not really supported and a lot of TextViews are needed to fill the space between games. So I am not sure if this is the best way to do it.
Does anyone have better suggestions or maybe even an example of something similar?
I'd suggest custom drawing using Canvas. That way you can draw wherever it makes sense and probably even support zooming without too much work.

Android MapView path.draw draws crazy polygon lines all over the place

I've been struggling for a couple of weeks now with google's android mapview.
I'm drawing a large amount of polygons with a large amount of points. on average 15 polygons and around 1000 points each.
The first issue I experienced was performance... No surprise. After doing some testing I realised the culprit is projection.ToPixel() which I successfully bypass when the users pans by simply moving all my points in the direction by x amount of pixels (the difference), however when zooming I have no choice but to make use of the toPixel method.
Is there possibly a more efficient way of modifying my points depending on the zoom level? after some research I've found examples on how to do this with circles and other shapes, but I have no clue where to begin with reshaping polygons, any ideas on this?
The second issue i'm having is that when I have the entire polygon in view all is grand, but when I pan over the map bounds (where the map is effectively starting again to the left and right) on any side the polygon lines seem to reach and stretch out across the map bounds causing crazy spaghetti lines all over the place! I take it what's happening is that the path.close() or path.LineTo() methods think the shortest path is flying halfway across the world to reach the next point which causes these lines. I have no idea how to address this. I simply can't ignore points that do not fall within the current lon/lat spans because that (obviously) causes the polygon to change shape al the time!
Has anyone experienced this issue and how can one go about solving it? I'm not even sure what I should be googling!?
UPDATE 1:
The problem can be easily solved by preventing the mapview from looping. Is there some way to prevent the mapview from looping the world!?!?

Showing the Google Maps reticle on Android

I'v encountered a problem with Google Maps on Android. In my app I have a location-chooser where the user navigates to his desired location to save the exact street location. In order for the user to actually see what street he is no (and not just the general area) I need to mark the middle of the map clearly.
The problem is that the reticle (the little circle marking the center) from Google Maps usually won't show. It appears at the most 1 out of 10 times I open the map, probably less. This happens regardless if I add other overlays or if I just show the map as is. I am aware of ReticleDrawMode and have tried setting it to DRAW_RETICLE_OVER, but this does not seem to work (and it should be the default already).
Have I missed something here? I have searched for the problem and from what I have see the problem seems to be common, but I havn't seen a solution for actually forcing it to always show, only for hiding it.
If the reticle is broken, does anyone have a good suggestion for how to create a custom one? As I said the the user will navigate the map, so I can't just do a normal overlay on a fixed point of the map, and the map also does not take up the full screen so drawing something over it is a bit ugly (although I guess that will be my last resort).
And of course I found the answer just after I asked the question, or at least part of the answer.
I haven't found out how to get the reticle to work, but the easy workaround for this is to use the fact that different widgets can overlap each other in a RelativeLayout, whichever is declared last will simply lay above the other. So I ended up putting the MapView in a RelativeLayout and then simply placing a TextView in the center of the same layout. The TextView is now over the center of the map and can be used to mark the middle.
(Going to replace the TextView with something more appropriate later, but the concept stays the same).

Categories

Resources