简体   繁体   English

基本的android Google地图开发

[英]basic android google map development

After I acquire an apiKey from Google, according to development document, if I use MapFragment, a map shows up , but if I use MapView, I get this error from the server: 根据开发文档,从Google获得apiKey后,如果使用MapFragment,则会显示一张地图,但是如果使用MapView,则会从服务器收到此错误:

IOException processing: 26          
java.io.IOException: Server returned: 3

Then I see someone in the forum said that, in order to use MapView, this app must be downloaded from google play. 然后我在论坛上看到有人说,要使用MapView,必须从Google Play下载此应用。 So, 所以,

  1. I wonder how developers use MapView to develop? 我想知道开发人员如何使用MapView进行开发吗?

  2. What's the difference between MapView and MapFragment? MapView和MapFragment有什么区别?

  3. Does the google map depends on google play service? Google地图是否取决于Google Play服务?

Developer use MapView must forward all the activity life cycle methods - such as onCreate(), onDestroy(), onResume(), and onPause() - to the corresponding methods in the MapView class. 开发人员使用MapView必须将所有活动生命周期方法(例如onCreate(),onDestroy(),onResume()和onPause())转发到MapView类中的相应方法。

MapFragment is a subclass of the Android Fragment class, allows you to place a map in an Android fragment. MapFragment是Android Fragment类的子类,允许您将地图放置在Android片段中。 MapFragment objects act as containers for the map, and provide access to the GoogleMap object. MapFragment对象充当地图的容器,并提供对GoogleMap对象的访问。 Unlike a View, a Fragment represents a behavior or a portion of user interface in an activity. 与视图不同,片段表示活动中的行为或用户界面的一部分。 You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. 您可以在一个活动中组合多个片段以构建多窗格UI,并在多个活动中重用一个片段。

MapView is a subclass of the Android View class, allows you to place a map in an Android View. MapView是Android View类的子类,可让您将地图放置在Android View中。 A View represents a rectangular region of the screen, and is a fundamental building block for Android applications and widgets. 视图代表屏幕的矩形区域,并且是Android应用程序和小部件的基本构建块。 Much like a MapFragment, the MapView acts as a container for the map, exposing core map functionality through the GoogleMap object. 就像MapFragment一样,MapView充当地图的容器,通过GoogleMap对象公开核心地图功能。

The Google Maps Android API v2 is distributed as part of the Google Play services SDK. Google Maps Android API v2是Google Play服务SDK的一部分。 You can download the Google Play services SDK via the Android SDK Manager. 您可以通过Android SDK Manager下载Google Play服务SDK。

For detailed instructions, see the Google Play services documentation. 有关详细说明,请参阅Google Play服务文档。 Here is a summary of the steps you will need to take: 以下是您需要采取的步骤的摘要:

  • Install the Google Play services SDK. 安装Google Play服务SDK。
  • Add Google Play services as an Android library project. 将Google Play服务添加为Android库项目。
  • Reference the Google Play services in your app's project. 在您应用的项目中引用Google Play服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM