|
POST
|
@Mark, To add to Brian's comment. As mentioned above, you can listen for a map event such as a setOnSingleTapListener and then get the graphic IDs from the graphic layer. The getGraphicsIDs() method is an overloaded method and you can find more information on it here. Once you have the graphic IDs you can either iterate through them and test for a certain condition, or just grab the first one. You can see an example of this code in the "Nearby" SDK sample. Here's the code snippet from that sample: map.setOnSingleTapListener(new OnSingleTapListener() {
private static final long serialVersionUID = 1L;
public void onSingleTap(float x, float y) {
if(callout != null){
callout.hide();
}
else
{
callout = map.getCallout();
callout.setStyle(R.xml.calloutstyle);
}
int[] graphicIDs = graphicsLayer.getGraphicIDs(x, y, 25);
if (graphicIDs != null && graphicIDs.length > 0) {
Graphic gr = graphicsLayer.getGraphic(graphicIDs[0]);
updateContent((String) gr.getAttributeValue("Rating"),
(String) gr.getAttributeValue("Title"));
Point location = (Point) gr.getGeometry();
callout.setOffset(0, -15);
callout.show(location, content);
}
}
});
... View more
11-28-2012
06:17 AM
|
0
|
0
|
2542
|
|
POST
|
Does the rest endpoint work? I tried to load it in a browser and it failed. Also check DDMS for any possible errors when the app loads. -Andy
... View more
10-29-2012
12:05 PM
|
0
|
0
|
1713
|
|
POST
|
it zooms the minimum LOD if the next level of LOD has no image, so i wonder how to do this. I think that's an internal workaround, and I'm not sure what they've done exactly. Maybe someone else on the forums has workaround code for Android? What our team has done for the other APIs when an app is designed for a specific geographic region we define polygons and zoom levels for areas where we know there are null tiles. Then set a listener on the layer and when it met the right criteria (e.g. polygon extent is within the view port and min zoom level is true) we reset the zoom level. Also note, I've been told the upcoming release is intended to include null tile support. -Andy
... View more
10-12-2012
07:11 AM
|
0
|
0
|
1691
|
|
POST
|
Dixon, can you explain the requirements for when you switch from local map to ArcGIS Online base map? Usually when you swap maps the intention is to keep the exact same extent and zoom level. And, is the ArcGIS Online base map a "WebMap" or an ArcGIS Server Map Service (REST endpoint)? If you need to change the extent and resolution/zoom level there are methods for those that you can apply that after a layer has been added to the map, for example: zoomToResolution(Point centerPt, double res)
setExtent(Geometry geometry)
-Andy
... View more
10-10-2012
08:19 AM
|
0
|
0
|
1691
|
|
POST
|
Shane, for your questions not directly related to the ArcGIS Android SDK, such as your questions about debugging in Eclipse, feel free to ping me: agup at esri dot com. Why would there be an issue with the HTTP REST requests with ArcGIS Server? There are a few ways that HTTP REST requests can go wrong, such as: - Some attribute was set incorrect in your code and ArcGIS Server couldn't interpret it properly - There was a problem in the configuration of the REST Service within ArcGIS Server that causes an error - The HTTP request was blocked by a firewall You will typically find out about these problems by inspecting the HTTP Request response that is sent back from the web server. Here are some common examples: - 404 Not Found > when a file is not found, typically the GIS service didn't get published correctly - 401 Unauthorized > you might need additional permissions to access the service - 500 Internal Server Error > there was an internal problem with your web server or ArcGIS Server configuration. -Andy
... View more
10-09-2012
08:55 AM
|
0
|
0
|
1766
|
|
POST
|
It looks like you have a null pointer exception in your AsyncTask onPostExecute event handler. Use your debugger and check the IdentifyTask input parameters as well as the result value that comes back in onPostExecute. If you need to view your HTTP REST requests with ArcGIS Server for troubleshooting then here's a post that may help: http://www.andygup.net/?p=695 -Andy
... View more
10-05-2012
02:31 PM
|
0
|
0
|
1766
|
|
POST
|
Shane, make sure to run the app in debug mode. When an app exits or crashes there is almost always a fatal error logged in logcat. Once you have the error info you should be able to narrow down the problem with something like a null pointer exception, etc. -Andy
... View more
10-04-2012
01:44 PM
|
0
|
0
|
1766
|
|
POST
|
Sorry for the confusion, the issue has been reopened. In meantime please use this workaround:
// Show the callout at the correct location.
Callout callout = mMapView.getCallout();
callout.setContent(textView);
callout.setCoordinates(point);
callout.setStyle(R.xml.callout);
// @WORKAROUND - Force map to zoom in
mMapView.zoomToResolution(point, 100);
callout.refresh();
callout.show();
-Andy
... View more
09-14-2012
10:30 AM
|
0
|
0
|
2549
|
|
POST
|
@jwmarin Good catch. I tried it on a different test phone and was able to reproduce as well. I'll submit a ticket and post my findings. -Andy
... View more
09-11-2012
06:45 AM
|
0
|
0
|
2549
|
|
POST
|
John, here's a code snippet that should help. It doesn't cover everything you asked for but should give you a good idea of how to implement the listeners. @Override
public void onStatusChanged(Object source, STATUS status) {
if (OnStatusChangedListener.STATUS.INITIALIZED == status && source == _mapView) {
_isMapLoaded = true;
setMapType(_maptype);
if(_center_lat == null || _center_lon == null){
latlon = new Point(_DEFAULT_LON,_DEFAULT_LAT);
}
else{
latlon = new Point(_center_lon,_center_lat);
}
Point point = (Point)GeometryEngine.project(latlon,SpatialReference.create(4326), _mapView.getSpatialReference());
_mapView.centerAt(point,false);
if(_center_scale == null){
_mapView.setScale(_DEFAULT_SCALE);
}
else{
_mapView.setScale(_center_scale);
}
Log.d("MapViewController", "setOnStatusChangedListener() STATUS: " + status);
dispatchStatusEvent(new MapViewControllerEvent(MapViewEvent.STATUS_INITIALIZED), status.toString()); //custom event
}
if (OnStatusChangedListener.STATUS.LAYER_LOADING_FAILED == status && source == _mapView){
Log.d("MapViewController", "setMapListeners() STATUS: " + status + ", " + status.toString());
displayToast("There was a map problem with loading a layer: " + status.toString());
dispatchStatusErrorEvent(new MapViewControllerEvent(MapViewEvent.STATUS_LAYER_LOADING_FAILED), status.toString()); //custom event
}
}
-Andy
... View more
08-10-2012
07:07 AM
|
0
|
0
|
2728
|
|
POST
|
Not sure if this will help or not since it's not the exact code you are asking about. However, this snippet shows one example for iterating through the layers and work with the various properties: Layer[] layerArr = map.getLayers();
for(Layer layer : layerArr)
{
Boolean visible = layer.isVisible();
if(layer instanceof ArcGISTiledMapServiceLayer && visible == true){
ArcGISTiledMapServiceLayer tempMap = (ArcGISTiledMapServiceLayer) layer;
ArcGISLayerInfo[] info = tempMap.getLayers();
Log.d("test","Layer name= " + tempMap.getName() + ", " + info[0].getName());
String name = info[0].getName().toLowerCase();
Boolean vis = info[0].isVisible();
if(name.equals("world street map")){
layerButton.setText("Topo");
streetLayer.setVisible(false);
topoLayer.setVisible(true);
}
if(name.equals("topographic info")){
layerButton.setText("Streets");
streetLayer.setVisible(true);
topoLayer.setVisible(false);
}
}
}
-Andy
... View more
08-08-2012
12:11 PM
|
0
|
0
|
1821
|
|
POST
|
I agree with Andrew. Other examples are when you are running an application with multiple views (Activities), or when you minimize the application and then start it back up. During those conditions and depending on how you coded your app the GPS may resume before the map is loaded and then your mapping code may throw an error since the map won't be ready. When you minimize the app or return to your MapView Activity, the best practice is to test to make sure the map is loaded after onResume() is called. You can accomplish this by using a Handler. Each Handler runs a single thread off of the main User Interface and you can check to see if the STATUS.INITIALIZED has occured. And once the map is loaded (and visible) then use the GPS. Using this pattern you can ensure that everything happens in the correct order and you can fail gracefully if, for example, that map didn't load because of a poor internet connection. If anyone needs the code for this scenario ping me agup at esri dot com. I also blogged about using onResume() here: http://www.andygup.net/?p=779. -Andy
... View more
08-08-2012
11:57 AM
|
0
|
0
|
2728
|
|
POST
|
Did you look at the addLayer(Layer layer, int index) method? You can add a layer using an index. Conversely, you can also remove a layer using removeLayer(int index). -Andy
... View more
08-08-2012
11:32 AM
|
0
|
0
|
1821
|
|
POST
|
@totogogo that issue was fixed in the latest version and you took the recommended steps. Did you clean the project and also delete the old copy of the app off your phone? If that still doesn't work, I recommend opening a support ticket. That way we can collect all the details of your environment. -Andy
... View more
08-08-2012
11:21 AM
|
0
|
0
|
1316
|
|
POST
|
Luke, Make sure you are listening for when the first layer has been initialized using the MapView's OnStatusChanged event, for example:
mapView = new MapView(this);
mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
@Override
public void onStatusChanged(Object source, STATUS status) {
if (OnStatusChangedListener.STATUS.INITIALIZED == status && source == _mapView) {
//TODO Set your extent here
}
if (OnStatusChangedListener.STATUS.LAYER_LOADING_FAILED == status && source == _mapView){
//TODO
}
}
});
-Andy
... View more
08-01-2012
10:59 AM
|
0
|
0
|
1147
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-10-2026 08:29 AM | |
| 1 | 03-26-2026 03:12 PM | |
| 2 | 02-21-2026 10:23 AM | |
| 2 | 08-01-2025 06:20 AM | |
| 1 | 05-27-2025 12:39 PM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|