-
MapView Probleme/Fragen
Hallo Community,
hoffe ihr könnt mir weiterhelfen.
Ich plane eine App mit einer MapView.
Soweit klappt alles, doch ein paar Probleme/Fragen bestehen noch:
Ich kann weder die Map auf dem Smartphone verschieben noch pinch-to-zoom anwenden.
Auch klappen bei mir die Setfunktionen (SetCenter und AnimateTo) des MapControllers nicht.
Suchergebnisse bei Google haben bis jetzt leider nur folgendes gebracht:
Es gab in 2.1 einen Bug mit dem Zoom. setZoom musste vorher aufgerufen werden und dann sollte es gehen. Leider funktioniert auch das nicht. :(
Mein aktueller Code sieht folgendermaßen aus:
Code:
package -******-;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.widget.Toast;
public class MAIN extends MapActivity {
MapController MC;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView MV = (MapView) findViewById(R.id.MAP);
//MV.setBuiltInZoomControls(true);
MC = MV.getController();
MC.setZoom(5);
MC.setCenter(new GeoPoint(**, **));
MC.animateTo(new GeoPoint(**, **));
/*
LocationManager LM = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener LL = new LocationListener() {
public void onLocationChanged(Location arg0) {
MC.setCenter(new GeoPoint((int)arg0.getLatitude()*10^6,(int)arg0.getLongitude()*10^6));
Toast.makeText(getBaseContext(),"lat: " + arg0.getLatitude() + "\nlon: " + arg0.getLongitude(), Toast.LENGTH_LONG).show();
}
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
// TODO Auto-generated method stub
}};
LM.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, LL);
//Location l = LM.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);//lastknownposition
*/
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Ich wäre euch sehr dankbar für einen Ansatz oder ähnliches ;)