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


Java GeocodeResult.getDisplayLocation方法代码示例

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


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

示例1: displaySearchResult

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入方法依赖的package包/类
/**
 * Turns a GeocodeResult into a Point and adds it to a GraphicOverlay which is then drawn on the map.
 *
 * @param geocodeResult a single geocode result
 */
private void displaySearchResult(GeocodeResult geocodeResult) {
  // dismiss any callout
  if (mMapView.getCallout() != null && mMapView.getCallout().isShowing()) {
    mMapView.getCallout().dismiss();
  }
  // clear map of existing graphics
  mMapView.getGraphicsOverlays().clear();
  mGraphicsOverlay.getGraphics().clear();
  // create graphic object for resulting location
  Point resultPoint = geocodeResult.getDisplayLocation();
  Graphic resultLocGraphic = new Graphic(resultPoint, geocodeResult.getAttributes(), mPinSourceSymbol);
  // add graphic to location layer
  mGraphicsOverlay.getGraphics().add(resultLocGraphic);
  // zoom map to result over 3 seconds
  mMapView.setViewpointAsync(new Viewpoint(geocodeResult.getExtent()), 3);
  // set the graphics overlay to the map
  mMapView.getGraphicsOverlays().add(mGraphicsOverlay);
  showCallout(resultLocGraphic);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:25,代码来源:MainActivity.java

示例2: displaySearchResult

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入方法依赖的package包/类
/**
 * Turns a list of GeocodeResults into Points and adds them to a GraphicOverlay which is then drawn on the map. The
 * points are added to a multipoint used to calculate a viewpoint.
 *
 * @param geocodeResults as a list
 */
private void displaySearchResult(List<GeocodeResult> geocodeResults) {
  // dismiss any callout
  if (mMapView.getCallout() != null && mMapView.getCallout().isShowing()) {
    mMapView.getCallout().dismiss();
  }
  // clear map of existing graphics
  mMapView.getGraphicsOverlays().clear();
  mGraphicsOverlay.getGraphics().clear();
  // create a list of points from the geocode results
  List<Point> resultPoints = new ArrayList<>();
  for (GeocodeResult result : geocodeResults) {
    // create graphic object for resulting location
    Point resultPoint = result.getDisplayLocation();
    Graphic resultLocGraphic = new Graphic(resultPoint, result.getAttributes(), mPinSourceSymbol);
    // add graphic to location layer
    mGraphicsOverlay.getGraphics().add(resultLocGraphic);
    resultPoints.add(resultPoint);
  }
  // add result points to a Multipoint and get an envelope surrounding it
  Multipoint resultsMultipoint = new Multipoint(resultPoints);
  Envelope resultsEnvelope = resultsMultipoint.getExtent();
  // add a 25% buffer to the extent Envelope of result points
  Envelope resultsEnvelopeWithBuffer = new Envelope(resultsEnvelope.getCenter(), resultsEnvelope.getWidth() * 1.25,
      resultsEnvelope.getHeight() * 1.25);
  // zoom map to result over 3 seconds
  mMapView.setViewpointAsync(new Viewpoint(resultsEnvelopeWithBuffer), 3);
  // set the graphics overlay to the map
  mMapView.getGraphicsOverlays().add(mGraphicsOverlay);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:36,代码来源:MainActivity.java

示例3: run

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入方法依赖的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();
      mapView.setViewpointCenterAsync(location, 10000);

      // 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, pinSymbol);

      // update the callout
      Platform.runLater(() -> {
        // clear out previous results
        graphicsOverlay.getGraphics().clear();

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

        // display the callout
        Callout callout = mapView.getCallout();
        callout.setTitle(marker.getAttributes().get("title").toString());
        callout.setDetail(marker.getAttributes().get("detail").toString());
        callout.showCalloutAt(location, new Point2D(0, -24), Duration.ZERO);
      });
    }

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

示例4: run

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

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

      // get attributes from the result for the callout
      String addrType = geocode.getAttributes().get("Addr_type").toString();
      String placeName = geocode.getAttributes().get("PlaceName").toString();
      String placeAddr = geocode.getAttributes().get("Place_addr").toString();
      String matchAddr = geocode.getAttributes().get("Match_addr").toString();
      String locType = geocode.getAttributes().get("Type").toString();

      // format callout details
      String title;
      String detail;
      switch (addrType) {
        case "POI":
          title = placeName.equals("") ? "" : placeName;
          if (!placeAddr.equals("")) {
            detail = placeAddr;
          } else if (!matchAddr.equals("") && !locType.equals("")) {
            detail = !matchAddr.contains(",") ? locType : matchAddr.substring(matchAddr.indexOf(", ") + 2);
          } else {
            detail = "";
          }
          break;
        case "StreetName":
        case "PointAddress":
        case "Postal":
          if (matchAddr.contains(",")) {
            title = matchAddr.equals("") ? "" : matchAddr.split(",")[0];
            detail = matchAddr.equals("") ? "" : matchAddr.substring(matchAddr.indexOf(", ") + 2);
            break;
          }
        default:
          title = "";
          detail = matchAddr.equals("") ? "" : matchAddr;
      }

      HashMap<String, Object> attributes = new HashMap<>();
      attributes.put("title", title);
      attributes.put("detail", detail);

      // create the marker
      Graphic marker = new Graphic(geocode.getDisplayLocation(), attributes, pinSymbol);

      // set the viewpoint to the marker
      Point location = geocodes.get(0).getDisplayLocation();
      mapView.setViewpointCenterAsync(location, 10000);

      // update the marker
      Platform.runLater(() -> {
        // clear out previous results
        graphicsOverlay.getGraphics().clear();
        searchBox.hide();

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

        // display the callout
        Callout callout = mapView.getCallout();
        callout.setTitle(marker.getAttributes().get("title").toString());
        callout.setDetail(marker.getAttributes().get("detail").toString());
        callout.showCalloutAt(location, new Point2D(0, -24), Duration.ZERO);
      });
    }

  } catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:76,代码来源:FindAddressSample.java

示例5: run

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入方法依赖的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.tasks.geocode.GeocodeResult.getDisplayLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。