com.google.android.gms.maps.Projection Java Examples
The following examples show how to use
com.google.android.gms.maps.Projection.
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: ClustersBuilder.java From clusterkraf with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: ClusterTransitions.java From clusterkraf with Apache License 2.0 | 6 votes |
void add(ClusterPoint currentClusterPoint) { Projection projection = projectionRef != null ? projectionRef.get() : null; if (currentClusterPoint != null && projection != null) { boolean animated = false; if (previousClusterPoints != null) { for (ClusterPoint previousClusterPoint : previousClusterPoints) { for (InputPoint previousInputPoint : previousClusterPoint.getPointsInCluster()) { if (currentClusterPoint.containsInputPoint(previousInputPoint)) { AnimatedTransition transition = getTransition(previousInputPoint); if (transition != null) { transition.addOriginClusterRelevantInputPoint(previousInputPoint); } else { transition = new AnimatedTransition(projection, previousClusterPoint, previousInputPoint, currentClusterPoint); animatedTransitions.add(transition); animated = true; } } } } } if (animated == false) { stationaryTransitions.add(currentClusterPoint); } } }
Example #3
Source File: MyView.java From mil-sym-android with Apache License 2.0 | 6 votes |
private void ptsGeoToPixels() { _points.clear(); int j = 0; LatLng ptGeo = null; double longitude = 0; double latitude = 0; Projection projection = map.getProjection(); android.graphics.Point ptPixels = null; for (j = 0; j < _pointsGeo.size(); j++) { ptGeo = _pointsGeo.get(j); longitude = ptGeo.longitude; latitude = ptGeo.longitude; ptPixels = projection.toScreenLocation(ptGeo); _points.add(new Point(ptPixels.x, ptPixels.y)); } }
Example #4
Source File: NativeGoogleMapFragment.java From AirMapView with Apache License 2.0 | 6 votes |
@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(); builder.include(projection.fromScreenLocation(new Point(hOffset, vOffset))); // top-left builder.include(projection.fromScreenLocation( new Point(getView().getWidth() - hOffset, vOffset))); // top-right builder.include(projection.fromScreenLocation( new Point(hOffset, getView().getHeight() - vOffset))); // bottom-left builder.include(projection.fromScreenLocation(new Point(getView().getWidth() - hOffset, getView().getHeight() - vOffset))); // bottom-right callback.onMapBoundsReady(builder.build()); }
Example #5
Source File: RichPolygon.java From richmaps with Apache License 2.0 | 6 votes |
protected void drawHole(final Bitmap bitmap, final Projection projection, final List<RichPoint> points2Draw, final int paddingLeft, final int paddingTop, final int paddingRight, final int paddingBottom) { Canvas canvas = new Canvas(bitmap); Path linePath = new Path(); boolean firstPoint = true; for (RichPoint point : points2Draw) { LatLng position = point.getPosition(); if (position != null) { Point bmpPoint = projection.toScreenLocation(position); int bmpPointX = bmpPoint.x; int bmpPointY = bmpPoint.y + paddingBottom / 2 - paddingTop / 2; if (firstPoint) { linePath.moveTo(bmpPointX, bmpPointY); firstPoint = false; } else { linePath.lineTo(bmpPointX, bmpPointY); } } } Paint paint = getDefaultHolePaint(); canvas.drawPath(linePath, paint); }
Example #6
Source File: RichLayer.java From richmaps with Apache License 2.0 | 5 votes |
public void refresh() { CameraPosition cameraPosition = map.getCameraPosition(); if (cameraPosition.zoom >= MINIMUM_ZOOM_LEVEL) { Projection projection = map.getProjection(); prepareBitmap(); draw(bitmap, projection); float mapWidth = (float) SphericalUtil.computeDistanceBetween( projection.getVisibleRegion().nearLeft, projection.getVisibleRegion().nearRight); if (overlay == null) { GroundOverlayOptions background = new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromBitmap(bitmap)) .position(cameraPosition.target, mapWidth) .bearing(cameraPosition.bearing) .zIndex(zIndex); overlay = map.addGroundOverlay(background); } else { overlay.setImage(BitmapDescriptorFactory.fromBitmap(bitmap)); overlay.setPosition(cameraPosition.target); overlay.setDimensions(mapWidth); overlay.setBearing(cameraPosition.bearing); } } else { if (overlay != null) { overlay.remove(); overlay = null; } } }
Example #7
Source File: AnimatedTransition.java From clusterkraf with Apache License 2.0 | 5 votes |
AnimatedTransition(Projection projection, ClusterPoint originClusterPoint, InputPoint firstRelevantInputPointFromOriginClusterPoint, ClusterPoint destinationClusterPoint) { originClusterPoint.clearScreenPosition(); originClusterPoint.buildScreenPosition(projection); this.originClusterPoint = originClusterPoint; this.originClusterRelevantInputPoints = new ClusterPoint(firstRelevantInputPointFromOriginClusterPoint, projection, true, originClusterPoint.getMapPosition()); this.originClusterRelevantInputPoints.setScreenPosition(originClusterPoint.getScreenPosition()); this.destinationClusterPoint = destinationClusterPoint; this.spans180Meridian = Math.abs((originClusterPoint.getMapPosition().longitude) - (destinationClusterPoint.getMapPosition().longitude)) > 180; }
Example #8
Source File: Clusterkraf.java From clusterkraf with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") public void executeTask(Projection projection) { if (projection != null) { ClusterTransitionsBuildingTask.Argument arg = new ClusterTransitionsBuildingTask.Argument(); arg.currentClusters = currentClusters; arg.previousClusters = previousClusters; arg.projection = projection; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, arg); } else { task.execute(arg); } } }
Example #9
Source File: ChatAttachAlertLocationLayout.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void updatePositions() { if (googleMap == null) { return; } Projection projection = googleMap.getProjection(); for (HashMap.Entry<Marker, View> entry : views.entrySet()) { Marker marker = entry.getKey(); View view = entry.getValue(); Point point = projection.toScreenLocation(marker.getPosition()); view.setTranslationX(point.x - view.getMeasuredWidth() / 2); view.setTranslationY(point.y - view.getMeasuredHeight() + AndroidUtilities.dp(22)); } }
Example #10
Source File: LocationActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void updatePositions() { if (googleMap == null) { return; } Projection projection = googleMap.getProjection(); for (HashMap.Entry<Marker, View> entry : views.entrySet()) { Marker marker = entry.getKey(); View view = entry.getValue(); Point point = projection.toScreenLocation(marker.getPosition()); view.setTranslationX(point.x - view.getMeasuredWidth() / 2); view.setTranslationY(point.y - view.getMeasuredHeight() + AndroidUtilities.dp(22)); } }
Example #11
Source File: ClustersBuilder.java From clusterkraf with Apache License 2.0 | 5 votes |
ClustersBuilder(Projection projection, Options options, ArrayList<ClusterPoint> initialClusteredPoints) { this.options = options; this.projectionRef = new WeakReference<Projection>(projection); this.visibleRegionRef = new WeakReference<VisibleRegion>(projection.getVisibleRegion()); if (initialClusteredPoints != null) { addRelevantInitialInputPoints(initialClusteredPoints); } }
Example #12
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; }
Example #13
Source File: RichPolygon.java From richmaps with Apache License 2.0 | 5 votes |
protected void drawFill(final Bitmap bitmap, final Projection projection, final List<RichPoint> points2Draw, final int paddingLeft, final int paddingTop, final int paddingRight, final int paddingBottom) { Canvas canvas = new Canvas(bitmap); Path linePath = new Path(); boolean firstPoint = true; for (RichPoint point : points2Draw) { LatLng position = point.getPosition(); if (position != null) { Point bmpPoint = projection.toScreenLocation(position); int bmpPointX = bmpPoint.x; int bmpPointY = bmpPoint.y + paddingBottom / 2 - paddingTop / 2; if (firstPoint) { linePath.moveTo(bmpPointX, bmpPointY); firstPoint = false; } else { linePath.lineTo(bmpPointX, bmpPointY); } } } Paint paint = getDefaultFillPaint(); if (fillShader != null) { paint.setShader(fillShader); } canvas.drawPath(linePath, paint); }
Example #14
Source File: RichPolyline.java From richmaps with Apache License 2.0 | 5 votes |
private void drawSegment(final Canvas canvas, final Paint paint, final Projection projection, final RichPoint from, final RichPoint to, final int paddingLeft, final int paddingTop, final int paddingRight, final int paddingBottom) { Point toScreenPoint = projection.toScreenLocation(to.getPosition()); Point fromScreenPoint = projection.toScreenLocation(from.getPosition()); int fromX = fromScreenPoint.x + paddingRight / 2 - paddingLeft / 2; int fromY = fromScreenPoint.y + paddingBottom / 2 - paddingTop / 2; int toX = toScreenPoint.x + paddingRight / 2 - paddingLeft / 2; int toY = toScreenPoint.y + paddingBottom / 2 - paddingTop / 2; if (linearGradient) { int[] colors = new int[]{from.getColor(), to.getColor()}; paint.setShader(new LinearGradient(fromX, fromY, toX, toY, colors, null, Shader.TileMode.CLAMP)); } else { paint.setColor(from.getColor()); } if (strokeShader != null) { paint.setShader(strokeShader); } canvas.drawLine(fromX, fromY, toX, toY, paint); }
Example #15
Source File: RichPolyline.java From richmaps with Apache License 2.0 | 5 votes |
protected void drawStroke(final Bitmap bitmap, final Projection projection, final List<RichPoint> points2Draw, final int paddingLeft, final int paddingTop, final int paddingRight, final int paddingBottom) { Canvas canvas = new Canvas(bitmap); Paint paint = getDefaultStrokePaint(); RichPoint firstPoint = null; boolean first = true; RichPoint lastPoint = null; for (RichPoint point : points2Draw) { paint = getDefaultStrokePaint(); LatLng position = point.getPosition(); if (position != null) { if (first) { firstPoint = point; first = false; } if (point.getColor() == null) { point.color(strokeColor); } if (lastPoint != null) { drawSegment(canvas, paint, projection, lastPoint, point, paddingLeft, paddingTop, paddingRight, paddingBottom); } lastPoint = point; } } if (closed && firstPoint != null && lastPoint != null) { drawSegment(canvas, paint, projection, lastPoint, firstPoint, paddingLeft, paddingTop, paddingRight, paddingBottom); } }
Example #16
Source File: ClustersBuilder.java From clusterkraf with Apache License 2.0 | 5 votes |
void addAll(ArrayList<InputPoint> points) { if (points != null) { Projection projection = getProjection(); VisibleRegion visibleRegion = getVisibleRegion(); if (projection != null && visibleRegion != null) { LatLngBounds bounds = getExpandedBounds(visibleRegion.latLngBounds); for (InputPoint point : points) { addIfNecessary(point, projection, bounds); } } } }
Example #17
Source File: RichShape.java From richmaps with Apache License 2.0 | 5 votes |
public void draw(final Bitmap bitmap, final Projection projection, final int paddingLeft, final int paddingTop, final int paddingRight, final int paddingBottom) { if (bitmap == null || projection == null) { throw new IllegalStateException("Bitmap and Projection cannot be null"); } if (boundsIntersects(projection.getVisibleRegion().latLngBounds)) { doDraw(bitmap, projection, paddingLeft, paddingTop, paddingRight, paddingBottom); } }
Example #18
Source File: ClustersBuilder.java From clusterkraf with Apache License 2.0 | 5 votes |
private void addIfNecessary(InputPoint point, Projection projection, LatLngBounds bounds) { if (bounds != null && bounds.contains(point.getMapPosition()) && !releventInputPointsSet.contains(point)) { point.buildScreenPosition(projection); relevantInputPointsList.add(point); releventInputPointsSet.add(point); } }
Example #19
Source File: RichLayer.java From richmaps with Apache License 2.0 | 5 votes |
private Bitmap draw(final Bitmap bitmap, final Projection projection, final List<RichShape> shapes) { for (RichShape shape : shapes) { shape.draw(bitmap, projection, paddingLeft, paddingTop, paddingRight, paddingBottom); } return bitmap; }
Example #20
Source File: RichLayer.java From richmaps with Apache License 2.0 | 5 votes |
private Bitmap draw(final Bitmap bitmap, final Projection projection) { Set<Integer> zIndices = shapes.keySet(); for (Integer zIndex : zIndices) { draw(bitmap, projection, shapes.get(zIndex)); } return bitmap; }
Example #21
Source File: ClustersBuilder.java From clusterkraf with Apache License 2.0 | 4 votes |
private Projection getProjection() { return projectionRef.get(); }
Example #22
Source File: Clusterkraf.java From clusterkraf with Apache License 2.0 | 4 votes |
private void startClusterTransitionsBuildingTask(Projection projection) { clusterTransitionsBuildingTaskHost = new ClusterTransitionsBuildingTaskHost(); clusterTransitionsBuildingTaskHost.executeTask(projection); clusteringTaskHost = null; }
Example #23
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
public void setProjection(Projection projection) { this.mProjection = projection; }
Example #24
Source File: ClusterTransitions.java From clusterkraf with Apache License 2.0 | 4 votes |
Builder(Projection projection, ArrayList<ClusterPoint> previousClusterPoints) { this.projectionRef = new WeakReference<Projection>(projection); this.previousClusterPoints = previousClusterPoints; }
Example #25
Source File: BasePoint.java From clusterkraf with Apache License 2.0 | 4 votes |
void buildScreenPosition(Projection projection) { if (projection != null && mapPosition != null) { screenPosition = projection.toScreenLocation(mapPosition); } }
Example #26
Source File: ClusterPoint.java From clusterkraf with Apache License 2.0 | 4 votes |
ClusterPoint(InputPoint initialPoint, Projection projection, boolean transition, LatLng overridePosition) { this(initialPoint, projection, transition); this.mapPosition = overridePosition; }
Example #27
Source File: ClusterPoint.java From clusterkraf with Apache License 2.0 | 4 votes |
ClusterPoint(InputPoint initialPoint, Projection projection, boolean transition) { this.mapPosition = initialPoint.getMapPosition(); this.transition = transition; add(initialPoint); buildScreenPosition(projection); }
Example #28
Source File: MessageQueueData.java From Curve-Fit with Apache License 2.0 | 4 votes |
public MessageQueueData(CurveOptions curveOptions, Projection projection) { this.curveOptions = curveOptions; this.projection = projection; }
Example #29
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override public void handleMessage(Message msg) { if (msg.what == TASK_FINISHED) { mViewModificationInProgress = false; if (mNextClusters != null) { // Run the task that was queued up. sendEmptyMessage(RUN_TASK); } return; } removeMessages(RUN_TASK); if (mViewModificationInProgress) { // Busy - wait for the callback. return; } if (mNextClusters == null) { // Nothing to do. return; } Projection projection = mMap.getProjection(); RenderTask renderTask; synchronized (this) { renderTask = mNextClusters; mNextClusters = null; mViewModificationInProgress = true; } renderTask.setCallback(new Runnable() { @Override public void run() { sendEmptyMessage(TASK_FINISHED); } }); renderTask.setProjection(projection); renderTask.setMapZoom(mMap.getCameraPosition().zoom); // It seems this cannot use a thread pool due to thread locking issues (#660) new Thread(renderTask).start(); }
Example #30
Source File: RichPolyline.java From richmaps with Apache License 2.0 | 4 votes |
@Override public void doDraw(final Bitmap bitmap, final Projection projection, final int paddingLeft, final int paddingTop, final int paddingRight, final int paddingBottom) { drawStroke(bitmap, projection, points, paddingLeft, paddingTop, paddingRight, paddingBottom); }