ArcGis for Android work and learn

Source: Internet
Author: User
Tags polyline


ArcGIS Installation
Demand
Windows7 (32/64)
Eclipse3.6 or later
Android SDK 2.2 or more
JDK 7

Installation steps
Eclipse installation
Download the ArcGIS Plugin
Open Help >> Install New software on eclipse

Create an ArcGIS Project
Created in the same way as an Android project, when you create a project from different points, choose to create an ArcGIS project, and then the dummy next. (the default supported minimum SDK is 2.2)

Project Testing
Add:
ArcGIS drawing differs from Android in that it does not draw on the UI (main) thread, but instead uses OpenGL to do the drawing (the benefit: GPU drawing, which greatly reduces CPU dependence, so the drawing becomes more coherent and natural, drawing OpenGL has a dedicated drawing thread, Does not affect the main thread)

Simulator testing should be noted:
ArcGIS Runtime SDK for Android uses OpenGL ES 2.0. If you are developing with an emulator, you need to use Android 4.0.3 + versions of the simulator (GPU supported)


The main control in ArcGIS inherits from Framlayout's Mapview
Mapview
1,mapview is the container that renders the map data, Mapview can add one or more layers, and the layer will only be displayed if it is added to the Mapview container. Second, the Mapview can be used to set the extent of the map display, whether it is allowed to be rotated, the map background, the maximum/minimum resolution of the map, and
It specifies the resolution/scale bar currently displayed. Finally, Mapview provides a rich gesture monitoring interface through which you can listen to various gestures such as tap, double-click, move or long-click operations

Two ways to add 2,mapview
XML addition is:
<com.esri.android.map.mapview
Android:id= "@+id/map"
Android:layout_width= "Fill_parent"
android:layout_height= "Match_parent" >
Dynamically added in code:
Mapview map = new Mapview (this);//--new Mapview Object
Map.setlayoutparams (New Layoutparams (Layoutparams.fill_parent,
Layoutparams.fill_parent)); --Set Layoutparams
Tilelayer = new Arcgistiledmapservicelayer ("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_ Map/mapserver "); --Creation of tile layers
Map.addlayer (tilelayer);//--Layer Additions
Setcontentview (map); --Add the layer to the form, and finally it appears on the phone.
3, Map zoom (API)
1, Common zoom mode
Mmapview.zoomin (...)//--zoom in
Mmapview.zoomout (...) --Shrinking


2, Other zoom mode
Mmapview.zoomtoresolution (...);
Mmapview.zoomtoscale (...);
4, introduction of Common API
Envelope env = new Envelope (...); /Range
Mmapview.setextent (env)//Set map display range
Mmapview.setscale (295828763);//The scale bar currently displayed
Mmapview.setresolution (9783.93962049996);//Set the current display resolution

Mmapview.setmapbackground (...); /Set Map background
Mmapview.setallowrotationbypinch (...); Allow rotation of the map using pinch mode
Mmapview.setrotationangle (...); How many degrees of rotation the map rotates when initialized, and the parameter is positive when rotated in a counterclockwise direction.

Mmapview.tomappoint (x, y);//screen coordinates converted to spatial coordinates
Mmapview.toscreenpoint (PT);//Convert to screen coordinate object

Listener Settings for 5,mapview
Map Click Listen: Onsingletaplistener (app in code, when you click the graphic point displayed on the map, you need to convert the coordinates of the graphic on the map to screen coordinates, and then use the ArcGIS for Callout show the data in Android)
Pan listening: Onpanlistener//--here refers to the map panning listening, code in the use of nothing.
Long Press listen: Onlongpresslistener//--a point on the map to listen for, use in code, define the current event point.
Zoom Listener: Onzoomlistener//--The zoom operation of the map, using nothing in code.
State monitoring: Onstatuschangedlistener//--State Monitoring, mainly is the current mapview state changes corresponding to the callback.
Pinch monitor: Onpinchlistener//--Here is a multi-fingered zoom of the map (zooming in and out of the map)


Layer
Tile layers, dynamic layers, this map layer, and more
1,arcgistiledmapservicelayer
Slice layer, as the name implies, sheet of display data, the design of multi-threaded operation, and therefore processing speed.
2, Arcgisdynamicmapservicelayer
Performance is less than (1) and relies heavily on the complexity of the data.
3,arcgisimageservicelayer
Basic equivalent (2)
4,arcgisfeaturelayer
5, Arcgislocaltiledlayer
The layer being used in the current project. Load Benli offline database data.
6,graphicslayer
The display layer for the various icon icons in the current project, which allows adding graphic.
For example:
Picturemarkersymbol Msymbol = new Picturemarkersymbol (drawable),//drawable is the corresponding PNG in Android.
Graphicslayer.addgraphic (New Graphic (Point, msymbol,atttributes)); --point draws the coordinates of the point, the symbol picture, attributes the attribute information that needs to be added.

Spatialreference
Spatial reference, primarily for conversion operations of coordinate systems (spatial coordinate systems to projected coordinate systems, and vice versa).



Drawing operations
Draw a point (Icon. layer. 6)

Draws a line.
Polyline mployline = new Polyline ();//--the object that draws the segment
Simplelinesymbol outline = new Simplelinesymbol (color.red, 3, STYLE. SOLID);//--sets zodiac for the segment, such as the color of the line segment, style

Mployline.setempty (); All data before//--is emptied only when down.
Mployline.startpath (Presspoint); --Sets the starting position of the drawing. Just empty when you're down.
Mpolyline.lineto (Movepoint); --Sets the next location point where the current position is moved. Move is called here

Graphic Graphic = new Graphic (mycustompolyline, outline);//--Create Graphic just once
Mpolygonid = mcustomgraphiclayer.addgraphic (graphic); --add graphic to the layer just once
Mcustomgraphiclayer.updategraphic (Mpolygonid, mycpolyline); --Update the current data to the layer.

Notes: If you wish to draw a fold that is finally closed, this can be done by setting Mployline.lineto (Presspoint);

Drawing polygons (equivalent operations, the only difference being in drawing objects)
Polygon Mpolygon = new Polygon ();
Simplefillsymbol Mpolygonsymbol = new Simplefillsymbol (color);
...
Graphic Graphic = new Graphic (Mpolygon,mpolygonsymbol);
Mpolygonid = mcustomgraphiclayer.addgraphic (graphic);
Mcustomgraphiclayer.updategraphic (Mpolygonid, mycpolyline);

Notes: Here is the opposite of the drawing operation, the surface as the name implies is closed state, so the entire drawing process of the face are in a closed state;

From the beginning of learning to now one months of time, understand is too little, I here to mention a few I do not understand the question, I hope that the great God will pass by leaving a footprint, answer doubts.

Mmapview.setscale ();
Mmapview.setresolution ();

The difference between the above API, although they can play the same effect, but still do not distinguish between the resolution and the final difference between the scale? Secondly, I think there is a way to convert, according to which they have the equivalent effect?

Geographic coordinate system, space coordinate system (actual coordinate system unit is meters)?

ArcGis for Android work and learn

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.