supportmapfragment

getMap() in onCreate(), created from layout gives nullpointerexception

天大地大妈咪最大 提交于 2019-12-02 04:10:52
This my code: import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; Inside onCreate() method:(I have only this at onCreate(), aside a bundle creation and variables asignation, using that bundle.) FragmentManager myFM = getSupportFragmentManager(); SupportMapFragment myMAPF =(SupportMapFragment)myFM. findFragmentById(R.id.mapfragment); map=myMAPF.getMap();//Exception at this line Layout: <fragment android:id="@+id

Google map inside another fragment - Error when calling getMapAsync

无人久伴 提交于 2019-12-01 19:10:32
I'm trying to convert a google map activity to work inside a fragment that will be called in NavigationView. The map is showing but when i used the code getMapAsync mFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map); mFragment.getMapAsync(this); I got an error message E/AndroidRuntime: FATAL EXCEPTION: main E/AndroidRuntime: java.lang.NullPointerException E/AndroidRuntime: at com.sample.samplemap.samplemapFragment.onCreate(samplemapFragment.java:32) E/AndroidRuntime: at android.support.v4.app.Fragment.performCreate(Fragment.java:1942) E/AndroidRuntime: at

SupportMapFragment Instead of MapFragment

时间秒杀一切 提交于 2019-11-30 23:59:46
I want to make an android application that uses Google Maps for Android v2. I can show a map. I can even navigate and zoom. But, when I want to search for more operations to make, I can't find any. I want this application to work on API level 8 and above. So, I used SupportMapFragment . I heard that, if I want to make my application to work on API level 8 and above, I have to use SupporMapFragment . I found examples about MapFragment s, but unfortunately, not about SupportMapFragment . I want to make these operations work in my application, however, they're using MapFragment : One Two Is there

SupportMapFragment or GoogleMap is null

拟墨画扇 提交于 2019-11-30 19:10:17
问题 Managed to get the codes error free, however upon launching, I somehow always get a null pointer exception at the line mMap = mapFrag.getMap(); Why is this so? Am I missing some imports or some steps? I am unsure if it's the SupportMapFragment or GoogleMap object that's causing the problem. package com.fragments; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.android.gms.maps.GoogleMap; import com.google

How to use SupportMapFragment inside a Fragment?

人走茶凉 提交于 2019-11-30 04:51:49
I know that there has been an issue in using a nested fragment. But my application was designed to run on fragments and if i will be using activity for the map, my casting functions will have error. I would like to ask help from you on how to achieve this. I've been searching in the internet but i couldn't find best solution. I've tried this code: private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. if (mMap == null) { // Try to obtain the map from the SupportMapFragment. mMap = ((SupportMapFragment) myFragmentActivity

mapFragment.getMap() returns null

放肆的年华 提交于 2019-11-29 13:52:12
I'm trying to get a map from a SupportMapFragment but it returns null. From what I read this could be because the fragment is not yet fully displayed and therefore no map exists?! I tried fixing it using executePendingTransactions() but with no success so far. Any ideas how to fix it? Here is the code private GoogleMap map; private SupportMapFragment mapFragment; @Override public void onCreate( Bundle savedInstanceState ) { //... super.onCreate( savedInstanceState ); setContentView( R.layout.screen_mission2 ); GoogleMapOptions mapOptions = new GoogleMapOptions(); mapOptions.mapType(GoogleMap

How to use SupportMapFragment inside a Fragment?

爷,独闯天下 提交于 2019-11-29 06:12:47
问题 I know that there has been an issue in using a nested fragment. But my application was designed to run on fragments and if i will be using activity for the map, my casting functions will have error. I would like to ask help from you on how to achieve this. I've been searching in the internet but i couldn't find best solution. I've tried this code: private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. if (mMap == null) { // Try to obtain

Google Maps Android API v2 SupportMapFragment memory leak

瘦欲@ 提交于 2019-11-29 05:43:13
Using 2 simple activities. First Activity which only holds a button to start the 2nd Activity which holds the map: Main Activity: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void goToMap(View view){ //This is just the onClick method for the button Intent intent=new Intent( this, BigMapTest.class); startActivity(intent); } The map activity: public class BigMapTest extends FragmentActivity { SupportMapFragment mapFragment; GoogleMap map; @Override

Android SupportMapFragment Exception Error

核能气质少年 提交于 2019-11-29 04:55:34
I am trying to use the new Google Play Services Lib and embbed Maps in side the Maps Fragment as below PlaceMapsFragment.java public class PlaceMapsFragment extends SupportMapFragment { private GoogleMap mMap; private LatLng mPosFija; public PlaceMapsFragment() { super(); } public static PlaceMapsFragment newInstance(LatLng posicion) { PlaceMapsFragment frag = new PlaceMapsFragment(); frag.mPosFija = posicion; return frag; } @Override public GoogleMap getMap() { // TODO Auto-generated method stub return super.getMap(); } @Override public void onCreate(Bundle arg0) { // TODO Auto-generated

mapFragment.getMap() returns null

人走茶凉 提交于 2019-11-28 08:13:45
问题 I'm trying to get a map from a SupportMapFragment but it returns null. From what I read this could be because the fragment is not yet fully displayed and therefore no map exists?! I tried fixing it using executePendingTransactions() but with no success so far. Any ideas how to fix it? Here is the code private GoogleMap map; private SupportMapFragment mapFragment; @Override public void onCreate( Bundle savedInstanceState ) { //... super.onCreate( savedInstanceState ); setContentView( R.layout