POST
|
One way to mix MapView controls with LinearLayout is to put the LinearLayout inside a PopupWindow. package com.esri.android.editdemo; import com.esri.android.map.GraphicsLayer; import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISTiledMapServiceLayer; import com.esri.android.map.event.OnSingleTapListener; import com.esri.core.geometry.Envelope; import com.esri.core.geometry.GeometryEngine; import com.esri.core.geometry.Point; import com.esri.core.geometry.SpatialReference; import com.esri.core.map.Graphic; import com.esri.core.symbol.SimpleMarkerSymbol; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.Toast; public class EditDemoActivity extends Activity { MapView map = null; GraphicsLayer graphicsLayer = null; SpatialReference webMercator = SpatialReference.create(102100); PopupWindow popupWindow = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); map = new MapView(this); setContentView(map); // Add the ArcGIS Online layer to the map. map.addLayer(new ArcGISTiledMapServiceLayer("" + "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")); map.setOnSingleTapListener(new OnSingleTapListener() { public void onSingleTap(float x, float y) { Point newPoint = map.toMapPoint(new Point(x, y)); SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(Color.RED, 20, SimpleMarkerSymbol.STYLE.CIRCLE); graphicsLayer.addGraphic(new Graphic(newPoint, simpleMarkerSymbol)); } }); // Set the extent to ESRI Redlands Campus Point minPoint = GeometryEngine.project(-117.200, 34.057, webMercator); Point maxPoint = GeometryEngine.project(-117.198, 34.059, webMercator); Envelope extent = new Envelope(minPoint.getX(), minPoint.getY(), maxPoint.getX(), maxPoint.getY()); extent.inflate(10000, 10000); map.setExtent(extent); // Create a graphics layer and add it to the map. graphicsLayer = new GraphicsLayer(); map.addLayer(graphicsLayer); // Post create PopupWindow since it created during onCreate(). final Context context = this; map.post( new Runnable() { public void run() { popupWindow = new PopupWindow(context); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.HORIZONTAL); Button button = new Button(context); button.setText("Clear"); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { graphicsLayer.removeAll(); Toast.makeText(context, "Graphics Layer Cleared", Toast.LENGTH_SHORT).show(); } }); linearLayout.addView(button); popupWindow.setContentView(linearLayout); popupWindow.showAtLocation(linearLayout, Gravity.LEFT | Gravity.BOTTOM, 10, 10); popupWindow.update(64, 64); } } ); } protected void onPause() { super.onPause(); map.pause(); } protected void onResume() { super.onResume(); map.unpause(); } }
... View more
07-01-2012
06:01 PM
|
0
|
0
|
541
|
POST
|
Hi, which SDK are you using? I had stable OpenGL behavior with the older 1.0.1 SDK and the newer 2.0.0 SDK. I found that the 1.1.1 SDK was quite problematic. If you have 1.1.1 SDK, you should consider upgrading to 2.0.0 SDK. When you upgrade your SDK, be sure to update your projects too. Right click on your project > ArcGIS Tools > Fix Project Properties
... View more
06-26-2012
05:04 PM
|
0
|
0
|
203
|
POST
|
I am having two issues when I place a MapView control in a LinearLayout (i.e. useLinearLayout = true😞 1. The MapView no longer renders properly. It renders black. If a show a popup Toast, the MapView renders temporarily then goes black again. 2. The MapView no longer generates OnSingleTapListener() events. If I setContentView() on the MapView control, everything works fine (i.e. useLinearLayout = false). The reason why I want to use a LinearLayout is I want to add other UI controls to my Activity, such as a Button. The following code demonstrate the above symptoms. It is based on the Hello World Map sample. By setting useLinearLayout to true or false will cause the either of the above two symptoms to occur. I get these symptoms on both SDK 1.0.1 and SDK 2.0.0. package com.esri.android.editdemo; import com.esri.android.map.GraphicsLayer; import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISTiledMapServiceLayer; import com.esri.android.map.event.OnSingleTapListener; import com.esri.core.geometry.Envelope; import com.esri.core.geometry.GeometryEngine; import com.esri.core.geometry.Point; import com.esri.core.geometry.SpatialReference; import com.esri.core.map.Graphic; import com.esri.core.symbol.SimpleMarkerSymbol; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.Toast; public class EditDemoActivity extends Activity { LinearLayout linearLayout = null; MapView map = null; GraphicsLayer graphicsLayer = null; SpatialReference webMercator = SpatialReference.create(102100); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = this; boolean useLinearLayout = true; // <-- mapView fails, but has button // boolean useLinearLayout = false; // <-- mapView works, but no button if (useLinearLayout) { linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); setContentView(linearLayout); Button testButton = new Button(this); testButton.setText("Hello"); testButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(context, "Test", Toast.LENGTH_SHORT).show(); } }); linearLayout.addView(testButton); map = new MapView(this); linearLayout.addView(map); } else { map = new MapView(this); setContentView(map); } // Add the ArcGIS Online layer to the map. map.addLayer(new ArcGISTiledMapServiceLayer("" + "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")); map.setOnSingleTapListener(new OnSingleTapListener() { public void onSingleTap(float x, float y) { Point newPoint = map.toMapPoint(new Point(x, y)); SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(Color.RED, 20, SimpleMarkerSymbol.STYLE.CIRCLE); graphicsLayer.addGraphic(new Graphic(newPoint, simpleMarkerSymbol)); } }); // Set the extent to ESRI Redlands Campus Point minPoint = GeometryEngine.project(-117.200, 34.057, webMercator); Point maxPoint = GeometryEngine.project(-117.198, 34.059, webMercator); Envelope extent = new Envelope(minPoint.getX(), minPoint.getY(), maxPoint.getX(), maxPoint.getY()); extent.inflate(10000, 10000); map.setExtent(extent); // Create a graphics layer and add it to the map. graphicsLayer = new GraphicsLayer(); map.addLayer(graphicsLayer); } protected void onPause() { super.onPause(); map.pause(); } protected void onResume() { super.onResume(); map.unpause(); } }
... View more
06-25-2012
10:46 PM
|
0
|
3
|
1380
|
POST
|
The Resources page http://resources.arcgis.com/content/arcgis-android/about has not been updated to reflect the 2.0 SDK (it still shows 1.1.1).
... View more
06-25-2012
08:53 PM
|
0
|
2
|
880
|
POST
|
I agree with Robert. I had the problem with the 1.1.1 SDK but it went away with the latest 2.0.0 SDK.
... View more
06-25-2012
04:52 PM
|
0
|
0
|
344
|
POST
|
These devices DO reproduce the issue: Samsung Galaxy Tab 10.1, Android 3.2 Samsung Gio, Android 2.2.1 Samsung Nexus S, Android 4.0.4 Samsung Tab 7, Android 2.3.3 HTC Desire, Android 2.2 Emulator with GPU emulation, Android 4.0.3 Additionally I found that by switching the device from Portrait to Landscape mode (and vice versa) will also crash the Hello World Map sample. Because this is similar to the "Back" button scenario, it feels like a problem with handling the suspend / resume application lifecycle. I've repeated the test against the 1.0.1 SDK on the same devices and the problem doesn't exists so it's a new issue.
... View more
06-18-2012
08:34 PM
|
0
|
0
|
390
|
POST
|
These devices DO reproduce the issue: Samsung Galaxy Tab 10.1, Android 3.2 Samsung Gio, Android 2.2.1 These devices DO NOT reproduce the issue: Samsung Nexus S, Android 4.0.4 Samsung Tab 7, Android 2.3.3 HTC Desire, Android 2.2 Emulator with GPU emulation, Android 4.0.3 **EDIT** When testing on the older 1.0.1 SDK the issue doesn't occur on the all of the above devices.
... View more
06-18-2012
08:26 PM
|
0
|
0
|
443
|
POST
|
I'm encountering a polygon drawing issue with the automatic black outline you get when using SimpleFillSymbol on the GraphicsLayer. When using Australian coordinates (Elmore, Victoria, Australia) the automatically black outline does not follow the perimeter of the polygon. Instead, it is incorrectly drawn to infinity. When using American coordinates (e.g. ESRI campus) the black outline does follow the perimeter of the polygon. So, this feels like there's an arithmetic issue in the 1.1.1 SDK. The same code works correctly in the 1.0.1 SDK. [ATTACH=CONFIG]15270[/ATTACH] The following code example is a modified Hello World Map sample with code for GraphicsLayer with the Polygon and SimpleFillSymbol. Both Elmore and Redlands coordinates are provided with the Redlands commented out. package com.esri.android.graphicsdemo; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import com.esri.android.map.GraphicsLayer; import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISTiledMapServiceLayer; import com.esri.core.geometry.Envelope; import com.esri.core.geometry.GeometryEngine; import com.esri.core.geometry.Line; import com.esri.core.geometry.MultiPath; import com.esri.core.geometry.Point; import com.esri.core.geometry.Polygon; import com.esri.core.geometry.Segment; import com.esri.core.geometry.SpatialReference; import com.esri.core.map.Graphic; import com.esri.core.symbol.SimpleFillSymbol; import com.esri.core.symbol.SimpleMarkerSymbol; public class GraphicsDemoActivity extends Activity { MapView map = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Retrieve the map and initial extent from XML layout map = (MapView)findViewById(R.id.map); map.addLayer(new ArcGISTiledMapServiceLayer("" + "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")); // Prepare Web Mercator projection. SpatialReference sr = SpatialReference.create(102100); // Define 3 points in Elmore, Victoria, Australia. Point pt1 = GeometryEngine.project(144.5933, -36.5067, sr); Point pt2 = GeometryEngine.project(144.6307, -36.5067, sr); Point pt3 = GeometryEngine.project(144.6109, -36.4799, sr); // Define 3 points on ESRI Redlands Campus //Point pt1 = GeometryEngine.project(-117.200, 34.057, sr); //Point pt2 = GeometryEngine.project(-117.198, 34.057, sr); //Point pt3 = GeometryEngine.project(-117.199, 34.059, sr); // Determine a simple bounding box for the points. Envelope extent = new Envelope(pt1.getX(), pt1.getY(), pt2.getX(), pt3.getY()); extent.inflate(10000, 10000); // Create a graphics layer and add it to the map. GraphicsLayer graphicsLayer = new GraphicsLayer(); map.addLayer(graphicsLayer); map.setExtent(extent); // Add a GRAY filled polygon to the graphics layer. MultiPath poly = new Polygon(); Segment seg = new Line(); seg.setStart(pt1); seg.setEnd(pt2); poly.addSegment(seg, true); seg = new Line(); seg.setStart(pt2); seg.setEnd(pt3); poly.addSegment(seg, false); seg = new Line(); seg.setStart(pt3); seg.setEnd(pt1); poly.addSegment(seg, false); poly.closePathWithLine(); graphicsLayer.addGraphic(new Graphic(poly, new SimpleFillSymbol(Color.GRAY))); // Add RED markers to the graphics layer. graphicsLayer.addGraphic(new Graphic(pt1, new SimpleMarkerSymbol(Color.RED, 10, SimpleMarkerSymbol.STYLE.CIRCLE))); graphicsLayer.addGraphic(new Graphic(pt2, new SimpleMarkerSymbol(Color.RED, 10, SimpleMarkerSymbol.STYLE.CIRCLE))); graphicsLayer.addGraphic(new Graphic(pt3, new SimpleMarkerSymbol(Color.RED, 10, SimpleMarkerSymbol.STYLE.CIRCLE))); } protected void onPause() { super.onPause(); map.pause(); } protected void onResume() { super.onResume(); map.unpause(); } }
... View more
06-17-2012
04:34 PM
|
0
|
2
|
1772
|
POST
|
I recently installed the latest 1.1.1 SDK and started experiencing crashes with the Hello World Map sample. The device I'm using is a Samsung Galaxy Tab 10.1 with Android 3.2. I had been running the Hello World Map sample with the 1.0.1 SDK with no issue. After installing the 1.1.1 SDK I created a new ArcGIS Project for Android and implemented Hello World Map as per http://help.arcgis.com/en/arcgismobile/10.0/apis/android/help/#/Hello_World_Map/011900000005000000/ The first time I build, deploy and run the app on my device, it works as intended, with the World_Street_Map layer appearing almost immediately. I close the app by using the "Back" button. The second time I run the app, I get a black screen for about 15 seconds and then it **CRASHES**!!! I, again, close the app by using the "Back" button. The third time I run the app, I either get a white screen with graticules or I see World_Street_Map layer. On subsequent runs, I alternate between the second time and third time symptoms. **Edit** after further investigation, I found that if you avoid using the "Back" button to terminate the app (e.g. tap and hold home to launch the Task Manager manager) then the Hello World Map runs correctly every time. This is a nasty workaround, not something I would want to ask any user to do.
... View more
06-13-2012
06:02 PM
|
0
|
2
|
988
|
POST
|
Did you remember to implement onPause() and onResume() as per the HelloWorldMap sample? Neglecting to do so can cause the map control not play nice with the Android application life cycle.
protected void onPause() {
super.onPause();
map.pause();
}
protected void onResume() {
super.onResume();
map.unpause();
}
... View more
03-14-2012
10:32 PM
|
0
|
0
|
485
|
POST
|
Hi, I am encountering a problem when the Callout I create doesn't pan with the map programmatically on a call to MapView.centerAt(). To reproduce the problem: I create a MapView with the World_Street_Map service (i.e. the HelloWorldMap sample) I create a point that represents the ESRI HQ in WebMercator coordinates (by reprojecting it from 34.05691 latitude, -117.1957 longitude) I construct a Callout at this coordinate IF I STOP HERE, THE CALLOUT IS SPATIALLY IN THE CORRECT POSITION If I now call MapView.centerAt to the ESRI HQ the map pans so that ESRI HQ is in the center of the map, but the callout is now in Moreno Valley?!?! If I were to interactively pan the map the Callout will magically jump back to ESRI HQ in Redlands Here is additional references and steps to reproduce the problem: Create the HelloWorldMap sample, http://help.arcgis.com/en/arcgismobile/10.0/apis/android/help/#/Hello_World_Map/011900000005000000/ Define the calloutstyle.xml with patches (see below) and http://help.arcgis.com/en/arcgismobile/10.0/apis/android/api/com/esri/android/map/Callout.html Replace the body of your HelloWorldMap sample with the code below Here's my calloutstyle.xml (needs to be placed under res/xml folder): <?xml version="1.0" encoding="utf-8"?> <resources> <calloutViewStyle titleTextColor="#000000" titleTextSize="10" titleTextStyle="0" titleTextTypeFace="0" backgroundColor="#ffffff" backgroundAlpha="255" frameColor="#000000" flat="true" anchor="5" /> </resources> Here's my Activity's main body (you may need to change package and class names to match your project): package com.esri.android.calloutcentertest; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; import com.esri.android.map.Callout; import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer; import com.esri.android.map.event.OnSingleTapListener; import com.esri.core.geometry.GeometryEngine; import com.esri.core.geometry.Point; import com.esri.core.geometry.SpatialReference; public class CalloutCenterTestActivity extends Activity { MapView map = null; /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Retrieve the map and initial extent from XML layout map = (MapView)findViewById(R.id.map); map.addLayer(new ArcGISDynamicMapServiceLayer( "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer") ); // The map.getCallout().setCoordinates() / map.centerAt() bug. Toast.makeText(this, "TAP SCREEN TO SHOW ESRI HQ", Toast.LENGTH_LONG).show(); final Context ctx = this; map.setOnSingleTapListener(new OnSingleTapListener() { private static final long serialVersionUID = 5173550791541184304L; public void onSingleTap(float x, float y) { Toast.makeText(ctx, "SHOWING ESRI HQ IN CALLOUT", Toast.LENGTH_SHORT).show(); // Create a point for ESRI HQ in WebMercator coordinate system. Point esri4326 = new Point(-117.1957, 34.05691); Point esri102100 = (Point) GeometryEngine.project( esri4326, SpatialReference.create(4326), SpatialReference.create(102100) ); // Construct the Callout content. TextView textView = new TextView(ctx); textView.setText("ESRI HQ"); // Show the callout at the correct location. Callout callout = map.getCallout(); callout.setContent(textView); callout.setCoordinates(esri102100); callout.setStyle(R.xml.calloutstyle); callout.refresh(); callout.show(); // The map pans to ESRI HQ but the callout stays behind! map.centerAt(esri102100, true); // If the user pans the map interactively, the callout corrects itself. } } ); } protected void onPause() { super.onPause(); map.pause(); } protected void onResume() { super.onResume(); map.unpause(); } }
... View more
03-01-2012
06:48 PM
|
0
|
10
|
4700
|
POST
|
A couple of gotchas that I had to go through to make callouts work for me: callout.setCoordinates() needs to take a Point expressed in your map's coordinate system, not screen units. callout.setStyle(R.xml.calloutstyle) should be used in conjunction with a res/xml/calloutstyle.xml file. callout.refresh() may need to be called. Where Res/xml/calloutstyle.xml is defined in your resource tree as: <?xml version="1.0" encoding="utf-8"?>
<resources>
<calloutViewStyle
titleTextColor="#000000"
titleTextSize="10"
titleTextStyle="0"
titleTextTypeFace="0"
backgroundColor="#ffffff"
backgroundAlpha="255"
frameColor="#000000"
flat="true"
anchor="5" />
</resources>
Here's an example of your callout working in a MapView.onSingleTap: final Context ctx = this;
final LayoutInflater inflater = this.getLayoutInflater();
map.setOnSingleTapListener(new OnSingleTapListener() {
private static final long serialVersionUID = 5173550791541184304L;
public void onSingleTap(float x, float y) {
Toast.makeText(
ctx,
"onSingleTap(" + String.valueOf(x) + " , " + String.valueOf(y) + ")",
Toast.LENGTH_SHORT
).show();
Point screenPoint = new Point(x, y);
Point mapPoint = map.toMapPoint(screenPoint);
Callout callout = map.getCallout();
callout.setCoordinates(mapPoint);
//callout.setCoordinates((Point) event.getGeometry());
//callout.setTitle(event.getName());
View calloutView = inflater.inflate(R.layout.callout, null);
//Access the internal Textviews inside the calloutView.
TextView begins = (TextView) calloutView.findViewById(R.id.calloutBeginsAt);
TextView ends = (TextView) calloutView.findViewById(R.id.calloutEndsAt);
TextView loc = (TextView) calloutView.findViewById(R.id.calloutLoc);
//Set Up values
begins.setText("begins");
ends.setText("ends");
loc.setText("loc");
begins.setEnabled(true);
ends.setEnabled(true);
loc.setEnabled(true);
//Set the content, show the view
callout.setContent(calloutView);
callout.setStyle(R.xml.calloutstyle);
callout.refresh();
callout.show();
}
} );
... View more
02-29-2012
08:30 PM
|
0
|
0
|
678
|
POST
|
In the API help for Class Callout http://help.arcgis.com/en/arcgismobile/10.0/apis/android/api/com/esri/android/map/Callout.html there is a bad XML file given: <?xml version="1.0" encoding="utf-8"?>
<resources>
<calloutViewStyle
titleTextColor="#000000" // some RGB color or a reference to a color
titleTextSize = 10; // size of the title text in scaled pixels (based on screen density and user font size preference)
titleTextStyle = 0; // See the class Typeface in the Android SDK for available values
titleTextTypeFace = 0; // See the class Typeface in the Android SDK for available values
backgroundColor="#ffffff" // some RGB color or a reference to a color
backgroundAlpha="255" // 0(transparent) to 255(opaque)
frameColor="#000000" // some RGB color or a reference to a color
flat="true" // draws a 3D frame
style.getCornerCurve()="0" // the radius of the window's corners' curvature (max=40)
anchor="5" /> // the position of the anchor (0-8, see ANCHOR_POSITION_XXX constants)
</resources>
i.e. the code example isn't really a well formed XML file but is corrupted with Java comments, Java assignments, Java semicolons, and Java style function calls.
... View more
02-28-2012
02:16 PM
|
0
|
1
|
459
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|