4
votes

I have implemented a MapFragment with an xml layout like this:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/activity_mappa_partenza" />

In Google map api v.2 I want to draw a Polygon:

PolygonOptions optionsShadow = new PolygonOptions();
optionsShadow.fillColor(Color.RED);
optionsShadow.strokeColor(Color.RED);
optionsShadow.strokeWidth(1f);
optionsShadow.addAll(ombraLinkList);
map.addPolygon(optionsShadow);

ombraLinkList is a LinkedList filled with all point from Sun Terminator Line

What I want to achieve is a polygon filled with night region of the earth.

If the Latitude and Longitude are of this type: Lat 90 Lon -180, Lat 78 Lon -150, Lat 75 Lon -120, -------- --------- Lat 35 Lon -45, Lat 55 Lon 0, Lat 65 Lon 20, Lat 75 Lon 45, Lat 80 Lon 75, Lat 90 Lon 180

Lat 90, Lon 180 is the same point of Lat 90, Lon -180 and i'm unable to draw and close the poligon area.

Any suggestion will be appreciated. Thanks all.

1

1 Answers

0
votes

Usually in GIS when drawing polygon the start point is the same as end point ("closed polygon"). So use (90,180) as this start-end point. Also usually the order of the coordinates in the list matters. So just remove coordinates (90,-180) if (90,180) exist and make sure (90,180) is the first and the last in the list.

EDIT:

The data type of the list of coordinates is com.google.android.gms.maps.model.LatLng and pay attention to the specification which is:

Longitude, in degrees. This value is in the range [-180, 180 )

Latitude, in degrees. This value is in the range [-90, 90 ].

Which means ain't collisions. So you tried (90,180) as start-end, so now we know that in Google maps GIS system it should be (90,-180)...