yay, polygon! #1716
This commit is contained in:
@@ -317,7 +317,7 @@ public class MainActivity extends ActionBarActivity {
|
||||
private void addPolygon() {
|
||||
String geojsonStr = null;
|
||||
try {
|
||||
geojsonStr = Util.loadStringFromAssets(this, "small_polygon.geojson");
|
||||
geojsonStr = Util.loadStringFromAssets(this, "small_poly.geojson");
|
||||
LatLng[] latLngs = Util.parseGeoJSONCoordinates(geojsonStr);
|
||||
MapView map = mMapFragment.getMap();
|
||||
Polygon polygon = map.addPolygon(new PolygonOptions()
|
||||
|
||||
@@ -32,7 +32,13 @@ public class Util {
|
||||
JSONArray features = jsonObject.getJSONArray("features");
|
||||
JSONObject feature = features.getJSONObject(0);
|
||||
JSONObject geometry = feature.getJSONObject("geometry");
|
||||
JSONArray coordinates = geometry.getJSONArray("coordinates");
|
||||
String type = geometry.getString("type");
|
||||
JSONArray coordinates;
|
||||
if (type.equals("Polygon")) {
|
||||
coordinates = geometry.getJSONArray("coordinates").getJSONArray(0);
|
||||
} else {
|
||||
coordinates = geometry.getJSONArray("coordinates");
|
||||
}
|
||||
int len = coordinates.length();
|
||||
LatLng[] latLngs = new LatLng[coordinates.length()];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user