當前位置: 首頁>>代碼示例>>Java>>正文


Java MapView類代碼示例

本文整理匯總了Java中com.google.android.maps.MapView的典型用法代碼示例。如果您正苦於以下問題:Java MapView類的具體用法?Java MapView怎麽用?Java MapView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MapView類屬於com.google.android.maps包,在下文中一共展示了MapView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
  if (overlayImage == null || overlayImage.isRecycled()) {
    return false;
  }
  float x = mapView.getWidth() / 2f;
  float y = mapView.getHeight() / 2f;

  imageMatrix.reset();
  imageMatrix.postTranslate(-centerX + x, -centerY + y);
  imageMatrix.postRotate(rotation, x, y);
  imageMatrix.postScale(scale, scale, x, y);

  canvas.drawBitmap(overlayImage, imageMatrix, transparency);

  // Draw small black ring with white edge to indicate center point
  centerPaint.setColor(0xffffffff);
  centerPaint.setStrokeWidth(4f);
  canvas.drawCircle(x, y, 5, centerPaint);
  centerPaint.setColor(0xff000000);
  centerPaint.setStrokeWidth(2f);
  canvas.drawCircle(x, y, 5, centerPaint);

  return false;
}
 
開發者ID:markoteittinen,項目名稱:custom-maps,代碼行數:26,代碼來源:MapImageOverlay.java

示例2: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
    Projection projection = mapView.getProjection();
    if (shadow == false && mapView.getZoomLevel() >= minZoom) {
    		int zoomExtra = mapView.getZoomLevel() - minZoom;
         Paint rectPaint = new Paint();
         Paint textPaint = new Paint();
         Point point = new Point();
         projection.toPixels(gp, point);
         rectPaint.setColor(Color.GRAY);
         rectPaint.setAlpha(128);
         rectPaint.setStrokeWidth(2);
         textPaint.setTextSize(baseTextSize + (zoomExtra * 2));
         textPaint.setAntiAlias(true);
         //textPaint.setColor(Color.RED);
         textPaint.setColor(Color.parseColor(color));
         textPaint.setTextAlign(Align.LEFT);
         float textwidth = textPaint.measureText(text);
         canvas.drawRect(point.x, point.y, point.x + 4 + textwidth, point.y + 4 + textPaint.getTextSize(), rectPaint);
         rectPaint.setColor(Color.WHITE);
         canvas.drawCircle(point.x + 2, point.y + 2, 4, rectPaint);
         canvas.drawText(text, point.x + 1, point.y + textPaint.getTextSize(), textPaint);
    }
    return super.draw(canvas, mapView, shadow, when);
}
 
開發者ID:Hellek1,項目名稱:viaja-facil,代碼行數:26,代碼來源:StationOverlay.java

示例3: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	super.draw(canvas, mapView, shadow);
	if (shadow || pointsToDraw == null || pointsToDraw.length == 0)
		return;
	for (GeoPoint p : pointsToDraw) {
		// convert point to pixels
		Point screenPts = new Point();
		GeoPoint pointToDraw = new GeoPoint(p.getLatitudeE6(),
				p.getLongitudeE6());
		mapView.getProjection().toPixels(pointToDraw, screenPts);
		int pointRadius = (int) mapView.getProjection()
				.metersToEquatorPixels(5);
		int dotRadius = (int) mapView.getProjection()
				.metersToEquatorPixels(2);
		canvas.drawCircle(screenPts.x, screenPts.y, pointRadius,
				mPaintPoint);
		canvas.drawCircle(screenPts.x, screenPts.y, pointRadius,
				mPaintPointBorder);
		canvas.drawCircle(screenPts.x, screenPts.y, dotRadius,
				mPaintPointDot);
	}
	return;
}
 
開發者ID:MoveLab,項目名稱:tigatrapp-android,代碼行數:25,代碼來源:MapData.java

示例4: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public boolean draw(Canvas canvas, MapView mapView, 
boolean shadow, long when) 
{
    super.draw(canvas, mapView, shadow);                   
 
    //---translate the GeoPoint to screen pixels---
    Point screenPts = new Point();
    mapView.getProjection().toPixels(p, screenPts);
 
    //---add the marker---
    Bitmap bmp = BitmapFactory.decodeResource(
        getResources(), R.drawable.pushpin);            
    canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);         
    return true;
}
 
開發者ID:busradar,項目名稱:busradar,代碼行數:17,代碼來源:MapsActivity.java

示例5: onCreate

import com.google.android.maps.MapView; //導入依賴的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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:MapActivity.java

示例6: DragableOverlay

import com.google.android.maps.MapView; //導入依賴的package包/類
public DragableOverlay(AndroidPin pin, MapView mapview) {
    mPin = pin;
    mMapView = mapview;
    mProjector = mapview.getProjection();
    mVibrator = (Vibrator)mapview.getContext().getSystemService(Context.VIBRATOR_SERVICE);
    
    
    newPosition = pin.mPoint;
    targetDrawable = mapview.getContext().getResources().getDrawable(R.drawable.target);
    int width = targetDrawable.getIntrinsicWidth();
    int height = targetDrawable.getIntrinsicHeight();
    int w2 = width / 2;
    int h2 = height / 2;
   
    targetDrawable.setBounds(-w2, -h2, w2,h2);
   
}
 
開發者ID:misgod,項目名稱:geopicker,代碼行數:18,代碼來源:DragableOverlay.java

示例7: onCreate

import com.google.android.maps.MapView; //導入依賴的package包/類
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
	Log.i("rawphone", "Starting MapViewer ============");   	
	super.onCreate(savedInstanceState);
    setContentView(R.layout.map);
    
    ImageView imagev = new ImageView(this);
    mapv = (MapView) findViewById(R.id.mapView);  
    mapv.setBuiltInZoomControls(true);
    mapv.displayZoomControls(true);
    
    myDB=null;
    try {        	
    	myDB =  this.openOrCreateDatabase(DB_NAME, MODE_PRIVATE, null);
    	loadentries();
    } catch (SQLiteException se ) {
    	Log.e(getClass().getSimpleName(), "Could not Open the database:" +se);
    	myDB=null;
    }
}
 
開發者ID:jofrep,項目名稱:Android-RawPhone,代碼行數:23,代碼來源:MapViewer.java

示例8: ProximityOverlay

import com.google.android.maps.MapView; //導入依賴的package包/類
public ProximityOverlay(GeoPoint point, int initialMeterRadius, 
		OnProximityExceedingScreenListener largeListener, MapView mapView,
		float screenDensity) {
	super();
	assert point != null;
	assert largeListener != null;
	assert mapView != null;
	
	this.largeListener = largeListener;
	this.mMapView = mapView;
	
	mScreenDensity = screenDensity;
	
    paint.setStyle(Paint.Style.STROKE);

    updateColor();
    paint.setStrokeWidth(2);
	this.mPoint = point;
	mMeterRadius = initialMeterRadius;
	setMeterRadius(initialMeterRadius);
}
 
開發者ID:SpencerRiddering,項目名稱:flingtap-done,代碼行數:22,代碼來源:ProximityOverlay.java

示例9: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	super.draw(canvas, mapView, shadow);
	try{
		// Log.e(TAG, "draw(Canvas canvas, MapView mapView, boolean shadow) called.");
		
		float pixelsPerMeter = (float) calcPixelsPerMeter(
				(double) mPoint.getLatitudeE6(), 
				mapView.getZoomLevel(),
				mMeterRadius,
				mScreenDensity); 
		
		setPixelRadius( pixelsPerMeter );
		
		sXYCoords = mapView.getProjection().toPixels(mPoint, sXYCoords);
		
		canvas.drawCircle(sXYCoords.x, sXYCoords.y, pixelRadius, paint);
		displayPoints(mapView, canvas);
		
	}catch(HandledException h){ // Ignore.
	}catch(Exception exp){
		if( mActOnIt ){
			Log.e(TAG, "ERR00053", exp);
		}
		mActOnIt = ErrorUtil.handle("ERR00053", "", this, mActOnIt);
	}
}
 
開發者ID:SpencerRiddering,項目名稱:flingtap-done,代碼行數:27,代碼來源:ProximityOverlay.java

示例10: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public void draw(Canvas canvas, MapView map, boolean shadow) {
    if (shadow || this.location == null) {
        return;
    }

    Projection proj = map.getProjection();

    // check whether the current location is on the visible map
    this.currentLocationOnScreen = checkCurrentLocationOnScreen(map, proj);

    proj.toPixels(this.location, this.tmpPoint);
    float radius = proj.metersToEquatorPixels(this.accuracyAdjusted);
    canvas.drawCircle(this.tmpPoint.x, this.tmpPoint.y, radius, paintFill);
    canvas.drawCircle(this.tmpPoint.x, this.tmpPoint.y, radius, paintOuter);
}
 
開發者ID:jacekkopecky,項目名稱:parkjam,代碼行數:17,代碼來源:MyLocationOverlay.java

示例11: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow) return;
	
	Projection proj = mapView.getProjection();
	MapAreaData mapData = mapArea.mapData;
	
	Path path = new Path();
	pt = proj.toPixels(mapData.corners[0].asGeoPoint(), pt);
	path.moveTo(pt.x, pt.y);
	
	for (int i = 1; i < mapData.corners.length; i++) {
		proj.toPixels(mapData.corners[i].asGeoPoint(), pt);
		path.lineTo(pt.x, pt.y);
	}
	proj.toPixels(mapData.corners[0].asGeoPoint(), pt);
	path.lineTo(pt.x, pt.y);

	canvas.drawPath(path, paintFill);		
	canvas.drawPath(path, paintStroke);
}
 
開發者ID:almajeas,項目名稱:RHITMobile-Android,代碼行數:22,代碼來源:BuildingOverlay.java

示例12: draw

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow) {
		super.draw(canvas, mapView, shadow);
		return;
	}
	
	Projection proj = mapView.getProjection();
	android.graphics.Path directionsPath = new android.graphics.Path();
	
	pt = proj.toPixels(directions.paths[0].coord.asGeoPoint(), pt);
	directionsPath.moveTo(pt.x, pt.y);
	
	for (int i = 1; i < directions.paths.length; i++) {
		DirectionPath path = directions.paths[i];
		proj.toPixels(path.coord.asGeoPoint(), pt);
		directionsPath.lineTo(pt.x, pt.y);
	}
	
	canvas.drawPath(directionsPath, pathPaint);
	
	super.draw(canvas, mapView, shadow);
}
 
開發者ID:almajeas,項目名稱:RHITMobile-Android,代碼行數:24,代碼來源:DirectionsLayer.java

示例13: onTap

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public boolean onTap(GeoPoint p, MapView mapView) {
	pt = mapView.getProjection().toPixels(p, pt);
	
	Point snapPoint = new Point();
	for (BuildingOverlay building : overlays.values()) {
		if (building.onSnapToItem(pt.x, pt.y, snapPoint, mapView)) {
			GeoPoint dest = mapView.getProjection().fromPixels(snapPoint.x, snapPoint.y);
			setSelected(building);
			moveToSelected(dest, true);
			if (listener != null) {
				listener.onSelect(building.getLocation());
			}
			return true;
		}
	}
	return false;
}
 
開發者ID:almajeas,項目名稱:RHITMobile-Android,代碼行數:19,代碼來源:BuildingOverlayLayer.java

示例14: onActivityCreated

import com.google.android.maps.MapView; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);
	mListCheckinModel = new ListCheckinModel();
	mListCheckinModel.load();
	mCheckinModel = mListCheckinModel.getCheckins(getActivity());
	showUsers();
	mHandler = new Handler();
	map = new MapView(getActivity(), getActivity().getString(
			R.string.google_map_api_key));
	Preferences.loadSettings(getActivity());
	if (mCheckinModel.size() > 0) {
		map.setClickable(true);
		map.setBuiltInZoomControls(true);
		mHandler.post(mMarkersOnMap);

	} else {
		toastLong(R.string.no_checkin);
	}

	((ViewGroup) getView()).addView(map);

}
 
開發者ID:bartfaizoltan,項目名稱:Joszolgalat_Android_App,代碼行數:24,代碼來源:MapCheckinFragment.java

示例15: showBalloon

import com.google.android.maps.MapView; //導入依賴的package包/類
/** Show an information balloon on the map */
protected void showBalloon(GeoPoint pos, String text) {
	if(balloonView != null)
		mapView.removeView(balloonView);
	
	LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	balloonView = inflater.inflate(R.layout.balloon, mapView, false);
	
	mapView.addView(balloonView, new MapView.LayoutParams(
			MapView.LayoutParams.WRAP_CONTENT,
			MapView.LayoutParams.WRAP_CONTENT,
			pos,
			MapView.LayoutParams.BOTTOM_CENTER));
	
	// Set text and click listener
	Button bnBalloon = (Button)findViewById(R.id.balloonButton);
	bnBalloon.setText(text);
	bnBalloon.setOnClickListener(this);
	
	// Apply animation
	Animation showBalloonAnimation = AnimationUtils.loadAnimation(this, R.anim.balloon_show);
	balloonView.startAnimation(showBalloonAnimation);
}
 
開發者ID:magic-bus,項目名稱:BlueBus,代碼行數:24,代碼來源:BlueBus.java


注:本文中的com.google.android.maps.MapView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。