Java 类com.google.android.gms.maps.model.PolygonOptions 实例源码

项目:HackJakRawan    文件:MapsActivity.java   
private void setupPoly(double lattd, double longtd)
    {
        mMaps.addPolygon(new PolygonOptions()
                .add(new LatLng(-6.235615, 106.747218))
                .add(new LatLng(-6.236727, 106.747207))
                .add(new LatLng(-6.236052, 106.747848))
                .strokeColor(Color.RED)
                .fillColor(0x5500ff00));

//        mMaps.addPolygon(new PolygonOptions()
//                .add(new LatLng(-6.236727, 106.747207))
//                .strokeColor(Color.RED)
//                .fillColor(0x5500ff00));
//
//        mMaps.addPolygon(new PolygonOptions()
//                .add(new LatLng(-6.236052, 106.747848))
//                .strokeColor(Color.RED)
//                .fillColor(0x5500ff00));

    }
项目:geopackage-android-map    文件:MapUtils.java   
/**
 * Is the point of the polygon
 *
 * @param point     point
 * @param polygon   polygon
 * @param geodesic  geodesic check flag
 * @param tolerance distance tolerance
 * @return true if on the polygon
 */
public static boolean isPointOnPolygon(LatLng point, PolygonOptions polygon, boolean geodesic, double tolerance) {

    boolean onPolygon = PolyUtil.containsLocation(point, polygon.getPoints(), geodesic) ||
            PolyUtil.isLocationOnEdge(point, polygon.getPoints(), geodesic, tolerance);

    if (onPolygon) {
        for (List<LatLng> hole : polygon.getHoles()) {
            if (PolyUtil.containsLocation(point, hole, geodesic)) {
                onPolygon = false;
                break;
            }
        }
    }

    return onPolygon;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverter.java   
/**
 * Add a MultiPolygonOptions to the map as markers
 *
 * @param shapeMarkers
 * @param map
 * @param multiPolygon
 * @param polygonMarkerOptions
 * @param polygonMarkerHoleOptions
 * @param globalPolygonOptions
 * @return
 */
public MultiPolygonMarkers addMultiPolygonToMapAsMarkers(
        GoogleMapShapeMarkers shapeMarkers, GoogleMap map,
        MultiPolygonOptions multiPolygon,
        MarkerOptions polygonMarkerOptions,
        MarkerOptions polygonMarkerHoleOptions,
        PolygonOptions globalPolygonOptions) {
    MultiPolygonMarkers multiPolygonMarkers = new MultiPolygonMarkers();
    for (PolygonOptions polygon : multiPolygon.getPolygonOptions()) {
        PolygonMarkers polygonMarker = addPolygonToMapAsMarkers(
                shapeMarkers, map, polygon, polygonMarkerOptions,
                polygonMarkerHoleOptions, globalPolygonOptions);
        shapeMarkers.add(polygonMarker);
        multiPolygonMarkers.add(polygonMarker);
    }
    return multiPolygonMarkers;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverterUtils.java   
/**
 * Compare Polygon with Map Polygon
 *
    * @param converter
 * @param polygon
 * @param polygon2
 */
private static void comparePolygonAndMapPolygon(GoogleMapShapeConverter converter,
           Polygon polygon,
        PolygonOptions polygon2) {
    List<LineString> rings = polygon.getRings();
    List<LatLng> points = polygon2.getPoints();
    List<List<LatLng>> holes = polygon2.getHoles();

    TestCase.assertEquals(polygon.numRings(), 1 + holes.size());

    LineString polygonRing = rings.get(0);
    compareLineStringAndLatLngs(converter, polygonRing, points);

    for (int i = 1; i < rings.size(); i++) {
        LineString ring = rings.get(i);
        List<LatLng> hole = holes.get(i - 1);
        compareLineStringAndLatLngs(converter, ring, hole);
    }
}
项目:PokeRadar    文件:MapsActivity.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    mainPrefs = prefs;
    loadPrefs();
    for (Marker m : new ArrayList<>(markers)) {
        if (m == null || !pokemonMarkers.containsKey(m.getId())) continue;
        PMarker marker = pokemonMarkers.get(m.getId());
        if ((marker.type == PMarker.MarkerType.POKEMON && !showPokemons)
                || ((marker.type == PMarker.MarkerType.POKESTOP || marker.type == PMarker.MarkerType.LUREDPOKESTOP) && !showPokestops)
                || (marker.type == PMarker.MarkerType.GYM && !showGyms)
                || (marker.type == PMarker.MarkerType.SPAWNPOINT && !showSpawnpoints)) {
            forts.remove(marker.getId());
            luredPokemon.remove(marker.getId());
            if (marker.type == PMarker.MarkerType.POKEMON)
                pokemon.remove(Long.parseLong(marker.getId()));
            spawnpoints.remove(marker.getId());

            removeMarker(m);
        }
    }
    if (scanArea != null) scanArea.remove();
    if (showScanArea)
        scanArea = mMap.addPolygon(new PolygonOptions().addAll(createRectangle(location, steps * gpsOffset)).fillColor(Color.argb(20, 50, 0, 255)));
}
项目:Japp16    文件:JappMapFragment.java   
public void setupDeelgebied(Deelgebied deelgebied) {
    if(!deelgebied.getCoordinates().isEmpty()) {
        PolygonOptions options = new PolygonOptions().addAll(deelgebied.getCoordinates());
        if(JappPreferences.getAreasColorEnabled()) {
            int alphaPercent = JappPreferences.getAreasColorAlpha();
            float alpha = ((float)(100 - alphaPercent))/100 * 255;
            options.fillColor(deelgebied.alphaled(Math.round(alpha)));
        } else {
            options.fillColor(Color.TRANSPARENT);
        }

        options.strokeColor(deelgebied.getColor());
        if(JappPreferences.getAreasEdgesEnabled()) {
            options.strokeWidth(JappPreferences.getAreasEdgesWidth());
        } else {
            options.strokeWidth(0);
        }
        options.visible(true);

        areas.put(deelgebied.getName(), jotiMap.addPolygon(options));
    }
}
项目:Japp16    文件:AbstractTransducer.java   
/**
 * Reconstructs the result.
 *
 * @param in The parcel where the result was written to
 */
protected Result(Parcel in) {
    bundleId = in.readString();
    markers = new ArrayList<>();
    ArrayList<MarkerOptions> optionsList = in.createTypedArrayList(MarkerOptions.CREATOR);
    ArrayList<Bitmap> bitmapList = in.createTypedArrayList(Bitmap.CREATOR);
    ArrayList<Pair<MarkerOptions, Bitmap>> markers = new ArrayList<>();

    polylines = in.createTypedArrayList(PolylineOptions.CREATOR);
    polygons = in.createTypedArrayList(PolygonOptions.CREATOR);
    circles = in.createTypedArrayList(CircleOptions.CREATOR);
    if (bitmapList.size() != optionsList.size()){
        throw new RuntimeException("optionlist and bitmapList are not equal in size");
    }
    for (int i = 0; i < optionsList.size(); i++){
        markers.add(new Pair<MarkerOptions, Bitmap>(optionsList.get(i),bitmapList.get(i)));
    }
    this.markers = markers;
}
项目:Tower-develop    文件:GoogleMapFragment.java   
@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));
    }

}
项目:SpatiAtlas    文件:MapFragment.java   
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));
}
项目:PublicOpenSpaceToolApp    文件:ProjectAddEditFragment.java   
private void drawPolygon() {
    googleMap.clear();

    for (LatLng point : arrayPoints) {
        googleMap.addMarker(new MarkerOptions().position(point));
    }

    if (arrayPoints.size() >= 3) {
        PolygonOptions polygonOptions = new PolygonOptions();
        polygonOptions.addAll(arrayPoints);
        polygonOptions.strokeColor(Color.argb(0, 0, 0, 100));
        polygonOptions.strokeWidth(7);
        polygonOptions.fillColor(Color.argb(100, 0, 0, 100));
        googleMap.addPolygon(polygonOptions);
    }
}
项目:geohashdroid    文件:SelectAGraticuleMode.java   
private void outlineGraticule(Graticule g) {
    // If we had an outline, remove it.
    if(mPolygon != null)
        mPolygon.remove();

    // A null Graticule means either there's no valid input or we're in
    // globalhash mode, so we just don't draw the outline at all.
    if(g == null) return;

    // And with that Graticule, we can get a Polygon.
    PolygonOptions opts = g.getPolygon()
            .strokeColor(ContextCompat.getColor(mCentralMap, R.color.graticule_stroke))
            .strokeWidth(2)
            .fillColor(ContextCompat.getColor(mCentralMap, R.color.graticule_fill));

    if(mMap != null) {
        mPolygon = mMap.addPolygon(opts);

        zoomToPoint(g.getCenterLatLng());
    }
}
项目:UWP-navigation    文件:MapObject.java   
public boolean pointInPolygon(LatLng point, PolygonOptions polygon) {
    // ray casting alogrithm http://rosettacode.org/wiki/Ray-casting_algorithm
    int crossings = 0;
    List<LatLng> path = polygon.getPoints();
    //path.remove(path.size()); //remove the last point that is added automatically by getPoints()

    // for each edge
    for (int i = 0; i < path.size(); i++) {
        LatLng a = path.get(i);
        int j = i + 1;
        //to close the last edge, you have to take the first point of your polygon
        if (j >= path.size()) {
            j = 0;
        }
        LatLng b = path.get(j);
        if (rayCrossesSegment(point, a, b)) {
            crossings++;
        }
    }

    // odd number of crossings?
    return (crossings % 2 == 1);
}
项目:UWP-navigation    文件:BuildingList.java   
public BuildingList() {
        buildingHashMap = new HashMap<>();
        for (Map.Entry<String, PolygonOptions> entry : CONSTANTS.buildingOutlines.entrySet()) {
            Building b = new Building(entry.getKey(), entry.getValue());
            buildingHashMap.put(b.getName(), b);
        }
        buildingHashMap.get("Student Center").setNavId("Student_Center");
        buildingHashMap.get("Molinaro Hall").setNavId("Molinaro_Hall");
        buildingHashMap.get("Greenquist Hall").setNavId("Greenquist_Hall");
        buildingHashMap.get("Wyllie Hall").setNavId("Wyllie_Hall");
        buildingHashMap.get("The Rita").setNavId("The_Rita");
        buildingHashMap.get("Sports and Activity Center").setNavId("Sports_and_Activity_Center");
//        FUTURE BUILDINGS
//        buildingHashMap.get("Tallent Hall").setNavId("Tallent_Hall");
//        buildingHashMap.get("Student Health and Counseling Center").setNavId("Student_Health_and_Counseling_Center");
    }
项目:AndroidMarkerClusteringMaps    文件:KmlRenderer.java   
/**
 * Sets the inline polygon style by copying over the styles that have been set
 *
 * @param polygonOptions polygon options object to add inline styles to
 * @param inlineStyle    inline styles to apply
 */
private void setInlinePolygonStyle(PolygonOptions polygonOptions, KmlStyle inlineStyle) {
    PolygonOptions inlinePolygonOptions = inlineStyle.getPolygonOptions();
    if (inlineStyle.hasFill() && inlineStyle.isStyleSet("fillColor")) {
        polygonOptions.fillColor(inlinePolygonOptions.getFillColor());
    }
    if (inlineStyle.hasOutline()) {
        if (inlineStyle.isStyleSet("outlineColor")) {
            polygonOptions.strokeColor(inlinePolygonOptions.getStrokeColor());
        }
        if (inlineStyle.isStyleSet("width")) {
            polygonOptions.strokeWidth(inlinePolygonOptions.getStrokeWidth());
        }
    }
    if (inlineStyle.isPolyRandomColorMode()) {
        polygonOptions.fillColor(KmlStyle.computeRandomColor(inlinePolygonOptions.getFillColor()));
    }
}
项目:DroidPlanner-Tower    文件:GoogleMapFragment.java   
@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));
    }

}
项目:esnavi    文件:WarningAreaManager.java   
/**
 * 形状を追加する。
 *
 * @param shapeOptions 形状オプション
 */
private void addShapes(@NonNull List<Parcelable> shapeOptions) {
    if (mMap == null) {
        return;
    }

    for (final Parcelable shapeOption : shapeOptions) {
        if (shapeOption instanceof PolygonOptions) {
            mShapes.add(mMap.addPolygon((PolygonOptions) shapeOption));
        } else if (shapeOption instanceof PolylineOptions) {
            mShapes.add(mMap.addPolyline((PolylineOptions) shapeOption));
        } else if (shapeOption instanceof CircleOptions) {
            mShapes.add(mMap.addCircle((CircleOptions) shapeOption));
        } else {
            Log.w(TAG, "想定していない形状。" + shapeOption.getClass().getSimpleName());
        }
    }
}
项目:anti-piracy-android-app    文件:OfflineMap.java   
@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;
}
项目:uwaterloo-api    文件:ParkingFragment.java   
private void redrawPolygons(final GoogleMap map) {
  map.clear();

  for (final ParkingLot parkingLot : mResponse) {
    final PolygonOptions polygon = ParkingLots.getShape(parkingLot.getLotName());

    final float taken = parkingLot.getPercentFilled();
    if (taken < 0.75f) {
      polygon.fillColor(Colors.mask(0x80, Colors.GREEN_500));
    } else if (taken < 0.90f) {
      polygon.fillColor(Colors.mask(0x80, Colors.YELLOW_500));
    } else {
      polygon.fillColor(Colors.mask(0x80, Colors.RED_500));
    }

    polygon.strokeColor(parkingLot == mSelected
                            ? Colors.mask(0xFF, mPrimaryColor)
                            : Colors.mask(0xFF, Color.BLACK)
    );

    map.addPolygon(polygon);
  }
}
项目:mapquiz    文件:StateQuestion.java   
@Override
public void changeMap(GoogleMap map) {
    //      Select state and choose location within state to display
    LatLng loc = mCorrect.getRandomPoint();
    final Iterable<LatLng> outline = mCorrect.getPoints();
    map.clear();
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, mDifficulty.getZoomLevel()));
    Resources res = mContext.getResources();
    map.addMarker(new MarkerOptions()
            .title(res.getString(R.string.marker_title))
            .position(loc));
    map.addPolygon(new PolygonOptions()
            .strokeColor(OUTLINE_COLOR)
            .strokeWidth(OUTLINE_STROKE_WIDTH)
            .addAll(outline));
}
项目:disconnected-content-explorer-android    文件:OfflineMap.java   
@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;
}
项目:Field-Work    文件:ATKPolygonView.java   
private void drawPolygon(){
    if(this.polygon.boundary != null && this.polygon.boundary.size() > 0){
        if(this.mapPolygon == null){
            //Setup options
            this.polygonOptions = new PolygonOptions();         
            this.polygonOptions.addAll(polygon.boundary);
            this.polygonOptions.strokeColor(this.viewOptions.getStrokeColor());
            this.polygonOptions.strokeWidth(this.viewOptions.getStrokeWidth());
            this.polygonOptions.fillColor(this.viewOptions.getFillColor());
            this.polygonOptions.visible(this.viewOptions.isVisible());
            this.polygonOptions.zIndex(this.viewOptions.getZindex());
            this.mapPolygon = map.addPolygon(this.polygonOptions);
        } else {
            this.mapPolygon.setPoints(this.polygon.boundary);
        }
    } else {
        //Model doesn't have a boundary remove the polygon from the map
        if(this.mapPolygon != null) this.mapPolygon.remove();
        this.mapPolygon = null;
    }
    this.drawLabel();
}
项目:OpenATKLib    文件:ATKPolygonView.java   
private void drawPolygon(){
    if(this.polygon.boundary != null && this.polygon.boundary.size() > 0){
        if(this.mapPolygon == null){
            //Setup options
            this.polygonOptions = new PolygonOptions();         
            this.polygonOptions.addAll(polygon.boundary);
            this.polygonOptions.strokeColor(this.viewOptions.getStrokeColor());
            this.polygonOptions.strokeWidth(this.viewOptions.getStrokeWidth());
            this.polygonOptions.fillColor(this.viewOptions.getFillColor());
            this.polygonOptions.visible(this.viewOptions.isVisible());
            this.polygonOptions.zIndex(this.viewOptions.getZindex());
            this.mapPolygon = map.addPolygon(this.polygonOptions);
        } else {
            this.mapPolygon.setPoints(this.polygon.boundary);
        }
    } else {
        //Model doesn't have a boundary remove the polygon from the map
        if(this.mapPolygon != null) this.mapPolygon.remove();
        this.mapPolygon = null;
    }
    this.drawLabel();
}
项目:Location-tracker    文件:MapDrawer.java   
public PolygonOptions drawCircle(LatLng center, int radius) {
    // Clear the map to remove the previous circle
    map1.clear();
    // Generate the points
    List<LatLng> points = new ArrayList<LatLng>();
    int totalPonts = 50; // number of corners of the pseudo-circle
    for (int i = 0; i < totalPonts; i++) {
        points.add(getpoint(center, radius, i*2*Math.PI/totalPonts));
    }
    // Create and return the polygon
    return (new PolygonOptions().addAll(points).geodesic(true).strokeWidth(2).strokeColor(Color.TRANSPARENT).
            fillColor(Color.HSVToColor(100, new float[] {234, 1, 1})));



}
项目:android-maps-utils    文件:Renderer.java   
/**
 * Sets the inline polygon style by copying over the styles that have been set
 *
 * @param polygonOptions polygon options object to add inline styles to
 * @param inlineStyle    inline styles to apply
 */
private void setInlinePolygonStyle(PolygonOptions polygonOptions, KmlStyle inlineStyle) {
    PolygonOptions inlinePolygonOptions = inlineStyle.getPolygonOptions();
    if (inlineStyle.hasFill() && inlineStyle.isStyleSet("fillColor")) {
        polygonOptions.fillColor(inlinePolygonOptions.getFillColor());
    }
    if (inlineStyle.hasOutline()) {
        if (inlineStyle.isStyleSet("outlineColor")) {
            polygonOptions.strokeColor(inlinePolygonOptions.getStrokeColor());
        }
        if (inlineStyle.isStyleSet("width")) {
            polygonOptions.strokeWidth(inlinePolygonOptions.getStrokeWidth());
        }
    }
    if (inlineStyle.isPolyRandomColorMode()) {
        polygonOptions.fillColor(KmlStyle.computeRandomColor(inlinePolygonOptions.getFillColor()));
    }
}
项目:Zones    文件:GooglePolygonMap.java   
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);
    }
  }
}
项目:FiveMinsMore    文件:MapsManager.java   
@Override
    public void onCameraMove() {
        // 顯示縮放層級
        CameraPosition cameraPosition = mMaps.get(MAP_CODE_MAIN).getCameraPosition();
        float currentZoomNumber = cameraPosition.zoom;
//        String currentZoom = Integer.twd2String(Math.round(currentZoomNumber));
        String currentZoom = "" + (int) currentZoomNumber;
        mZoomNumber.setText(currentZoom);


        LatLng latLng = cameraPosition.target;
        mCrossCoor.setText(ProjFuncs.getCurrentCoor(latLng, true));

        // 改變比例尺
        adjustScaleBar();

        // 次要地圖,若同步,則隨主要地圖移動畫面,若非同步,使用Polygon顯示主要地圖的範圍
        if (mMaps.size() > 1) {
            if (isMapsSync) {
                mMaps.get(MAP_CODE_SUB).moveCamera(CameraUpdateFactory
                        .newCameraPosition(cameraPosition));
            } else {
                LatLngBounds latLngBounds = MapUtils.getMapBounds(mMaps.get(MAP_CODE_MAIN));
                if (boundaryMainPolygon == null) {
                    boundaryMain = new PolygonOptions()
                            .addAll(getBounds(latLngBounds))
                            .strokeColor(Color.YELLOW)
                            .zIndex(10);
                    boundaryMainPolygon = mMaps.get(MAP_CODE_SUB).addPolygon(boundaryMain);
                } else {
                    boundaryMainPolygon.setPoints(getBounds(latLngBounds));
                }
            }
        }
    }
项目:GoogleMapsLayout-Android    文件:PolygonOptionsFactory.java   
public static PolygonOptions defaultPolygonOptions() {
    return new PolygonOptions()
            .fillColor(Color.parseColor("#306ed88a"))
            .strokeWidth(0)
            .strokeColor(Color.BLACK)
            .geodesic(false)
            .clickable(true)
            .zIndex(MapLayout.ZONE_Z_INDEX);
}
项目:GoogleMapsLayout-Android    文件:PolygonOptionsFactory.java   
public static PolygonOptions defaultHighlightPolygonOptions() {
    return new PolygonOptions()
            .fillColor(Color.parseColor("#80C5E1A5"))
            .strokeWidth(10)
            .strokeColor(Color.BLACK)
            .geodesic(false)
            .clickable(true)
            .zIndex(MapLayout.ZONE_Z_INDEX);
}
项目:GoogleMapsLayout-Android    文件:MapLayout.java   
/**
 * Refreshes the polygon and  label marker of the given zone according to zone's appearance options.
 *
 * @param zone zone object
 */
private void refreshZone(Zone zone) {
    Pair<Marker,Polygon> markerAndPolygon = zoneVsMarkerAndPolygonMap.get(zone);
    ZoneOptions zoneOptions = zone.getOptions();
    //update polygon
    Polygon p = markerAndPolygon.second;
    PolygonOptions polygonOptions = zoneOptions.getPolygonOptions();
    p.setStrokeColor(polygonOptions.getStrokeColor());
    p.setStrokeWidth(polygonOptions.getStrokeWidth());
    p.setFillColor(polygonOptions.getFillColor());
    p.setGeodesic(polygonOptions.isGeodesic());
    p.setHoles(polygonOptions.getHoles());
    p.setVisible(polygonOptions.isVisible());
    p.setZIndex(polygonOptions.getZIndex());
    p.setClickable(polygonOptions.isClickable());

    Log.i(TAG,"updated polygon id: "+p.getId());

    //update label marker
    Marker m = markerAndPolygon.first;
    ZoneLabelOptions zoneLabelOptions = zoneOptions.getZoneLabelOptions();
    MarkerOptions mO = zoneLabelOptions.getLabelMarkerOptions();

    if(zoneLabelOptions.isDisplayLabel())
        mO.icon(BitmapDescriptorFactory.fromBitmap(getLabelBitmap(zone.getName(),zoneLabelOptions)));

    m.setIcon(mO.getIcon());
    m.setZIndex(mO.getZIndex());
    m.setVisible(mO.isVisible());
    m.setAlpha(mO.getAlpha());
    m.setAnchor(mO.getAnchorV(),mO.getAnchorU());
    m.setDraggable(mO.isDraggable());
    m.setFlat(mO.isFlat());
    m.setInfoWindowAnchor(mO.getInfoWindowAnchorV(),mO.getInfoWindowAnchorU());
    m.setRotation(mO.getRotation());
    m.setSnippet(mO.getSnippet());
    m.setTitle(zone.getName());
}
项目:geopackage-android-map    文件:MapUtils.java   
/**
 * Is the point on the multi polygon
 *
 * @param point        point
 * @param multiPolygon multi polygon
 * @param geodesic     geodesic check flag
 * @param tolerance    distance tolerance
 * @return true if on the multi polygon
 */
public static boolean isPointOnMultiPolygon(LatLng point, MultiPolygonOptions multiPolygon, boolean geodesic, double tolerance) {
    boolean near = false;
    for (PolygonOptions polygon : multiPolygon.getPolygonOptions()) {
        near = isPointOnPolygon(point, polygon, geodesic, tolerance);
        if (near) {
            break;
        }
    }
    return near;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverter.java   
/**
 * Convert a {@link MultiPolygon} to a {@link MultiPolygonOptions}
 *
 * @param multiPolygon
 * @return
 */
public MultiPolygonOptions toPolygons(MultiPolygon multiPolygon) {

    MultiPolygonOptions polygons = new MultiPolygonOptions();

    for (Polygon polygon : multiPolygon.getPolygons()) {
        PolygonOptions polygonOptions = toPolygon(polygon);
        polygons.add(polygonOptions);
    }

    return polygons;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverter.java   
/**
 * Convert a list of {@link PolygonOptions} to a {@link MultiPolygon}
 *
 * @param multiPolygonOptions
 * @param hasZ
 * @param hasM
 * @return
 */
public MultiPolygon toMultiPolygonFromOptions(
        MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) {

    MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM);

    for (PolygonOptions mapPolygon : multiPolygonOptions
            .getPolygonOptions()) {
        Polygon polygon = toPolygon(mapPolygon);
        multiPolygon.addPolygon(polygon);
    }

    return multiPolygon;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverter.java   
/**
 * Convert a {@link PolyhedralSurface} to a {@link MultiPolygonOptions}
 *
 * @param polyhedralSurface
 * @return
 */
public MultiPolygonOptions toPolygons(PolyhedralSurface polyhedralSurface) {

    MultiPolygonOptions polygons = new MultiPolygonOptions();

    for (Polygon polygon : polyhedralSurface.getPolygons()) {
        PolygonOptions polygonOptions = toPolygon(polygon);
        polygons.add(polygonOptions);
    }

    return polygons;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverter.java   
/**
 * Convert a {@link MultiPolygonOptions} to a {@link PolyhedralSurface}
 *
 * @param multiPolygonOptions
 * @param hasZ
 * @param hasM
 * @return
 */
public PolyhedralSurface toPolyhedralSurfaceWithOptions(
        MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) {

    PolyhedralSurface polyhedralSurface = new PolyhedralSurface(hasZ, hasM);

    for (PolygonOptions mapPolygon : multiPolygonOptions
            .getPolygonOptions()) {
        Polygon polygon = toPolygon(mapPolygon);
        polyhedralSurface.addPolygon(polygon);
    }

    return polyhedralSurface;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverter.java   
/**
 * Add a Polygon to the map as markers
 *
 * @param shapeMarkers
 * @param map
 * @param polygonOptions
 * @param polygonMarkerOptions
 * @param polygonMarkerHoleOptions
 * @param globalPolygonOptions
 * @return
 */
public PolygonMarkers addPolygonToMapAsMarkers(
        GoogleMapShapeMarkers shapeMarkers, GoogleMap map,
        PolygonOptions polygonOptions, MarkerOptions polygonMarkerOptions,
        MarkerOptions polygonMarkerHoleOptions,
        PolygonOptions globalPolygonOptions) {

    PolygonMarkers polygonMarkers = new PolygonMarkers(this);

    if (globalPolygonOptions != null) {
        polygonOptions.fillColor(globalPolygonOptions.getFillColor());
        polygonOptions.strokeColor(globalPolygonOptions.getStrokeColor());
        polygonOptions.geodesic(globalPolygonOptions.isGeodesic());
    }

    com.google.android.gms.maps.model.Polygon polygon = addPolygonToMap(
            map, polygonOptions);
    polygonMarkers.setPolygon(polygon);

    List<Marker> markers = addPointsToMapAsMarkers(map,
            polygon.getPoints(), polygonMarkerOptions, true);
    polygonMarkers.setMarkers(markers);

    for (List<LatLng> holes : polygon.getHoles()) {
        List<Marker> holeMarkers = addPointsToMapAsMarkers(map, holes,
                polygonMarkerHoleOptions, true);
        PolygonHoleMarkers polygonHoleMarkers = new PolygonHoleMarkers(
                polygonMarkers);
        polygonHoleMarkers.setMarkers(holeMarkers);
        shapeMarkers.add(polygonHoleMarkers);
        polygonMarkers.addHole(polygonHoleMarkers);
    }

    return polygonMarkers;
}
项目:geopackage-android-map    文件:GoogleMapShapeConverterUtils.java   
/**
 * Test the Polygon conversion
 * 
 * @param converter
 * @param polygon
 */
private static void convertPolygon(GoogleMapShapeConverter converter,
        Polygon polygon) {

    PolygonOptions polygonOptions = converter.toPolygon(polygon);
    TestCase.assertNotNull(polygonOptions);

    comparePolygonAndMapPolygon(converter, polygon, polygonOptions);

    Polygon polygon2 = converter.toPolygon(polygonOptions);
    comparePolygons(polygon, polygon2);
}
项目:geopackage-android-map    文件:GoogleMapShapeConverterUtils.java   
/**
 * Compare list of polygons with list of map polygons
 *
    * @param converter
 * @param polygons
 * @param mapPolygons
 */
private static void comparePolygonsAndMapPolygons(GoogleMapShapeConverter converter, List<Polygon> polygons,
        List<PolygonOptions> mapPolygons) {

    TestCase.assertEquals(polygons.size(), mapPolygons.size());
    for (int i = 0; i < polygons.size(); i++) {
        comparePolygonAndMapPolygon(converter, polygons.get(i), mapPolygons.get(i));
    }

}
项目:Bee-Analyzer    文件:MapsActivity.java   
private void setUpMap()
{
    LatLng localLatLng = new LatLng(41.104889999999997D, 29.027756D);
    this.mMap.moveCamera(CameraUpdateFactory.newLatLng(localLatLng));
    this.mMap.animateCamera(CameraUpdateFactory.zoomTo(15.0F));
    if (this.mMap == null)
        this.mMap = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
    if (this.mMap != null)
    {
        this.ituArea = new PolygonOptions().add(new LatLng(41.106655000000003D, 29.014520999999998D)).add(new LatLng(41.108691999999998D, 29.021429999999999D)).add(new LatLng(41.108967D, 29.029983999999999D)).add(new LatLng(41.111206000000003D, 29.037043000000001D)).add(new LatLng(41.099578999999999D, 29.038195999999999D)).add(new LatLng(41.097768000000002D, 29.022210000000001D)).add(new LatLng(41.106655000000003D, 29.014520999999998D)).strokeWidth(5.0F).strokeColor(-16776961).geodesic(true);
        this.mMap.addPolygon(ituArea);

        final LinkedHashMap<PolygonOptions,Pair> densityMap = new LinkedHashMap<PolygonOptions,Pair>();

        densityMap.put( new PolygonOptions().add(new LatLng(41.104940, 29.017533)).add(new LatLng(41.105251, 29.019770)).add(new LatLng(41.104369, 29.019925)).add(new LatLng(41.104232, 29.019303)).add(new LatLng(41.103755, 29.019378)).add(new LatLng(41.103545, 29.017833)).add(new LatLng(41.104940, 29.017533)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("İnşaat Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.104290, 29.020028)).add(new LatLng(41.104482, 29.021505)).add(new LatLng(41.103404, 29.021770)).add(new LatLng(41.103198, 29.020281)).add(new LatLng(41.104290, 29.020028)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Kütüphane",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.104492, 29.021625)).add(new LatLng(41.104617, 29.022429)).add(new LatLng(41.103101, 29.022772)).add(new LatLng(41.102972, 29.021989)).add(new LatLng(41.104492, 29.021625)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Yemekhane",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.102416, 29.020708)).add(new LatLng(41.102525, 29.021996)).add(new LatLng(41.101854, 29.022152)).add(new LatLng(41.101708, 29.021009)).add(new LatLng(41.101833, 29.020564)).add(new LatLng(41.102266, 29.020559)).add(new LatLng(41.102416, 29.020708)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Uçak Uzay Bilimleri Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.102101, 29.022205)).add(new LatLng(41.102150, 29.022392)).add(new LatLng(41.102461, 29.023051)).add(new LatLng(41.102352, 29.023931)).add(new LatLng(41.100989, 29.024323)).add(new LatLng(41.100447, 29.023774)).add(new LatLng(41.100500, 29.022583)).add(new LatLng(41.102101, 29.022205)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Stadyum",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.104662, 29.023917)).add(new LatLng(41.104812, 29.025129)).add(new LatLng(41.104311, 29.025258)).add(new LatLng(41.104174, 29.024094)).add(new LatLng(41.104662, 29.023917)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Elektrik Elektronik Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.104128, 29.024062)).add(new LatLng(41.104279, 29.025306)).add(new LatLng(41.103572, 29.025451)).add(new LatLng(41.103394, 29.024217)).add(new LatLng(41.104128, 29.024062)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Bilgisayar ve Bilişim Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.104848, 29.025299)).add(new LatLng(41.105025, 29.026757)).add(new LatLng(41.104269, 29.026891)).add(new LatLng(41.104172, 29.026542)).add(new LatLng(41.103586, 29.026698)).add(new LatLng(41.103513, 29.026381)).add(new LatLng(41.104144, 29.026209)).add(new LatLng(41.104087, 29.025533)).add(new LatLng(41.104848, 29.025299)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Maden Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.104521, 29.026871)).add(new LatLng(41.104606, 29.027906)).add(new LatLng(41.103377, 29.028174)).add(new LatLng(41.103231, 29.027133)).add(new LatLng(41.104521, 29.026871)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Kimya Metalurji Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.105643, 29.022831)).add(new LatLng(41.105805, 29.024298)).add(new LatLng(41.104976, 29.024491)).add(new LatLng(41.104794, 29.023013)).add(new LatLng(41.105643, 29.022831)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Merkezi Derslik Binası",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.107237, 29.022601)).add(new LatLng(41.107342, 29.023416)).add(new LatLng(41.106869, 29.023491)).add(new LatLng(41.106756, 29.022724)).add(new LatLng(41.107237, 29.022601)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Süleyman Demirel Kültür Merkezi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.107188, 29.023894)).add(new LatLng(41.107248, 29.024297)).add(new LatLng(41.106904, 29.024388)).add(new LatLng(41.107106, 29.025777)).add(new LatLng(41.106633, 29.025938)).add(new LatLng(41.106649, 29.026367)).add(new LatLng(41.106394, 29.026426)).add(new LatLng(41.106135, 29.024200)).add(new LatLng(41.107188, 29.023894)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Fen Edebiyat Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.102853, 29.026462)).add(new LatLng(41.103043, 29.028095)).add(new LatLng(41.102242, 29.028298)).add(new LatLng(41.102044, 29.026680)).add(new LatLng(41.102853, 29.026462)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Gemi İnşaatı ve Deniz Bilimleri Fakültesi",0));
        densityMap.put( new PolygonOptions().add(new LatLng(41.107821, 29.021052)).add(new LatLng(41.107853, 29.021733)).add(new LatLng(41.107461, 29.021803)).add(new LatLng(41.107380, 29.021347)).add(new LatLng(41.107158, 29.021315)).add(new LatLng(41.107085, 29.021133)).add(new LatLng(41.107821, 29.021052)).strokeWidth(3.0F).strokeColor(Color.BLACK).geodesic(true).clickable(true), Pair.create("Rektörlük",0));
        List<PolygonOptions> arr = new ArrayList(densityMap.keySet());
        for(PolygonOptions x: arr)
            this.mMap.addPolygon(x);
    }
}
项目:Japp16    文件:MapItemController.java   
protected void processResult(O result)
{
    ArrayList<Pair<MarkerOptions, Bitmap>> markers = result.getMarkers();
    IMarker marker;
    for(int m = 0; m < markers.size(); m++)
    {
        marker = jotiMap.addMarker(markers.get(m));
        marker.setVisible(visiblity);
        this.markers.add(marker);
    }

    ArrayList<PolylineOptions> polylines = result.getPolylines();
    IPolyline polyline;
    for(int p = 0; p < polylines.size(); p++)
    {
        polyline = jotiMap.addPolyline(polylines.get(p));
        polyline.setVisible(visiblity);
        this.polylines.add(polyline);
    }

    ArrayList<PolygonOptions> polygons = result.getPolygons();
    IPolygon polygon;
    for(int g = 0; g < polygons.size(); g++)
    {
        polygon = jotiMap.addPolygon(polygons.get(g));
        polygon.setVisible(visiblity);
        this.polygons.add(polygon);
    }

    ArrayList<CircleOptions> circles = result.getCircles();
    for(int c = 0; c < circles.size(); c++)
    {
        ICircle circle = jotiMap.addCircle(circles.get(c));
        circle.setVisible(visiblity);
        this.circles.put(circle, circle.getFillColor());
        if (!JappPreferences.fillCircles()){
            circle.setFillColor(Color.TRANSPARENT);
        }
    }
}
项目:Japp16    文件:OsmPolygon.java   
public OsmPolygon(PolygonOptions polygonOptions, MapView  osmMap) {
    osmPolygon = new org.osmdroid.views.overlay.Polygon();
    osmPolygon.setFillColor(polygonOptions.getFillColor());
    osmPolygon.setStrokeColor(polygonOptions.getStrokeColor());
    osmPolygon.setStrokeWidth(polygonOptions.getStrokeWidth());
    ArrayList<GeoPoint> points = new ArrayList<>();
    for (LatLng ll: polygonOptions.getPoints()){
        points.add(new GeoPoint(ll.latitude,ll.longitude));
    }
    osmPolygon.setPoints(points);
    this.osmMap = osmMap;
    osmMap.getOverlays().add(osmPolygon);
}