• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GeocodeResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



GeocodeResult类属于com.esri.arcgisruntime.tasks.geocode包,在下文中一共展示了GeocodeResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: reverseGeocode

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 *  Calls reverseGeocode on a Locator Task and, if there is a result, passes the result to a
 *  Callout method
 * @param point user generated map point
 * @param graphic used for marking the point on which the user touched
 */
private void reverseGeocode(final Point point, final Graphic graphic) {
    if (mLocatorTask != null) {
        final ListenableFuture<List<GeocodeResult>> results =
                mLocatorTask.reverseGeocodeAsync(point, mReverseGeocodeParameters);
        results.addDoneListener(new Runnable() {
            public void run() {
                try {
                    List<GeocodeResult> geocodeResult = results.get();
                    if (geocodeResult.size() > 0) {
                        graphic.getAttributes().put(
                                "Match_addr", geocodeResult.get(0).getLabel());
                        showCalloutForGraphic(graphic, point);
                    } else {
                        //no result was found
                        mMapView.getCallout().dismiss();
                    }
                } catch (InterruptedException | ExecutionException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:30,代码来源:MobileMapViewActivity.java


示例2: 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


示例3: markFire

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
private void markFire() {

    try {
      List<GeocodeResult> results = geocodeResult.get();

      if (results.size() > 0) {
        // get the geocode location
        fireLocation = results.get(0).getDisplayLocation();

        // set attributes for a fire feature
        Map<String, Object> attributes = new HashMap<>();
        attributes.put("eventtype", 7); // fire origin
        attributes.put("description", "fire");

        // create a new feature and add it to the table
        Feature fire = pointsFeatureTable.createFeature(attributes, fireLocation);
        pointsFeatureTable.addFeatureAsync(fire);

        truckButton.setDisable(false);
      }

    } catch (InterruptedException | ExecutionException exception) {
      exception.printStackTrace();
    }

  }
 
开发者ID:Esri,项目名称:arcgis-runtime-demo-java,代码行数:27,代码来源:MonitorController.java


示例4: showSuggestedPlace

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 * Given an address and the geocode results, dismiss
 * progress dialog and keyboard and show the geocoded location.
 * @param locationResults - List of GeocodeResult
  */
private void showSuggestedPlace(final List<GeocodeResult> locationResults, final String address){

	Point resultPoint = null;
	String resultAddress = null;
	if (locationResults != null && locationResults.size() > 0) {
		// Get the first returned result
		mGeocodedLocation = locationResults.get(0);
		resultPoint = mGeocodedLocation.getDisplayLocation();
		resultAddress = mGeocodedLocation.getLabel();
	}else{
		Log.i(MapFragment.TAG, "No geocode results found for suggestion");
	}

	if (resultPoint == null){
		Toast.makeText(getActivity(),
				getString(R.string.location_not_foud) + resultAddress,
				Toast.LENGTH_LONG).show();
		return;
	}
	// Display the result
	displaySearchResult(resultPoint, address);
}
 
开发者ID:Esri,项目名称:maps-app-android,代码行数:28,代码来源:MapFragment.java


示例5: showReverseGeocodeResult

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 * Displays any gecoded results by add a PictureMarkerSymbol to the map's
 * graphics layer.
 *
 * @param results
 *            A list of GeocodeResult items
 */
private void showReverseGeocodeResult(List<GeocodeResult> results) {

	if (results != null && results.size() > 0) {
		// Show the first item returned
		// Address string is saved for use in routing
		mLocationLayerPointString = results.get(0).getLabel();
		mFoundLocation = results.get(0).getDisplayLocation();
		// Draw marker on map.
		// create marker symbol to represent location

		BitmapDrawable bitmapDrawable = (BitmapDrawable) ContextCompat
				.getDrawable(getActivity().getApplicationContext(), R.drawable.pin_circle_red);
		PictureMarkerSymbol destinationSymbol = new PictureMarkerSymbol(bitmapDrawable);
		mLocationLayer.getGraphics().add(new Graphic(mFoundLocation, destinationSymbol));

		// center the map to result location
		mMapView.setViewpointCenterAsync(mFoundLocation);

		// Show the result on the search result layout
		showSearchResultLayout(mLocationLayerPointString);
	}
}
 
开发者ID:Esri,项目名称:maps-app-android,代码行数:30,代码来源:MapFragment.java


示例6: geocodeAddress

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 * Geocode the given string and search for EMUs.
 * @param addresss - The string entered into the search view
 */
@Override public void geocodeAddress(final String addresss) {
  mDataManager.queryForAddress(addresss, mMapView.getSpatialReference(),  new ServiceApi.GeocodingCallback() {
    @Override public void onGeocodeResult(final List<GeocodeResult> results) {
      if (results == null){
        mMapView.showMessage(NO_LOCATION_FOUND + addresss);
      }else{
        final GeocodeResult result = results.get(0);
        setSelectedPoint(result.getDisplayLocation());
      }
    }
  });
}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:17,代码来源:MapPresenter.java


示例7: getPlacesFromService

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
@Override public void getPlacesFromService(@NonNull final GeocodeParameters parameters,@NonNull final PlacesServiceCallback callback)  {
  final String searchText = "";
  provisionOutputAttributes(parameters);
  provisionCategories(parameters);
  final ListenableFuture<List<GeocodeResult>> results = sLocatorTask
      .geocodeAsync(searchText, parameters);
  Log.i(TAG,"Geocode search started...");
  results.addDoneListener(new GeocodeProcessor(results, callback));
}
 
开发者ID:Esri,项目名称:nearby-android,代码行数:10,代码来源:LocationService.java


示例8: search

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 * Searches for places near the chosen location when the "search" button is clicked.
 */
@FXML
private void search() {
  String placeQuery = placeBox.getEditor().getText();
  String locationQuery = locationBox.getEditor().getText();
  if (placeQuery != null && locationQuery != null && !"".equals(placeQuery) && !"".equals(locationQuery)) {
    GeocodeParameters geocodeParameters = new GeocodeParameters();
    geocodeParameters.getResultAttributeNames().add("*"); // return all attributes
    geocodeParameters.setOutputSpatialReference(mapView.getSpatialReference());

    // run the locatorTask geocode task
    ListenableFuture<List<GeocodeResult>> results = locatorTask.geocodeAsync(locationQuery, geocodeParameters);
    results.addDoneListener(() -> {
      try {
        List<GeocodeResult> points = results.get();
        if (points.size() > 0) {
          // create a search area envelope around the location
          Point p = points.get(0).getDisplayLocation();
          Envelope preferredSearchArea = new Envelope(p.getX() - 10000, p.getY() - 10000, p.getX() + 10000, p.getY
              () + 10000, p.getSpatialReference());
          // set the geocode parameters search area to the envelope
          geocodeParameters.setSearchArea(preferredSearchArea);
          // zoom to the envelope
          mapView.setViewpointAsync(new Viewpoint(preferredSearchArea));
          // perform the geocode operation
          ListenableFuture<List<GeocodeResult>> geocodeTask = locatorTask.geocodeAsync(placeQuery,
              geocodeParameters);

          // add a listener to display the results when loaded
          geocodeTask.addDoneListener(new ResultsLoadedListener(geocodeTask));
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    });
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:40,代码来源:FindPlaceController.java


示例9: searchByCurrentViewpoint

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 * Searches for places within the current map extent when the "redo search in this area" button is clicked.
 */
@FXML
private void searchByCurrentViewpoint() {
    String placeQuery = placeBox.getEditor().getText();
    GeocodeParameters geocodeParameters = new GeocodeParameters();
    geocodeParameters.getResultAttributeNames().add("*"); // return all attributes
    geocodeParameters.setOutputSpatialReference(mapView.getSpatialReference());
    geocodeParameters.setSearchArea(mapView.getCurrentViewpoint(Viewpoint.Type.BOUNDING_GEOMETRY).getTargetGeometry());

    //perform the geocode operation
    ListenableFuture<List<GeocodeResult>> geocodeTask = locatorTask.geocodeAsync(placeQuery, geocodeParameters);

    // add a listener to display the results when loaded
    geocodeTask.addDoneListener(new ResultsLoadedListener(geocodeTask));
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:18,代码来源:FindPlaceController.java


示例10: onLongPress

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
@Override
public void onLongPress(MotionEvent e) {
    android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()),
            Math.round(e.getY()));

    Point longPressPoint = mMapView.screenToLocation(screenPoint);

    ListenableFuture<List<GeocodeResult>> results = mLocatorTask.reverseGeocodeAsync(longPressPoint,
            mReverseGeocodeParameters);
    results.addDoneListener(new ResultsLoadedListener(results));

}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:13,代码来源:MainActivity.java


示例11: 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


示例12: geocodeAddress

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 *
 * Geocode an address typed in by user
 *
 * @param address - String
 * @param geocodingCallback GeoCodingCallback
 */
@Override
public void geocodeAddress(final String address,
    final DataManagerCallbacks.GeoCodingCallback geocodingCallback){
  if (hasLocatorTask()){
    if (mLocatorTask == null){
      mLocatorTask = mMobileMapPackage.getLocatorTask();
      // If locator task is still null, then the mobile map package doesn't have a locator
      if (mLocatorTask == null){
        geocodingCallback.onNoGeoCodingTask("No locator task found in mobile map package");
        return;
      }
    }
    mLocatorTask.addDoneLoadingListener(new Runnable() {
      @Override public void run() {
        if (mLocatorTask.getLoadStatus() == LoadStatus.LOADED){
          // Call geocodeAsync passing in an address
          final ListenableFuture<List<GeocodeResult>> geocodeFuture = mLocatorTask.geocodeAsync(address,
              mGeocodeParameters);
          geocodeFuture.addDoneListener(new Runnable() {
            @Override public void run() {

              try {
                final List<GeocodeResult> geocodeResults = geocodeFuture.get();
                geocodingCallback.onGeoCodingTaskCompleted(geocodeResults);

              } catch (InterruptedException | ExecutionException e) {

                Log.e(TAG, e.getMessage());
                geocodingCallback.onGeoCodingError(e.getCause());
              }
            }
          });
        }else{
          geocodingCallback.onGeoCodingTaskNotLoaded(mLocatorTask.getLoadError());
        }
      }
    });
    mLocatorTask.loadAsync();
  }else{
    geocodingCallback.onNoGeoCodingTask("No locator task available");
  }
}
 
开发者ID:Esri,项目名称:mapbook-android,代码行数:50,代码来源:DataManager.java


示例13: onGeocodeResult

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
void onGeocodeResult(List<GeocodeResult> results
);
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:3,代码来源:ServiceApi.java


示例14: GeocodeProcessor

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
public GeocodeProcessor(final ListenableFuture<List<GeocodeResult>> results,final PlacesServiceCallback callback ){
  mCallback = callback;
  mResults = results;
}
 
开发者ID:Esri,项目名称:nearby-android,代码行数:5,代码来源:LocationService.java


示例15: handle

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

  // get the mouse location coordinates
  Point point = mapView.screenToLocation(new Point2D(event.getX(), event.getY()));

  // disable the move event listener to reduce unnecessary geocode calls
  mapView.setOnMouseMoved(null);

  // run the locator task
  ListenableFuture<List<GeocodeResult>> results = locatorTask.reverseGeocodeAsync(point, reverseGeocodeParameters);
  results.addDoneListener(() -> {
    try {
      // get the geocode from the result
      List<GeocodeResult> geocodes = results.get();
      GeocodeResult geocode = geocodes.get(0);

      // update the marker's position
      graphicsOverlay.getGraphics().get(0).setGeometry(geocode.getDisplayLocation());

      // format result's attributes for callout
      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();

      // update the callout
      Platform.runLater(() -> {
        Callout callout = mapView.getCallout();
        callout.setTitle(street);
        callout.setDetail(city + ", " + state + " " + zip);
        callout.showCalloutAt(geocode.getDisplayLocation(), new Point2D(0, -24), Duration.ZERO);
      });

    } catch (Exception e) {
      // mouse is out of bounds
    }
    // re-enable the mouse move listener
    mapView.setOnMouseMoved(this);
  });
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:42,代码来源:OfflineGeocodeSample.java


示例16: 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


示例17: 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


示例18: geoCodeTypedAddress

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的package包/类
/**
 * Geocode an address typed in by user
 *
 * @param address
 */
private void geoCodeTypedAddress(final String address) {
    // Null out any previously located result
    mGeocodedLocation = null;

    // Execute async task to find the address
    mLocatorTask.addDoneLoadingListener(new Runnable() {
        @Override
        public void run() {
            if (mLocatorTask.getLoadStatus() == LoadStatus.LOADED) {
                // Call geocodeAsync passing in an address
                final ListenableFuture<List<GeocodeResult>> geocodeFuture = mLocatorTask.geocodeAsync(address,
                        mGeocodeParameters);
                geocodeFuture.addDoneListener(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            // Get the results of the async operation
                            List<GeocodeResult> geocodeResults = geocodeFuture.get();

                            if (geocodeResults.size() > 0) {
                                // Use the first result - for example
                                // display on the map
                                mGeocodedLocation = geocodeResults.get(0);
                                displaySearchResult(mGeocodedLocation.getDisplayLocation(), mGeocodedLocation.getLabel());

                            } else {
                                Toast.makeText(getApplicationContext(),
                                        getString(R.string.location_not_foud) + address,
                                        Toast.LENGTH_LONG).show();
                            }

                        } catch (InterruptedException | ExecutionException e) {
                            // Deal with exception...
                            e.printStackTrace();
                            Toast.makeText(getApplicationContext(),
                                    getString(R.string.geo_locate_error),
                                    Toast.LENGTH_LONG).show();

                        }
                        // Done processing and can remove this listener.
                        geocodeFuture.removeDoneListener(this);
                    }
                });

            } else {
                Log.i(TAG, "Trying to reload locator task");
                mLocatorTask.retryLoadAsync();
            }
        }
    });
    mLocatorTask.loadAsync();
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:58,代码来源:MainActivity.java


示例19: onTouch

import com.esri.arcgisruntime.tasks.geocode.GeocodeResult; //导入依赖的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


示例20: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TagName类代码示例发布时间:2022-05-23
下一篇:
Java CLPlatform类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap