Drawing A Polygon Over The Entire Map
I'm using Google Maps V2 for Android, and I need to draw a polygon over the entire map, then add a hole in a selected town. The purpose of this is to highlight specific areas of th
Solution 1:
I should work with:
floatdelta=0.1f;
Listpoints= Arrays.asList(newLatLng(90, -180),
newLatLng(-90+delta, -180+delta),
newLatLng(-90+delta, 0),
newLatLng(-90+delta, 180-delta),
newLatLng(0, 180-delta),
newLatLng(90-delta, 180-delta),
newLatLng(90-delta, 0),
newLatLng(90-delta, -180+delta),
newLatLng(0,-180+delta));
PolygonOptionsoptions=newPolygonOptions();
options.addAll(points);
options.fillColor(R.color.red_half_alpha); // 50% opacity red, for example #80FF0000
map.addPolygon(options);
I hope you see where this code is going. It works fine with a android v2 map.
I think there are some problems with the floating point calculation. The other point is, if you look very carfully between Russia and America (e.g LatLng(0,180), LatLng(0,-180)) you will most likely see a very thin line.
This is your polygon.
PS: If you see holes in your map give a short heads up, how it worked out for you. I think many people have the same problem.
Solution 2:
Have a Try using this one
new PolygonOptions()
.add(new LatLng(85,90), new LatLng(85,0.1),
new LatLng(85,-90), new LatLng(85,-179.9),
new LatLng(0,-179.9), new LatLng(-85,-179.9),
new LatLng(-85,-90), new LatLng(-85,0.1),
new LatLng(-85,90), new LatLng(-85,179.9),
new LatLng(0,179.9), new LatLng(85,179.9))
Solution 3:
Reading PolygonOptions, I think you should be able to do it by:
List points = Arrays.asList(new LatLng(90, -180),
new LatLng(-90, -180),
new LatLng(-90, 180),
new LatLng(90, 180),
new LatLng(90, 180));
PolygonOptions options = new PolygonOptions();
options.addAll(points)
options.fillColor(#80FF0000); // 50% opacity red, for examplemap.addPolygon(options);
You have to specify a fill color, if you didn't do it. If you did, sorry, but I cannot guess the code that you haven't posted :)
Post a Comment for "Drawing A Polygon Over The Entire Map"