本文整理匯總了Java中com.google.android.gms.maps.model.Polygon類的典型用法代碼示例。如果您正苦於以下問題:Java Polygon類的具體用法?Java Polygon怎麽用?Java Polygon使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Polygon類屬於com.google.android.gms.maps.model包,在下文中一共展示了Polygon類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
/**
* Remove the polygon
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void remove(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Polygon polygon = this.getPolygon(id);
if (polygon == null) {
this.sendNoResult(callbackContext);
return;
}
this.objects.remove(id);
id = "polygon_bounds_" + polygon.getId();
this.objects.remove(id);
polygon.remove();
this.sendNoResult(callbackContext);
}
示例2: setHoles
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
/**
* Set holes
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setHoles(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Polygon polygon = this.getPolygon(id);
JSONArray holesJSONArray = args.getJSONArray(2);
List<List<LatLng>> holes = new LinkedList<List<LatLng>>();
for (int i = 0; i < holesJSONArray.length(); i++) {
JSONArray holeJSONArray = holesJSONArray.getJSONArray(i);
holes.add(PluginUtil.JSONArray2LatLngList(holeJSONArray));
}
polygon.setHoles(holes);
this.sendNoResult(callbackContext);
}
示例3: setPoints
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
/**
* Set points
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setPoints(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Polygon polygon = this.getPolygon(id);
JSONArray points = args.getJSONArray(2);
List<LatLng> path = PluginUtil.JSONArray2LatLngList(points);
polygon.setPoints(path);
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (int i = 0; i < path.size(); i++) {
builder.include(path.get(i));
}
this.objects.put("polygon_bounds_" + polygon.getId(), builder.build());
this.sendNoResult(callbackContext);
}
示例4: call
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
@Override public void call(final Subscriber<? super Polygon> subscriber) {
GoogleMap.OnPolygonClickListener listener = new GoogleMap.OnPolygonClickListener() {
@Override public void onPolygonClick(Polygon polygon) {
if (!subscriber.isUnsubscribed()) {
subscriber.onNext(polygon);
}
}
};
googleMap.setOnPolygonClickListener(listener);
subscriber.add(Subscriptions.create(new Action0() {
@Override public void call() {
googleMap.setOnPolygonClickListener(null);
}
}));
}
示例5: updatePolygonsPaths
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
@Override
public void updatePolygonsPaths(List<List<LatLong>> paths) {
GoogleMap map = getMap();
if (map == null) {
return;
}
for (Polygon poly : polygonsPaths) {
poly.remove();
}
for (List<LatLong> contour : paths) {
PolygonOptions pathOptions = new PolygonOptions();
pathOptions.strokeColor(POLYGONS_PATH_DEFAULT_COLOR).strokeWidth(
POLYGONS_PATH_DEFAULT_WIDTH);
final List<LatLng> pathPoints = new ArrayList<LatLng>(contour.size());
for (LatLong coord : contour) {
pathPoints.add(MapUtils.coordToLatLng(coord));
}
pathOptions.addAll(pathPoints);
polygonsPaths.add(map.addPolygon(pathOptions));
}
}
示例6: addToMap
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
/**
* Adds a single geometry object to the map with its specified style
*
* @param geometry defines the type of object to add to the map
* @param style defines styling properties to add to the object when added to the map
* @return the object that was added to the map, this is a Marker, Polyline, Polygon or an array
* of either objects
*/
private Object addToMap(KmlPlacemark placemark, KmlGeometry geometry, KmlStyle style,
KmlStyle inlineStyle, boolean isVisible) {
String geometryType = geometry.getGeometryType();
if (geometryType.equals("Point")) {
Marker marker = addPointToMap(placemark, (KmlPoint) geometry, style, inlineStyle);
marker.setVisible(isVisible);
return marker;
} else if (geometryType.equals("LineString")) {
Polyline polyline = addLineStringToMap((KmlLineString) geometry, style, inlineStyle);
polyline.setVisible(isVisible);
return polyline;
} else if (geometryType.equals("Polygon")) {
Polygon polygon = addPolygonToMap((KmlPolygon) geometry, style, inlineStyle);
polygon.setVisible(isVisible);
return polygon;
} else if (geometryType.equals("MultiGeometry")) {
return addMultiGeometryToMap(placemark, (KmlMultiGeometry) geometry, style, inlineStyle,
isVisible);
}
return null;
}
示例7: updatePolygonsPaths
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
@Override
public void updatePolygonsPaths(List<List<LatLong>> paths) {
for (Polygon poly : polygonsPaths) {
poly.remove();
}
for (List<LatLong> contour : paths) {
PolygonOptions pathOptions = new PolygonOptions();
pathOptions.strokeColor(POLYGONS_PATH_DEFAULT_COLOR).strokeWidth(
POLYGONS_PATH_DEFAULT_WIDTH);
final List<LatLng> pathPoints = new ArrayList<LatLng>(contour.size());
for (LatLong coord : contour) {
pathPoints.add(DroneHelper.CoordToLatLang(coord));
}
pathOptions.addAll(pathPoints);
polygonsPaths.add(getMap().addPolygon(pathOptions));
}
}
示例8: remove
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
/**
* Remove the polygon
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void remove(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Polygon polygon = this.getPolygon(id);
if (polygon == null) {
this.sendNoResult(callbackContext);
return;
}
this.objects.remove(id);
id = "polygon_bounds_" + polygon.getId();
this.objects.remove(id);
polygon.remove();
this.sendNoResult(callbackContext);
}
示例9: setPoints
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
/**
* Set points
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setPoints(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Polygon polygon = this.getPolygon(id);
JSONArray points = args.getJSONArray(2);
List<LatLng> path = PluginUtil.JSONArray2LatLngList(points);
polygon.setPoints(path);
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (int i = 0; i < path.size(); i++) {
builder.include(path.get(i));
}
this.objects.put("polygon_bounds_" + polygon.getId(), builder.build());
this.sendNoResult(callbackContext);
}
示例10: drawPolygons
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
public void drawPolygons(
List<Circuit> circuits,
int fillColor,
int strokeColor,
int strokeWidth) {
if (mZonePolygons != null && !mZonePolygons.isEmpty()) {
mZonePolygons.clear();
mZonePolygons = null;
}
int circuitsCount = circuits.size();
mZonePolygons = new ArrayList<>(circuitsCount);
for (int i = 0; i < circuitsCount; i++) {
Circuit circuit = circuits.get(i);
Polygon zonePolygon = drawPolygon(circuit, fillColor, strokeColor, strokeWidth);
mZonePolygons.add(zonePolygon);
}
}
示例11: doInBackground
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
@Override
protected Collection<PolygonOptions> doInBackground(Geometry... features) {
Collection<PolygonOptions> polygons = new ArrayList<PolygonOptions>(features.length);
for (Geometry feature : features) {
if (feature instanceof com.vividsolutions.jts.geom.Polygon) {
polygons.add(generatePolygon((com.vividsolutions.jts.geom.Polygon)feature));
}
else if(feature instanceof com.vividsolutions.jts.geom.MultiPolygon) {
MultiPolygon multiPolygon = (MultiPolygon)feature;
for(int i = 0; i < multiPolygon.getNumGeometries(); i++) {
Geometry geometry = multiPolygon.getGeometryN(i);
if(geometry instanceof com.vividsolutions.jts.geom.Polygon) {
polygons.add(generatePolygon((com.vividsolutions.jts.geom.Polygon)geometry));
}
//nested MultiPolygons are ignored for now. Recursive solution has performance implications.
}
}
}
return polygons;
}
示例12: setVisible
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
public void setVisible(boolean visible) {
Log.d(TAG, "set visible " + visible);
backgroundTileOverlay.setVisible(visible);
if (polygonOptions == null) {
Log.d(TAG, "waiting for polygons");
waitingForPolygons.add(this);
return;
}
else if (polygons == null) {
polygonsReady();
}
else {
for (Polygon polygon : polygons) {
polygon.setVisible(visible);
}
}
}
示例13: doInBackground
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
@Override
protected List<PolygonOptions> doInBackground(Void... voids) {
startTime = System.currentTimeMillis();
Log.d(TAG, "transforming geometries to polygons");
List<PolygonOptions> polygons = new ArrayList<>(features.size());
for (Geometry feature : features) {
// For now all offline map features are polygons
if ("Polygon".equals(feature.getGeometryType())) {
polygons.add(transformPolygon((com.vividsolutions.jts.geom.Polygon) feature));
}
else if ("MultiPolygon".equals(feature.getGeometryType())) {
MultiPolygon mp = (MultiPolygon) feature;
for (int i = 0; i < mp.getNumGeometries(); i++) {
com.vividsolutions.jts.geom.Polygon polygon = (com.vividsolutions.jts.geom.Polygon) mp.getGeometryN(i);
polygons.add(transformPolygon(polygon));
}
}
}
return polygons;
}
示例14: addPolygonsWithinBounds
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
private void addPolygonsWithinBounds(LatLngBounds bounds) {
TaggedPolygon<TaggedPoint> visiblePolygon;
List<TaggedPolygon<TaggedPoint>> polygons;
PolygonOptions mapPolygonOptions;
Polygon mapPolygon;
mapMarkers.clear();
mapPolygons.clear();
googleMap.clear();
visiblePolygon = GoogleGeometryFactory.buildTaggedPolygon(bounds);
polygons = applicationStorage.polygons.getPolygonsIntersectingPolygon(visiblePolygon);
for(TaggedPolygon<TaggedPoint> polygon : polygons) {
if(mapActivity.getState() != DrawState.NEW_POINTS || polygon.getID() != mapActivity.getSelectedPolygon().getID()) {
mapPolygonOptions = GoogleGeometryFactory.buildPolygonOptions(polygon);
mapPolygonOptions.fillColor(POLYGON_FILL_COLOR).strokeWidth(POLYGON_STROKE_WIDTH);
mapPolygon = googleMap.addPolygon(mapPolygonOptions);
mapPolygons.put(polygon.getID(), mapPolygon);
}
}
}
示例15: insidePoly
import com.google.android.gms.maps.model.Polygon; //導入依賴的package包/類
/**
* Check whether a the marker position is inside the municipality borders (polygon)
*
* @poly the polygon borders
* @lng longitude of marker
* @lat latitude of marker
*/
public static boolean insidePoly(Polygon poly, double lng, double lat){
List<LatLng> p = poly.getPoints();
int polyPoints = poly.getPoints().size();
int polySides = polyPoints - 1;
double[] polyY = new double[polyPoints];
double[] polyX = new double[polyPoints];
for (int i = 0; i < polyPoints; i++){
polyY[i] = p.get(i).latitude;
polyX[i] = p.get(i).longitude;
}
boolean oddTransitions = false;
for( int i = 0, j = polySides -1; i < polySides; j = i++ ) {
if( ( polyY[ i ] < lat && polyY[ j ] >= lat ) || ( polyY[ j ] < lat && polyY[ i ] >= lat ) ) {
if( polyX[ i ] + ( lat - polyY[ i ] ) / ( polyY[ j ] - polyY[ i ] ) * ( polyX[ j ] - polyX[ i ] ) < lng ) {
oddTransitions = !oddTransitions;
}
}
}
return oddTransitions;
}