/** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * This is where we can add markers or lines, add listeners or move the camera. In this case, * we just add a marker near Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney and move the camera Log.e("zzzz"+MainActivity.mylocationa, ""+MainActivity.myLocationb); LatLng sydney = new LatLng(MainActivity.lat,MainActivity.longi); mMap.addMarker(new MarkerOptions().position(sydney).title("Marker at your location")); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney,16)); Toast.makeText(getApplicationContext(),"At the height of "+MainActivity.diffelevation+" metres",Toast.LENGTH_LONG).show(); }
private void showMarkers() { googleMap.clear(); Observable .fromIterable(currentDevices) .subscribe(device -> { Location center = GeoHash.fromString(device.getGeoHash()).getCenter(); Marker marker = googleMap.addMarker(new MarkerOptions() .position(new LatLng(center.getLatitude(), center.getLongitude())) .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher)) .flat(true) .title(device.getName()) .snippet(device.getAddress()) ); Bitmap bitmap = Device.getBitmapImage(device.getImage(), getResources()); Bitmap bmp = Bitmap.createScaledBitmap(bitmap, markerSize, markerSize, false); bitmap.recycle(); marker.setIcon(BitmapDescriptorFactory.fromBitmap(bmp)); }); }
public LinkedHashMap<String,String> getDirectionsUrl(LatLng origin, LatLng dest){ LinkedHashMap<String,String> map = new LinkedHashMap<>(); map.put("origin",origin.latitude+","+origin.longitude); map.put("destination",dest.latitude+","+dest.longitude); map.put("sensor","false"); map.put("units","metric"); if (modeType!=null){ map.put(MODE,modeType.getName()); } else{ map.put(MODE, Mode.DRIVING.getName()); } return map; }
public static QuestionAnswerManager.QuestionAnswers getQuestionAnswers(LatLng latLng, int qaId) { JSONObject obj = qa.get(latLng); String questionKey = "Question" + qaId; String question = ""; List<String> answers = new ArrayList<>(); String answerKey = "Answer" + qaId; try { question = obj.getString(questionKey); for (int i = 1; i <= 3; i++) { answers.add(obj.getString(answerKey + i)); } } catch (JSONException e) { e.printStackTrace(); } return new QuestionAnswers(question, answers); }
/** * Build a bounding box using the location coordinate click location and map view bounds * * @param latLng click location * @param mapBounds map bounds * @return bounding box * @since 1.2.7 */ public BoundingBox buildClickBoundingBox(LatLng latLng, BoundingBox mapBounds) { // Get the screen width and height a click occurs from a feature double width = TileBoundingBoxMapUtils.getLongitudeDistance(mapBounds) * screenClickPercentage; double height = TileBoundingBoxMapUtils.getLatitudeDistance(mapBounds) * screenClickPercentage; LatLng leftCoordinate = SphericalUtil.computeOffset(latLng, width, 270); LatLng upCoordinate = SphericalUtil.computeOffset(latLng, height, 0); LatLng rightCoordinate = SphericalUtil.computeOffset(latLng, width, 90); LatLng downCoordinate = SphericalUtil.computeOffset(latLng, height, 180); BoundingBox boundingBox = new BoundingBox(leftCoordinate.longitude, downCoordinate.latitude, rightCoordinate.longitude, upCoordinate.latitude); return boundingBox; }
private void updateUI() { if (mMap == null || mMapImage == null) { return; } Log.d(TAG, "updateUI: "); LatLng itemPoint = new LatLng(mMapItem.getLat(), mMapItem.getLon()); LatLng myPoint = new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()); BitmapDescriptor itemBitmap = BitmapDescriptorFactory.fromBitmap(mMapImage); MarkerOptions itemMarker = new MarkerOptions() .position(itemPoint) .icon(itemBitmap); MarkerOptions myMarker = new MarkerOptions() .position(myPoint); mMap.clear(); mMap.addMarker(itemMarker); mMap.addMarker(myMarker); LatLngBounds bounds = new LatLngBounds.Builder() .include(itemPoint) .include(myPoint) .build(); int margin = getResources().getDimensionPixelSize(R.dimen.map_inset_margin); CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin); mMap.animateCamera(update); }
public void showPermissionGranted(String permission) { makeInitialRequest(); if (getActivity() != null) { LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && getActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { notificationManager.showMessage(getString(R.string.no_location)); map.setMyLocationEnabled(false); } else { map.setMyLocationEnabled(true); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); map.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() { @Override public boolean onMyLocationButtonClick() { if (userLocation != null) { LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16)); } return true; } }); } } } }
public boolean isClosestGate(LatLng point){ int gate=Integer.MAX_VALUE; float minDistance=Float.MAX_VALUE; Location loca1 = new Location(""); loca1.setLatitude(point.latitude); loca1.setLongitude(point.longitude); int count=0; for(String iterator:delegate.gateNameArray()){ Location loca2 = new Location(""); loca2.setLatitude(Double.parseDouble(delegate.gateLatArray()[count])); loca2.setLongitude(Double.parseDouble(delegate.gateLongArray()[count])); float distance = loca1.distanceTo(loca2); if(distance <= minDistance){ gate = count; minDistance = distance; } count++; } if(gate == this.gatePosition) return true; else return false; }
@Override protected Integer doInBackground(String... params) { android.location.Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); int times = 0; while (location == null && times < 20){ try { Thread.sleep(500); } catch (InterruptedException e) { } location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); times++; } if (location != null) { final CameraPosition position = new CameraPosition.Builder() .target(new LatLng(location.getLatitude(), location.getLongitude())) .zoom(14.0f).build(); getActivity().runOnUiThread(new Runnable() { public void run() { map.animateCamera(CameraUpdateFactory.newCameraPosition(position)); } }); } return null; }
public void PlacePinAndPositionCamera(LatLng addressPosition) { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(addressPosition); mMap.addMarker(markerOptions .title("Crisis Location").icon(BitmapDescriptorFactory .defaultMarker(BitmapDescriptorFactory.HUE_RED))); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(addressPosition, 12)); LatLngBounds.Builder builder = new LatLngBounds.Builder(); builder.include(addressPosition); LatLngBounds bounds = builder.build(); int padding = 150; // offset from edges of the map in pixels CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding); mMap.animateCamera(cu); }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources() .getString(R.string.style_json))); if (!success) { Log.e("Style", "Style parsing failed."); } LatLng jakarta = new LatLng(-6.232812, 106.820933); LatLng southjakarta = new LatLng(-6.22865,106.8151753); mMap.addMarker(new MarkerOptions().position(jakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Pickup Location", R.drawable.dot_pickup)))); mMap.addMarker(new MarkerOptions().position(southjakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Dropoff Location", R.drawable.dot_dropoff)))); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(jakarta, 15f)); }
public void addGateway(Packet packet) { for (Gateway gateway : packet.getGateways()) { double gwLat = gateway.getLatitude(); double gwLon = gateway.getLongitude(); if (gwLat != 0 && gwLon != 0) { String gatewayId = gateway.getGatewayID(); if (gatewaysWithMarkers.contains(gatewayId)) { //already has a marker for this gateway } else { MarkerOptions gwoptions = new MarkerOptions(); gwoptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.gateway_dot)); gwoptions.position(new LatLng(gwLat, gwLon)); gwoptions.title(gatewayId); //gwoptions.snippet(gatewayId); gwoptions.anchor((float) 0.5, (float) 0.5); mMap.addMarker(gwoptions); gatewaysWithMarkers.add(gatewayId); } } } }
/** * For actually moving the map to the desired location. * @param fctx * @param loc */ public static void gotoLocation(Activity fctx, Location loc) { Location locc = loc; sloc = loc; if(loc == null){ locc = getCurrentLocation(fctx); } if(code == AddHabitEventActivity.EVENT_PERMISSION_CHECK){ } float zoom = 15.0f; if(locc == null){ DummyMainActivity.toastMe("Could not get location", fctx); }else{ double[] d = {locc.getLatitude(), locc.getLongitude()}; AddHabitEventActivity.setLocation(d); LatLng ll = new LatLng(locc.getLatitude(), locc.getLongitude()); CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll, zoom); gmap.moveCamera(update); } }
/** * Add map markers for all events that have valid locations */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; LatLngBounds.Builder builder = new LatLngBounds.Builder(); // whether there is atleast one event with a location to be displayed on the map or not boolean atleastOneEvent = false; for (CompletedEventDisplay event : events){ Location location = event.getLocation(); if (location != null){ LatLng coordinates = new LatLng(location.getLatitude(), location.getLongitude()); builder.include(coordinates); atleastOneEvent = true; mMap.addMarker(new MarkerOptions().position(coordinates).title(event.getDescriptionWithLocation(this))); } } /** * This, along with the LatLngBounds.Builder part of this method is based off of andr's answer: * https://stackoverflow.com/a/14828739 * * The width, height, padding aspects of newLatLngBounds() is from: * https://github.com/OneBusAway/onebusaway-android/issues/581 */ if (atleastOneEvent) { mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels, (int) Math.ceil(0.12 * getResources().getDisplayMetrics().widthPixels))); } else { // move the map to the device's current location Location deviceLoc = LocationUtilities.getLocation(this); if (deviceLoc != null) googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(deviceLoc.getLatitude(), deviceLoc.getLongitude()), 30)); } }
/** * Is the point near any points in the multi lat lng * * @param point point * @param multiLatLng multi lat lng * @param tolerance distance tolerance * @return true if near */ public static boolean isPointNearMultiLatLng(LatLng point, MultiLatLng multiLatLng, double tolerance) { boolean near = false; for (LatLng multiPoint : multiLatLng.getLatLngs()) { near = isPointNearPoint(point, multiPoint, tolerance); if (near) { break; } } return near; }
/** * Build a feature results information message and close the results * * @param results feature index results * @param tolerance distance tolerance * @param clickLocation map click location * @param projection desired geometry projection * @return results message or null if no results */ public String buildResultsInfoMessageAndClose(FeatureIndexResults results, double tolerance, LatLng clickLocation, Projection projection) { String message = null; try { message = buildResultsInfoMessage(results, tolerance, clickLocation, projection); } finally { results.close(); } return message; }
private static void setIntersection(Context context, GoogleMap gMap, LatLng latLng) { Marker marker = gMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_arrow))); mIntersectingToClear.add(marker); DatabaseHelper myDb = DatabaseHelper.getInstance(context); myDb.saveIntersections(mIntersecting); myDb.close(); }
private void showMyLocationMarker() { String str = "My Location"; // Log.e(TAG, "mCurrentLocation="+mCurrentLocation); if (null != mCurrentLocation) { mCurrentPosition = new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()); Geocoder geocoder = new Geocoder(getApplicationContext()); try { List<android.location.Address> addressList = geocoder.getFromLocation(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude(), 1); str = ""; if (addressList.get(0).getSubLocality() != null) { str = addressList.get(0).getSubLocality()+","; } str += addressList.get(0).getLocality(); // Log.d(TAG, "GEOCODER STARTED."); } catch (IOException e) { e.printStackTrace(); // Log.e(TAG, "GEOCODER DIDN'T WORK."); } if (myLocationMarker != null) { myLocationMarker.remove(); } myLocationMarker = mMap.addMarker(new MarkerOptions() .position(new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude())) .title(str)); myLocationMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.start_blue)); // mMap.animateCamera(CameraUpdateFactory.newLatLng( // new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()))); } }
private void setLocation(LatLng location){ CameraPosition cameraPosition = new CameraPosition.Builder() .target(location) // Sets the center of the map to Mountain View .zoom(13) // Sets the zoom .build(); // Creates a CameraPosition from the builder map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); }
/** * Method used to generate a JSONArray from a list of coordinates. */ public void addToJSONArray(JSONArray array, List<LatLng> item) throws Exception { JSONObject data = new JSONObject(); for(LatLng x : item) { data.put("latitude", x.latitude); data.put("longitude", x.longitude); } array.put(data); }
@Override public void initializeCurrentUserMarker(User userData) { LatLng currentUserLocation = new LatLng(userData.getLatitude(), userData.getLongitude()); builder = new LatLngBounds.Builder(); builder.include(currentUserLocation); currentMarker = setMarker(userData, currentUserLocation); currentMarker.setTitle("Jij"); // Initialize markers for other users ArrayList<User> initializedUsers = FirebaseHelper.getOtherUserMapMarkers(userList); initializeOtherUserMarkers(initializedUsers); }
private synchronized void checkDataAndMapReady() { if (isMapReady && isDatasetReady) { progressDialogHandler.dismiss(); runOnUiThread(() -> { googleMap.addPolyline( new PolylineOptions().clickable(true).add( timeLocationMap.values().toArray( new LatLng[timeLocationMap.size()] ) ) ); LatLngBounds.Builder latLongBoundsBuilder = new LatLngBounds.Builder(); for (LatLng latLng : timeLocationMap.values()) { latLongBoundsBuilder.include(latLng); } View mapFragmentView = mapFragment.getView(); if (timeLocationMap.size() != 0) { LatLngBounds latLngBounds = latLongBoundsBuilder.build(); if (mapFragmentView != null && googleMap != null) { mapFragmentView.post(() -> googleMap.moveCamera( // TODO Is mapCameraPadding w/ 150dp converted to px a good approach? Seems like maybe we'd prefer a geographic unit, aka 1 mile padding if that's possible? CameraUpdateFactory.newLatLngBounds(latLngBounds, mapCameraPadding))); } } }); isMapReady = false; isDatasetReady = false; } }
/** * Viene effettuata la ricerca delle coordinate tramite Google Geocoding API */ @Override protected String doInBackground(Void... params) { if (HelperRete.isNetworkAvailable(mMainActivity)) { String queryFormattata = mQueryGrezza.replaceAll(" ", "+" + ""); mQueryTitolo = mQueryGrezza.substring(0,1).toUpperCase() + mQueryGrezza.substring(1); // creazione url String url = "https://maps.google.com/maps/api/geocode/json" + "?address=" + queryFormattata + "&key=" + mMainActivity.getString(R.string.google_geoc_key); JSONObject response = HelperRete.volleySyncRequest(mMainActivity, url); // ottieni le coordinate dell'indirizzo tramite la risposta di GoogleApi try { if (response != null) { Log.i("jsonresp", response.toString()); double lng = ((JSONArray) response.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lng"); double lat = ((JSONArray) response.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lat"); mCoordinateCercate = new LatLng(lat, lng); return RICERCA_COMPLETATA; } } catch (JSONException e) { e.printStackTrace(); } } else { return NO_INTERNET; } return null; }
private List<LatLng> decodePoly(String encoded) { List<LatLng> poly = new ArrayList<LatLng>(); int index = 0, len = encoded.length(); int lat = 0, lng = 0; while (index < len) { int b, shift = 0, result = 0; do { b = encoded.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lat += dlat; shift = 0; result = 0; do { b = encoded.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lng += dlng; LatLng p = new LatLng((((double) lat / 1E5)), (((double) lng / 1E5))); poly.add(p); } return poly; }
@NonNull public Map<LatLng, SparseBooleanArray> getAnswerCorrectnessMap () { Map<LatLng, SparseBooleanArray> res = new HashMap<>(); for (LatLng id : pointMap.keySet()) { SparseBooleanArray isCorrectList = new SparseBooleanArray(); for (Score score : pointMap.get(id)) { isCorrectList.put(score.getQuestionId(), score.isCorrect()); } } return res; }
@Override public void onLocationChanged(Location l) { if (l != null) { userLocation = new LatLng(l.getLatitude(), l.getLongitude()); if (mUser.getUserID() != null) { mDatabase.child("users").child(mUser.getUserID()).child("latitude").setValue(userLocation.latitude); mDatabase.child("users").child(mUser.getUserID()).child("longitude").setValue(userLocation.longitude); } else { Toast.makeText(getApplicationContext(), "Current user not recognized. Try reauthenticating.", Toast.LENGTH_LONG).show(); } } }
@Override public void onReceive(Context context, Intent intent) { if (LocationResult.hasResult(intent)) { LocationResult locationResult = LocationResult.extractResult(intent); Location location = locationResult.getLastLocation(); if (location != null) { GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude()); adapter.notifyDataSetChanged(); } } }
public void Insertion(LatLng localLatLng, String out){ TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String imei = tm.getDeviceId(); Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); String formattedDate = df.format(c.getTime()); InsertToSqlite(imei, Double.toString(localLatLng.latitude), Double.toString(localLatLng.longitude), out); DBTransaction.InsertToDB(imei, Double.toString(localLatLng.latitude), Double.toString(localLatLng.longitude), formattedDate, out); }
@Test public void testUnconfirmUnresolveUnreport() throws ParseException, InterruptedException { Location mockLocation = LocationAdapter.getLocation(new LatLng(MOCK_LATITUDE, MOCK_LONGITUDE)); //CivifyMap.getInstance().setMockLocation(mockLocation); Issue mockIssue = mockIssue(USER_AUTH_TOKEN); mockIssue.setConfirmedByAuthUser(true); mockIssue.setResolvedByAuthUser(true); mockIssue.setReportedByAuthUser(true); mockIssue.showIssueDetails(); String userAuthToken = UserAdapter.getCurrentUser().getUserAuthToken(); sleep(2250); onView(withId(R.id.details_scrollview)).perform(swipeUp()); // Unconfirm issue mockResponse(ISSUE_WITH_AUTH_TOKEN + ISSUE_AUTH_TOKEN + UN + CONFIRMED_BY_USER_WITH_AUTH_TOKEN + userAuthToken); onView(withId(R.id.confirmButton)).perform(click()); onView(allOf(withId(android.support.design.R.id.snackbar_text), withText(getTargetContext().getString(R.string.unconfirm_message)))) .check(matches(isDisplayed())); // Unresolve issue mockResponse(RESOLUTION_DELETED); onView(withId(R.id.resolveButton)).perform(click()); onView(allOf(withId(android.support.design.R.id.snackbar_text), withText(getTargetContext().getString(R.string.unresolve_message)))) .check(matches(isDisplayed())); // Unreport issue mockResponse(ISSUE_WITH_AUTH_TOKEN + ISSUE_AUTH_TOKEN + UN + REPORTED_BY_USER_WITH_AUTH_TOKEN + userAuthToken); onView(withId(R.id.reportButton)).perform(click()); onView(allOf(withId(android.support.design.R.id.snackbar_text), withText(getTargetContext().getString(R.string.unreport_message)))) .check(matches(isDisplayed())); }
@Override public void hideHintAndShowMap() { super.hideHintAndShowMap(); LatLng currentLatLng = new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()); if(path.isEmpty() && CoordinatesUtility.get2DDistanceInKm(currentLatLng, poi) < KM_DISTANCE_HINT) { endMatch(); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_map, container, false); mMapView = (MapView) rootView.findViewById(R.id.mapView); mMapView.onCreate(savedInstanceState); mMapView.onResume(); // needed to get the map to display immediately try { MapsInitializer.initialize(getActivity().getApplicationContext()); } catch (Exception e) { e.printStackTrace(); } mMapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap mMap) { googleMap = mMap; // For dropping a marker at a point on the Map LatLng sydney = new LatLng(-34, 151); googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title").snippet("Marker Description")); // For zooming automatically to the location of the marker CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(12).build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } }); return rootView; }
@Override public void onMapReady(GoogleMap googleMap) { mGoogleMap = googleMap; LatLng lg = new LatLng(0, 0); CameraUpdate update = CameraUpdateFactory.newLatLng(lg); mGoogleMap.moveCamera(update); }
/** * Method to decode polyline points * Courtesy : http://jeffreysambells.com/2010/05/27/decoding-polylines-from-google-maps-direction-api-with-java * */ private List decodePoly(String encoded) { List poly = new ArrayList(); int index = 0, len = encoded.length(); int lat = 0, lng = 0; while (index < len) { int b, shift = 0, result = 0; do { b = encoded.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lat += dlat; shift = 0; result = 0; do { b = encoded.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lng += dlng; LatLng p = new LatLng((((double) lat / 1E5)), (((double) lng / 1E5))); poly.add(p); Log.e("CallNumber", String.valueOf(i)); Log.e("Encoded", String.valueOf(p)); } i++; return poly; }
@Override public void onMapClick(LatLng latLng) { Projection projection = mMap.getProjection(); Point point = projection.toScreenLocation(latLng); Rect rect = new Rect(); bottomSheet.getGlobalVisibleRect(rect); if (!rect.contains(point.x, point.y)) { Utils.logD(LOG_TAG, "outside bottom sheet"); mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } }
@Override public void onConnected(@Nullable Bundle bundle) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if(lastLocation!=null) { LatLng center = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); mMap.addMarker(new MarkerOptions().position(center).title("Place Pickup here")); //pickUpMarker.setDraggable(true); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 10)); } } }
/** * Check distance between current location and this locations * @param latLng location compared to current location * @param range distance to filter events by * @return true if within range; false otherwise */ public boolean checkDistance(LatLng latLng, Double range) { lastLocation = getDeviceLoc(); float results[] = new float[10]; Location.distanceBetween(lastLocation.getLatitude(), lastLocation.getLongitude(), latLng.latitude, latLng.longitude, results); if (results[0] <= range) { return true; } else { return false; } }
public void onMarkerClick() { // centerMarker di klik LatLng cur=gmaps.getCameraPosition().target; if (addr_from.isFocused()) { setAddrValue(addr_from, cur); } else if (addr_to.isFocused()) { setAddrValue(addr_to, cur); } }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney, Australia, and move the camera. LatLng sydney = new LatLng(-34, 151); mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); }
private void handleNewLocation(Location location) { Log.d("a", location.toString()); double currentLatitude = location.getLatitude(); double currentLongitude = location.getLongitude(); LatLng latLng = new LatLng(currentLatitude, currentLongitude); MarkerOptions options = new MarkerOptions() .position(latLng) .title("I am here!"); mMap.addMarker(options); mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); }
/** * Adds a marker for each event with a location. * @param map */ private void addAllMarkers(GoogleMap map){ for (HabitEvent e:events){ if ((e.getLat()!=null && e.getLong()!=null) && (e.getLat()!=0 && e.getLong()!=0)){ map.addMarker(new MarkerOptions() .position(new LatLng(e.getLat(), e.getLong())) .title(e.getHabitType())); } } }