コード例 #1
0
 public FeatureLayer addLayer(String url) {
   if (url == null || url.equals("url")) {
     return null;
   }
   Geodatabase localGdb = null;
   try {
     localGdb = new Geodatabase(PathUitl.getInnerSDCardPath() + url);
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   }
   if (localGdb != null) {
     for (GeodatabaseFeatureTable gdbFeatureTable : localGdb.getGeodatabaseTables()) {
       if (gdbFeatureTable.hasGeometry()) {
         FeatureLayer featureLayer = new FeatureLayer(gdbFeatureTable);
         Symbol symbol = new SimpleFillSymbol(Color.BLUE);
         Renderer renderer = new SimpleRenderer(symbol);
         featureLayer.setRenderer(renderer);
         featureLayer.setVisible(false);
         mMapView.addLayer(featureLayer);
         mMapView.setExtent(featureLayer.getExtent());
         return featureLayer;
       }
     }
   }
   return null;
 }
コード例 #2
0
  public void search(String keywords) {
    System.out.println(keywords);
    featureLayer.clearSelection();
    QueryParameters q = new QueryParameters();
    q.setWhere("NAME = '" + keywords + "'");
    q.setReturnGeometry(true);
    q.setInSpatialReference(mMapView.getSpatialReference());
    // q.setGeometry(g.getGeometry());
    q.setSpatialRelationship(SpatialRelationship.INTERSECTS);
    featureLayer.selectFeatures(
        q,
        FeatureLayer.SelectionMode.NEW,
        new CallbackListener<FeatureResult>() {
          @Override
          public void onError(Throwable e) {
            e.printStackTrace();
          }

          @Override
          public void onCallback(FeatureResult featureResult) {
            if (null != featureResult) {
              // If there are no query results, inform user.
              if (featureResult.featureCount() < 1) {
                System.out.println("无查询结果");
                return;
              }

              // Iterate the results and select each feature.
              for (Object objFeature : featureResult) {
                Feature feature = (Feature) objFeature;
                System.out.println(feature.getAttributes().get("NAME"));
                resultCallOut = mMapView.getCallout();
                //    content = (View) view.findViewById(R.layout.calloutlayout);//弹出窗口布局文件对象
                //                        PopupContainer mPopupContainer = new
                // PopupContainer(mMapView);
                //                        Popup popup =featureLayer.createPopup(mMapView, 0,
                // feature);
                //
                //                        popup.setEditable(true);
                //
                //                        mPopupContainer.addPopup(popup);

                //  mMapView.centerAt(feature.getGeometry(), true);
                // mMapView.setExtent(feature.getGeometry());
                //  featureLayer.selectFeature(feature.getId());
              }
              // 创建弹出窗体

            }
          }
        });
  }