ArcGIS Runtime for Android Development tutorial V2.0 (3) Basic---Hello world Map

Source: Internet
Author: User

Original address:

ArcGIS Runtime for Android Development tutorial V2.0 (3) Basic---Hello World map-arcgis_mobile column-Blog channel-csdn.net
http://blog.csdn.net/arcgis_mobile/article/details/8124005

In the section above, we've learned how to configure an ArcGIS Runtime for Android development environment, and we'll show you how to use Eclipse to create an ArcGIS mobile project Hello World Map and analyze the related structure of the project.

1 , Create a project

Open the Eclipse tool that we've configured, right-click in our workspace to create an ArcGIS mobile project,

Right-click Work area-->new-->other ..., tap other ... option, select the ArcGIS Project for Android option in the pop-up form:

Click the Next button in the form above to jump to the Create Project interface

In the Project name input box, enter the name of the project we want to create, such as: Helloworldmap; Enter the project name click the Next button to jump to the app settings screen

We need to modify the package name input box structure name, such as: Com.esri.demo; After modifying the click Finish button, our project has been created.

2 , Project Structure

According to this, we can see that the ArcGIS project is basically the same as a normal Android project, so let's take a holistic look at the project structure of ArcGIS:

This needless to say, everyone should know that this is the directory of Java source code, directory files are based on the package structure management.

/gen is also a source code directory, but the inside of the Java file is automatically generated by the Android platform, and this directory of R.java class files are managed by the Android framework, do not need our manual operation, In Gen you may find that there is a Buildconfig.java file in the previous version that is not this file, he is an Android ADT Update added later, and its role is to check your code and keep running debugging.

This is the library of Java functions needed in the project, which has more ArcGIS libraries than normal Android projects.

We can store the required files in the assets directory for easy access. The resource files in/assets are similar to those in/res, which are directories that hold resource files, but the resources in/assets do not generate ID IDs for each resource file as resources in/res.

For/bin we are not unfamiliar, this directory is to store the compiled generated applications, such as: HELLOWORLDMAP.APK is our compilation of the generated application installation files.

The/libs directory contains the dynamic link libraries that are required for some projects, and for ArcGIS projects it stores the dynamic link libraries required by the two GIS by default, and of course we can add some other dynamic link libraries that we need.

The/res directory contains most of the resources we need, the default directory has three categories of resources: Drawable directory mainly store some pictures, layout directory mainly put some layouts files, the values directory is mainly stored in some projects required parameter value files; Of course, there are some other categories besides these, such as ANIM and XML directories, and so on, no longer described here.

We should not be unfamiliar with this file, this XML file is a system configuration file for our project that contains information such as activity (behavior), view, service (services), and a list of user rights required to run the Android application. The project structure of Android application is also described in detail.

3 , Encoding Implementation

After describing the project structure of ArcGIS, let's analyze the code area to see how we can properly display the map.

Open the Helloworldmapactivity.java file, simply modify the code, the code is as follows:

[Java] view plaincopy

    1. @Override  
    2. public void onCreate (Bundle savedinstancestate) { 
    3. B>super . OnCreate (savedinstancestate); 
    4.         mmapview = New Mapview ( this );//Instantiate Mapview object
    5.         Mmapview.setlayoutparams ( New layoutparams (Layoutparams.fill_parent, layoutparams.fill_parent)); 
    6.         Arcgistiledmapservicelayer tilelayer = New Arcgistiledmapservicelayer ("Http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer") ;//Instantiate layer
    7.         mmapview.addlayer (tilelayer);//Add layer
    8.  & nbsp;      Setcontentview (mmapview); 
    9.    } 

With the above code we can see that to display the map, we first have to create a Mapview object and then create a Layer object and add it to the Mapview for display. In this example, add a arcgistiledmapservicelayer layer that shows the effect as shown in:

ArcGIS Runtime for Android Development tutorial V2.0 (3) Basic---Hello world Map

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.