Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ArcGIS for Android,带弹出窗口和路由_Java_Android_Routing_Popup_Arcgis - Fatal编程技术网

Java ArcGIS for Android,带弹出窗口和路由

Java ArcGIS for Android,带弹出窗口和路由,java,android,routing,popup,arcgis,Java,Android,Routing,Popup,Arcgis,我想用SDK“ArcGIS for Android”开发一个Android应用程序。在那里,我下载了两个示例:用于查看路由的PopupinWebMap。这就是我的目标:我希望将这两个示例放在一个Projekt或一个.java文件中 我已经这样做了,但是这个应用程序在我的智能手机上不工作。它只显示应用程序已停止。如果我把路由中的所有内容都注释掉,它就会起作用。如果我取消对路由中所有层的注释,它也会工作。通过长时间单击地图将激活路由。但在这种情况下,应用程序将崩溃 我对java知之甚少,但它是大学的

我想用SDK“ArcGIS for Android”开发一个Android应用程序。在那里,我下载了两个示例:用于查看路由的PopupinWebMap。这就是我的目标:我希望将这两个示例放在一个Projekt或一个.java文件中

我已经这样做了,但是这个应用程序在我的智能手机上不工作。它只显示应用程序已停止。如果我把路由中的所有内容都注释掉,它就会起作用。如果我取消对路由中所有层的注释,它也会工作。通过长时间单击地图将激活路由。但在这种情况下,应用程序将崩溃

我对java知之甚少,但它是大学的一个项目。我希望有人能帮助我

提前非常感谢你们的帮助,并对我的英语不好表示歉意

代码如下:

public class BAAppActivity extends Activity {

    // Progress dialog to show when route is being calculated
    ProgressDialog dialog;
    // Spatial references used for projecting points
    final SpatialReference wm = SpatialReference.create(102100);
    final SpatialReference egs = SpatialReference.create(4326);
    // Index of the currently selected route segment (-1 = no selection)
    int selectedSegmentID = -1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Lade die Basemap von ArcGIS online.
        map = new MapView(this, "map", "", "");
        setContentView(map);

        // Retrieve the map and initial extent from XML layout
        map = (MapView) findViewById(R.id.map);
        // Add tiled layer to MapView
        tileLayer = new ArcGISTiledMapServiceLayer(
                "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
        map.addLayer(tileLayer);

        // Add the route graphic layer (shows the full route)
        routeLayer = new GraphicsLayer();
        map.addLayer(routeLayer);

        // Add the hidden segments layer (for highlighting route segments)
        hiddenSegmentsLayer = new GraphicsLayer();
        map.addLayer(hiddenSegmentsLayer);

        // Make the segmentHider symbol "invisible"
        segmentHider.setAlpha(1);

        // Get the location service and start reading location. Don't auto-pan
        // to center our position
        LocationService ls = map.getLocationService();
        ls.setLocationListener(new MyLocationListener());
        ls.start();
        ls.setAutoPan(false);

        // Set the directionsLabel with initial instructions.
        directionsLabel = (TextView) findViewById(R.id.directionsLabel);
        directionsLabel.setText(getString(R.string.route_label));

        directionsLabel.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                if (curDirections == null)
                    return;
                Intent i = new Intent(getApplicationContext(),
                        ShowDirections.class);
                i.putStringArrayListExtra("directions", curDirections);
                startActivityForResult(i, 1);
            }

        });

        directionsLabel.setOnLongClickListener(new OnLongClickListener() {

            public boolean onLongClick(View v) {
                routeLayer.removeAll();
                hiddenSegmentsLayer.removeAll();
                curRoute = null;
                curDirections = null;
                directionsLabel.setText(getString(R.string.route_label));
                return true;
            }

        });

        // Tippe auf die Karte und öffne ein Popup für das selektierte Feature.
        map.setOnSingleTapListener(new OnSingleTapListener() {
            private static final long serialVersionUID = 1L;

            public void onSingleTap(float x, float y) {
                // Get all the graphics within 20 pixels the click
                int[] indexes = hiddenSegmentsLayer.getGraphicIDs(x, y, 20);
                // Hide the currently selected segment
                hiddenSegmentsLayer.updateGraphic(selectedSegmentID,
                        segmentHider);

                if (indexes.length < 1) {
                    // If no segments were found but there is currently a route,
                    // zoom to the extent of the full route
                    if (curRoute != null) {
                        map.setExtent(curRoute.getEnvelope(), 250);
                        directionsLabel.setText(routeSummary);
                    }
                    return;
                }
                // Otherwise update our currently selected segment
                selectedSegmentID = indexes[0];
                Graphic selected = hiddenSegmentsLayer
                        .getGraphic(selectedSegmentID);
                // Highlight it on the map
                hiddenSegmentsLayer.updateGraphic(selectedSegmentID,
                        segmentShower);
                String direction = ((String) selected.getAttributeValue("text"));
                double time = ((Double) selected.getAttributeValue("time"))
                        .doubleValue();
                double length = ((Double) selected.getAttributeValue("length"))
                        .doubleValue();
                // Update the label with this direction's information
                String label = String.format(
                        "%s%nTime: %.1f minutes, Length: %.1f miles",
                        direction, time, length);
                directionsLabel.setText(label);
                // Zoom to the extent of that segment
                map.setExtent(selected.getGeometry(), 50);

                if (map.isLoaded()) {
                    // PopupContainer realisieren.
                    popupContainer = new PopupContainer(map);
                    int id = popupContainer.hashCode();
                    popupDialog = null;
                    // spinner (Auswahl) anzeigen.
                    if (progressDialog == null || !progressDialog.isShowing())
                        progressDialog = ProgressDialog.show(map.getContext(), "", "Rufe Informationen ab...");

                    // Loop durch jeden Layer in der Basemap.
                    int tolerance = 20;
                        Envelope env = new Envelope(map.toMapPoint(x, y), 20 * map.getResolution(), 20 * map.getResolution());
                    Layer[] layers = map.getLayers();
                    count = new AtomicInteger();
                    for (Layer layer : layers) {
                        // Wenn der Layer noch nicht geladen wurde oder unsichtbar ist, nichts machen.
                        if (!layer.isInitialized() || !layer.isVisible())
                            continue;

                        if (layer instanceof ArcGISFeatureLayer) {
                            // Frage den FeatureLayer ab und zeige die Popups.
                            ArcGISFeatureLayer featureLayer = (ArcGISFeatureLayer) layer;
                            if (featureLayer.getPopupInfo() != null) {
                                // Frage den FeatureLayer ab, welcher mit den Popupdefinitionen verknüpft ist.
                                count.incrementAndGet();
                                new RunQueryFeatureLayerTask(x, y, tolerance, id).execute(featureLayer);
                            }
                        }
                        else if (layer instanceof ArcGISDynamicMapServiceLayer) {
                            // Frage den DynamicLayer ab und zeige die Popups.
                            ArcGISDynamicMapServiceLayer dynamicLayer = (ArcGISDynamicMapServiceLayer) layer;
                            // Empfange Layerinfos für jeden Sub-Layer des dynamic map service layer.
                            ArcGISLayerInfo[] layerinfos = dynamicLayer.getAllLayers();
                            if (layerinfos == null)
                                continue;

                            // Loop durch jeden Sub-Layer.
                            for (ArcGISLayerInfo layerInfo : layerinfos) {
                                // erhalte PopupInfo für die Sub-Layer.
                                PopupInfo popupInfo = dynamicLayer.getPopupInfo(layerInfo.getId());
                                // Überspringe Sub-Layer, welche keine Popup-Definitionen enthalten.
                                if (popupInfo == null) {
                                    continue;
                                }
                                // Überprüfe ob der Sub-Layer sichtbar ist.
                                ArcGISLayerInfo info = layerInfo;
                                while (info != null && info.isVisible()) {
                                    info = info.getParentLayer();
                                }
                                // Überspringe unsichtbare Sub-Layer.
                                if (info != null && ! info.isVisible()) {
                                    continue;
                                };

                                // Überprüfe ob der Sub-Layer innerhalb des Skalenbereichs ist.
                                double maxScale = (layerInfo.getMaxScale() != 0) ? layerInfo.getMaxScale():popupInfo.getMaxScale();
                                double minScale = (layerInfo.getMinScale() != 0) ? layerInfo.getMinScale():popupInfo.getMinScale();

                                if ((maxScale == 0 || map.getScale() > maxScale) && (minScale == 0 || map.getScale() < minScale)) {
                                    // Frage die Sub-Layer ab, welche mit den Popup-Definitionen verknüpft sind und sichtbar sind und im Skalenbereich liegen.
                                    count.incrementAndGet();
                                    new RunQueryDynamicLayerTask(env, layer, layerInfo.getId(), dynamicLayer.getSpatialReference(), id).execute(dynamicLayer.getUrl() + "/" + layerInfo.getId());
                                }
                            }
                        }               
                    }
                }
            }
        });

        map.setOnLongPressListener(new OnLongPressListener() {

            private static final long serialVersionUID = 1L;

            public void onLongPress(final float x, final float y) {

                // Clear the graphics and empty the directions list
                routeLayer.removeAll();
                hiddenSegmentsLayer.removeAll();
                curDirections = new ArrayList<String>();
                mResults = null;

                // retrieve the user clicked location
                final Point loc = map.toMapPoint(x, y);

                // Show that the route is calculating
                dialog = ProgressDialog.show(BAAppActivity.this, "",
                        "Calculating route...", true);
                // Spawn the request off in a new thread to keep UI responsive
                Thread t = new Thread() {
                    @Override
                    public void run() {
                        try {
                            // Start building up routing parameters
                            RoutingParameters rp = new RoutingParameters();
                            NAFeaturesAsFeature rfaf = new NAFeaturesAsFeature();
                            // Convert point to EGS (decimal degrees)
                            Point p = (Point) GeometryEngine.project(loc, wm,
                                    egs);
                            // Create the stop points (start at our location, go
                            // to pressed location)
                            StopGraphic point1 = new StopGraphic(mLocation);
                            StopGraphic point2 = new StopGraphic(p);
                            rfaf.setFeatures(new Graphic[] { point1, point2 });
                            rfaf.setCompressedRequest(true);
                            rp.setStops(rfaf);
                            // Set the routing service output SR to our map
                            // service's SR
                            rp.setOutSpatialReference(wm);

                            // Create a new routing task pointing to an
                            // NAService (null credentials -> free service)
                            RoutingTask rt = new RoutingTask(
                                    "http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_EU/NAServer/Route",
                                    null);

                            // Solve the route and use the results to update UI
                            // when received
                            mResults = rt.solve(rp);
                            mHandler.post(mUpdateResults);
                        } catch (Exception e) {
                            mException = e;
                            mHandler.post(mUpdateResults);
                        }
                    }
                };
                // Start the operation
                t.start();
            }
        });
    }

    private void createPopupViews(Graphic[] graphics, final int id) {
        if (id != popupContainer.hashCode()) {
            if (progressDialog != null && progressDialog.isShowing() && count.intValue() == 0)
                progressDialog.dismiss();

            return;
        }

        if (popupDialog == null) {
            if (progressDialog != null && progressDialog.isShowing())
                progressDialog.dismiss();

            // Mache einen Dialog für die popups und zeige ihn.
            popupDialog = new PopupDialog(map.getContext(), popupContainer);
            popupDialog.show();
        }
    }

    // Frage den Feature Layer durch einen Trefferüberprüfung ab.
    private class RunQueryFeatureLayerTask extends AsyncTask<ArcGISFeatureLayer, Void, Graphic[]> {

        private int tolerance;
        private float x;
        private float y;
        private ArcGISFeatureLayer featureLayer;
        private int id;

        public RunQueryFeatureLayerTask(float x, float y, int tolerance, int id) {
            super();
            this.x = x;
            this.y = y;
            this.tolerance = tolerance;
            this.id = id;
        }

        @Override
        protected Graphic [] doInBackground(ArcGISFeatureLayer...params) {
            for (ArcGISFeatureLayer featureLayer : params) {
                this.featureLayer = featureLayer;
                // Grafik-IDs in der Nähe der Punkte abrufen.
                int[] ids = featureLayer.getGraphicIDs(x, y, tolerance);
                if (ids != null && ids.length > 0) {
                    ArrayList<Graphic> graphics = new ArrayList<Graphic>();
                    for (int id : ids) {
                        // Grafiken basierend auf den IDs erhalten.
                        Graphic g = featureLayer.getGraphic(id);
                        if (g == null)
                            continue;
                        graphics.add(g);
                    }
                    // Liefert ein Array von Grafiken in der Nähe des Punktes.
                    return graphics.toArray(new Graphic[0]);
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Graphic[] graphics) {
            count.decrementAndGet();
            if (graphics == null || graphics.length == 0) {
                if (progressDialog != null && progressDialog.isShowing() && count.intValue() == 0)
                    progressDialog.dismiss();

                return;
            }

            for (Graphic gr : graphics) {
                Popup popup = featureLayer.createPopup(map, 0, gr);
                popupContainer.addPopup(popup);
            }
            createPopupViews(graphics, id);
        }

    }

    // Frage den Dynamic Map Service Layer mit QueryTask ab.
    private class RunQueryDynamicLayerTask extends AsyncTask<String, Void, FeatureSet> {
        private Envelope env;
        private SpatialReference sr;
        private int id;
        private Layer layer;
        private int subLayerId;

        public RunQueryDynamicLayerTask(Envelope env, Layer layer, int subLayerId, SpatialReference sr, int id) {
            super();
            this.env = env;
            this.sr = sr;
            this.id = id;
            this.layer = layer;
            this.subLayerId = subLayerId;
        }

        @Override
        protected FeatureSet doInBackground(String... urls) {
            for (String url : urls) {
                // Erhalte Grafiken innerhalb der Hülle.
                Query query = new Query();
                query.setInSpatialReference(sr);
                query.setOutSpatialReference(sr);
                query.setGeometry(env);
                query.setMaxFeatures(10);
                query.setOutFields(new String[] { "*" });

                QueryTask queryTask = new QueryTask(url);
                try {
                    FeatureSet results = queryTask.execute(query);
                    return results;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(final FeatureSet result) {
            count.decrementAndGet();
            if (result == null) {
                if (progressDialog != null && progressDialog.isShowing() && count.intValue() == 0)
                    progressDialog.dismiss();

                return;
            }
            Graphic[] graphics = result.getGraphics();
            if (graphics == null || graphics.length == 0) {
                if (progressDialog != null && progressDialog.isShowing() && count.intValue() == 0)
                    progressDialog.dismiss();

                return;
            }
            // Überprüfen, ob die angeforderte PopupContainer-Id identisch mit dem aktuellen PopupContainer ist.
            // Andernfalls verlasse die veralteten Abfragen.
            if (id != popupContainer.hashCode()) {
                // Spinner verwerfen.
                if (progressDialog != null && progressDialog.isShowing() && count.intValue() == 0)
                    progressDialog.dismiss();

                return;
            }
            PopupInfo popupInfo = layer.getPopupInfo(subLayerId);
            if (popupInfo == null) {
                // Spinner verwerfen.
                if (progressDialog != null && progressDialog.isShowing() && count.intValue() == 0)
                    progressDialog.dismiss();

                return;
            }

            for (Graphic gr : graphics) {
                Popup popup = layer.createPopup(map,  subLayerId,  gr);
                popupContainer.addPopup(popup);

            }
            createPopupViews(graphics, id);

        }
    }

    // Ein angepasster Vollbild-Dialog.
    private class PopupDialog extends Dialog {
        private PopupContainer popupContainer;

        public PopupDialog(Context context, PopupContainer popupContainer) {
            super(context, android.R.style.Theme);
            this.popupContainer = popupContainer;           
        }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                LinearLayout layout = new LinearLayout(getContext());
                layout.addView(popupContainer.getPopupContainerView(), LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
                setContentView(layout, params);
        }

    }

    void updateUI() {
        dialog.dismiss();
        if (mResults == null) {
            Toast.makeText(BAAppActivity.this, mException.toString(),
                    Toast.LENGTH_LONG).show();
            return;
        }
        curRoute = mResults.getRoutes().get(0);
        // Symbols for the route and the destination (blue line, checker flag)
        SimpleLineSymbol routeSymbol = new SimpleLineSymbol(Color.BLUE, 3);
        PictureMarkerSymbol destinationSymbol = new PictureMarkerSymbol(
                getResources().getDrawable(R.drawable.flag_finish));

        // Add all the route segments with their relevant information to the
        // hiddenSegmentsLayer, and add the direction information to the list
        // of directions
        for (RoutingDirection rd : curRoute.getRoutingDirections()) {
            HashMap<String, Object> attribs = new HashMap<String, Object>();
            attribs.put("text", rd.getText());
            attribs.put("time", Double.valueOf(rd.getTime()));
            attribs.put("length", Double.valueOf(rd.getLength()));
            curDirections.add(String.format(
                    "%s%nTime: %.1f minutes, Length: %.1f miles", rd.getText(),
                    rd.getTime(), rd.getLength()));
            hiddenSegmentsLayer.addGraphic(new Graphic(rd.getGeometry(),
                    segmentHider, attribs, null));
        }
        // Reset the selected segment
        selectedSegmentID = -1;

        // Add the full route graphic and destination graphic to the routeLayer
        Graphic routeGraphic = new Graphic(curRoute.getRoute().getGeometry(),
                routeSymbol);
        Graphic endGraphic = new Graphic(
                ((Polyline) routeGraphic.getGeometry()).getPoint(((Polyline) routeGraphic
                        .getGeometry()).getPointCount() - 1), destinationSymbol);
        routeLayer.addGraphics(new Graphic[] { routeGraphic, endGraphic });
        // Get the full route summary and set it as our current label
        routeSummary = String.format(
                "%s%nTotal time: %.1f minutes, length: %.1f miles",
                curRoute.getRouteName(), curRoute.getTotalTime(),
                curRoute.getTotalLength());
        directionsLabel.setText(routeSummary);
        // Zoom to the extent of the entire route with a padding
        map.setExtent(curRoute.getEnvelope(), 250);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // Response from directions list view
        if (requestCode == 1) {
            if (resultCode == RESULT_OK) {
                String direction = data.getStringExtra("returnedDirection");
                if (direction == null)
                    return;
                // Look for the graphic that corresponds to this direction
                for (int index : hiddenSegmentsLayer.getGraphicIDs()) {
                    Graphic g = hiddenSegmentsLayer.getGraphic(index);
                    if (direction
                            .contains((String) g.getAttributeValue("text"))) {
                        // When found, hide the currently selected, show the new
                        // selection
                        hiddenSegmentsLayer.updateGraphic(selectedSegmentID,
                                segmentHider);
                        hiddenSegmentsLayer.updateGraphic(index, segmentShower);
                        selectedSegmentID = index;
                        // Update label with information for that direction
                        directionsLabel.setText(direction);
                        // Zoom to the extent of that segment
                        map.setExtent(
                                hiddenSegmentsLayer.getGraphic(
                                        selectedSegmentID).getGeometry(), 50);
                        break;
                    }
                }
            }
        }
    }

    private class MyLocationListener implements LocationListener {

        public MyLocationListener() {
            super();
        }

        /**
         * If location changes, update our current location. If being found for
         * the first time, zoom to our current position with a resolution of 20
         */
        public void onLocationChanged(Location loc) {
            if (loc == null)
                return;
            boolean zoomToMe = (mLocation == null) ? true : false;
            mLocation = new Point(loc.getLongitude(), loc.getLatitude());
            if (zoomToMe) {
                Point p = (Point) GeometryEngine.project(mLocation, egs, wm);
                map.zoomToResolution(p, 20.0);
            }
        }    
    }
}
公共类BAAppActivity扩展活动{
//“进度”对话框以显示正在计算路线的时间
进程对话;
//用于投影点的空间参照
最终空间参考wm=空间参考.create(102100);
最终空间参考egs=空间参考.create(4326);
//当前所选线路段的索引(-1=无选择)
int selectedSegmentID=-1;
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Lade die Basemap von ArcGIS online。
地图=新地图视图(此“地图”、“地图”、“地图”);
setContentView(地图);
//从XML布局检索地图和初始范围
map=(MapView)findviewbyd(R.id.map);
//将平铺图层添加到MapView
tileLayer=新的ArcGISTiledMapServiceLayer(
"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.addLayer(tileLayer);
//添加路线图形层(显示完整路线)
routeLayer=新的GraphicsLayer();
map.addLayer(路由器层);
//添加“隐藏管段”图层(用于高亮显示管段)
HiddenSectionSlayer=新的GraphicsLayer();
map.addLayer(HiddenSolayer);
//使分段隐藏符号“不可见”
segmentHider.setAlpha(1);
//获取定位服务并开始读取位置。不要自动平移
//居中
LocationService ls=map.getLocationService();
ls.setLocationListener(新的MyLocationListener());
ls.start();
ls.setAutoPan(假);
//使用初始指令设置directionsLabel。
directionsLabel=(TextView)findViewById(R.id.directionsLabel);
directionsLabel.setText(getString(R.string.route_-label));
directionsLabel.setOnClickListener(新的OnClickListener(){
公共void onClick(视图v){
if(curDirections==null)
返回;
意图i=新意图(getApplicationContext(),
展示方向(课堂);
i、 putStringArrayListExtra(“方向”,curDirections);
startActivityForResult(i,1);
}
});
directionsLabel.setOnLongClickListener(新的OnLongClickListener(){
仅长按公共布尔值(视图v){
routeLayer.removeAll();
hiddensalyer.removeAll();
curRoute=null;
curDirections=null;
directionsLabel.setText(getString(R.string.route_-label));
返回true;
}
});
//卡丁车和卡丁车的顶部弹出一个选择功能。
setOnSingleTapListener(新的OnSingleTapListener(){
私有静态最终长serialVersionUID=1L;
单个贴图上的公共无效(浮动x、浮动y){
//单击鼠标,获取20像素范围内的所有图形
int[]index=hiddenSectionSlayer.getGraphicId(x,y,20);
//隐藏当前选定的段
HiddenSectsLayer.updateGraphic(selectedSegmentID,
(隐藏者);
如果(索引长度<1){
//如果未找到管段,但当前有一条管线,
//缩放到整个管线的范围
if(curRoute!=null){
setExtent(curRoute.getEnvelope(),250);
directionsLabel.setText(路由摘要);
}
返回;
}
//否则,请更新我们当前选择的细分市场
selectedSegmentID=索引[0];
所选图形=隐藏分段杀手
.getGraphic(selectedSegmentID);
//在地图上突出显示它
HiddenSectsLayer.updateGraphic(selectedSegmentID,
(淋浴);
字符串方向=((字符串)选中。getAttributeValue(“文本”);
双时间=((双)选中。getAttributeValue(“时间”))
.doubleValue();
双精度长度=((双精度)已选定。getAttributeValue(“长度”))
.doubleValue();
//使用此方向的信息更新标签
String label=String.format(
%s%n时间:%.1f分钟,长度:%.1f英里,
方向、时间、长度);
directionsLabel.setText(标签);
//缩放到该段的范围
map.setExtent(selected.getGeometry(),50);
if(map.isLoaded()){
//PopupContainer实现器。
popupContainer=新的popupContainer(地图);
int id=popupContainer.hashCode();
popupDialog=null;
/
10-28 14:19:27.586: E/ArcGIS(26937): Can not parse MapView.initExtent from xml
10-28 14:19:27.586: E/ArcGIS(26937): java.text.ParseException: Unparseable number: "-19332033.11," (at offset 9)
10-28 14:19:27.586: E/ArcGIS(26937):    at java.text.NumberFormat.parse(NumberFormat.java:545)
10-28 14:19:27.586: E/ArcGIS(26937):    at com.esri.android.map.MapView.a(Unknown Source)
10-28 14:19:27.586: E/ArcGIS(26937):    at com.esri.android.map.MapView.a(Unknown Source)
10-28 14:19:27.586: E/ArcGIS(26937):    at com.esri.android.map.MapView.<init>(Unknown Source)
10-28 14:19:27.586: E/ArcGIS(26937):    at java.lang.reflect.Constructor.constructNative(Native Method)
10-28 14:19:27.586: E/ArcGIS(26937):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-28 14:19:27.586: E/ArcGIS(26937):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:318)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.Activity.setContentView(Activity.java:1901)
10-28 14:19:27.586: E/ArcGIS(26937):    at fhffm.wernicke.ba.app.BAAppActivity.onCreate(BAAppActivity.java:111)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.Activity.performCreate(Activity.java:5047)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.ActivityThread.access$700(ActivityThread.java:134)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.os.Looper.loop(Looper.java:137)
10-28 14:19:27.586: E/ArcGIS(26937):    at android.app.ActivityThread.main(ActivityThread.java:4867)
10-28 14:19:27.586: E/ArcGIS(26937):    at java.lang.reflect.Method.invokeNative(Native Method)
10-28 14:19:27.586: E/ArcGIS(26937):    at java.lang.reflect.Method.invoke(Method.java:511)
10-28 14:19:27.586: E/ArcGIS(26937):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
10-28 14:19:27.586: E/ArcGIS(26937):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
10-28 14:19:27.586: E/ArcGIS(26937):    at dalvik.system.NativeStart.main(Native Method)
10-28 14:19:27.806: E/SensorManager(26937): thread start
10-28 14:19:27.816: E/AndroidRuntime(26937): FATAL EXCEPTION: main
10-28 14:19:27.816: E/AndroidRuntime(26937): java.lang.RuntimeException: Unable to start activity ComponentInfo{fhffm.wernicke.ba.app/fhffm.wernicke.ba.app.BAAppActivity}: java.lang.NullPointerException
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2092)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.ActivityThread.access$700(ActivityThread.java:134)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.os.Looper.loop(Looper.java:137)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.ActivityThread.main(ActivityThread.java:4867)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at java.lang.reflect.Method.invokeNative(Native Method)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at java.lang.reflect.Method.invoke(Method.java:511)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at dalvik.system.NativeStart.main(Native Method)
10-28 14:19:27.816: E/AndroidRuntime(26937): Caused by: java.lang.NullPointerException
10-28 14:19:27.816: E/AndroidRuntime(26937):    at fhffm.wernicke.ba.app.BAAppActivity.onCreate(BAAppActivity.java:146)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.Activity.performCreate(Activity.java:5047)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
10-28 14:19:27.816: E/AndroidRuntime(26937):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
10-28 14:19:27.816: E/AndroidRuntime(26937):    ... 11 more
<com.esri.android.map.MapView
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    initExtent = "-19332033.11, -3516.27, -1720941.80, 11737211.28">
</com.esri.android.map.MapView>
    initExtent = "-19332033.11 -3516.27 -1720941.80 11737211.28">
map = new MapView(this, "some map", "", "");
setContentView(map);
featureLayer = new ArcGISFeatureLayer(
                "featureLayer", MODE.ONDEMAND);
map.addLayer(featureLayer);
map = (MapView) findViewById(R.id.map);
tileLayer = new ArcGISTiledMapServiceLayer(
                 "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.addLayer(tileLayer);
map.setOnSingleTapListener(new OnSingleTapListener() {
            private static final long serialVersionUID = 1L;

            public void onSingleTap(float x, float y) {
                if (map.isLoaded()) {
                    // PopupContainer realisieren.
                    popupContainer = new PopupContainer(map);
                    int id = popupContainer.hashCode();
                    popupDialog = null;
                    // spinner (Auswahl) anzeigen.
                    if (progressDialog == null || !progressDialog.isShowing())
                        progressDialog = ProgressDialog.show(map.getContext(), "", "Rufe Informationen ab...");

                    // Loop durch jeden Layer in der Basemap.
                    int tolerance = 20;
                        Envelope env = new Envelope(map.toMapPoint(x, y), 20 * map.getResolution(), 20 * map.getResolution());
                    Layer[] layers = map.getLayers();
                    count = new AtomicInteger();
                    for (Layer layer : layers) {
                        // Wenn der Layer noch nicht geladen wurde oder unsichtbar ist, nichts machen.
                        if (!layer.isInitialized() || !layer.isVisible())
                            continue;

                        if (layer instanceof ArcGISFeatureLayer) {
                            // Frage den FeatureLayer ab und zeige die Popups.
                            ArcGISFeatureLayer featureLayer = (ArcGISFeatureLayer) layer;
                            if (featureLayer.getPopupInfo() != null) {
                                // Frage den FeatureLayer ab, welcher mit den Popupdefinitionen verknüpft ist.
                                count.incrementAndGet();
                                new RunQueryFeatureLayerTask(x, y, tolerance, id).execute(featureLayer);
                            }
                        }
                    }
                }
            }
            ////////////////////////////// Routing /////////////////////////////
            public void onSingleTap1(float x, float y) {
            // Get all the graphics within 20 pixels the click
            int[] indexes = hiddenSegmentsLayer.getGraphicIDs(x, y, 20);
            // Hide the currently selected segment
            hiddenSegmentsLayer.updateGraphic(selectedSegmentID,
                    segmentHider);

            if (indexes.length < 1) {
                // If no segments were found but there is currently a route,
                // zoom to the extent of the full route
                if (curRoute != null) {
                    map.setExtent(curRoute.getEnvelope(), 250);
                    directionsLabel.setText(routeSummary);
                }
                return;
            }
            // Otherwise update our currently selected segment
            selectedSegmentID = indexes[0];
            Graphic selected = hiddenSegmentsLayer
                    .getGraphic(selectedSegmentID);
            // Highlight it on the map
            hiddenSegmentsLayer.updateGraphic(selectedSegmentID,
                    segmentShower);
            String direction = ((String) selected.getAttributeValue("text"));
            double time = ((Double) selected.getAttributeValue("time"))
                    .doubleValue();
            double length = ((Double) selected.getAttributeValue("length"))
                    .doubleValue();
            // Update the label with this direction's information
            String label = String.format(
                    "%s%nTime: %.1f minutes, Length: %.1f miles",
                    direction, time, length);
            directionsLabel.setText(label);
            // Zoom to the extent of that segment
            map.setExtent(selected.getGeometry(), 50);
            }
        });