Ich verwende Google Maps Android API V2. Wenn ich Googlemap setMyLocationEnabled (true) verwende, wird der aktuelle Standort als blauer Punkt angezeigt. Wie kann ich den aktuellen Standort als blinkenden Pfeil anzeigen, der den aktuellen Kurs anzeigen kann?Wie zeige ich den aktuellen Standort als Pfeil in Google Maps Android API V2?
Antwort
Verwenden unten funktioniert es für aktuellen Standort zu erhalten
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
System.out.println("Provider " + provider + " has been selected.");
onLocationChanged(location);
}
Geocoder geocoder = new Geocoder(ViewTestDrive.this, Locale.getDefault());
List<Address> addresses = null;
try {
addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
} catch (IOException e) {
e.printStackTrace();
// Update address field with the exception.
//Message.obtain(mHandler, UPDATE_ADDRESS, e.toString()).sendToTarget();
}
String addressText = null;
if (addresses != null && addresses.size() > 0) {
Address address = addresses.get(0);
// Format the first line of address (if available), city, and country name.
addressText = String.format("%s, %s, %s",
address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "",
address.getLocality(),
address.getCountryName());
// Update address field on UI.
//Message.obtain(mHandler, UPDATE_ADDRESS, addressText).sendToTarget();
}
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr="+addressText+"&daddr="+));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
@Override
public void onLocationChanged(Location location) {
int lat = (int) (location.getLatitude());
int lng = (int) (location.getLongitude());
String.valueOf(lat);
String.valueOf(lng);
}
@Override
public void onProviderDisabled(String provider) {
Toast.makeText(this, "Disabled provider " + provider,
Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderEnabled(String provider) {
Toast.makeText(this, "Enabled new provider " + provider,
Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
(Sorry, ich bin zu spät zu beantworten. Hoffe, dass Sie das Problem bis zu diesem Zeitpunkt festgelegt.)
Sie die Art und Weise anpassen können Marker sollten in einigen einfachen Schritten erscheinen. Die folgenden Code-Teile sind erforderlich, um dies zu erreichen.
//You need a GoogleMap object to deal with the map functionality.
private GoogleMap map;
...
//Find Your Map view from layout
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
//This method will do the rest needed
showMarker(userLatitude, userLongitude)
...
...
// Pass the desired latitude and longitude to this method
public void showMarker(Double lat, Double lon) {
map.clear();
// Create a LatLng object with the given Latitude and Longitude
LatLng markerLoc = new LatLng(lat, lon);
//Add marker to map
map.addMarker(new MarkerOptions()
.position(markerLoc) // at the location you needed
.title("Desired Title") // with a title you needed
.snippet("Any summary if needed") // and also give some summary of available
.icon(BitmapDescriptorFactory.fromResource(R.drawable.your_flashing_arrow_anim_drawable))); // and give your animation drawable as icon
}
// To work these functionalities, you may require the following imports
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
Und schließlich das Layout sollte einen Eintrag wie diesen als MAP
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
Hope this Fragen einige andere auch löst enthalten ... :)
bewegen!
Der Standort wird auf der Karte durch einen kleinen blauen Punkt angezeigt, wenn das Gerät stationär ist, oder als ein Chevron, wenn sich das Gerät bewegt.
den blauen Pfeil bekommen wie das, was wir in Googles Google Maps App standardmäßig oder über die API auf Android sehen, ist nicht möglich, nach this post. Ich schließe daraus, dass wir für dieses spezielle Merkmal vielleicht alleine sind. Nur meine 2 Cent.
- 1. Android: Wie Routenanweisungen Google Maps API V2 vom aktuellen Standort zum Zielort
- 2. Wie bekomme ich den aktuellen Standort mit Google Maps API in Android?
- 3. Android Google Maps V2 ändern Mein Standort-Symbol
- 4. Android - Google Maps api v2 - Zoomsteuerung deaktivieren
- 5. Android 2.3 und Google Maps API v2
- 6. Google Maps Android V2 und Direction API
- 7. Google Maps Android API v2 Route Overlay
- 8. Android Google Maps API v2 Anzeige Route
- 9. So zeigen Sie meinen Standort in Google Maps für Android API an v2
- 10. Google Maps Android API und aktueller Standort
- 11. Map-Markierungen mit Text in Google Maps Android API v2
- 12. Google Maps v2: Autorisierungsfehler
- 13. Wie kann ich Google Maps api v2 direkt zu meinem Standort gehen
- 14. Android Google Maps v2 Kameraanimation
- 15. Google Maps Android API v2, falscher Marker Ort
- 16. Wie man fortwährend den aktuellen Standortmarker in Google Maps v2 android bewegt
- 17. ios - Google Maps im Webview lädt nicht den aktuellen Standort
- 18. Um den aktuellen Standort
- 19. Ausblenden Marker Info Fenster in Android Google Maps API v2
- 20. Google Maps API v2 grauen Bildschirm
- 21. Google Maps API v2: LatLngBounds von CameraPosition
- 22. Google Maps api v2 Klasse nicht gefunden
- 23. Wie kann man einen Marker zum aktuellen Standort in Google Maps v2 hinzufügen?
- 24. Android Google Maps V2 User Location
- 25. Google Maps API v2 in Mono für Android hinzufügen
- 26. Wie google android Plätze api an Ihrem aktuellen Standort laden
- 27. Google Maps Android API v2 erstellt eine neue LocationSource
- 28. Android: Google Maps API GeoPoint vs Android-Standort, warum Mikrodegre
- 29. So erhalten Sie den Freischaltcode für Google Maps API v2
- 30. Google Maps Android API v2 - MarkerOptions ziehbare und sichtbare Methoden
Dies beantwortet nur die Hälfte der Poster Frage. Ich interessiere mich mehr dafür, wie man den Pfeil oben auf der Karte malt, ihn animiert (d. H. Nicht einen Marker) und ihn synchron zum Benutzerstandort hält, selbst wenn die Karte gescrollt wird. – gsysko
Ich denke nicht, dass dies die Frage überhaupt beantwortet. Der Fokus liegt dabei auf dem Erreichen des blauen Pfeils wie in der offiziellen Google Maps App selbst – ericn