Java Code Examples for com.google.android.gms.maps.GoogleMap#getProjection()
The following examples show how to use
com.google.android.gms.maps.GoogleMap#getProjection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Clusterkraf.java From clusterkraf with Apache License 2.0 | 6 votes |
@SuppressLint("NewApi") public void executeTask() { GoogleMap map = mapRef.get(); if (map != null) { ProcessingListener processingListener = options.getProcessingListener(); if (processingListener != null) { processingListener.onClusteringStarted(); } ClusteringTask.Argument arg = new ClusteringTask.Argument(); arg.projection = map.getProjection(); arg.options = options; arg.points = points; arg.previousClusters = previousClusters; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, arg); } else { task.execute(arg); } } }
Example 2
Source File: MapUtils.java From geopackage-android-map with MIT License | 5 votes |
/** * Build a lat lng bounding box using the click location, map view, map, and screen percentage tolerance. * The bounding box can be used to query for features that were clicked * * @param latLng click location * @param view map view * @param map map * @param screenClickPercentage screen click percentage between 0.0 and 1.0 for how close a feature * on the screen must be to be included in a click query * @return lat lng bounding box */ public static LatLngBoundingBox buildClickLatLngBoundingBox(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { // Get the screen width and height a click occurs from a feature int width = (int) Math.round(view.getWidth() * screenClickPercentage); int height = (int) Math.round(view.getHeight() * screenClickPercentage); // Get the screen click location Projection projection = map.getProjection(); android.graphics.Point clickLocation = projection.toScreenLocation(latLng); // Get the screen click locations in each width or height direction android.graphics.Point left = new android.graphics.Point(clickLocation); android.graphics.Point up = new android.graphics.Point(clickLocation); android.graphics.Point right = new android.graphics.Point(clickLocation); android.graphics.Point down = new android.graphics.Point(clickLocation); left.offset(-width, 0); up.offset(0, -height); right.offset(width, 0); down.offset(0, height); // Get the coordinates of the bounding box points LatLng leftCoordinate = projection.fromScreenLocation(left); LatLng upCoordinate = projection.fromScreenLocation(up); LatLng rightCoordinate = projection.fromScreenLocation(right); LatLng downCoordinate = projection.fromScreenLocation(down); LatLngBoundingBox latLngBoundingBox = new LatLngBoundingBox(leftCoordinate, upCoordinate, rightCoordinate, downCoordinate); return latLngBoundingBox; }