本文整理汇总了Java中com.google.android.maps.MapController类的典型用法代码示例。如果您正苦于以下问题:Java MapController类的具体用法?Java MapController怎么用?Java MapController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapController类属于com.google.android.maps包,在下文中一共展示了MapController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
import com.google.android.maps.MapController; //导入依赖的package包/类
public boolean onKeyDown(int keyCode, KeyEvent event)
{
MapController mc = mapView.getController();
switch (keyCode)
{
case KeyEvent.KEYCODE_3:
mc.zoomIn();
break;
case KeyEvent.KEYCODE_1:
mc.zoomOut();
break;
}
return super.onKeyDown(keyCode, event);
}
示例2: onCreate
import com.google.android.maps.MapController; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
/**
* To show a map of San Francisco, we need to create a geo point object
* with longitude and latitude in center of SF.
*/
GeoPoint point = new GeoPoint(37779300, -122419200);
/**
* MapController is needed to set view location and zooming.
*/
MapController mc = mapView.getController();
mc.setCenter(point);
mc.setZoom(14);
}
示例3: centerOnCurrentLocation
import com.google.android.maps.MapController; //导入依赖的package包/类
public static void centerOnCurrentLocation(Context context, MapController mapController) {
PendingIntent pIntent = PendingIntent.getBroadcast(context, -1, new Intent() , PendingIntent.FLAG_ONE_SHOT);
assert pIntent != null;
LocationManager locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
if( null != provider ){
LocationProvider locationProvider = locationManager.getProvider(provider);
if( null != locationProvider ){
locationManager.requestLocationUpdates(locationProvider.getName(), 0, 0, pIntent); // I think this is needed to start the location hardware (I read that somewhere and I was not able to get a position without it).
Location location = locationManager.getLastKnownLocation(locationProvider.getName());
locationManager.removeUpdates(pIntent);
if( null != location ){
mapController.setCenter(new GeoPoint((int)((location.getLatitude())*1E6), (int)((location.getLongitude())*1E6)));
}
}
}
}
示例4: getController
import com.google.android.maps.MapController; //导入依赖的package包/类
@Implementation
public MapController getController() {
if (mapController == null) {
try {
mapController = Robolectric.newInstanceOf(MapController.class);
shadowMapController = shadowOf(mapController);
shadowMapController.setShadowMapView(this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return mapController;
}
示例5: moveToCampus
import com.google.android.maps.MapController; //导入依赖的package包/类
private void moveToCampus(boolean animate) {
MapController controller = mapView.getController();
controller.setZoom(MIN_ZOOM_LEVEL+1);
GeoPoint center = new GeoPoint(39483760, -87325929);
if (animate) {
controller.animateTo(center);
} else {
controller.setCenter(center);
}
}
示例6: showWhois
import com.google.android.maps.MapController; //导入依赖的package包/类
public void showWhois(String Msg, double Latitude, double Longitude)
{
/*TextView MsgBody = new TextView(this);
MsgBody.setText(Msg);
MsgBody.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
MapBody = new TableLayout(this);
MapBody.setGravity(Gravity.CENTER);
MapBody.addView(MsgBody);
*/
FrameLayout MapBody = new FrameLayout(this);
MapBodyRef = new WeakReference<FrameLayout>(MapBody);
MapBody.addView(GeoIPMap);
MapController GeoIPControl = GeoIPMap.getController();
GeoPoint MapPoint = new GeoPoint((int)Longitude,(int)Latitude);
GeoIPControl.setZoom(8);
GeoIPControl.animateTo(MapPoint);
GeoIPControl.setCenter(MapPoint);
GeoIPMap.getOverlays().add(new MapOverlay(this, MapPoint, R.drawable.point));
AlertDialog.Builder WhoisAlert = new AlertDialog.Builder(this);
WhoisAlert.setTitle("Whois");
WhoisAlert.setMessage(Msg);
WhoisAlert.setView(MapBody);
WhoisAlert.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if(MapBodyRef != null && MapBodyRef.get() != null) {
MapBodyRef.get().removeAllViews();
}
}
});
WhoisAlert.show();
}
示例7: setStartPoint
import com.google.android.maps.MapController; //导入依赖的package包/类
public void setStartPoint() {
Location location = getMixContext().getLocationFinder()
.getCurrentLocation();
MapController controller;
double latitude = location.getLatitude() * 1E6;
double longitude = location.getLongitude() * 1E6;
controller = getMapView().getController();
startPoint = new GeoPoint((int) latitude, (int) longitude);
controller.setCenter(startPoint);
controller.setZoom(15);
}
示例8: onCreate
import com.google.android.maps.MapController; //导入依赖的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);
}
示例9: onCreate
import com.google.android.maps.MapController; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mShowGMap = mPrefs.getBoolean("pref_use_city_map", true);
if (Application.OSBeforeHoneyComb()) {
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
}
setContentView(mShowGMap ? R.layout.city : R.layout.city_no_map);
if (Application.OSBeforeHoneyComb()) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.city_title_bar);
}
else {
ActionBarHelper.setDisplayHomeAsUpEnabled(this, true);
}
mList = (ListView)findViewById(R.id.lineslist);
mList.setItemsCanFocus(true);
mList.setOnItemClickListener(this);
final Intent intent = getIntent();
final Bundle bun = intent.getExtras();
// Sent directly from the suggestion search entry or from the SearchableActivity
mCityId = bun.getString("cityId");
mLines = new ArrayList<BusLine>();
mDirections = new ArrayList<List<City>>();
QueryManager finder = SQLQueryManager.getInstance();
String cityName = City.removeSelfSuffix(finder.getCityFromId(mCityId));
List<City> cities = finder.findCities(cityName, true);
List<BusLine> lines = finder.findLinesInCity(cityName);
if (Application.OSBeforeHoneyComb()) {
setPrimaryTitle(cityName);
setSecondaryTitle(getString(R.string.city_title));
}
else {
ActionBarHelper.setTitle(this, cityName);
}
new DirectionsRetreiverTask().execute(lines);
if (Application.OSBeforeHoneyComb()) {
Button searchButton = (Button)findViewById(R.id.btn_search);
searchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// Open search dialog
mCanFinish = true;
onSearchRequested();
}
});
}
if (mShowGMap) {
MapView mapView = (MapView) findViewById(R.id.mapview);
MapController controller = mapView.getController();
// Display city on map
Drawable marker = getResources().getDrawable(android.R.drawable.star_big_on);
int markerWidth = marker.getIntrinsicWidth();
int markerHeight = marker.getIntrinsicHeight();
marker.setBounds(0, markerHeight, markerWidth, 0);
BaseItemsOverlay busOverlay = new BaseItemsOverlay(marker);
GPSPoint pt = finder.getCityGPSCoordinates(cities.get(0));
GeoPoint cityPoint = new GeoPoint(pt.getLatitude(), pt.getLongitude());
busOverlay.addItem(cityPoint, "doo", "Kilo");
mapView.getOverlays().add(busOverlay);
// Center map on the city
controller.setCenter(cityPoint);
controller.setZoom(DEFAULT_MAP_ZOOM);
}
}
示例10: shadowOf
import com.google.android.maps.MapController; //导入依赖的package包/类
public static ShadowMapController shadowOf(MapController instance) {
return (ShadowMapController) Robolectric.shadowOf_(instance);
}
示例11: SelectAreaOverlays
import com.google.android.maps.MapController; //导入依赖的package包/类
public SelectAreaOverlays(Drawable defaultMarker, Context context, SelectAreaOverlayItem[] overlayItems, MapController controller) {
super(defaultMarker);
assert null != defaultMarker;
mDefaultMarker = defaultMarker;
assert null != context;
mContext = context;
assert null != controller;
mController = controller;
assert null != overlayItems;
mOverlayItems = overlayItems;
boundCenterBottom(defaultMarker);
populate();
}
示例12: getController
import com.google.android.maps.MapController; //导入依赖的package包/类
public MapController getController() {
return mController;
}
示例13: setController
import com.google.android.maps.MapController; //导入依赖的package包/类
public void setController(MapController controller) {
mController = controller;
}
示例14: onCreate
import com.google.android.maps.MapController; //导入依赖的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);
}
}
示例15: smoothMove
import com.google.android.maps.MapController; //导入依赖的package包/类
public static void smoothMove(final MapView mapView, Handler handler, GeoPoint targetCenter, final int targetLongSpan,
final int targetLatSpan, boolean zoom, Running running) {
final MapController mControl = mapView.getController();
// a Quick runnable to zoom in
GeoPoint currentCenter = mapView.getMapCenter();
// yes brandon, we need doubles.
double currentLat = currentCenter.getLatitudeE6();
double currentLong = currentCenter.getLongitudeE6();
final int targetLat = targetCenter.getLatitudeE6();
final int targetLong = targetCenter.getLongitudeE6();
int rateOfChange = 100;
double deltaLong = 0;
double deltaLat = 0;
deltaLat = -(currentLat - targetLat) / rateOfChange;
deltaLong = -(currentLong - targetLong) / rateOfChange;
long delay = 0;
while (!equalWithinEpsilon(currentLat, targetLat, deltaLat * 2) || !equalWithinEpsilon(currentLong, targetLong, deltaLong * 2)) {
if (!equalWithinEpsilon(currentLong, targetLong, deltaLong * 2)) {
currentLong += deltaLong;
}
if (!equalWithinEpsilon(currentLat, targetLat, deltaLat * 2)) {
currentLat += deltaLat;
}
final int newLong = (int) currentLong;
final int newLat = (int) currentLat;
handler.postDelayed(new RunnableMover(mControl, new GeoPoint(newLat, newLong), running), delay);
delay += 5;
if (delay > 1000) // just so we don't get stuck in an infinite loop
break;
}
// System.out.println(delay);
handler.postDelayed(new RunnableMover(mControl, new GeoPoint(targetLat, targetLong), running), delay);
if (zoom) {
AnimatedMapZoomer amz = new AnimatedMapZoomer(mapView, handler, targetLatSpan, targetLongSpan, delay);
new Thread(amz).start();
}
}