Android中的Google Map键? [英] Google Map key in Android?

查看:117
本文介绍了Android中的Google Map键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个android应用程序,其中我必须在前一个应用程序中显示地图视图,但在前一个应用程序中使用的键不适用于他的应用程序。
这只是在应用程序中显示空白屏幕的引脚。
我是否必须为每个项目使用不同的Map键,如果不是,请帮助我如何使用我之前的Key。
,我也尝试生成一个新的密钥,但给了相同的密钥。



这是我使用的代码

  public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
btn =(Button)findViewById(R.id.mapbtn);
str1 = getIntent()。getStringExtra(LATITUDE);
str2 = getIntent()。getStringExtra(LONGITUDE);





mapView =(MapView)findViewById(R.id.mapView1);
//查看zoomView = mapView.getZoomControls();

mapView.setBuiltInZoomControls(true);
//mapView.setSatellite(true);
mc = mapView.getController();
btn.setOnClickListener(this);

MapOverlay mapOverlay = new MapOverlay();
列表< Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);


字符串坐标[] = {str1,str2};
double lat = Double.parseDouble(coordinates [0]);
double lng = Double.parseDouble(coordinates [1]);

p =新的GeoPoint(
(int)(lat * 1E6),
(int)(lng * 1E6));

mc.animateTo(p);
mc.setZoom(17);
mapView.invalidate();

//mp.equals(o);

@Override
protected boolean isRouteDisplayed(){
// TODO自动生成的方法存根
return false;
}
类MapOverlay扩展了com.google.android.maps.Overlay
{
@Override
public boolean draw(Canvas canvas,MapView mapView,
boolean shadow,long when)
{
super.draw(canvas,mapView,shadow);
Paint mPaint = new Paint();
mPaint.setDither(true);
mPaint.setColor(Color.RED);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(2);

---将GeoPoint转换为屏幕像素---
Point screenPts = new Point();
mapView.getProjection()。toPixels(p,screenPts);

// ---添加标记---
位图bmp = BitmapFactory.decodeResource(getResources(),R.drawable.pin);
canvas.drawBitmap(bmp,screenPts.x,screenPts.y-50,null);
返回true;
}

谢谢....

  amandeep有两种地图键:调试键和释放键
调试键适用于您的系统正在开发可用于每个应用程序的应用程序
,而第二个是针对每个应用程序和每个应用程序都需要创建新应用程序的版本密钥。

http://code.google.com/android/add-ons/google-apis/mapkey.html



调试和签名键之间的区别


I am developing an android app in which i have to show map view i have done it once in a previous app but the key i used in the previous is not working int his app . It is just showing a pin in the application with blank screen. Do i have to use a different Map key for each project , If not Kindly help me how can i use my previous Key in this. and also I tried generating a new key but gave the the same key back .

Here is the code i used

  public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);
        btn=(Button)findViewById(R.id.mapbtn);
        str1=getIntent().getStringExtra("LATITUDE");
        str2=getIntent().getStringExtra("LONGITUDE");





        mapView =  (MapView)findViewById(R.id.mapView1);
        //View zoomView = mapView.getZoomControls(); 

        mapView.setBuiltInZoomControls(true);
         //mapView.setSatellite(true);
         mc = mapView.getController();
         btn.setOnClickListener(this);

          MapOverlay mapOverlay = new MapOverlay();
            List<Overlay> listOfOverlays = mapView.getOverlays();
            listOfOverlays.clear();
            listOfOverlays.add(mapOverlay); 


            String coordinates[] = {str1,  str2};
            double lat = Double.parseDouble(coordinates[0]);
            double lng = Double.parseDouble(coordinates[1]);

            p = new GeoPoint(
                (int) (lat * 1E6), 
                (int) (lng * 1E6));

            mc.animateTo(p);
            mc.setZoom(17); 
            mapView.invalidate();

        //mp.equals(o);
    }
    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
    class MapOverlay extends com.google.android.maps.Overlay
    {
        @Override
        public boolean draw(Canvas canvas, MapView mapView, 
        boolean shadow, long when) 
        {
            super.draw(canvas, mapView, shadow);                   
            Paint mPaint = new Paint();
            mPaint.setDither(true);
            mPaint.setColor(Color.RED);
            mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            mPaint.setStrokeJoin(Paint.Join.ROUND);
            mPaint.setStrokeCap(Paint.Cap.ROUND);
            mPaint.setStrokeWidth(2);

            //---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.pin);            
            canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);         
            return true;
        }

Thanks....

解决方案

amandeep there are two kinds of key for maps debug key and release key 
debug key is for your system on which you are developping your application 
that can be used for every application and the seconde one is release key that is different for every application and for each application you have to create new one

http://code.google.com/android/add-ons/google-apis/mapkey.html

Difference between Debug and Signing key

这篇关于Android中的Google Map键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆