Android 通过地名获得经纬度并标识在地图上
2010-10-21 01:38:14 来源:WEB开发网Projection projection = mapView.getProjection();
Point point = new Point();
projection.toPixels(geoPoint, point);
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),
drawable);
canvas.drawBitmap(bitmap, point.x-bitmap.getWidth()/2 , point.y-bitmap.getHeight(), null);
super.draw(canvas, mapView, shadow);
}
}
}
/**
*
*/
package com.decarta.demo;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;
/**
* @author Tony Shen
*
*/
public class Main extends MapActivity {
// 地图显示控制相关变量定义
private MapView map = null;
private MapController mapCon;
private Geocoder geo;
private static final int ERROR_DIALOG = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
geo = new Geocoder(this, Locale.CHINA);
更多精彩
赞助商链接