Java源码示例:com.esri.arcgisruntime.UnitSystem

示例1
@Override
public void start(Stage stage) {

  // create stack pane and application scene
  StackPane stackPane = new StackPane();
  Scene scene = new Scene(stackPane);

  // set title, size and scene to stage
  stage.setTitle("Scale Bar Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();

  // create a map view
  mapView = new MapView();
  ArcGISMap map = new ArcGISMap(Basemap.Type.IMAGERY, 64.1405, -16.2426, 16);
  mapView.setMap(map);

  // create a scale bar for the map view
  Scalebar scaleBar = new Scalebar(mapView);

  // specify skin style for the scale bar
  scaleBar.setSkinStyle(Scalebar.SkinStyle.GRADUATED_LINE);

  // set the unit system (default is METRIC)
  scaleBar.setUnitSystem(UnitSystem.IMPERIAL);

  // to enhance visibility of the scale bar, by making background transparent
  Color transparentWhite = new Color(1, 1, 1, 0.7);
  scaleBar.setBackground(new Background(new BackgroundFill(transparentWhite, new CornerRadii(5), Insets.EMPTY)));

  // add the map view and scale bar to stack pane
  stackPane.getChildren().addAll(mapView, scaleBar);

  // set position of scale bar
  StackPane.setAlignment(scaleBar, Pos.BOTTOM_CENTER);
  // give padding to scale bar
  StackPane.setMargin(scaleBar, new Insets(0, 0, 50, 0));
}