Here are the examples of the java api class com.google.android.gms.maps.Projection taken from open source projects.
1. GoogleMapFragment#projectPathIntoMap()
Project: Tower
File: GoogleMapFragment.java
File: GoogleMapFragment.java
@Override public List<LatLong> projectPathIntoMap(List<LatLong> path) { List<LatLong> coords = new ArrayList<LatLong>(); Projection projection = getMap().getProjection(); for (LatLong point : path) { LatLng coord = projection.fromScreenLocation(new Point((int) point.getLatitude(), (int) point.getLongitude())); coords.add(DroneHelper.LatLngToCoord(coord)); } return coords; }
2. ClustersBuilder#build()
Project: clusterkraf
File: ClustersBuilder.java
File: ClustersBuilder.java
ArrayList<ClusterPoint> build() { Projection projection = getProjection(); ArrayList<ClusterPoint> clusteredPoints = null; if (projection != null) { clusteredPoints = new ArrayList<ClusterPoint>(relevantInputPointsList.size()); for (InputPoint point : relevantInputPointsList) { boolean addedToExistingCluster = false; for (ClusterPoint clusterPoint : clusteredPoints) { if (clusterPoint.getPixelDistanceFrom(point) <= options.getPixelDistanceToJoinCluster()) { clusterPoint.add(point); addedToExistingCluster = true; break; } } if (addedToExistingCluster == false) { clusteredPoints.add(new ClusterPoint(point, projection, false)); } } } return clusteredPoints; }
3. NativeGoogleMapFragment#getMapScreenBounds()
Project: AirMapView
File: NativeGoogleMapFragment.java
File: NativeGoogleMapFragment.java
@Override public void getMapScreenBounds(OnMapBoundsCallback callback) { final Projection projection = googleMap.getProjection(); int hOffset = getResources().getDimensionPixelOffset(R.dimen.map_horizontal_padding); int vOffset = getResources().getDimensionPixelOffset(R.dimen.map_vertical_padding); LatLngBounds.Builder builder = LatLngBounds.builder(); // top-left builder.include(projection.fromScreenLocation(new Point(hOffset, vOffset))); builder.include(projection.fromScreenLocation(// top-right new Point(getView().getWidth() - hOffset, vOffset))); builder.include(projection.fromScreenLocation(// bottom-left new Point(hOffset, getView().getHeight() - vOffset))); builder.include(projection.fromScreenLocation(new Point(getView().getWidth() - hOffset, // bottom-right getView().getHeight() - vOffset))); callback.onMapBoundsReady(builder.build()); }