Android Google Maps API教程-入门

This is android google maps api tutorial.

这是android Google Maps API教程。

In this tutorial I will teach you to integrate google maps in your android app using google maps api v2.

在本教程中,我将教您使用google maps api v2将google maps集成到您的android应用中。

This API provides us various functionality like showing locations in map, showing routes, add marker, etc.

该API为我们提供了各种功能,例如在地图上显示位置,显示路线,添加标记等。

Android Google Maps API教程 (Android Google Maps API Tutorial)

Android专案 (Android Project)

1. Open Android Studio and go to New Project option. Now give a name to your project and press Next.

1.打开Android Studio并转到“ 新建项目”选项。 现在为您的项目命名,然后按Next

Android Google Maps API Tutorial

2. Choose Google Maps Activity, choosing this activity makes easier to integrate google maps.

2.选择Google Maps Activity ,选择此活动可以更轻松地集成google maps。

Android Google Maps API Tutorial

3. Click Next and finally click on Finish to create the project.

3.单击下一步 ,最后单击完成以创建项目。

获取API密钥 (Getting API Key)

For using google maps in our project we need API key. It can be obtained in following way.

为了在我们的项目中使用Google Maps,我们需要API密钥。 可以通过以下方式获得。

1. After creating the project you will see a file google_maps_api.xml as shown in below image. Copy the URL given in it and open it in browser.

1.创建项目后,您将看到一个google_maps_api.xml文件,如下图所示。 复制其中提供的URL,然后在浏览器中将其打开。

Android Google Maps API Tutorial

2. You will see a page as shown below. There agree with the terms and click Agree and continue. Make sure you are logged in to google account.

2.您将看到如下页面。 同意条款,然后单击同意并继续 。 确保您已登录到Google帐户。

Android Google Maps API Tutorial

3. Then click Create API key button.

3.然后单击创建API密钥按钮。

Android Google Maps API Tutorial

4. On the next page you will get API key, just copy it.

4.在下一页上,您将获得API密钥,只需复制它即可。

Android Google Maps API Tutorial

5. Finally paste the API key in google_maps_api.xml file under string tag.

5.最后,将API密钥粘贴到google_maps_api.xml文件中的字符串标签下。

Android Google Maps API Tutorial

6. Save and run the project.

6.保存并运行项目。

When we created the project by default we got the code to display a simple google map with a marker at some location. Make sure google play services is installed and internet is enabled in the device on which you are running this app.

默认情况下,当我们创建该项目时,我们获得了显示带有标记的简单Google地图的代码。 确保正在运行此应用的设备上已安装Google Play服务并启用了互联网。

Android Google Maps API Tutorial

Comment below if you have any doubts related to above tutorial.

如果您对以上教程有任何疑问,请在下面评论。

翻译自: https://www.thecrazyprogrammer.com/2017/01/android-google-maps-api-tutorial.html

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值