Simple use of ArcGIS for Android collout

Source: Internet
Author: User

1. Define the appearance of callout, which can be defined in an XML file.

<? XML version = "1.0" encoding = "UTF-8"?> <Resources> <calloutviewstyle titletextcolor = "#000000" <! -Title color/> titletextsize = 10; <! -Title font size/> titletextstyle = 0; <! -Title Font/> backgroundcolor = "# ffffff" <! -Background color/> backgroundalpha = "255" <! -Transparency 0 (transparent) to 255 (opaque)/> framecolor = "#000000" <! -Border color/> flat = "true" <! -Whether it will be in 3D effect/> cornercurve = "0" <! -Degree of rounded corner/> anchor = "5"/> <! -Position of the anchor (0-8)/> </resources>

2. Define the content to be displayed in callout, which can be defined in a layout.

<? Xmlversion ="1.0"Encoding ="UTF-8"?>

<Linearlayoutxmlns: Android =Http://schemas.android.com/apk/res/android"

Android: layout_width ="Wrap_content"

Android: layout_height ="Wrap_content"

Android: gravity ="Center">

<Imageview

Android: src ="@ Drawable/ic_launcher"

Android: layout_width ="Wrap_content"

Android: layout_height ="Wrap_content"

/>

<TextviewAndroid: text ="This is callout"

Android: layout_width ="Wrap_content"

Android: layout_height ="Wrap_content"/>

</Linearlayout>

 

3. Display callout. The following code displays callout when you click the screen.

Public
Class
Callouttestactivity ExtendsActivityImplementsOnsingletaplistener {

Mapviewmmapview;

PrivateCalloutcallout;

 

/** Called when the activity is first created .*/

@ Override

Public
Void
Oncreate (bundlesavedinstancestate ){

Super. Oncreate (savedinstancestate );

Setcontentview (R. layout.Main);

 

Mmapview = (mapview) findviewbyid (R. Id.Mapview);

Arcgistiledmapservicelayerarm =NewArcgistiledmapservicelayer ("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer ");

Mmapview. addlayer (ARM );

Mmapview. setonsingletaplistener (This);

Callout = mmapview. getcallout (); // obtain the callout of the mapview. One mapview can have only one callout.

}

 

Public
Void
Onsingletap (FloatArg0,FloatArg1 ){

Pointp = mmapview. tomappoint (NewPoint (arg0, arg1 ));

Callout.Setstyle(R. xml.Colloutxml); // Set the display style (XML defined in step 1)

Callout. setcontent (view.Inflate(This, R. layout.Colloutlay,Null); // Use the layout defined in step 1 as the display content of callout.

Callout. setcoordinates (p); // set the displayed position to the clicked position.

Callout. Show (); // display callout

}

}

4. Effect

Related Article

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.