当前位置: 首页>>代码示例>>Java>>正文


Java Graphic.setSelected方法代码示例

本文整理汇总了Java中com.esri.arcgisruntime.mapping.view.Graphic.setSelected方法的典型用法代码示例。如果您正苦于以下问题:Java Graphic.setSelected方法的具体用法?Java Graphic.setSelected怎么用?Java Graphic.setSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.esri.arcgisruntime.mapping.view.Graphic的用法示例。


在下文中一共展示了Graphic.setSelected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showGeometry

import com.esri.arcgisruntime.mapping.view.Graphic; //导入方法依赖的package包/类
private void showGeometry(Geometry resultGeometry) {
  // add a graphic from the result geometry, showing result in red (0xFFE91F1F)
  Graphic resultGraphic = new Graphic(resultGeometry, resultFillSymbol);
  resultGeometryOverlay.getGraphics().add(resultGraphic);

  // select the result to highlight it
  resultGraphic.setSelected(true);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:9,代码来源:MainActivity.java

示例2: onTouch

import com.esri.arcgisruntime.mapping.view.Graphic; //导入方法依赖的package包/类
@Override
public boolean onTouch(View view, MotionEvent event) {

    switch (event.getAction()) {

        case MotionEvent.ACTION_DOWN:
            dX = view.getX() - event.getRawX();
            dY = view.getY() - event.getRawY();
            break;

        case MotionEvent.ACTION_MOVE:
            final int pointerIndex = MotionEventCompat.getActionIndex(event);
            final float x = MotionEventCompat.getX(event, pointerIndex);
            final float y = MotionEventCompat.getY(event, pointerIndex);
            android.graphics.Point screenPoint = new android.graphics.Point(Math.round(x), Math.round(y));
            final Point singleTapPoint = mMapView.screenToLocation(screenPoint);
            final ListenableFuture<List<GeocodeResult>> results = mLocatorTask.reverseGeocodeAsync(singleTapPoint,
                    mReverseGeocodeParameters);
            graphicsOverlay.getGraphics().clear();
            Graphic resultLocGraphic = new Graphic(singleTapPoint, mPinSourceSymbol);
            resultLocGraphic.setSelected(true);
            // add graphic to location layer
            graphicsOverlay.getGraphics().add(resultLocGraphic);
            // display callout with reverse-geocode result on UI thread
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        List<GeocodeResult> geocodes = results.get();
                        if (geocodes.size() > 0) {
                            // get the top result
                            GeocodeResult geocode = geocodes.get(0);
                            String detail;
                            // attributes from a click-based search
                            String street = geocode.getAttributes().get("Street").toString();
                            String city = geocode.getAttributes().get("City").toString();
                            String state = geocode.getAttributes().get("State").toString();
                            String zip = geocode.getAttributes().get("ZIP").toString();
                            detail = city + ", " + state + " " + zip;

                            String address = street + "," + detail;
                            mCalloutContent.setText(address);
                            // get callout, set content and show
                            mCallout = mMapView.getCallout();
                            mCallout.setLocation(singleTapPoint);
                            mCallout.setContent(mCalloutContent);
                            mCallout.show();

                            mGraphicPoint = singleTapPoint;
                            mGraphicPointAddress = address;
                        }

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });


            break;
        case MotionEvent.ACTION_UP:
            if (graphicsOverlay.getGraphics().size() > 0) {
                graphicsOverlay.getGraphics().get(0).setSelected(false);
                isPinSelected = false;
                mMapView.setOnTouchListener(new MapTouchListener(getApplicationContext(), mMapView));
            }
            break;
        default:
            return false;
    }
    return true;
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:73,代码来源:MainActivity.java

示例3: run

import com.esri.arcgisruntime.mapping.view.Graphic; //导入方法依赖的package包/类
@Override
public void run() {

    try {
        List<GeocodeResult> geocodes = results.get();
        if (geocodes.size() > 0) {
            // get the top result
            GeocodeResult geocode = geocodes.get(0);

            // set the viewpoint to the marker
            Point location = geocode.getDisplayLocation();
            // get attributes from the result for the callout
            String title;
            String detail;
            Object matchAddr = geocode.getAttributes().get("Match_addr");
            if (matchAddr != null) {
                // attributes from a query-based search
                title = matchAddr.toString().split(",")[0];
                detail = matchAddr.toString().substring(matchAddr.toString().indexOf(",") + 1);
            } else {
                // attributes from a click-based search
                String street = geocode.getAttributes().get("Street").toString();
                String city = geocode.getAttributes().get("City").toString();
                String state = geocode.getAttributes().get("State").toString();
                String zip = geocode.getAttributes().get("ZIP").toString();
                title = street;
                detail = city + ", " + state + " " + zip;
            }

            // get attributes from the result for the callout
            HashMap<String, Object> attributes = new HashMap<>();
            attributes.put("title", title);
            attributes.put("detail", detail);


            // create the marker
            Graphic marker = new Graphic(geocode.getDisplayLocation(), attributes, mPinSourceSymbol);
            graphicsOverlay.getGraphics().clear();

            // add the markers to the graphics overlay
            graphicsOverlay.getGraphics().add(marker);

            if (isPinSelected) {
                marker.setSelected(true);
            }
            String calloutText = title + ", " + detail;
            mCalloutContent.setText(calloutText);
            // get callout, set content and show
            mCallout = mMapView.getCallout();
            mCallout.setLocation(geocode.getDisplayLocation());
            mCallout.setContent(mCalloutContent);
            mCallout.show();

            mGraphicPoint = location;
            mGraphicPointAddress = title + ", " + detail;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:62,代码来源:MainActivity.java


注:本文中的com.esri.arcgisruntime.mapping.view.Graphic.setSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。