Add multiple polygons at once to increase performance

This commit is contained in:
Niklas Ulvinge
2015-07-19 00:27:45 +02:00
parent 0f56c2b0d5
commit 45311e98de
4 changed files with 118 additions and 28 deletions

View File

@@ -327,10 +327,12 @@ public class MainActivity extends ActionBarActivity {
geojsonStr = Util.loadStringFromAssets(this, "small_poly.geojson");
LatLng[] latLngs = Util.parseGeoJSONCoordinates(geojsonStr);
MapView map = mMapFragment.getMap();
Polygon polygon = map.addPolygon(new PolygonOptions()
.add(latLngs)
.strokeColor(Color.MAGENTA)
.fillColor(Color.BLUE));
ArrayList<PolygonOptions> opts = new ArrayList<PolygonOptions>();
opts.add(new PolygonOptions()
.add(latLngs)
.strokeColor(Color.MAGENTA)
.fillColor(Color.BLUE));
Polygon polygon = map.addPolygons(opts).get(0);
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {