本文整理了Java中com.google.android.gms.maps.SupportMapFragment
类的一些代码示例,展示了SupportMapFragment
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SupportMapFragment
类的具体详情如下:
包路径:com.google.android.gms.maps.SupportMapFragment
类名称:SupportMapFragment
暂无
代码示例来源:origin: hussien89aa/AndroidTutorialForBeginners
void LoadMap(){
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
代码示例来源:origin: facebook/facebook-android-sdk
private void toggleMapAndList() {
state = state == State.MAP ? State.LIST : State.MAP;
if (state == State.LIST) {
if (mapFragment != null) {
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
ft.hide(mapFragment).commit();
}
recyclerView.setVisibility(View.VISIBLE);
currentPlaceCardView.setVisibility(View.VISIBLE);
}
if (state == State.MAP) {
if (mapFragment == null) {
mapFragment = SupportMapFragment.newInstance();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.id.place_search_map_placeholder, mapFragment);
transaction.commit();
mapFragment.getMapAsync(this);
} else {
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
ft.show(mapFragment).commit();
}
recyclerView.setVisibility(View.INVISIBLE);
currentPlaceCardView.setVisibility(View.INVISIBLE);
}
displayPlaces(placesToDisplay);
}
代码示例来源:origin: novoda/android-demos
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
View view = super.onCreateView(inflater, viewGroup, bundle);
setUpMapIfNeeded();
return view;
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (readyToGo()) {
setContentView(R.layout.activity_main);
SupportMapFragment mapFrag=
(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
if (savedInstanceState == null) {
needsInit=true;
}
mapFrag.setRetainInstance(true);
mapFrag.getMapAsync(this);
}
}
代码示例来源:origin: Michenux/YourAppIdea
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SupportMapFragment mapFragment = getMapFragment();
if (BuildConfig.DEBUG) {
Log.d(YourApplication.LOG_TAG, "simpleMapFragment.onViewCreated - mapFragment = " + mapFragment);
}
if (mapFragment == null) {
mapFragment = new SupportMapFragment();
mapFragment.setRetainInstance(true);
getChildFragmentManager().beginTransaction().replace(R.id.simplemap, mapFragment, null).commit();
}
mapFragment.getMapAsync(this);
}
代码示例来源:origin: polyak01/IconSwitch
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
window = getWindow();
initColors();
initAnimationRelatedFields();
content = findViewById(R.id.content);
toolbar = findViewById(R.id.toolbar);
TextView title = (TextView) findViewById(R.id.toolbar_title);
title.setText(R.string.app_name);
iconSwitch = (IconSwitch) findViewById(R.id.icon_switch);
iconSwitch.setCheckedChangeListener(this);
updateColors(false);
FragmentManager fm = getSupportFragmentManager();
SupportMapFragment fragment = (SupportMapFragment) fm.findFragmentById(R.id.map_container);
if (fragment == null) {
fragment = new SupportMapFragment();
fm.beginTransaction().replace(R.id.map_container, fragment).commit();
}
fragment.getMapAsync(this);
findViewById(R.id.credit_polyak).setOnClickListener(this);
findViewById(R.id.credit_yarolegovich).setOnClickListener(this);
findViewById(R.id.credit_prokhoda).setOnClickListener(this);
}
代码示例来源:origin: SkyTreasure/Airbnb-Android-Google-Map-View
mapFragment = SupportMapFragment.newInstance();
getSupportFragmentManager().beginTransaction().replace(R.id.map, mapFragment).commit();
map = mapFragment.getMap();
代码示例来源:origin: CUTR-at-USF/OpenTripPlanner-for-Android
/**
* Retrieves a map if the map fragment parameter is null.
* <p>
* If there is an error tries to solve it checking if it was because of
* "Google Play Services" sending the corresponding intent.
*
* @param mMap map fragment to check if the map is already initialized
* @return initialized map fragment
*/
private GoogleMap retrieveMap(GoogleMap mMap) {
// Do a null check to confirm that we have not already instantiated the map.
mMapFailed = false;
if (mMap == null) {
mMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap == null) {
int status = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(mApplicationContext);
if (status != ConnectionResult.SUCCESS) {
enableUIElements(false);
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, getActivity(),
OTPApp.CHECK_GOOGLE_PLAY_REQUEST_CODE);
dialog.show();
mMapFailed = true;
}
}
}
return mMap;
}
代码示例来源:origin: googlemaps/android-samples
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
case 1:
return new TextFragment();
case 2:
return SupportMapFragment.newInstance();
default:
return null;
}
}
}
代码示例来源:origin: googlemaps/android-samples
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.basic_demo);
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
if (savedInstanceState == null) {
// First incarnation of this activity.
mapFragment.setRetainInstance(true);
}
mapFragment.getMapAsync(this);
}
代码示例来源:origin: GeoODK/collect
.findFragmentById(R.id.map)).getMap();
mMap.setOnMarkerDragListener(this);
代码示例来源:origin: nglauber/dominando_android2
private void init() {
Log.d("NGVL", "init::BEGIN");
SupportMapFragment fragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentByTag(TAG);
if (fragment == null) {
fragment = SupportMapFragment.newInstance();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.map, fragment, TAG)
.commit();
}
mGoogleApiClient.connect();
Log.d("NGVL", "init::END");
}
}
代码示例来源:origin: googlemaps/android-maps-utils
private void setUpMap() {
((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMapAsync(this);
}
代码示例来源:origin: googlemaps/android-samples
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// It isn't possible to set a fragment's id programmatically so we set a tag instead and
// search for it using that.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);
// We only create a fragment if it doesn't already exist.
if (mapFragment == null) {
// To programmatically add the map, we first create a SupportMapFragment.
mapFragment = SupportMapFragment.newInstance();
// Then we add it using a FragmentTransaction.
FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(android.R.id.content, mapFragment, MAP_FRAGMENT_TAG);
fragmentTransaction.commit();
}
mapFragment.getMapAsync(this);
}
代码示例来源:origin: airbnb/AirMapView
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
init();
return v;
}
代码示例来源:origin: CUTR-at-USF/OpenTripPlanner-for-Android
LatLngBounds routeBounds = boundsCreator.build();
if (((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map))
.getMap()
!= null){
showRouteOnMapAnimateCamera(routeBounds, firstTransitMarker, animateCamera);
代码示例来源:origin: commonsguy/cw-omnibus
private void onCreateForRealz(boolean canGetLocation) {
if (canGetLocation) {
if (readyToGo()) {
setContentView(R.layout.activity_main);
SupportMapFragment mapFrag=
(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
mapFrag.getMapAsync(this);
}
}
else if (!isInPermission) {
isInPermission=true;
ActivityCompat.requestPermissions(this,
new String[] {Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_PERMS);
}
}
代码示例来源:origin: google-developer-training/android-advanced
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready
// to be used.
SupportMapFragment mapFragment = SupportMapFragment.newInstance();
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, mapFragment).commit();
mapFragment.getMapAsync(this);
}
代码示例来源:origin: Phantast/smartnavi
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
mOriginalContentView = super.onCreateView(inflater, parent, savedInstanceState);
mTouchView = new TouchableWrapper(getActivity());
mTouchView.addView(mOriginalContentView);
return mTouchView;
}
代码示例来源:origin: CUTR-at-USF/OpenTripPlanner-for-Android
@Override
public void onStart() {
super.onStart();
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addApi(API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
if (mMapFailed) {
mMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
enableUIElements(true);
initializeMapInterface(mMap);
runAutoDetectServerNoLocation(true);
}
}
connectLocationClient();
}
内容来源于网络,如有侵权,请联系作者删除!