/** Sets the map view to center itself around the given user location geoPoint */ public void setMapViewToLocation(LatLng latLng) { if (autoZoom) { googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, POSITION_ZOOM_LEVEL)); } else { googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); } }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney and move the camera ubicacion = new Ubicacion(MapsActivity.this); currentLatLng = ubicacion.latLng(); localizacion = new Localizacion(MapsActivity.this, currentLatLng); information = Arrays.toString(localizacion.gps()).replaceAll("\\[|\\]", ""); mMap.addMarker( new MarkerOptions() .position(currentLatLng) .draggable(true) .title(information) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLatLng)); cameraUpdate = CameraUpdateFactory.newLatLngZoom((currentLatLng), 16); mMap.animateCamera(cameraUpdate); preferences = new Preferences( getApplicationContext(), "Latitude,Longitude,CountryCode,Country, State, City, Address", String.valueOf(currentLatLng.latitude) + "," + String.valueOf(currentLatLng.longitude) + "," + information, "Laundry"); preferences.savePreferences(); mMap.setOnMarkerDragListener(this); }
private void drawCurrentLocation(LatLng current_location) { if (cLMarker != null) { cLMarker.remove(); } cLMarker = googleMap.addMarker( markerOptions .position(current_location) .title("Current Position") .snippet("") .flat(true) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))); if (firstTimeCameraMove) { googleMap.animateCamera(CameraUpdateFactory.newLatLng(current_location)); CameraPosition cameraPosition = new CameraPosition.Builder() .target(current_location) // Sets the center of the map to location user .zoom(17) // Sets the zoom .build(); // Creates a CameraPosition from the builder googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); firstTimeCameraMove = false; } }
@Override protected void onPostExecute(List<EarthQuakeRec> result) { // Get Map Object mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); if (null != mMap) { // Add a marker for every earthquake for (EarthQuakeRec rec : result) { // Add a new marker for this earthquake mMap.addMarker( new MarkerOptions() // Set the Marker's position .position(new LatLng(rec.getLat(), rec.getLng())) // Set the title of the Marker's information window .title(String.valueOf(rec.getMagnitude())) // Set the color for the Marker .icon(BitmapDescriptorFactory.defaultMarker(getMarkerColor(rec.getMagnitude())))); } // Center the map // Should compute map center from the actual data mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(CAMERA_LAT, CAMERA_LNG))); } if (null != mClient) mClient.close(); }
public void changeMap(LatLng latLng) { // Show the current location in Google Map mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); // Zoom in the Google Map mMap.animateCamera(CameraUpdateFactory.zoomTo(14)); }
@Override public void onMapReady(GoogleMap map) { // LatLng Kazik = new LatLng(51.2351792, 22.5469426); // map.addMarker(new MarkerOptions().position(Kazik).title("Klub Kazik")); // map.moveCamera(CameraUpdateFactory.newLatLng(Kazik)); // // LatLng Silence = new LatLng(51.2464403, 22.5415827); // map.addMarker(new MarkerOptions().position(Silence).title("Klub Silence")); // map.moveCamera(CameraUpdateFactory.newLatLng(Silence)); // // LatLng Shine = new LatLng(51.2491831, 22.5507555); // map.addMarker(new MarkerOptions().position(Shine).title("Klub Shine")); // map.moveCamera(CameraUpdateFactory.newLatLng(Shine)); // // LatLng Czekolada = new LatLng(51.2470281, 22.5610082); // map.addMarker(new MarkerOptions().position(Czekolada).title("Klub Czekolada")); // map.moveCamera(CameraUpdateFactory.newLatLng(Czekolada)); this.map = map; LatLng Miejsce = new LatLng(51.2323839, 22.5575203); this.map.addMarker( new MarkerOptions().position(Miejsce).title(wydarzenie.getMiejsce().getNazwa())); this.map.moveCamera(CameraUpdateFactory.newLatLng(Miejsce)); this.map.moveCamera(CameraUpdateFactory.zoomTo(15)); }
@Override public void onLocationChanged(Location location) { if (mRefreshLocation) { mLocation = location; if (mLocation != null) { // Bug report: cached GeoPoint is being returned as the first value. // Wait for the 2nd value to be returned, which is hopefully not cached? ++mLocationCount; InfoLogger.geolog( "GeoPointMapActivity: " + System.currentTimeMillis() + " onLocationChanged(" + mLocationCount + ") lat: " + mLocation.getLatitude() + " long: " + mLocation.getLongitude() + " acc: " + mLocation.getAccuracy()); if (mLocationCount > 1) { mLocationStatus.setText( getString( R.string.location_provider_accuracy, mLocation.getProvider(), truncateFloat(mLocation.getAccuracy()))); mLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude()); if (!mZoomed) { mZoomed = true; mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16)); } else { mMap.animateCamera(CameraUpdateFactory.newLatLng(mLatLng)); } // create a marker on the map or move the existing marker to the // new location if (mMarker == null) { mMarkerOption.position(mLatLng); mMarker = mMap.addMarker(mMarkerOption); mShowLocation.setClickable(true); } else { mMarker.setPosition(mLatLng); } // If location is accurate enough, stop updating position and make the marker draggable if (mLocation.getAccuracy() <= mLocationAccuracy) { stopGeolocating(); } } } else { InfoLogger.geolog( "GeoPointMapActivity: " + System.currentTimeMillis() + " onLocationChanged(" + mLocationCount + ") null location"); } } }
@Override public void onMapReady(GoogleMap googleMap) { LatLng latLng = new LatLng(23.156116, 113.445332); mMap.addMarker(new MarkerOptions().position(latLng).flat(true).title("Marker here")); mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); mMap.animateCamera(CameraUpdateFactory.zoomTo(15)); }
// --------------------------------------------------------------------------------------------- // Method for updating the icons of the markers and plotting the new route. -------------------- private void updateMarkersAndRoute(Marker marker) { Log.d("VetFirstActivity", ">> Marker clicked: " + marker.getTitle()); vetMap.clear(); int temp_i = 0; for (int i = 0; i < markerOptionsList.size(); i++) { if (marker.getTitle().equals(markerOptionsList.get(i).getTitle())) { temp_i = i; Log.d("VetFirstActivity", ">> Position in list:" + temp_i); } } for (int i = 0; i < markerOptionsList.size(); i++) { if ((i != nearestVetPosition) && (i != temp_i)) { vetMap.addMarker(markerOptionsList.get(i).icon(vetIcon).alpha(0.6f)); } else if ((i != nearestVetPosition) && (i == temp_i)) { vetMap.addMarker(markerOptionsList.get(i).icon(vetIcon).alpha(1f)); } else { vetMap.addMarker(markerOptionsList.get(i).icon(nearestVetIcon)); } } vetMap.addMarker( new MarkerOptions() .position(currentLocationLatLng) .title("Βρίσκεστε εδώ") .icon(currentLocationIcon)); GetRouteTask markerGetRouteTask = new GetRouteTask(); markerGetRouteTask.execute( ConnectionManager.getDirectionsURL(currentLocationLatLng, vetLatLng)); vetMap.animateCamera(CameraUpdateFactory.newLatLng(vetLatLng)); }
private void init() { cnt = 0; GooglePlayServicesUtil.isGooglePlayServicesAvailable(MapsActivity.this); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new MyLocationListener(); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, locationListener); // GPS ������� �������� gps = new GPSInfo(MapsActivity.this); locationListener = new MyLocationListener(); if (gps.isGetLocation()) { double latitude = gps.getLatitude(); double longitude = gps.getLongitude(); // Creating a LatLng object for the current location LatLng latLng = new LatLng(latitude, longitude); // Showing the current location in Google Map mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); // Map �� zoom �մϴ�. mMap.animateCamera(CameraUpdateFactory.zoomTo(15)); mMap.addMarker(new MarkerOptions().position(latLng).title("My")); } }
@Override public void onMyLocationChange(Location location) { misCoordenadas = new double[] {location.getLongitude(), location.getLatitude()}; if (!centered && mustCenter && getMap() != null) { getMap() .moveCamera( CameraUpdateFactory.newLatLng(new LatLng(misCoordenadas[1], misCoordenadas[0]))); centered = true; buscarParadas(); } if (posUltimaBusqueda == null) { posUltimaBusqueda = new LatLng(misCoordenadas[0], misCoordenadas[1]); } else { if (DataStorage.filtro.getDistancia() == Integer.MAX_VALUE) { return; } float[] distancia = new float[1]; Location.distanceBetween( posUltimaBusqueda.latitude, posUltimaBusqueda.longitude, misCoordenadas[0], misCoordenadas[1], distancia); if (distancia[0] > 10) { buscarParadas(); posUltimaBusqueda = new LatLng(misCoordenadas[0], misCoordenadas[1]); } } }
@Override public void onResume() { if (getMap() != null && getView() != null) { // Ponemos que inicie el mapa en el Kiosko de Surbus getMap().moveCamera(CameraUpdateFactory.newLatLng(coordenadas)); getMap().setMapType(GoogleMap.MAP_TYPE_HYBRID); getMap().setMyLocationEnabled(true); getMap().setOnMyLocationChangeListener(this); getMap().moveCamera(CameraUpdateFactory.zoomTo(15)); getMap() .setOnMarkerClickListener( new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { synchronized (DataStorage.paradas) { Parada p = DataStorage.paradas.get(Integer.parseInt(marker.getTitle())); DialogFragment f = MostrarInfoParada.newInstance(p.getId()); f.show(getActivity().getSupportFragmentManager(), "Info"); } return true; } }); bitmapParada = BitmapDescriptorFactory.fromResource(R.drawable.bus_stop); buscarParadas(); } super.onResume(); }
private void setUpMap() { if (this.permissionGranted) { try { this.mMap.getUiSettings().setMyLocationButtonEnabled(false); this.mMap.setMyLocationEnabled(true); } catch (SecurityException e) { e.printStackTrace(); } } try { MapsInitializer.initialize(this.getActivity()); } catch (Exception e) { e.printStackTrace(); } // For dropping a marker at a point on the Map // For zooming automatically to the Dropped PIN Location this.mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(latitude, longitude))); this.mMap.animateCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 13.0f)); this.mapIsInitialised = true; }
@Override protected void onPostExecute(List<Address> addresses) { if (addresses == null || addresses.size() == 0) { Toast.makeText(getActivity(), "No Location found", Toast.LENGTH_SHORT).show(); } // Clears all the existing markers on the map googleMap.clear(); // Adding Markers on Google Map for each matching address for (int i = 0; i < addresses.size(); i++) { Address address = (Address) addresses.get(i); // Creating an instance of GeoPoint, to display in Google Map latLng = new LatLng(address.getLatitude(), address.getLongitude()); String addressText = String.format( "%s, %s", address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "", address.getCountryName()); markerOptions = new MarkerOptions(); markerOptions.position(latLng); markerOptions.title(addressText); googleMap.addMarker(markerOptions); // Locate the first location if (i == 0) googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); } }
private void setUpMap() { if (showRoute == false) { mMap.addMarker( new MarkerOptions() .position(CAFETERIA) .title("Cafeteria") .snippet("Hochschule Karlsruhe")); mMap.moveCamera(CameraUpdateFactory.newLatLng(CAFETERIA)); mMap.animateCamera(CameraUpdateFactory.zoomTo(17.00f)); } else if (showRoute == true) { String uri = "http://maps.google.com/maps?saddr=" + standortLatitude + "," + standortLongitude + "&daddr=" + 49.01578 + "," + 8.39137; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } }
public void zoomToLocation(Location location, Float zoom, boolean calloutOffset) { if (mGoogleMap == null) return; // float density = getResources().getDisplayMetrics().density; // float targetZoom = zoom > 0 ? zoom : mGoogleMap.getCameraPosition().zoom; // double scale = 256 * Math.pow(2, (targetZoom - 1)) / Math.PI; // double latitude = location.getLatitude(); // double longitude = location.getLongitude(); mGoogleMap.moveCamera( CameraUpdateFactory.newLatLngZoom(mGoogleMap.getCameraPosition().target, zoom)); LatLng dest; if (calloutOffset) { Point pt = mGoogleMap .getProjection() .toScreenLocation(new LatLng(location.getLatitude(), location.getLongitude())); pt.offset(0, getResources().getDimensionPixelSize(R.dimen.callout_offset)); dest = mGoogleMap.getProjection().fromScreenLocation(pt); /* double y = Math.log(Math.tan(Math.toRadians(latitude) / 2 + Math.PI / 4)); y += getResources().getDimensionPixelSize(R.dimen.callout_offset) / scale; latitude = Math.toDegrees((Math.atan(Math.exp(y)) - Math.PI / 4) * 2);*/ } else { dest = new LatLng(location.getLatitude(), location.getLongitude()); } if (zoom > 0) { mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(dest, zoom)); } else { mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(dest)); } }
@Override public void BuildMap() { map = fragment.getMap(); map.addMarker( new MarkerOptions().position(pontoCentralFatec()).title(ConstantsMenus.TITULO_PONTO)); map.moveCamera(CameraUpdateFactory.newLatLng(pontoCentralFatec())); map.animateCamera(CameraUpdateFactory.zoomTo(15)); }
@Override public void onLocationChanged(Location location) { double latitude = location.getLatitude(); double longitude = location.getLongitude(); LatLng latLng = new LatLng(latitude, longitude); mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); mMap.animateCamera(CameraUpdateFactory.zoomTo(15)); }
@Override public void onMapClick(LatLng point) { if (marker != null) { marker.remove(); } marker = mMap.addMarker(new MarkerOptions().position(point).title("Your destination")); mMap.moveCamera(CameraUpdateFactory.newLatLng(point)); appMethodsInstance.setGeoPoints(point); }
public MapFragment centerOnLatLng(LatLng latLng, Float zoom) { if (latLng != null) if (zoom == null) { googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); } else { googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom)); } return this; }
private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. if (norwayMap == null) { // Try to obtain the map from the SupportMapFragment. norwayMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); // Hide the zoom controls as the button panel will cover it norwayMap.getUiSettings().setZoomControlsEnabled(true); // Set map type getting configuration from Sharedsettings /*MapConfiguration mConf = new MapConfiguration(); SharedPreferences mapSettings = getSharedPreferences("mapType", 0); boolean mTypeNormal = mapSettings.getBoolean("normal", false); boolean mTypeSatellite = mapSettings.getBoolean("satellite", false); boolean mTypeTerrain = mapSettings.getBoolean("terrain", false);*/ /*if (mTypeNormal) { mMap.setMapType(1); } if (mTypeSatellite) { mMap.setMapType(2); } if (mTypeTerrain) { mMap.setMapType(3); }*/ // Set default camera position and zoom LatLng defaultlLatLong = new LatLng(60.8175897, 11.0134724); CameraUpdate center = CameraUpdateFactory.newLatLng(defaultlLatLong); CameraUpdate zoom = CameraUpdateFactory.zoomTo(5); norwayMap.moveCamera(center); norwayMap.animateCamera(zoom); // Buildings enabled norwayMap.setBuildingsEnabled(true); // Check if we were successful in obtaining the map. if (norwayMap != null) { // new ConnectAsync().execute(); setUpMap("Manolo" + " " + "Holsetgata street", "60.7967395", "11.0735713"); hairdresserObjects oTest = new hairdresserObjects(); oTest.setHairdresserName("headZUP"); oTest.setAddress("Torggata 13"); oTest.setSchedule("10-22"); oTest.setEmail("empty"); oTest.setPhone("62 52 99 88"); oTest.sethType("Unisex"); oTest.setFacebookPage("Empty"); hObjectsList.add(oTest); } } }
@Override public void onLocationChanged(Location location) { mLatitude = location.getLatitude(); mLongitude = location.getLongitude(); LatLng latLng = new LatLng(mLatitude, mLongitude); mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(12)); }
public void finishMap(objData objDataList) { // add a marker for the stop position. map.addMarker( new MarkerOptions() .position(new LatLng(objDataList.lat, objDataList.lng)) .title("End " + objDataList.distance + " Miles")); // move the camera to center it to it. map.moveCamera(CameraUpdateFactory.newLatLng(objDataList.myLatlng)); }
/** * 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 LatLng sydney = new LatLng(-34, 151); mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); }
@Override public void onMapReady(GoogleMap map) { // On ajoute le marker de l'alert quand la map est dispo map.addMarker( new MarkerOptions() .position(this.currentAlert.getCoord()) .title(this.currentAlert.getSender() + SPACE + getString(R.string.marker_text))); map.moveCamera(CameraUpdateFactory.newLatLng(this.currentAlert.getCoord())); map.moveCamera(CameraUpdateFactory.zoomTo(12)); }
private void setMyLocationOnMapWithZoom(Location location) { // Creating a LatLng object for the current location LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); // Showing the current location in Google Map googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); // Zoom in the Google Map // Zoom in, animating the camera. googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); }
/** ��ʼ��һЩdemo�� */ private void initDemoPoint() { final LatLng ll = new LatLng(37.339085, -121.8914807); MarkerOptions mo = new MarkerOptions(); mo.position(ll); map.addMarker(mo); // move to marker position. CameraUpdate cu = CameraUpdateFactory.newLatLng(ll); map.animateCamera(cu); }
private void handleNewLocation(Location location) { Log.d(TAG, location.toString()); double currentLatitude = location.getLatitude(); double currentLongitude = location.getLongitude(); LatLng latLng = new LatLng(currentLatitude, currentLongitude); MarkerOptions options = new MarkerOptions().position(latLng); mMap.addMarker(options); mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); }
public void refreshMap() { List<Tag> tags = HANDLER.getAllTags(); Tag[] tagArray = new Tag[tags.size()]; tags.toArray(tagArray); for (int i = 0; i < tagArray.length; i++) { HASHMAP.put(addMarkerToMap(tagArray[i]), tagArray[i]); } MAP.moveCamera( CameraUpdateFactory.newLatLng(new LatLng(tagArray[0].getLat(), tagArray[0].getLong()))); }
private void handleNewLocation(Location location) { if (location != null) { double currentLatitude = location.getLatitude(); double currentLongitude = location.getLongitude(); LatLng latLng = new LatLng(currentLatitude, currentLongitude); options = new MarkerOptions().position(latLng); mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); setUpMap(); } }