當前位置: 首頁>>代碼示例>>Java>>正文


Java Polygon類代碼示例

本文整理匯總了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);
}
 
開發者ID:AdrianBZG,項目名稱:PhoneChat,代碼行數:23,代碼來源:PluginPolygon.java

示例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);
}
 
開發者ID:AdrianBZG,項目名稱:PhoneChat,代碼行數:24,代碼來源:PluginPolygon.java

示例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);
}
 
開發者ID:AdrianBZG,項目名稱:PhoneChat,代碼行數:23,代碼來源:PluginPolygon.java

示例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);
    }
  }));
}
 
開發者ID:aaronhe42,項目名稱:RxGoogleMapsBinding,代碼行數:18,代碼來源:PolygonClickOnSubscribe.java

示例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));
    }

}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:25,代碼來源:GoogleMapFragment.java

示例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;
}
 
開發者ID:josegury,項目名稱:AndroidMarkerClusteringMaps,代碼行數:32,代碼來源:KmlRenderer.java

示例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));
    }

}
 
開發者ID:sommishra,項目名稱:DroidPlanner-Tower,代碼行數:20,代碼來源:GoogleMapFragment.java

示例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);
}
 
開發者ID:neo4art,項目名稱:neo4art,代碼行數:23,代碼來源:PluginPolygon.java

示例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);
}
 
開發者ID:neo4art,項目名稱:neo4art,代碼行數:23,代碼來源:PluginPolygon.java

示例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);
    }
}
 
開發者ID:johnjohndoe,項目名稱:Umweltzone,代碼行數:19,代碼來源:MapDrawer.java

示例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;
}
 
開發者ID:ngageoint,項目名稱:anti-piracy-android-app,代碼行數:23,代碼來源:OfflineMap.java

示例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);
        }
    }
}
 
開發者ID:ngageoint,項目名稱:disconnected-content-explorer-android,代碼行數:19,代碼來源:OfflineMap.java

示例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;
}
 
開發者ID:ngageoint,項目名稱:disconnected-content-explorer-android,代碼行數:24,代碼來源:OfflineMap.java

示例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);
    }
  }
}
 
開發者ID:pemulis,項目名稱:Zones,代碼行數:23,代碼來源:GooglePolygonMap.java

示例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;
}
 
開發者ID:MKLab-ITI,項目名稱:ImproveMyCity-Mobile,代碼行數:33,代碼來源:GEO.java


注:本文中的com.google.android.gms.maps.model.Polygon類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。