Java Code Examples for com.mapbox.mapboxsdk.geometry.LatLng#getLongitude()
The following examples show how to use
com.mapbox.mapboxsdk.geometry.LatLng#getLongitude() .
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: NavigationLauncherActivity.java From graphhopper-navigation-example with Apache License 2.0 | 6 votes |
@Override public void onDialogPositiveClick(DialogFragment dialog) { EditText jobId = dialog.getDialog().findViewById(R.id.job_id); // Check if it's a solution fetch if (jobId != null) { EditText vehicleId = dialog.getDialog().findViewById(R.id.vehicle_id); fetchVrpSolution(jobId.getText().toString(), vehicleId.getText().toString()); } // Check if it's a geocoding search EditText search = dialog.getDialog().findViewById(R.id.geocoding_input_id); if (search != null) { currentGeocodingInput = search.getText().toString(); showLoading(); String point = null; LatLng pointLatLng = this.mapboxMap.getCameraPosition().target; if (pointLatLng != null) point = pointLatLng.getLatitude() + "," + pointLatLng.getLongitude(); new FetchGeocodingTask(this, getString(R.string.gh_key)).execute(new FetchGeocodingConfig(currentGeocodingInput, getLanguageFromSharedPreferences().getLanguage(), 5, false, point, "default")); } }
Example 2
Source File: CircleContainer.java From AirMapSDK-Android with Apache License 2.0 | 6 votes |
public static ArrayList<LatLng> calculateCirclePoints(LatLng location, double radius) { int degreesBetweenPoints = 8; int numberOfPoints = (int) Math.floor(360 / degreesBetweenPoints); double distRadians = radius / 6371000.0; // earth radius in meters double centerLatRadians = location.getLatitude() * Math.PI / 180; double centerLonRadians = location.getLongitude() * Math.PI / 180; ArrayList<LatLng> polygons = new ArrayList<>(); //array to hold all the path for (int index = 0; index < numberOfPoints; index++) { double degrees = index * degreesBetweenPoints; double degreeRadians = degrees * Math.PI / 180; double pointLatRadians = Math.asin(Math.sin(centerLatRadians) * Math.cos(distRadians) + Math.cos(centerLatRadians) * Math.sin(distRadians) * Math.cos(degreeRadians)); double pointLonRadians = centerLonRadians + Math.atan2(Math.sin(degreeRadians) * Math.sin(distRadians) * Math.cos(centerLatRadians), Math.cos(distRadians) - Math.sin(centerLatRadians) * Math.sin(pointLatRadians)); double pointLat = pointLatRadians * 180 / Math.PI; double pointLon = pointLonRadians * 180 / Math.PI; polygons.add(new LatLng(pointLat, pointLon)); } return polygons; }
Example 3
Source File: AnnotationsFactory.java From AirMapSDK-Android with Apache License 2.0 | 6 votes |
public ArrayList<LatLng> polygonCircleForCoordinate(LatLng location, double radius) { int degreesBetweenPoints = 8; int numberOfPoints = (int) Math.floor(360 / degreesBetweenPoints); double distRadians = radius / 6371000.0; // earth radius in meters double centerLatRadians = location.getLatitude() * Math.PI / 180; double centerLonRadians = location.getLongitude() * Math.PI / 180; ArrayList<LatLng> polygons = new ArrayList<>(); //array to hold all the points for (int index = 0; index < numberOfPoints; index++) { double degrees = index * degreesBetweenPoints; double degreeRadians = degrees * Math.PI / 180; double pointLatRadians = Math.asin(Math.sin(centerLatRadians) * Math.cos(distRadians) + Math.cos(centerLatRadians) * Math.sin(distRadians) * Math.cos(degreeRadians)); double pointLonRadians = centerLonRadians + Math.atan2(Math.sin(degreeRadians) * Math.sin(distRadians) * Math.cos(centerLatRadians), Math.cos(distRadians) - Math.sin(centerLatRadians) * Math.sin(pointLatRadians)); double pointLat = pointLatRadians * 180 / Math.PI; double pointLon = pointLonRadians * 180 / Math.PI; LatLng point = new LatLng(pointLat, pointLon); polygons.add(point); } return polygons; }
Example 4
Source File: MapTileLayerArray.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public LatLng getCenterCoordinate() { float latitude = 0; float longitude = 0; int nb = 0; synchronized (mTileProviderList) { for (final MapTileModuleLayerBase tileProvider : mTileProviderList) { LatLng providerCenter = tileProvider.getCenterCoordinate(); if (providerCenter != null) { latitude += providerCenter.getLatitude(); longitude += providerCenter.getLongitude(); nb++; } } } if (nb > 0) { latitude /= nb; longitude /= nb; return new LatLng(latitude, longitude); } return null; }
Example 5
Source File: CheckinData.java From android with MIT License | 5 votes |
public CheckinData(long id, long checkinAt, long checkoutAt, String address, LatLng latLng) { this.id = id; this.checkinAt = new Date(checkinAt); this.checkoutAt = !Long.valueOf(Const.UNKNOWN_VALUE).equals(checkoutAt) ? new Date(checkoutAt) : null; this.address = address; this.latitude = latLng.getLatitude(); this.longitude = latLng.getLongitude(); }
Example 6
Source File: IntentUtils.java From android with MIT License | 5 votes |
public static Intent getDirectionsIntent(LatLng origin, LatLng destination) { if (destination == null) { return null; } final String sDestination = destination.getLatitude() + "," + destination.getLongitude(); final String sOrigin = (origin != null ? origin.getLatitude() + "," + origin.getLongitude() : ""); final Uri uri = Uri.parse(String.format(GOOGLE_MAPS, sOrigin, sDestination)); return new Intent(Intent.ACTION_VIEW, uri); }
Example 7
Source File: UserLocationOverlay.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
public boolean goToMyPosition(final boolean animated) { if (mLocation == null) { return false; } float currentZoom = mMapView.getZoomLevel(false); if (currentZoom <= mRequiredZoomLevel) { double requiredZoom = mRequiredZoomLevel; if (mZoomBasedOnAccuracy && mMapView.isLayedOut()) { double delta = (mLocation.getAccuracy() / 110000) * 1.2; // approx. meter per degree latitude, plus some margin final Projection projection = mMapView.getProjection(); LatLng desiredSouthWest = new LatLng(mLocation.getLatitude() - delta, mLocation.getLongitude() - delta); LatLng desiredNorthEast = new LatLng(mLocation.getLatitude() + delta, mLocation.getLongitude() + delta); float pixelRadius = Math.min(mMapView.getMeasuredWidth(), mMapView.getMeasuredHeight()) / 2; BoundingBox currentBox = projection.getBoundingBox(); if (desiredNorthEast.getLatitude() != currentBox.getLatNorth() || desiredNorthEast.getLongitude() != currentBox.getLonEast() || desiredSouthWest.getLatitude() != currentBox.getLatSouth() || desiredSouthWest.getLongitude() != currentBox.getLonWest()) { mMapView.zoomToBoundingBox(new BoundingBox(desiredNorthEast, desiredSouthWest), true, animated, true); } } else if (animated) { return mMapController.setZoomAnimated((float) requiredZoom, mLatLng, true, false); } else { mMapController.setZoom((float) requiredZoom, mLatLng, false); } } else if (animated) { return mMapController.animateTo(mLatLng); } else { return mMapController.goTo(mLatLng, new PointF(0, 0)); } return true; }
Example 8
Source File: GeoUtils.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Build a BoundingBox for a List of LatLng * @param coordinates List of coordinates * @param padding Option padding. Recommended 0.01. Send in null to have no padding applied * @return BoundingBox containing the given List of LatLng */ public static BoundingBox findBoundingBoxForGivenLocations(List<LatLng> coordinates, Double padding) { double west = 0.0; double east = 0.0; double north = 0.0; double south = 0.0; for (int lc = 0; lc < coordinates.size(); lc++) { LatLng loc = coordinates.get(lc); if (lc == 0) { north = loc.getLatitude(); south = loc.getLatitude(); west = loc.getLongitude(); east = loc.getLongitude(); } else { if (loc.getLatitude() > north) { north = loc.getLatitude(); } else if (loc.getLatitude() < south) { south = loc.getLatitude(); } if (loc.getLongitude() < west) { west = loc.getLongitude(); } else if (loc.getLongitude() > east) { east = loc.getLongitude(); } } } // OPTIONAL - Add some extra "padding" for better map display if (padding != null) { north = north + padding; south = south - padding; west = west - padding; east = east + padding; } return new BoundingBox(north, east, south, west); }
Example 9
Source File: MapActivity.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void saveMapPosition() { LatLng c = mapView.getCenter(); float lat = (float) c.getLatitude(); float lng = (float) c.getLongitude(); float z = mapView.getZoomLevel(); SharedPreferences.Editor editor = getPreferences(Context.MODE_PRIVATE).edit(); editor.putFloat(PREVIOUS_LAT, lat); editor.putFloat(PREVIOUS_LNG, lng); editor.putFloat(PREVIOUS_ZOOM, z); editor.apply(); }
Example 10
Source File: OSMNode.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * This constructor is used when we are creating an new OSMElement, * such as when a new Node is created. This constructor assumes * that we are creating a NEW element in the current survey. */ public OSMNode(LatLng latLng) { super(); // super sets the element to be modified lat = latLng.getLatitude(); lng = latLng.getLongitude(); }
Example 11
Source File: OSMNode.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * This moves an OSMNode to a new location on the map. * * The LatLng in the node is reset, the LatLng in the * marker is reset, and the node is removed and replaced * in the JTSModel's spatial index. * * @param jtsModel - the model in which the node is spatially indexed * @param latLng - the new location to move the node to */ public void move(JTSModel jtsModel, LatLng latLng) { lat = latLng.getLatitude(); lng = latLng.getLongitude(); jtsModel.removeOSMElement(this); jtsModel.addOSMStandaloneNode(this); if (marker != null) { marker.setPoint(latLng); } }