private LatLng getMapCenter(){ VisibleRegion visibleRegion = mGoogleMap.getProjection() .getVisibleRegion(); Point x = mGoogleMap.getProjection().toScreenLocation( visibleRegion.farRight); Point y = mGoogleMap.getProjection().toScreenLocation( visibleRegion.nearLeft); Point centerPoint = new Point(x.x / 2, y.y / 2); LatLng centerFromPoint = mGoogleMap.getProjection().fromScreenLocation( centerPoint); return centerFromPoint; }
/** * Return the visible region of the map * Thanks @fschmidt */ @SuppressWarnings("unused") private void getVisibleRegion(final JSONArray args, final CallbackContext callbackContext) throws JSONException { VisibleRegion visibleRegion = map.getProjection().getVisibleRegion(); LatLngBounds latLngBounds = visibleRegion.latLngBounds; JSONObject result = new JSONObject(); JSONObject northeast = new JSONObject(); JSONObject southwest = new JSONObject(); northeast.put("lat", latLngBounds.northeast.latitude); northeast.put("lng", latLngBounds.northeast.longitude); southwest.put("lat", latLngBounds.southwest.latitude); southwest.put("lng", latLngBounds.southwest.longitude); result.put("northeast", northeast); result.put("southwest", southwest); JSONArray latLngArray = new JSONArray(); latLngArray.put(northeast); latLngArray.put(southwest); result.put("latLngArray", latLngArray); callbackContext.success(result); }
/** * Suggest an initial radius (in meters) for the quiet place based on the * current zoom level of the map. * <p/> * Current process: * * Get the bounding box of the current map view * * Find the shortest dimension (horizontal or vertical) * * Get the distance in meters of that dimension * * Suggest the radius as 1/8th of that. * * @return suggested radius in meters */ public double getSuggestedRadius() { VisibleRegion region = getMap().getProjection().getVisibleRegion(); double horizontalDistance = getDistance(region.farLeft, region.farRight); double verticalDistance = getDistance(region.nearLeft, region.farLeft); double chosenDimension = horizontalDistance; if (verticalDistance < horizontalDistance) { chosenDimension = verticalDistance; } double radius = chosenDimension * Config.SUGGESTED_RADIUS_MULTIPLIER; if (radius < Config.QP_SIZE_FLOOR) { radius = Config.QP_SIZE_FLOOR; } return radius; }
public VisibleRegion getVisibleRegion() { Parcel localParcel1 = Parcel.obtain(); Parcel localParcel2 = Parcel.obtain(); try { localParcel1.writeInterfaceToken("com.google.android.gms.maps.internal.IProjectionDelegate"); this.dU.transact(3, localParcel1, localParcel2, 0); localParcel2.readException(); VisibleRegion localVisibleRegion; if (localParcel2.readInt() != 0) localVisibleRegion = VisibleRegion.CREATOR.createFromParcel(localParcel2); else localVisibleRegion = null; return localVisibleRegion; } finally { localParcel2.recycle(); localParcel1.recycle(); } }
@Before public void init() { Mockito.when(map.getCameraPosition()).thenReturn(new CameraPosition(new LatLng(0, 0), 8, 0, 0)); Mockito.when(map.getProjection()).thenReturn(projection); Mockito.when(projection.getVisibleRegion()).thenReturn(new VisibleRegion(new LatLng(-1, -1), new LatLng(-1, 1), new LatLng(1, -1), new LatLng(1, 1), new LatLngBounds(new LatLng(-1, -1), new LatLng(1, 1)))); Mockito.when(marker1.isVisible()).thenReturn(true); Mockito.when(marker1.getPosition()).thenReturn(new LatLng(0, 0)); Mockito.when(marker2.isVisible()).thenReturn(true); Mockito.when(marker2.getPosition()).thenReturn(new LatLng(50, 50)); Mockito.when(marker3.isVisible()).thenReturn(true); Mockito.when(marker3.getPosition()).thenReturn(new LatLng(0.1, 0.1)); ClusteringSettings settings = new ClusteringSettings().addMarkersDynamically(true); strategy = new GridClusteringStrategy(settings, map, new ArrayList<DelegatingMarker>(), refresher); }
protected void setExtents() { if (map != null) { VisibleRegion region = map.getProjection().getVisibleRegion(); double ullon = region.farLeft.longitude; double ullat = region.farLeft.latitude; double lrlon = region.nearRight.longitude; double lrlat = region.nearRight.latitude; //set the geo extents utility.SetExtents(ullon, lrlon, ullat, lrlat); //set the pixels extents android.graphics.Point ul = map.getProjection().toScreenLocation(region.farLeft); android.graphics.Point lr = map.getProjection().toScreenLocation(region.nearRight); double width = lr.x - ul.x; double height = lr.y - ul.y; utility.set_displayPixelsWidth(width); utility.set_displayPixelsHeight(height); } return; }
public void onCameraChange(CameraPosition position) { LatLng pos = mMarker.getPosition(); final Projection proj = mMap.getProjection(); final VisibleRegion vr = proj.getVisibleRegion(); final LatLng farLeft = vr.farLeft; final LatLng farRight = vr.farRight; final LatLng nearLeft = vr.nearLeft; final LatLng nearRight = vr.nearRight; double screenLat = Math.abs(farLeft.latitude - nearRight.latitude) / 2.0; double screenLng = Math.abs(farLeft.longitude - nearRight.longitude) / 2.0; double latDiff = Math.abs(mInit.latitude - position.target.latitude); double lngDiff = Math.abs(mInit.longitude - position.target.longitude); if (latDiff > screenLat || lngDiff > screenLng) { double cLat = mMap.getCameraPosition().target.latitude; double cLng = mMap.getCameraPosition().target.longitude; mInit = new LatLng(cLat, cLng); mMarker.position(mInit); mMap.clear(); mMap.addMarker(mMarker); } }
private void calculateVisibleClusters() { IProjection projection = map.getProjection(); VisibleRegion visibleRegion = projection.getVisibleRegion(); LatLngBounds bounds = visibleRegion.latLngBounds; visibleClusters[0] = convLat(bounds.southwest.latitude); visibleClusters[1] = convLng(bounds.southwest.longitude); visibleClusters[2] = convLat(bounds.northeast.latitude); visibleClusters[3] = convLng(bounds.northeast.longitude); }
private void showMarkersInVisibleRegion() { IProjection projection = map.getProjection(); VisibleRegion visibleRegion = projection.getVisibleRegion(); visibleRegionBounds = visibleRegion.latLngBounds; Iterator<DelegatingMarker> iterator = markers.iterator(); while (iterator.hasNext()) { DelegatingMarker marker = iterator.next(); if (visibleRegionBounds.contains(marker.getPosition())) { marker.changeVisible(true); iterator.remove(); } } }
/** * Intersects using the Winding Number Algorithm * @ref http://www.nttpc.co.jp/company/r_and_d/technology/number_algorithm.html * @param path * @param point * @return */ private boolean isPolygonContains(List<LatLng> path, LatLng point) { int wn = 0; Projection projection = map.getProjection(); VisibleRegion visibleRegion = projection.getVisibleRegion(); LatLngBounds bounds = visibleRegion.latLngBounds; Point sw = projection.toScreenLocation(bounds.southwest); Point touchPoint = projection.toScreenLocation(point); touchPoint.y = sw.y - touchPoint.y; double vt; for (int i = 0; i < path.size() - 1; i++) { Point a = projection.toScreenLocation(path.get(i)); a.y = sw.y - a.y; Point b = projection.toScreenLocation(path.get(i + 1)); b.y = sw.y - b.y; if ((a.y <= touchPoint.y) && (b.y > touchPoint.y)) { vt = ((double)touchPoint.y - (double)a.y) / ((double)b.y - (double)a.y); if (touchPoint.x < ((double)a.x + (vt * ((double)b.x - (double)a.x)))) { wn++; } } else if ((a.y > touchPoint.y) && (b.y <= touchPoint.y)) { vt = ((double)touchPoint.y - (double)a.y) / ((double)b.y - (double)a.y); if (touchPoint.x < ((double)a.x + (vt * ((double)b.x - (double)a.x)))) { wn--; } } } return (wn != 0); }
public VisibleMapArea getVisibleMapArea(){ final GoogleMap map = getMap(); if(map == null) return null; final VisibleRegion mapRegion = map.getProjection().getVisibleRegion(); return new VisibleMapArea(MapUtils.latLngToCoord(mapRegion.farLeft), MapUtils.latLngToCoord(mapRegion.nearLeft), MapUtils.latLngToCoord(mapRegion.nearRight), MapUtils.latLngToCoord(mapRegion.farRight)); }
public final VisibleRegion a() { try { VisibleRegion localVisibleRegion = this.a.a(); return localVisibleRegion; } catch (RemoteException localRemoteException) { throw new bm(localRemoteException); } }
public final VisibleRegion getVisibleRegion() { try { VisibleRegion localVisibleRegion = this.Ce.getVisibleRegion(); return localVisibleRegion; } catch (RemoteException localRemoteException) { throw new RuntimeRemoteException(localRemoteException); } }
private void updateSlider() { if (null != mCircle) { mSlider.setEnabled(true); VisibleRegion region = mMap.getProjection().getVisibleRegion(); double dist = Utils.distance(region.farLeft, region.farRight, DistanceUnit.Kilometers) * 1000; mSlider.setMax(mSlider.getMeasuredWidth()); mSlider.setProgress((int) (mSlider.getMeasuredWidth() * mCircle.getRadius() * 2 / dist)); } else { mSlider.setEnabled(false); } }
private void updateCircleRadius(int progress) { VisibleRegion region = mMap.getProjection().getVisibleRegion(); double dist = Utils.distance(region.farLeft, region.farRight, DistanceUnit.Kilometers) * 1000; double radius = progress / (float) mSlider.getMax() * dist / 2.0f; mCircle.setRadius(radius); }
private void notifyNewCameraPosition() { MapListener mapListener = this.mapListenerWR == null ? null : this.mapListenerWR.get(); if (mapListener == null) { return; } ExtendedGoogleMap googleMap = getGoogleMapOrNull(); if (googleMap == null) { return; } VisibleRegion visibleRegion = googleMap.getProjection().getVisibleRegion(); mapListener.onCameraChange(visibleRegion.latLngBounds); }
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); } }
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); } } } }
@Override public VisibleRegion getVisibleRegion() { return projection.getVisibleRegion(); }
public LocationSearchTask(VisibleRegion vis, float bearing) { super(); mVis = vis; mBearing = bearing; }
public boolean onTransact(int paramInt1, Parcel paramParcel1, Parcel paramParcel2, int paramInt2) { switch (paramInt1) { default: return super.onTransact(paramInt1, paramParcel1, paramParcel2, paramInt2); case 1598968902: paramParcel2.writeString("com.google.android.gms.maps.internal.IProjectionDelegate"); return true; case 1: paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); LatLng localLatLng2 = a(eva.a(paramParcel1.readStrongBinder())); paramParcel2.writeNoException(); if (localLatLng2 != null) { paramParcel2.writeInt(1); localLatLng2.writeToParcel(paramParcel2, 1); } for (;;) { return true; paramParcel2.writeInt(0); } case 2: paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); if (paramParcel1.readInt() != 0) {} for (LatLng localLatLng1 = fkg.a(paramParcel1);; localLatLng1 = null) { euz localeuz = a(localLatLng1); paramParcel2.writeNoException(); IBinder localIBinder = null; if (localeuz != null) { localIBinder = localeuz.asBinder(); } paramParcel2.writeStrongBinder(localIBinder); return true; } } paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); VisibleRegion localVisibleRegion = a(); paramParcel2.writeNoException(); if (localVisibleRegion != null) { paramParcel2.writeInt(1); localVisibleRegion.writeToParcel(paramParcel2, 1); } for (;;) { return true; paramParcel2.writeInt(0); } }
public fyc a() { VisibleRegion localVisibleRegion = this.a.a(); return new fyc(new fxw(localVisibleRegion.b.b, localVisibleRegion.b.c), new fxw(localVisibleRegion.c.b, localVisibleRegion.c.c), new fxw(localVisibleRegion.d.b, localVisibleRegion.d.c), new fxw(localVisibleRegion.e.b, localVisibleRegion.e.c), new fxx(localVisibleRegion.f)); }
public boolean onTransact(int paramInt1, Parcel paramParcel1, Parcel paramParcel2, int paramInt2) { switch (paramInt1) { default: break; case 1598968902: paramParcel2.writeString("com.google.android.gms.maps.internal.IProjectionDelegate"); return true; case 1: paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); LatLng localLatLng2 = fromScreenLocation(b.a.E(paramParcel1.readStrongBinder())); paramParcel2.writeNoException(); if (localLatLng2 != null) { paramParcel2.writeInt(1); localLatLng2.writeToParcel(paramParcel2, 1); } else { paramParcel2.writeInt(0); } return true; case 2: paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); LatLng localLatLng1; if (paramParcel1.readInt() != 0) localLatLng1 = LatLng.CREATOR.createFromParcel(paramParcel1); else localLatLng1 = null; b localb = toScreenLocation(localLatLng1); paramParcel2.writeNoException(); IBinder localIBinder; if (localb != null) localIBinder = localb.asBinder(); else localIBinder = null; paramParcel2.writeStrongBinder(localIBinder); return true; case 3: paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); VisibleRegion localVisibleRegion = getVisibleRegion(); paramParcel2.writeNoException(); if (localVisibleRegion != null) { paramParcel2.writeInt(1); localVisibleRegion.writeToParcel(paramParcel2, 1); } else { paramParcel2.writeInt(0); } return true; } return super.onTransact(paramInt1, paramParcel1, paramParcel2, paramInt2); }
@Override public VisibleRegion getVisibleRegion() throws RemoteException { viewport.getMapExtents(extents, 0); // TODO: Support non-flat map extents return new VisibleRegion(GmsMapsTypeHelper.toLatLngBounds(viewport.getBBox(null, 0))); }
private VisibleRegion getVisibleRegion() { return visibleRegionRef.get(); }
public boolean onTransact(int paramInt1, Parcel paramParcel1, Parcel paramParcel2, int paramInt2) { switch (paramInt1) { default: return super.onTransact(paramInt1, paramParcel1, paramParcel2, paramInt2); case 1598968902: paramParcel2.writeString("com.google.android.gms.maps.internal.IProjectionDelegate"); return true; case 1: paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); LatLng localLatLng2 = a(ah.a(paramParcel1.readStrongBinder())); paramParcel2.writeNoException(); if (localLatLng2 != null) { paramParcel2.writeInt(1); localLatLng2.writeToParcel(paramParcel2, 1); } while (true) { return true; paramParcel2.writeInt(0); } case 2: paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); if (paramParcel1.readInt() != 0); for (LatLng localLatLng1 = h.a(paramParcel1); ; localLatLng1 = null) { af localaf = a(localLatLng1); paramParcel2.writeNoException(); IBinder localIBinder = null; if (localaf != null) localIBinder = localaf.asBinder(); paramParcel2.writeStrongBinder(localIBinder); return true; } case 3: } paramParcel1.enforceInterface("com.google.android.gms.maps.internal.IProjectionDelegate"); VisibleRegion localVisibleRegion = a(); paramParcel2.writeNoException(); if (localVisibleRegion != null) { paramParcel2.writeInt(1); localVisibleRegion.writeToParcel(paramParcel2, 1); } while (true) { return true; paramParcel2.writeInt(0); } }
VisibleRegion getVisibleRegion();
public abstract VisibleRegion a();