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


Java GeocodeResult类代码示例

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


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


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