반응형
how to use googlemap v2 over fragment
class MyFragment extends Fragment
{
SupportMapFragment myMapFragment;
GoogleMap myMap;
View convertView;
FragmentManager fm;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
convertView=inflater.inflate(R.layout.mymap,null);
fm=getChildFragmentManager();
myMapFragment=(SupportMapFragment) fm.findFragmentById(R.id.myMapId);
// here instead of using getMap(), we are using getMapAsync() which returns a callback and shows map only when it gets ready.
//it automatically checks for null pointer or older play services version, getMap() is deprecated as mentioned in google docs.
myMapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googlemap) {
// TODO Auto-generated method stub
myMap=googlemap;
startMap();
}
});
return convertView;
}
}
https://stackoverflow.com/questions/25653898/google-maps-fragment-returning-null-inside-a-fragment
반응형
'모바일개발(Mobile Dev) > 안드로이드개발(Android)' 카테고리의 다른 글
How to determine if user cancels Google Play subscription (0) | 2018.12.09 |
---|---|
how to get a skill to improve with sample code on android (0) | 2018.06.10 |
how to rename android app name, package name (0) | 2018.06.08 |
android sample source site (0) | 2018.05.06 |
google account registration (0) | 2017.09.30 |