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


Java MyLocationOverlay类代码示例

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


MyLocationOverlay类属于com.google.android.maps包,在下文中一共展示了MyLocationOverlay类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:language-and-engineering,项目名称:android-mvc-framework,代码行数:20,代码来源:MMapView.java

示例2: onCreate

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
protected void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	//Log.e(TAG, "onCreate(..) called.");
	try{
		initMap();
		myLocationOverlay = new MyLocationOverlay(this, mapView);
		if( Integer.parseInt(Build.VERSION.SDK) >= 4){
			Class<MyLocationOverlay> myLocationOverlayClass = MyLocationOverlay.class;
			try{
				enableCompassMethod = myLocationOverlayClass.getMethod("enableCompass");
				disableCompassMethod = myLocationOverlayClass.getMethod("disableCompass");
			}catch(NoSuchMethodException nsme){
				Log.e(TAG, "ERR000IX", nsme);
				ErrorUtil.handleException("ERR000IX", nsme, this);
			}
		}
		mapView.getOverlays().add(myLocationOverlay);
		
	}catch(HandledException h){ // Ignore.
	}catch(Exception exp){
		Log.e(TAG, "ERR000IW", exp);
		ErrorUtil.handleExceptionFinish("ERR000IW", exp, this);
	}
}
 
开发者ID:SpencerRiddering,项目名称:flingtap-done,代码行数:25,代码来源:BasicMapActivity.java

示例3: 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;
}
 
开发者ID:simon-heinen,项目名称:droidar,代码行数:25,代码来源:GMap.java

示例4: onCreate

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.main);
    
    mImageManager = ImageManager.getInstance(this);
    
    FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
    Button goButton = (Button) findViewById(R.id.go);
    goButton.setOnClickListener(this);
   
    // Add the map view to the frame
    mMapView = new MapView(this, "Panoramio_DummyAPIKey");
    frame.addView(mMapView, 
            new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    // Create an overlay to show current location
    mMyLocationOverlay = new MyLocationOverlay(this, mMapView);
    mMyLocationOverlay.runOnFirstFix(new Runnable() { public void run() {
        mMapView.getController().animateTo(mMyLocationOverlay.getMyLocation());
    }});

    mMapView.getOverlays().add(mMyLocationOverlay);
    mMapView.getController().setZoom(15);
    mMapView.setClickable(true);
    mMapView.setEnabled(true);
    mMapView.setSatellite(true);
    
    addZoomControls(frame);
}
 
开发者ID:tgmarinho,项目名称:apps-for-android,代码行数:32,代码来源:Panoramio.java

示例5: onPause

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
@Override
protected void onPause() {
    super.onPause();
    mLocationManager.removeUpdates(this);
    ((MyLocationOverlay) mLocationOverlay).disableMyLocation();

}
 
开发者ID:sages-health,项目名称:sagesmobile-mCollect,代码行数:8,代码来源:GeoPointMapActivity.java

示例6: onResume

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();

    ((MyLocationOverlay) mLocationOverlay).enableMyLocation();
    if (mGPSOn) {
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    }
    if (mNetworkOn) {
        mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    }

}
 
开发者ID:sages-health,项目名称:sagesmobile-mCollect,代码行数:14,代码来源:GeoPointMapActivity.java

示例7: onCreate

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
public void onCreate(Bundle bundle) {
	super.onCreate(bundle);
	setContentView(R.layout.main); // bind the layout to the activity

	// Configure the Map
	mapView = (MapView) findViewById(R.id.mapview);
	mapView.setBuiltInZoomControls(true);
	mapView.setSatellite(true);
	mapController = mapView.getController();
	mapController.setZoom(14); // Zoon 1 is world view
	locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
	locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
			0, new GeoUpdateHandler());

	myLocationOverlay = new MyLocationOverlay(this, mapView);
	mapView.getOverlays().add(myLocationOverlay);

	myLocationOverlay.runOnFirstFix(new Runnable() {
		public void run() {
			mapView.getController().animateTo(
					myLocationOverlay.getMyLocation());
		}
	});

	Drawable drawable = this.getResources().getDrawable(R.drawable.point);
	itemizedoverlay = new MyOverlays(this, drawable);
	createMarker();
}
 
开发者ID:vogellacompany,项目名称:codeexamples-android,代码行数:29,代码来源:ShowMapActivity.java

示例8: onCreate

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FrameLayout frame = new FrameLayout(this);
    mMapView = new MapView(this, "MapViewCompassDemo_DummyAPIKey");
    frame.addView(mMapView, 
            new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    setContentView(frame);

    mMyLocationOverlay = new MyLocationOverlay(this, mMapView);

    mMarker = getResources().getDrawable(R.drawable.map_pin);
    
    // Make sure to give mMarker bounds so it will draw in the overlay
    final int intrinsicWidth = mMarker.getIntrinsicWidth();
    final int intrinsicHeight = mMarker.getIntrinsicHeight();
    mMarker.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
    
    mMarkerXOffset = -(intrinsicWidth / 2);
    mMarkerYOffset = -intrinsicHeight;
    
    // Read the item we are displaying from the intent, along with the 
    // parameters used to set up the map
    Intent i = getIntent();
    mItem = i.getParcelableExtra(ImageManager.PANORAMIO_ITEM_EXTRA);
    int mapZoom = i.getIntExtra(ImageManager.ZOOM_EXTRA, Integer.MIN_VALUE);
    int mapLatitudeE6 = i.getIntExtra(ImageManager.LATITUDE_E6_EXTRA, Integer.MIN_VALUE);
    int mapLongitudeE6 = i.getIntExtra(ImageManager.LONGITUDE_E6_EXTRA, Integer.MIN_VALUE);
    
    final List<Overlay> overlays = mMapView.getOverlays();
    overlays.add(mMyLocationOverlay);
    overlays.add(new PanoramioOverlay());
    
    final MapController controller = mMapView.getController();
    if (mapZoom != Integer.MIN_VALUE && mapLatitudeE6 != Integer.MIN_VALUE
            && mapLongitudeE6 != Integer.MIN_VALUE) {
        controller.setZoom(mapZoom);
        controller.setCenter(new GeoPoint(mapLatitudeE6, mapLongitudeE6));
    } else {
        controller.setZoom(15);
        mMyLocationOverlay.runOnFirstFix(new Runnable() {
            public void run() {
                controller.animateTo(mMyLocationOverlay.getMyLocation());
            }
        });
    }

    mMapView.setClickable(true);
    mMapView.setEnabled(true);
    mMapView.setSatellite(true);
    addZoomControls(frame);
}
 
开发者ID:tgmarinho,项目名称:apps-for-android,代码行数:54,代码来源:ViewMap.java

示例9: 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);
  
   }
 
开发者ID:busradar,项目名称:busradar,代码行数:77,代码来源:BusRadar.java

示例10: onCreate

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setBackgroundDrawable(null);
    setContentView(R.layout.main);

    
    mFormatUtil = new FormatUtil(this);
    
    HandlerThread pThread = new HandlerThread(TAG);
    pThread.setPriority(Thread.MIN_PRIORITY);
    pThread.start();
    pHandler = new Handler(pThread.getLooper());


    locText = (TextSwitcher) findViewById(R.id.text_location);
    locText.setFactory(new ViewSwitcher.ViewFactory() {
        @Override
        public View makeView() {
            return getLayoutInflater()
                    .inflate(R.layout.coordinations, null).findViewById(
                            R.id.text);
        }

    });


    locText.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mFormatUtil.toggleFormat();
            setLocText(mPin.mPoint, true);
        }
    });


    mMapView = (MapView) findViewById(R.id.mapview);
    mMapView.setBuiltInZoomControls(true);
    mPin = new AndroidPin(this);
    Intent intent = getIntent();
    mPin.setPosition(mMapView.getMapCenter());


    fallOverlay = new FallInOverlay(mMapView);
    fallOverlay.setOnEndListener(new OnEndListener() {
        @Override
        public void onEnd() {
            mMapView.getOverlays().remove(fallOverlay);
            mMapView.getOverlays().add(dragOverlay);
        }
    });

    dragOverlay = new DragableOverlay(mPin, mMapView);
    dragOverlay.setOnLocationChangeListener(new OnLocationChangeListener() {
        @Override
        public void onChage(GeoPoint gp) {
            setLocText(gp, false);
        }
    });

    mMyLocationOverlay = new MyLocationOverlay(this, mMapView);

    mMapView.getOverlays().add(mMyLocationOverlay);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    setLocText(mPin.mPoint, false);

    mMapView.getOverlays().add(fallOverlay);
    isCreate = true;

}
 
开发者ID:misgod,项目名称:geopicker,代码行数:73,代码来源:GeoPickerActivity.java

示例11: onCreate

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	
	//initialize public feed parser
	PublicParser.initialize(getApplicationContext());
	StopsParser.initialize(getApplicationContext());
	
	// setup map view
	mapView = (MainView) findViewById(R.id.mapview);
	mapView.setBuiltInZoomControls(false);
	mapView.setZoomControlButtons(findViewById(R.id.bnZoomIn), findViewById(R.id.bnZoomOut));
	
	// set button click listener
	findViewById(R.id.biShowRoute).setOnClickListener(this);
	findViewById(R.id.bnMyLocation).setOnClickListener(this);
	findViewById(R.id.bnShowStop).setOnClickListener(this);
	findViewById(R.id.bnClearMap).setOnClickListener(this);

	// create map item overlay
	mapItemOverlay = new MapItemOverlay(this);
	mapItemOverlay.setBusTapListener(busTapListener);
	mapItemOverlay.setStopTapListener(stopTapListener);
	mapView.getOverlays().add(mapItemOverlay);
	
	// create my location overlay
	myLocationOverlay = new MyLocationOverlay(this, mapView);
	mapView.getOverlays().add(myLocationOverlay);
	
	// -- get default value
	int mapLatE6 = getResources().getInteger(R.integer.param_map_latE6_default);
	int mapLonE6 = getResources().getInteger(R.integer.param_map_lonE6_default);
	int mapZoom  = getResources().getInteger(R.integer.param_map_zoom_default);
	
	// -- load data from saved state
	if(savedInstanceState != null) {
		mapLatE6 = savedInstanceState.getInt(MAP_LAT, mapLatE6);
		mapLonE6 = savedInstanceState.getInt(MAP_LON, mapLonE6);
		mapZoom  = savedInstanceState.getInt(MAP_ZOOM, mapZoom);
		
		selectedRouteId = savedInstanceState.getInt(DISPLAYED_ROUTE, RouteItem.ROUTE_NULL);
	}
	
	// -- set default map position
	MapController ctrl = mapView.getController();
	ctrl.setCenter(new GeoPoint(mapLatE6, mapLonE6));
	ctrl.setZoom(mapZoom);
	
	switch( getIntent().getIntExtra(EX_INTENT, -1) ) {
	case -1:
		// Regular startup

		// -- Animate to my location on first fix
		// -- Add this condition to suppress fix on orientation change
		if(savedInstanceState == null)
			myLocationOverlay.runOnFirstFix(animateToMyLocation);	
		break;
		
	case EX_INTENT_SHOWSTOP:
		// create this activity to show a certain stop
		ctrl.setZoom(getResources().getInteger(R.integer.param_map_zoom_showstop));
		
		String stopName = getIntent().getStringExtra(EX_STOPNAME);
		// Assign AsyncTask
		new ShowStopTask().execute(stopName);
	}
}
 
开发者ID:magic-bus,项目名称:BlueBus,代码行数:70,代码来源:BlueBus.java

示例12: _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());
}
 
开发者ID:simon-heinen,项目名称:droidar,代码行数:49,代码来源:ARNavigatorSetup.java

示例13: setMapContentView

import com.google.android.maps.MyLocationOverlay; //导入依赖的package包/类
public void setMapContentView(int layoutID, int mapWidgetID){
  	
      setContentView(layoutID);
       
      this.mapView = (MapView) findViewById(mapWidgetID);      
      this.mapView.setBuiltInZoomControls(true);
              
      this.genericMarker = getResources().getDrawable(razor.android.lib.core.R.drawable.lib_red_map_marker);
      this.genericMarker.setBounds(0, 0, this.genericMarker.getIntrinsicWidth(),this.genericMarker.getIntrinsicHeight());

this.locationOverlay = new MyLocationOverlay(this, this.mapView);
mapView.getOverlays().add(this.locationOverlay);        
  }
 
开发者ID:paulshemmings,项目名称:pico,代码行数:14,代码来源:CoreMapActivity.java


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