当前位置: 首页>>代码示例>>Java>>正文


Java LocationSource类代码示例

本文整理汇总了Java中com.google.android.gms.maps.LocationSource的典型用法代码示例。如果您正苦于以下问题:Java LocationSource类的具体用法?Java LocationSource怎么用?Java LocationSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LocationSource类属于com.google.android.gms.maps包,在下文中一共展示了LocationSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
@Override public void call(final Subscriber<? super Location> subscriber) {
  MainThreadSubscription.verifyMainThread();

  LocationSource.OnLocationChangedListener listener =
      new LocationSource.OnLocationChangedListener() {
        @Override public void onLocationChanged(Location location) {
          if (!subscriber.isUnsubscribed()) {
            subscriber.onNext(location);
          }
        }
      };

  locationSource.activate(listener);

  subscriber.add(new MainThreadSubscription() {
    @Override protected void onUnsubscribe() {
      locationSource.deactivate();
    }
  });
}
 
开发者ID:aaronhe42,项目名称:RxGoogleMapsBinding,代码行数:21,代码来源:LocationChangeOnSubscribe.java

示例2: setLocationSource

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
@Override
public void setLocationSource(LocationSource locationSource) {
    real.setLocationSource(locationSource);
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:5,代码来源:DelegatingGoogleMap.java

示例3: setLocationSource

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
@Override
public final void setLocationSource(LocationSource source) {
    map.setLocationSource(source);
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:5,代码来源:GoogleMapWrapper.java

示例4: LocationChangeOnSubscribe

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
LocationChangeOnSubscribe(LocationSource locationSource) {
  this.locationSource = locationSource;
}
 
开发者ID:aaronhe42,项目名称:RxGoogleMapsBinding,代码行数:4,代码来源:LocationChangeOnSubscribe.java

示例5: onActivityCreated

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
  super.onActivityCreated(savedInstanceState);
  if (savedInstanceState != null) {
    keepCurrentLocationVisible = savedInstanceState.getBoolean(
        KEEP_CURRENT_LOCATION_VISIBLE_KEY, false);
    if (keepCurrentLocationVisible) {
      Location location = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
      if (location != null) {
        setCurrentLocation(location);
      }
    }
  }

  /*
   * At this point, after onCreateView, getMap will not return null and we can
   * initialize googleMap. However, onActivityCreated can be called multiple
   * times, e.g., when the user switches tabs. With
   * GoogleMapOptions.useViewLifecycleInFragment == false, googleMap lifecycle
   * is tied to the fragment lifecycle and the same googleMap object is
   * returned in getMap. Thus we only need to initialize googleMap once, when
   * it is null.
   */
  if (googleMap == null) {
    googleMap = getMap();
    googleMap.setMyLocationEnabled(true);

    /*
     * My Tracks needs to handle the onClick event when the my location button
     * is clicked. Currently, the API doesn't allow handling onClick event,
     * thus hiding the default my location button and providing our own.
     */
    googleMap.getUiSettings().setMyLocationButtonEnabled(false);
    googleMap.setIndoorEnabled(true);
    googleMap.setOnMarkerClickListener(new OnMarkerClickListener() {

        @Override
      public boolean onMarkerClick(Marker marker) {
        if (isResumed()) {
          String title = marker.getTitle();
          if (title != null && title.length() > 0) {
            long id = Long.valueOf(title);
            Context context = getActivity();
            Intent intent = IntentUtils.newIntent(context, MarkerDetailActivity.class)
                .putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, id);
            context.startActivity(intent);
          }
        }
        return true;
      }
    });
    googleMap.setLocationSource(new LocationSource() {

        @Override
      public void activate(OnLocationChangedListener listener) {
        onLocationChangedListener = listener;
      }

        @Override
      public void deactivate() {
        onLocationChangedListener = null;
      }
    });
    googleMap.setOnCameraChangeListener(new OnCameraChangeListener() {

        @Override
      public void onCameraChange(CameraPosition cameraPosition) {
        if (isResumed() && keepCurrentLocationVisible && currentLocation != null
            && !isLocationVisible(currentLocation)) {
          keepCurrentLocationVisible = false;
        }
      }
    });
  }
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:76,代码来源:MyTracksMapFragment.java

示例6: setLocationSource

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
@Override
public void setLocationSource(LocationSource locationSource) {
	real.setLocationSource(locationSource);
}
 
开发者ID:mtransitapps,项目名称:mtransit-for-android,代码行数:5,代码来源:DelegatingGoogleMap.java

示例7: setLocationSource

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
@Override
public final void setLocationSource(LocationSource source) {
	map.setLocationSource(source);
}
 
开发者ID:mtransitapps,项目名称:mtransit-for-android,代码行数:5,代码来源:GoogleMapWrapper.java

示例8: locationSourceLocationChanges

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
/**
 * Create an observable which emits on {@code source} location change events.
 * <p>
 * <em>Warning:</em> The created observable keeps a strong reference to {@code source}.
 * Unsubscribe to free this reference.
 * </p>
 */
@CheckResult @NonNull
public static Observable<Location> locationSourceLocationChanges(@NonNull LocationSource source) {
  checkNotNull(source, "source == null");
  return Observable.create(new LocationChangeOnSubscribe(source));
}
 
开发者ID:aaronhe42,项目名称:RxGoogleMapsBinding,代码行数:13,代码来源:RxGoogleMaps.java

示例9: setLocationSource

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
void setLocationSource(LocationSource locationSource); 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:2,代码来源:GoogleMap.java

示例10: setLocationSource

import com.google.android.gms.maps.LocationSource; //导入依赖的package包/类
void setLocationSource(LocationSource source); 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:2,代码来源:IGoogleMap.java


注:本文中的com.google.android.gms.maps.LocationSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。