本文整理汇总了Java中com.google.android.gms.maps.model.PolygonOptions.add方法的典型用法代码示例。如果您正苦于以下问题:Java PolygonOptions.add方法的具体用法?Java PolygonOptions.add怎么用?Java PolygonOptions.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.model.PolygonOptions
的用法示例。
在下文中一共展示了PolygonOptions.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPolygon
import com.google.android.gms.maps.model.PolygonOptions; //导入方法依赖的package包/类
private void addPolygon(String name, Polygon poly, int color) {
final PolygonOptions polyOptions = new PolygonOptions();
final LineString exteriorRing = poly.getExteriorRing();
for (int iPnt = 0; iPnt < exteriorRing.getNumPoints(); iPnt++) {
final Point p = exteriorRing.getPointN(iPnt);
polyOptions.add(new LatLng(p.getY(), p.getX()));
}
for (int iHole = 0; iHole < poly.getNumInteriorRing(); iHole++) {
final LineString interiorRing = poly.getInteriorRingN(iHole);
final List<LatLng> holePnts = new ArrayList<LatLng>();
for (int iPnt = 0; iPnt < interiorRing.getNumPoints(); iPnt++) {
final Point pnt = interiorRing.getPointN(iPnt);
holePnts.add(new LatLng(pnt.getY(), pnt.getX()));
}
polyOptions.addHole(holePnts);
}
mMap.addPolygon(polyOptions
.strokeWidth(1)
.strokeColor(Color.DKGRAY)
.fillColor(color));
}
示例2: addCameraFootprint
import com.google.android.gms.maps.model.PolygonOptions; //导入方法依赖的package包/类
@Override
public void addCameraFootprint(FootPrint footprintToBeDraw) {
PolygonOptions pathOptions = new PolygonOptions();
pathOptions.strokeColor(FOOTPRINT_DEFAULT_COLOR).strokeWidth(FOOTPRINT_DEFAULT_WIDTH);
pathOptions.fillColor(FOOTPRINT_FILL_COLOR);
for (LatLong vertex : footprintToBeDraw.getVertexInGlobalFrame()) {
pathOptions.add(MapUtils.coordToLatLng(vertex));
}
getMap().addPolygon(pathOptions);
}
示例3: drawPolygon
import com.google.android.gms.maps.model.PolygonOptions; //导入方法依赖的package包/类
private void drawPolygon( LatLng startingLocation ) {
LatLng point2 = new LatLng( startingLocation.latitude + .001, startingLocation.longitude );
LatLng point3 = new LatLng( startingLocation.latitude, startingLocation.longitude + .001 );
PolygonOptions options = new PolygonOptions();
options.add(startingLocation, point2, point3);
options.fillColor( getResources().getColor( R.color.fill_color ) );
options.strokeColor( getResources().getColor( R.color.stroke_color ) );
options.strokeWidth( 10 );
getMap().addPolygon(options);
}
示例4: addCameraFootprint
import com.google.android.gms.maps.model.PolygonOptions; //导入方法依赖的package包/类
@Override
public void addCameraFootprint(FootPrint footprintToBeDraw) {
PolygonOptions pathOptions = new PolygonOptions();
pathOptions.strokeColor(FOOTPRINT_DEFAULT_COLOR).strokeWidth(FOOTPRINT_DEFAULT_WIDTH);
pathOptions.fillColor(FOOTPRINT_FILL_COLOR);
for (LatLong vertex : footprintToBeDraw.getVertexInGlobalFrame()) {
pathOptions.add(DroneHelper.CoordToLatLang(vertex));
}
getMap().addPolygon(pathOptions);
}
示例5: drawField
import com.google.android.gms.maps.model.PolygonOptions; //导入方法依赖的package包/类
/**
* 戦場1つを描画する
*/
private void drawField(Field field) {
// マーカー定義
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.title(field.getName()); // 名前を設定
markerOptions.snippet(field.getMemo()); // 説明を設定
markerOptions.position(calcCenter(field.getVertexes())); // マーカーの座標を設定(区画の中心を自動算出)
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(field.getColorHue())); // 色を設定
// マップにマーカーを追加
mGoogleMap.addMarker(markerOptions);
// 区画を描画
final LatLng[] vertexes = field.getVertexes();
if (vertexes != null && vertexes.length > 3) {
// ポリゴン定義
PolygonOptions polygonOptions = new PolygonOptions();
// RGBそれぞれの色を作成
final int[] colorRgb = field.getColorRgb();
int colorRed = colorRgb[0];
int colorGreen = colorRgb[1];
int colorBlue = colorRgb[2];
// 区画の輪郭について設定
polygonOptions.strokeColor(Color.argb(0x255, colorRed, colorGreen, colorBlue));
polygonOptions.strokeWidth(5);
// 区画の塗りつぶしについて設定
polygonOptions.fillColor(Color.argb(0x40, colorRed, colorGreen, colorBlue));
// 各頂点の座標を設定
polygonOptions.add(vertexes); // LatLngでもLatLng[]でもOK
// マップにポリゴンを追加
mGoogleMap.addPolygon(polygonOptions);
}
}
示例6: createPolygon
import com.google.android.gms.maps.model.PolygonOptions; //导入方法依赖的package包/类
/**
* Create polygon
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void createPolygon(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
final PolygonOptions polygonOptions = new PolygonOptions();
int color;
LatLngBounds.Builder builder = new LatLngBounds.Builder();
JSONObject opts = args.getJSONObject(1);
if (opts.has("points")) {
JSONArray points = opts.getJSONArray("points");
List<LatLng> path = PluginUtil.JSONArray2LatLngList(points);
int i = 0;
for (i = 0; i < path.size(); i++) {
polygonOptions.add(path.get(i));
builder.include(path.get(i));
}
}
if (opts.has("strokeColor")) {
color = PluginUtil.parsePluginColor(opts.getJSONArray("strokeColor"));
polygonOptions.strokeColor(color);
}
if (opts.has("fillColor")) {
color = PluginUtil.parsePluginColor(opts.getJSONArray("fillColor"));
polygonOptions.fillColor(color);
}
if (opts.has("strokeWidth")) {
polygonOptions.strokeWidth(opts.getInt("strokeWidth") * this.density);
}
if (opts.has("visible")) {
polygonOptions.visible(opts.getBoolean("visible"));
}
if (opts.has("geodesic")) {
polygonOptions.geodesic(opts.getBoolean("geodesic"));
}
if (opts.has("zIndex")) {
polygonOptions.zIndex(opts.getInt("zIndex"));
}
Polygon polygon = map.addPolygon(polygonOptions);
String id = "polygon_"+ polygon.getId();
this.objects.put(id, polygon);
String boundsId = "polygon_bounds_" + polygon.getId();
this.objects.put(boundsId, builder.build());
JSONObject result = new JSONObject();
result.put("hashCode", polygon.hashCode());
result.put("id", id);
callbackContext.success(result);
}
示例7: buildPolygonOptions
import com.google.android.gms.maps.model.PolygonOptions; //导入方法依赖的package包/类
public static PolygonOptions buildPolygonOptions(TaggedPolygon<TaggedPoint> polygonRecord) {
PolygonOptions polygonOptions = new PolygonOptions();
for(TaggedPoint point : polygonRecord.getPoints())
polygonOptions.add(buildLatLng(point));
return polygonOptions;
}