Android 中带有释放键的地图显示

发布于 2024-11-14 10:22:50 字数 2342 浏览 2 评论 0原文

我已经为我的应用程序创建了发布密钥。但它没有显示地图。我做错了什么?我通过右键单击项目创建发布密钥 - >导出 - >给出别名 - >...喜欢然后通过使用 Keytool,我得到了发布密钥。我在我的 xml 上使用了它。

我的代码:

public class SampleMapActivity extends MapActivity {

    MapView         myMapView       = null;

    MapController   myMC            = null;

    GeoPoint        geoPoint        = null;

    double          latitude        = 12.937875, longitude = 77.622313;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        myMapView = (MapView) findViewById(R.id.myGMap);
        geoPoint = new GeoPoint((int) (latitude * 1000020), (int) (longitude * 1000020));
        myMapView.setStreetView(true);

        myMC = myMapView.getController();
        myMC.setCenter(geoPoint);
        myMC.setZoom(15);

        myMapView.setBuiltInZoomControls(true);
        myMapView.displayZoomControls(true);

    }
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_I) {
            myMapView.getController().setZoom(myMapView.getZoomLevel() + 1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_O) {
            myMapView.getController().setZoom(myMapView.getZoomLevel() - 1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_S) {
            myMapView.setSatellite(true);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_M) {
            myMapView.setSatellite(false);
            return true;
        }
        return false;
    }

}

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<com.google.android.maps.MapView
android:id="@+id/myGMap"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:enabled="true"
    android:clickable="true"
        android:apiKey="0GNnbje3crS0ZuqJfAFnJjO8zNPYy9OqNzHS2Aw"
    />

</LinearLayout>

I've created Release key for my application.But It doesnt show map.What did i wrong on that?i've created release key by Right click of project->Export->Giving alias_name->...like that.Then by the use of Keytool.,i got that release key.i used it on my xml.

My code:

public class SampleMapActivity extends MapActivity {

    MapView         myMapView       = null;

    MapController   myMC            = null;

    GeoPoint        geoPoint        = null;

    double          latitude        = 12.937875, longitude = 77.622313;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        myMapView = (MapView) findViewById(R.id.myGMap);
        geoPoint = new GeoPoint((int) (latitude * 1000020), (int) (longitude * 1000020));
        myMapView.setStreetView(true);

        myMC = myMapView.getController();
        myMC.setCenter(geoPoint);
        myMC.setZoom(15);

        myMapView.setBuiltInZoomControls(true);
        myMapView.displayZoomControls(true);

    }
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_I) {
            myMapView.getController().setZoom(myMapView.getZoomLevel() + 1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_O) {
            myMapView.getController().setZoom(myMapView.getZoomLevel() - 1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_S) {
            myMapView.setSatellite(true);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_M) {
            myMapView.setSatellite(false);
            return true;
        }
        return false;
    }

}

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<com.google.android.maps.MapView
android:id="@+id/myGMap"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:enabled="true"
    android:clickable="true"
        android:apiKey="0GNnbje3crS0ZuqJfAFnJjO8zNPYy9OqNzHS2Aw"
    />

</LinearLayout>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何时共饮酒 2024-11-21 10:22:50

让我们获取 MapAPIKey。

1)如何创建KeyStore

Project >> Export >> ExportAndroidApplication >> Next >> Create New Keystore (Remember Keystore Path) >> Fill All Detail >> ...etc

现在您的keystore和Apk已创建。

2)如何获取证书指纹 (MD5)

$ keytool -list -alias alias_name -keystore my-release-key.keystore

了解更多详情去这里

现在你得到了指纹,如

证书指纹(MD5): 94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98

3)如何获取MapApiKey
点击此处并粘贴您的 MD5,然后您将获得 MapAPIKey。
在您的应用程序中使用此密钥。

4)测试

使用此密钥库创建新的 apk 并检查..

lets go for get MapAPIKey.

1)How to create KeyStore

Project >> Export >> ExportAndroidApplication >> Next >> Create New Keystore (Remember Keystore Path) >> Fill All Detail >> ...etc

Now your keystore and Apk is created.

2)How to get Certificate fingerprint (MD5)

$ keytool -list -alias alias_name -keystore my-release-key.keystore

for more detail go here

Now you got fingerprint like as

Certificate fingerprint (MD5): 94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98

3)How to get MapApiKey
click here and paste your MD5 then u will get MapAPIKey.
Use this key in your application.

4)Test

create new apk using this keystore and check..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文