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


Java PictureMarkerSymbol.setWidth方法代码示例

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


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

示例1: showClickedLocation

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
/**
 * Create and add a marker to the map representing
 * the clicked location.
 * @param point - A com.esri.arcgisruntime.geometry.Point item
 */
@Override public void showClickedLocation(final Point point) {
  final Bitmap icon = BitmapFactory.decodeResource(getActivity().getResources(), R.mipmap.blue_pin);
  final BitmapDrawable drawable = new BitmapDrawable(getResources(), icon);
  final PictureMarkerSymbol markerSymbol = new PictureMarkerSymbol(drawable);
  markerSymbol.setHeight(40);
  markerSymbol.setWidth(40);
  markerSymbol.setOffsetY(markerSymbol.getHeight()/2);
  markerSymbol.loadAsync();
  markerSymbol.addDoneLoadingListener(new Runnable() {
    @Override public void run() {
      final Graphic marker = new Graphic(point, markerSymbol);
      mGraphicOverlay.getGraphics().clear();
      mGraphicOverlay.getGraphics().add(marker);
    }
  });

}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:23,代码来源:MapFragment.java

示例2: createFacilitiesAndGraphics

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
/**
 * Creates facilities around the San Diego region.
 * <p>
 * Facilities are created using point geometry which is then used to make graphics for the graphics overlay.
 */
private void createFacilitiesAndGraphics() {
  // List of facilities to be placed around San Diego area
  facilities = Arrays.asList(
      new Facility(new Point(-1.3042129900625112E7, 3860127.9479775648, spatialReference)),
      new Facility(new Point(-1.3042193400557665E7, 3862448.873041752, spatialReference)),
      new Facility(new Point(-1.3046882875518233E7, 3862704.9896770366, spatialReference)),
      new Facility(new Point(-1.3040539754780494E7, 3862924.5938606677, spatialReference)),
      new Facility(new Point(-1.3042571225655518E7, 3858981.773018156, spatialReference)),
      new Facility(new Point(-1.3039784633928463E7, 3856692.5980474586, spatialReference)),
      new Facility(new Point(-1.3049023883956768E7, 3861993.789732541, spatialReference)));

  // image for displaying facility
  String facilityUrl = "http://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png";
  PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(facilityUrl);
  facilitySymbol.setHeight(30);
  facilitySymbol.setWidth(30);

  // for each facility, create a graphic and add to graphics overlay
  facilities.stream().map(f -> new Graphic(f.getGeometry(), facilitySymbol))
      .collect(Collectors.toCollection(() -> facilityGraphicsOverlay.getGraphics()));
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:27,代码来源:ClosestFacilitySample.java

示例3: placePictureMarkerSymbol

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
/**
 * Adds a Graphic to the Graphics Overlay using a Point and a Picture Marker
 * Symbol.
 * 
 * @param markerSymbol PictureMarkerSymbol to be used
 * @param graphicPoint where the Graphic is going to be placed
 */
private void placePictureMarkerSymbol(PictureMarkerSymbol markerSymbol, Point graphicPoint) {

  // set size of the image
  markerSymbol.setHeight(40);
  markerSymbol.setWidth(40);

  // load symbol asynchronously
  markerSymbol.loadAsync();

  // add to the graphic overlay once done loading
  markerSymbol.addDoneLoadingListener(() -> {
    if (markerSymbol.getLoadStatus() == LoadStatus.LOADED) {
      Graphic symbolGraphic = new Graphic(graphicPoint, markerSymbol);
      graphicsOverlay.getGraphics().add(symbolGraphic);
    } else {
      Alert alert = new Alert(Alert.AlertType.ERROR, "Picture Marker Symbol Failed to Load!");
      alert.show();
    }
  });

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

示例4: createPictureMarkerSymbolFromFile

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
/**
 * Create a picture marker symbol from an image on disk. Called from checkSaveResourceToExternalStorage() or
 * onRequestPermissionsResult which validate required external storage and permissions
 */
private void createPictureMarkerSymbolFromFile() {

  //[DocRef: Name=Picture Marker Symbol File-android, Category=Fundamentals, Topic=Symbols and Renderers]
  //Create a picture marker symbol from a file on disk
  BitmapDrawable pinBlankOrangeDrawable = (BitmapDrawable) Drawable.createFromPath(mPinBlankOrangeFilePath);
  final PictureMarkerSymbol pinBlankOrangeSymbol = new PictureMarkerSymbol(pinBlankOrangeDrawable);
  //Optionally set the size, if not set the image will be auto sized based on its size in pixels,
  //its appearance would then differ across devices with different resolutions.
  pinBlankOrangeSymbol.setHeight(20);
  pinBlankOrangeSymbol.setWidth(20);
  //Optionally set the offset, to align the base of the symbol aligns with the point geometry
  pinBlankOrangeSymbol.setOffsetY(10); //The image used has not buffer and therefore the Y offset is height/2
  pinBlankOrangeSymbol.loadAsync();
  //[DocRef: END]
  pinBlankOrangeSymbol.addDoneLoadingListener(new Runnable() {
    @Override
    public void run() {
      //add a new graphic with the same location as the initial viewpoint
      Point pinBlankOrangePoint = new Point(-228835, 6550763, SpatialReferences.getWebMercator());
      Graphic pinBlankOrangeGraphic = new Graphic(pinBlankOrangePoint, pinBlankOrangeSymbol);
      mGraphicsOverlay.getGraphics().add(pinBlankOrangeGraphic);
    }
  });

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

示例5: initialize

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
@FXML
public void initialize() {

  ArcGISMap map = new ArcGISMap(Basemap.createStreets());
  mapView.setMap(map);
  // set mapview to San Diego
  mapView.setViewpoint(new Viewpoint(32.73, -117.14, 60000));

  // create service area task from url
  final String SanDiegoRegion = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/ServiceArea";
  serviceAreaTask = new ServiceAreaTask(SanDiegoRegion);
  serviceAreaTask.loadAsync();
  // create default parameters from task
  ListenableFuture<ServiceAreaParameters> parameters = serviceAreaTask.createDefaultParametersAsync();
  parameters.addDoneListener(() -> {
    try {
      serviceAreaParameters = parameters.get();
      serviceAreaParameters.setPolygonDetail(ServiceAreaPolygonDetail.HIGH);
      serviceAreaParameters.setReturnPolygons(true);
      // adding another service area of 2 minutes
      // default parameters have a default service area of 5 minutes
      serviceAreaParameters.getDefaultImpedanceCutoffs().addAll(Arrays.asList(2.0));
    } catch (ExecutionException | InterruptedException e) {
      e.printStackTrace();
    }
  });

  // for displaying graphics to mapview
  serviceAreasOverlay = new GraphicsOverlay();
  facilityOverlay = new GraphicsOverlay();
  barrierOverlay = new GraphicsOverlay();
  mapView.getGraphicsOverlays().addAll(Arrays.asList(serviceAreasOverlay, barrierOverlay, facilityOverlay));

  barrierBuilder = new PolylineBuilder(spatialReference);
  serviceAreaFacilities = new ArrayList<>();

  SimpleLineSymbol outline = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF000000, 3.0f);
  fillSymbols = new ArrayList<>();
  fillSymbols.add(new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0x66FF0000, outline));
  fillSymbols.add(new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0x66FFA500, outline));

  // icon used to display facilities to mapview
  String facilityUrl = "http://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png";
  PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(facilityUrl);
  facilitySymbol.setHeight(30);
  facilitySymbol.setWidth(30);

  // creates facilities and barriers at user's clicked location
  mapView.setOnMouseClicked(e -> {
    if (e.getButton() == MouseButton.PRIMARY && e.isStillSincePress()) {
      // create a point from where the user clicked
      Point2D point = new Point2D(e.getX(), e.getY());
      Point mapPoint = mapView.screenToLocation(point);
      if (btnAddFacility.isSelected()) {
        // create facility from point and display to mapview
        Point servicePoint = new Point(mapPoint.getX(), mapPoint.getY(), spatialReference);
        serviceAreaFacilities.add(new ServiceAreaFacility(servicePoint));
        facilityOverlay.getGraphics().add(new Graphic(servicePoint, facilitySymbol));
      } else if (btnAddBarrier.isSelected()) {
        // create barrier and display to mapview
        barrierBuilder.addPoint(new Point(mapPoint.getX(), mapPoint.getY(), spatialReference));
        barrierOverlay.getGraphics().add(barrierOverlay.getGraphics().size(), new Graphic(barrierBuilder.toGeometry(), outline));
      }
    }
  });
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:67,代码来源:ServiceAreaTaskController.java

示例6: setUpOfflineMapGeocoding

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
private void setUpOfflineMapGeocoding() {
    // create a basemap from a local tile package
    TileCache tileCache = new TileCache(extern + getResources().getString(R.string.sandiego_tpk));
    tiledLayer = new ArcGISTiledLayer(tileCache);
    Basemap basemap = new Basemap(tiledLayer);

    // create ArcGISMap with imagery basemap
    mMap = new ArcGISMap(basemap);

    mMapView.setMap(mMap);

    mMap.addDoneLoadingListener(new Runnable() {
        @Override
        public void run() {
            Point p = new Point(-117.162040, 32.718260, SpatialReference.create(4326));
            Viewpoint vp = new Viewpoint(p, 10000);
            mMapView.setViewpointAsync(vp, 3);
        }
    });


    // add a graphics overlay
    graphicsOverlay = new GraphicsOverlay();
    graphicsOverlay.setSelectionColor(Color.CYAN);
    mMapView.getGraphicsOverlays().add(graphicsOverlay);


    mGeocodeParameters = new GeocodeParameters();
    mGeocodeParameters.getResultAttributeNames().add("*");
    mGeocodeParameters.setMaxResults(1);

    //[DocRef: Name=Picture Marker Symbol Drawable-android, Category=Fundamentals, Topic=Symbols and Renderers]
    //Create a picture marker symbol from an app resource
    BitmapDrawable startDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin);
    mPinSourceSymbol = new PictureMarkerSymbol(startDrawable);
    mPinSourceSymbol.setHeight(90);
    mPinSourceSymbol.setWidth(20);
    mPinSourceSymbol.loadAsync();
    mPinSourceSymbol.setLeaderOffsetY(45);
    mPinSourceSymbol.setOffsetY(-48);

    mReverseGeocodeParameters = new ReverseGeocodeParameters();
    mReverseGeocodeParameters.getResultAttributeNames().add("*");
    mReverseGeocodeParameters.setOutputSpatialReference(mMap.getSpatialReference());
    mReverseGeocodeParameters.setMaxResults(1);

    mLocatorTask = new LocatorTask(extern + getResources().getString(R.string.sandiego_loc));

    mCalloutContent = new TextView(getApplicationContext());
    mCalloutContent.setTextColor(Color.BLACK);
    mCalloutContent.setTextIsSelectable(true);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:53,代码来源:MainActivity.java

示例7: onCreate

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  // inflate MapView from layout
  mMapView = (MapView) findViewById(R.id.mapView);

  // create a map with the imagery basemap
  ArcGISMap map = new ArcGISMap(Basemap.createTopographic());

  // set the map to be displayed in the mapview
  mMapView.setMap(map);

  // create an initial viewpoint using an envelope (of two points, bottom left and top right)
  Envelope envelope = new Envelope(new Point(-228835, 6550763, SpatialReferences.getWebMercator()),
      new Point(-223560, 6552021, SpatialReferences.getWebMercator()));
  //set viewpoint on mapview
  mMapView.setViewpointGeometryAsync(envelope, 100.0);

  // create a new graphics overlay and add it to the mapview
  mGraphicsOverlay = new GraphicsOverlay();
  mMapView.getGraphicsOverlays().add(mGraphicsOverlay);

  //[DocRef: Name=Picture Marker Symbol URL, Category=Fundamentals, Topic=Symbols and Renderers]
  //Create a picture marker symbol from a URL resource
  //When using a URL, you need to call load to fetch the remote resource
  final PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(
      "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae");
  //Optionally set the size, if not set the image will be auto sized based on its size in pixels,
  //its appearance would then differ across devices with different resolutions.
  campsiteSymbol.setHeight(18);
  campsiteSymbol.setWidth(18);
  campsiteSymbol.loadAsync();
  //[DocRef: END]
  campsiteSymbol.addDoneLoadingListener(new Runnable() {
    @Override
    public void run() {
      //Once the symbol has loaded, add a new graphic to the graphic overlay
      Point campsitePoint = new Point(-223560, 6552021, SpatialReferences.getWebMercator());
      Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol);
      mGraphicsOverlay.getGraphics().add(campsiteGraphic);
    }
  });

  //[DocRef: Name=Picture Marker Symbol Drawable-android, Category=Fundamentals, Topic=Symbols and Renderers]
  //Create a picture marker symbol from an app resource
  BitmapDrawable pinStarBlueDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin_star_blue);
  final PictureMarkerSymbol pinStarBlueSymbol = new PictureMarkerSymbol(pinStarBlueDrawable);
  //Optionally set the size, if not set the image will be auto sized based on its size in pixels,
  //its appearance would then differ across devices with different resolutions.
  pinStarBlueSymbol.setHeight(40);
  pinStarBlueSymbol.setWidth(40);
  //Optionally set the offset, to align the base of the symbol aligns with the point geometry
  pinStarBlueSymbol.setOffsetY(
      11); //The image used for the symbol has a transparent buffer around it, so the offset is not simply height/2
  pinStarBlueSymbol.loadAsync();
  //[DocRef: END]
  pinStarBlueSymbol.addDoneLoadingListener(new Runnable() {
    @Override
    public void run() {
      //add a new graphic with the same location as the initial viewpoint
      Point pinStarBluePoint = new Point(-226773, 6550477, SpatialReferences.getWebMercator());
      Graphic pinStarBlueGraphic = new Graphic(pinStarBluePoint, pinStarBlueSymbol);
      mGraphicsOverlay.getGraphics().add(pinStarBlueGraphic);
    }
  });

  //see createPictureMarkerSymbolFromFile() method for implementation
  //first run checks for external storage and permissions,
  checkSaveResourceToExternalStorage();

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

示例8: setUpOfflineMapGeocoding

import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入方法依赖的package包/类
/**
 * Sets up a LocatorTask from the loaded mobile map package, and graphics to show results from running the task.
 * Shows a message to user if Locator task is not found.
 */
private void setUpOfflineMapGeocoding() {

  if (mMobileMapPackage.getLocatorTask() == null) {
    Snackbar.make(mMapView, "Current mobile map package has no LocatorTask", Snackbar.LENGTH_SHORT).show();
    return;
  }

  // Get LocatorTask from loaded MobileMapPackage and listen for loading events
  mLocatorTask = mMobileMapPackage.getLocatorTask();
  mLocatorTask.addDoneLoadingListener(new Runnable() {
    @Override
    public void run() {
      if (mLocatorTask.getLoadStatus() != LoadStatus.LOADED) {
        Snackbar.make(mMapView, String.format(getString(R.string.object_not_loaded), "LocatorTask"),
            Snackbar.LENGTH_SHORT).show();
      }
    }
  });
  mLocatorTask.loadAsync();

  // Add a graphics overlay that will be used for geocoding results
  graphicsOverlay = new GraphicsOverlay();
  graphicsOverlay.setSelectionColor(0xFF00FFFF);
  mMapView.getGraphicsOverlays().add(graphicsOverlay);

  // Define the parameters that will be used by the locator task
  mGeocodeParameters = new GeocodeParameters();
  mGeocodeParameters.getResultAttributeNames().add("*");
  mGeocodeParameters.setMaxResults(10); //1);
  mGeocodeParameters.setOutputSpatialReference(mMapView.getSpatialReference());

  //Create picture marker symbols from app resources for geocode results
  BitmapDrawable addressDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin_blank_orange);
  mFromAddressSymbol = new PictureMarkerSymbol(addressDrawable);
  mFromAddressSymbol.setHeight(64);
  mFromAddressSymbol.setWidth(64);
  mFromAddressSymbol.loadAsync();
  mFromAddressSymbol.setLeaderOffsetY(32);
  mFromAddressSymbol.setOffsetY(32);

  BitmapDrawable hydrantDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin_circle_blue_d);
  mToAddressSymbol = new PictureMarkerSymbol(hydrantDrawable);
  mToAddressSymbol.setHeight(64);
  mToAddressSymbol.setWidth(64);
  mToAddressSymbol.loadAsync();
  mToAddressSymbol.setLeaderOffsetY(32);
  mToAddressSymbol.setOffsetY(32);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:53,代码来源:GeocodeRouteActivity.java


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