N
note3
Ambitioniertes Mitglied
- 0
Hallo kleinerkathe und Maps-Interessierte,
damit der Thread nicht zu lang wird, eröffne ich mal einen neuen.
Ich habe jetzt ein Update ausgeführt und bekomme (nach weiteren zig-Versuchen) die Map jetzt auch angezeigt.
Schon kommt ein neues Problem, weil die Beispiele im Internet nicht mehr zu der neuen Version passen.
Mein Problem ist, wie bekomme ich Zugriff auf eine map, damit ich z.B.
map.moveCamera nutzen kann?
Der lauffähige code sieht wie folgt aus und die Frage ist bei ??? in der MainActivity zu sehen.
Ich habe versucht das Problem mit
DJ-Android: Android - Google MAP V2 PART 2
zu lösen, das ist mir aber nicht gelungen.
damit der Thread nicht zu lang wird, eröffne ich mal einen neuen.
Ich habe jetzt ein Update ausgeführt und bekomme (nach weiteren zig-Versuchen) die Map jetzt auch angezeigt.
Schon kommt ein neues Problem, weil die Beispiele im Internet nicht mehr zu der neuen Version passen.
Mein Problem ist, wie bekomme ich Zugriff auf eine map, damit ich z.B.
map.moveCamera nutzen kann?
Der lauffähige code sieht wie folgt aus und die Frage ist bei ??? in der MainActivity zu sehen.
Ich habe versucht das Problem mit
DJ-Android: Android - Google MAP V2 PART 2
zu lösen, das ist mir aber nicht gelungen.
Code:
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
// import com.google.android.gms.maps.MapFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends FragmentActivity {
static GoogleMap gmap;
static LatLng HAMBURG;
static FragmentManager myFM;
static SupportMapFragment myMAPF;
static View gview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myFM = getSupportFragmentManager();
if (savedInstanceState == null)
{ myFM.beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
}
// myMAPF = ???
// gmap=myMAPF.getMap(); // ???
HAMBURG = new LatLng(53.558, 9.927);
// gmap.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) { return true;}
return super.onOptionsItemSelected(item);
}
// A placeholder fragment containing a simple view.
public static class PlaceholderFragment extends Fragment
{ public PlaceholderFragment() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
}
}
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.mymap.esmap.MainActivity$PlaceholderFragment" >
<TextView
android:id="@+id/prog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top"
android:paddingBottom="2dp" android:paddingTop="2dp" android:paddingLeft="6dp"
android:scrollbars="vertical"
android:singleLine="false"
android:scrollbarStyle="insideOverlay"
android:fadeScrollbars="true"
android:fadingEdge="vertical"
android:text="Input"
android:minLines="3"
android:maxLines="6"
android:textSize="16sp" >
</TextView>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="110dp"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>