本文整理汇总了Java中com.google.android.maps.MyLocationOverlay.enableMyLocation方法的典型用法代码示例。如果您正苦于以下问题:Java MyLocationOverlay.enableMyLocation方法的具体用法?Java MyLocationOverlay.enableMyLocation怎么用?Java MyLocationOverlay.enableMyLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.maps.MyLocationOverlay
的用法示例。
在下文中一共展示了MyLocationOverlay.enableMyLocation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: followMyLocation
import com.google.android.maps.MyLocationOverlay; //导入方法依赖的package包/类
/**
* 地図の中心地として,GPSの現在地情報を追跡し続ける
*/
public MMapView followMyLocation()
{
// マップ上にオーバレイを定義
overlay_myloc = new MyLocationOverlay( activity, this );
overlay_myloc.onProviderEnabled(LocationManager.GPS_PROVIDER);
overlay_myloc.enableMyLocation();
// 現在地の追跡を開始
waitForMyLocation();
// このオーバレイをマップ上に追加
getOverlays().add(overlay_myloc);
invalidate();
return this;
}
示例2: newDefaultGMap
import com.google.android.maps.MyLocationOverlay; //导入方法依赖的package包/类
public static GMap newDefaultGMap(MapActivity mapActivity,
String pc1debugkey) {
final GMap map = new GMap(mapActivity, GoogleMapsKey.pc1DebugKey);
final MyLocationOverlay o = new MyLocationOverlay(mapActivity, map);
o.enableCompass();
o.enableMyLocation();
map.addOverlay(o);
map.setSatellite(true);
map.setZoomLevel(17);
map.setClickable(true);
o.runOnFirstFix(new Runnable() {
@Override
public void run() {
/*
* When the positionis available for the first time center the
* map to this location:
*/
map.getController().setCenter(o.getMyLocation());
}
});
return map;
}
示例3: onCreate
import com.google.android.maps.MyLocationOverlay; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapView);
mapView.setStreetView(false);
mapView.setSatellite(false);
// ZOOM CONTROL
LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);
View zoomView = mapView.getZoomControls();
zoomLayout.addView(zoomView,
new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mapView.displayZoomControls(true);
// SAT VIEW
Button s = (Button) findViewById(R.id.sat);
s.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
toggleSatellite();
}
});
mc = mapView.getController();
//INIT DB
DataBaseHelper myDbHelper = new DataBaseHelper(this.getApplicationContext());
myDbHelper = new DataBaseHelper(this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
//PULL BUS STOPS FROM DB
stops = Stop.getAllStops();
StopOverlay itemizedOverlay = new StopOverlay(stops, this);
listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(itemizedOverlay);
// MyLocationOverlay
MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
listOfOverlays.add(myLocationOverlay);
myLocationOverlay.enableMyLocation();
// GPS
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
// Set the criteria for selection a location provider
criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
}
示例4: _e2_addElementsToGuiSetup
import com.google.android.maps.MyLocationOverlay; //导入方法依赖的package包/类
@Override
public void _e2_addElementsToGuiSetup(GuiSetup guiSetup, Activity context) {
map = new GMap(myTargetActivity, GoogleMapsKey.pc1DebugKey);
guiSetup.addViewToBottomRight(map, 2, 130);
map.setCenterToCurrentPos();
map.setZoomLevel(20);
map.setClickable(true);
try {
map.addOverlay(new CustomItemizedOverlay(ownPosition,
IO.loadDrawableFromId(myTargetActivity,
R.drawable.mapdotblue)));
} catch (Exception e) {
Log.e("Gmaps", "An itemized overlay could be created but "
+ "not added to the Google-Maps view. A reason might "
+ "be that the mapview could not determine its "
+ "position. Check if the phone is in airplane-mode!");
e.printStackTrace();
}
MyLocationOverlay o = new MyLocationOverlay(myTargetActivity, map);
o.enableCompass();
o.enableMyLocation();
map.addOverlay(o);
map.setOnDoubleTabCommand(ifMinimizedMaximazeMapElseAddPath(guiSetup));
EventManager.getInstance().addOnKeyPressedCommand(
KeyEvent.KEYCODE_BACK, minimizeMapIfMaximized());
map.setOnTabCommand(ifMaximizedAddItemToCurrentCustomGraph());
Wrapper walkWrapper = new Wrapper(true);
CommandSetWrapperToValue disableWalkFlag = new CommandSetWrapperToValue(
walkWrapper, false);
CommandSetWrapperToValue enableWalkFlag = new CommandSetWrapperToValue(
walkWrapper, true);
guiSetup.addItemToOptionsMenu(showSearchesList(), "Searches..");
guiSetup.addItemToOptionsMenu(showCustomsList(), "Custom graphs..");
guiSetup.addSearchbarToView(guiSetup.getTopView(),
searchCustomGraphsThenMapsAndDisplayRoute(walkWrapper),
"Find Directions to..");
guiSetup.addCheckBoxToView(guiSetup.getTopView(), "By car", false,
disableWalkFlag, enableWalkFlag);
guiSetup.addTaskmanagerToView(guiSetup.getTopView());
}