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


Java SpatialReferences.getWebMercator方法代码示例

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


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

示例1: addGraphicsOverlay

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
private void addGraphicsOverlay() {
    // create the polygon
    PolygonBuilder polygonGeometry = new PolygonBuilder(SpatialReferences.getWebMercator());
    polygonGeometry.addPoint(-20e5, 20e5);
    polygonGeometry.addPoint(20e5, 20.e5);
    polygonGeometry.addPoint(20e5, -20e5);
    polygonGeometry.addPoint(-20e5, -20e5);

    // create solid line symbol
    SimpleFillSymbol polygonSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.YELLOW, null);
    // create graphic from polygon geometry and symbol
    Graphic graphic = new Graphic(polygonGeometry.toGeometry(), polygonSymbol);

    // create graphics overlay
    grOverlay = new GraphicsOverlay();
    // create list of graphics
    ListenableList<Graphic> graphics = grOverlay.getGraphics();
    // add graphic to graphics overlay
    graphics.add(graphic);
    // add graphics overlay to the MapView
    mMapView.getGraphicsOverlays().add(grOverlay);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:23,代码来源:MainActivity.java

示例2: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

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

    // set title, size, and add scene to stage
    stage.setTitle("Map Initial Extent Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

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

    // create an initial extent envelope
    Point leftPoint = new Point(-12211308.778729, 4645116.003309, SpatialReferences.getWebMercator());
    Point rightPoint = new Point(-12208257.879667, 4650542.535773, SpatialReferences.getWebMercator());
    Envelope initialExtent = new Envelope(leftPoint, rightPoint);

    // create a viewpoint from envelope
    Viewpoint viewPoint = new Viewpoint(initialExtent);

    // set initial ArcGISMap extent
    map.setInitialViewpoint(viewPoint);

    // create a view and set ArcGISMap to it
    mapView = new MapView();
    mapView.setMap(map);

    // add the map view to stack pane
    stackPane.getChildren().add(mapView);
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:41,代码来源:MapInitialExtentSample.java

示例3: createPolygon

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
/**
 * Creates the polygon.
 */
private void createPolygon() {

  // part one
  PointCollection partSegmentCollectionOne = new PointCollection(SpatialReferences.getWebMercator());
  partSegmentCollectionOne.add(new Point(-13020, 6710130));
  partSegmentCollectionOne.add(new Point(-14160, 6710130));
  partSegmentCollectionOne.add(new Point(-14160, 6709300));
  partSegmentCollectionOne.add(new Point(-13020, 6709300));
  partSegmentCollectionOne.add(new Point(-13020, 6710130));
  Part partOne = new Part(partSegmentCollectionOne);

  // part two
  PointCollection partSegmentCollectionTwo = new PointCollection(SpatialReferences.getWebMercator());
  partSegmentCollectionTwo.add(new Point(-12160, 6710730));
  partSegmentCollectionTwo.add(new Point(-13160, 6710730));
  partSegmentCollectionTwo.add(new Point(-13160, 6709100));
  partSegmentCollectionTwo.add(new Point(-12160, 6709100));
  partSegmentCollectionTwo.add(new Point(-12160, 6710730));
  Part partTwo = new Part(partSegmentCollectionTwo);

  // part three
  PointCollection partSegmentCollectionThree = new PointCollection(SpatialReferences.getWebMercator());
  partSegmentCollectionThree.add(new Point(-12560, 6710030));
  partSegmentCollectionThree.add(new Point(-13520, 6710030));
  partSegmentCollectionThree.add(new Point(-13520, 6709000));
  partSegmentCollectionThree.add(new Point(-12560, 6709000));
  partSegmentCollectionThree.add(new Point(-12560, 6710030));
  Part partThree = new Part(partSegmentCollectionThree);

  PartCollection polygonParts = new PartCollection(partOne);
  polygonParts.add(partTwo);
  polygonParts.add(partThree);

  // transparent (0x00000000) fill
  SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0x00000000, line);
  polygon = new Graphic(new Polygon(polygonParts), fillSymbol);

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

示例4: onCreate

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的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.createImagery());

    // create an initial viewpoint with a point and scale
    Point point = new Point(-226773, 6550477, SpatialReferences.getWebMercator());
    Viewpoint vp = new Viewpoint(point, 7500);

    // set initial map extent
    map.setInitialViewpoint(vp);

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

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

    //[DocRef: Name=Point graphic with symbol, Category=Fundamentals, Topic=Symbols and Renderers]
    //create a simple marker symbol
    SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 12); //size 12, style of circle

    //add a new graphic with a new point geometry
    Point graphicPoint = new Point(-226773, 6550477, SpatialReferences.getWebMercator());
    Graphic graphic = new Graphic(graphicPoint, symbol);
    graphicsOverlay.getGraphics().add(graphic);
    //[DocRef: END]

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

示例5: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene scene = new Scene(stackPane);
    scene.getStylesheets().add(getClass().getResource("/css/style.css").toExternalForm());

    // set title, size, and add scene to stage
    stage.setTitle("Simple Line Symbol Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create a control panel
    VBox vBoxControl = new VBox(6);
    vBoxControl.setMaxSize(180, 200);
    vBoxControl.getStyleClass().add("panel-region");

    createSymbolFuntionality(vBoxControl);

    final ArcGISMap map = new ArcGISMap(Basemap.createImagery());

    // set initial map view point
    Point point = new Point(-226773, 6550477, SpatialReferences.getWebMercator());
    Viewpoint viewpoint = new Viewpoint(point, 7200); // point, scale
    map.setInitialViewpoint(viewpoint);

    // create a view for this ArcGISMap and set ArcGISMap to it
    mapView = new MapView();
    mapView.setMap(map);

    // creates a line from two points
    PointCollection points = new PointCollection(SpatialReferences.getWebMercator());
    points.add(-226913, 6550477);
    points.add(-226643, 6550477);
    Polyline line = new Polyline(points);

    // creates a solid red (0xFFFF0000) simple line symbol
    lineSymbol = new SimpleLineSymbol(Style.SOLID, 0xFFFF0000, 3);

    // add line with symbol to graphics overlay and add overlay to map view
    GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
    mapView.getGraphicsOverlays().add(graphicsOverlay);
    graphicsOverlay.getGraphics().add(new Graphic(line, lineSymbol));

    // add the map view and control panel to stack pane
    stackPane.getChildren().addAll(mapView, vBoxControl);
    StackPane.setAlignment(vBoxControl, Pos.TOP_LEFT);
    StackPane.setMargin(vBoxControl, new Insets(10, 0, 0, 10));
  } catch (Exception e) {
    // on any error, display the stack trace
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:58,代码来源:SimpleLineSymbolSample.java

示例6: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

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

    // size the stage, add a title, and set scene to stage
    stage.setTitle("Simple Marker Symbol Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create ArcGISMap with imagery basemap
    final ArcGISMap map = new ArcGISMap(Basemap.createImagery());

    // create spatial reference for WGS 1948
    final SpatialReference webMercator = SpatialReferences.getWebMercator();

    // create a initial viewpoint with a center point and scale
    Point point = new Point(-226773, 6550477, webMercator);
    Viewpoint viewpoint = new Viewpoint(point, 7500);

    // set initial view point to the ArcGISMap
    map.setInitialViewpoint(viewpoint);

    // create a view and set ArcGISMap to it
    mapView = new MapView();
    mapView.setMap(map);

    // create new graphics overlay and add it to the mapview
    GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
    mapView.getGraphicsOverlays().add(graphicsOverlay);

    // create a red (0xFFFF0000) simple marker symbol
    SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFFFF0000, 12);

    // create a new graphic with a our point and symbol
    Graphic graphic = new Graphic(point, symbol);
    graphicsOverlay.getGraphics().add(graphic);

    // add the map view and control box to stack pane
    stackPane.getChildren().add(mapView);
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:51,代码来源:SimpleMarkerSymbolSample.java

示例7: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene scene = new Scene(stackPane);
    scene.getStylesheets().add(getClass().getResource("/css/style.css").toExternalForm());

    // set title, size, and add scene to stage
    stage.setTitle("Simple Fill Symbol Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create a control panel
    vBoxControl = new VBox(6);
    vBoxControl.setMaxSize(180, 200);
    vBoxControl.getStyleClass().add("panel-region");

    createSymbolFuntionality();

    final ArcGISMap map = new ArcGISMap(Basemap.createTopographic());

    // set initial map view point
    Point initialPoint = new Point(-12000000, 5400000, SpatialReferences.getWebMercator());
    Viewpoint viewpoint = new Viewpoint(initialPoint, 10000000); // point, scale
    map.setInitialViewpoint(viewpoint);

    // create a view for this ArcGISMap and set ArcGISMap to it
    mapView = new MapView();
    mapView.setMap(map);

    // creates a square from four points
    PointCollection points = new PointCollection(SpatialReferences.getWebMercator());
    points.add(-1.1579397849033352E7, 5618494.623878779);
    points.add(-1.158486021463032E7, 5020365.591010623);
    points.add(-1.236324731219847E7, 5009440.859816683);
    points.add(-1.2360516129399985E7, 5621225.806677263);
    Polygon square = new Polygon(points);

    // transparent red (0x88FF0000) color symbol
    fillSymbol = new SimpleFillSymbol(Style.SOLID, 0x88FF0000, null);

    // renders graphics to the GeoView
    GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
    mapView.getGraphicsOverlays().add(graphicsOverlay);
    graphicsOverlay.getGraphics().add(new Graphic(square, fillSymbol));

    createLineSymbols();

    // add the map view and control panel to stack pane
    stackPane.getChildren().addAll(mapView, vBoxControl);
    StackPane.setAlignment(vBoxControl, Pos.TOP_LEFT);
    StackPane.setMargin(vBoxControl, new Insets(10, 0, 0, 10));

  } catch (Exception e) {
    // on any error, display the stack trace
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:63,代码来源:SimpleFillSymbolSample.java

示例8: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

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

    // set title, size, and add scene to stage
    stage.setTitle("Picture Marker Symbol Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

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

    // create view for this map
    mapView = new MapView();

    // create graphics overlay and add it to the mapview
    graphicsOverlay = new GraphicsOverlay();

    mapView.getGraphicsOverlays().add(graphicsOverlay);

    // create points for displaying graphics
    Point leftPoint = new Point(-228835, 6550763, SpatialReferences.getWebMercator()); // Disk
    Point rightPoint = new Point(-223560, 6552021, SpatialReferences.getWebMercator()); // URL
    Point middlePoint = new Point(-226773, 6550477, SpatialReferences.getWebMercator());

    // create orange picture marker symbol from disk
    if (saveResourceToExternalStorage()) {
      // create orange picture marker symbol
      PictureMarkerSymbol orangeSymbol = new PictureMarkerSymbol(orangeSymbolPath.getAbsolutePath());
      // place orange picture marker symbol on ArcGISMap
      placePictureMarkerSymbol(orangeSymbol, leftPoint);
    }

    // create blue picture marker symbol from local
    Image newImage = new Image("/symbols/blue_symbol.png");
    PictureMarkerSymbol blueSymbol = new PictureMarkerSymbol(newImage);
    // place blue picture marker symbol on ArcGISMap
    placePictureMarkerSymbol(blueSymbol, middlePoint);

    // create campsite picture marker symbol from URL
    PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(CAMPSITE_SYMBOL);

    // place campsite picture marker symbol on ArcGISMap
    map.addDoneLoadingListener(() -> {
      if (map.getLoadStatus() == LoadStatus.LOADED) {
        Platform.runLater(() -> placePictureMarkerSymbol(campsiteSymbol, rightPoint));
      } else {
        Alert alert = new Alert(Alert.AlertType.ERROR, "Map Failed to Load!");
        alert.show();
      }
    });

    // set ArcGISMap to be displayed in mapview
    mapView.setMap(map);

    // set viewpoint on mapview with padding
    Envelope envelope = new Envelope(leftPoint, rightPoint);
    mapView.setViewpointGeometryAsync(envelope, 100.0);

    // add the map view and control panel to stack pane
    stackPane.getChildren().add(mapView);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:72,代码来源:PictureMarkerSymbolSample.java

示例9: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

  StackPane stackPane = new StackPane();
  Scene fxScene = new Scene(stackPane);
  // for adding styling to any controls that are added 
  fxScene.getStylesheets().add(getClass().getResource("/css/style.css").toExternalForm());

  // set title, size, and add scene to stage
  stage.setTitle("Feature Layer Extrusion Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(fxScene);
  stage.show();

  // so scene can be visible within application
  ArcGISScene scene = new ArcGISScene(Basemap.createTopographic());
  sceneView = new SceneView();
  sceneView.setArcGISScene(scene);
  stackPane.getChildren().add(sceneView);

  // get us census data as a service feature table
  ServiceFeatureTable statesServiceFeatureTable = new ServiceFeatureTable("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3");

  // creates feature layer from table and add to scene
  final FeatureLayer statesFeatureLayer = new FeatureLayer(statesServiceFeatureTable);
  // feature layer must be rendered dynamically for extrusion to work
  statesFeatureLayer.setRenderingMode(FeatureLayer.RenderingMode.DYNAMIC);
  scene.getOperationalLayers().add(statesFeatureLayer);

  // symbols are used to display features (US states) from table
  SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF000000, 1.0f);
  SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFF0000FF, lineSymbol);
  final SimpleRenderer renderer = new SimpleRenderer(fillSymbol);
  //  need to set an extrusion type, BASE HEIGHT extrudes each point from feature individually
  renderer.getSceneProperties().setExtrusionMode(Renderer.SceneProperties.ExtrusionMode.BASE_HEIGHT);
  statesFeatureLayer.setRenderer(renderer);

  // set camera to focus on state features
  Point lookAtPoint = new Point(-10974490, 4814376, 0, SpatialReferences.getWebMercator());
  OrbitLocationCameraController orbitCamera = new OrbitLocationCameraController(lookAtPoint, 10000000);
  sceneView.setCameraController(orbitCamera);

  // create a control panel
  VBox vBoxControl = new VBox();
  vBoxControl.setMaxSize(200, 40);
  vBoxControl.getStyleClass().add("panel-region");
  stackPane.getChildren().add(vBoxControl);
  StackPane.setAlignment(vBoxControl, Pos.TOP_LEFT);
  StackPane.setMargin(vBoxControl, new Insets(10, 0, 0, 10));

  // controls for extruding by total population or by population density
  Button extrusionButton = new Button("Population Density");
  extrusionButton.setOnAction(v -> {
    if (showTotalPopulation) {
      // some feature's population is really big of need to sink it down
      renderer.getSceneProperties().setExtrusionExpression("[POP2007]/ 10");
      extrusionButton.setText("Population Density");
      showTotalPopulation = false;
    } else {
      // density of population is a small value to need to increase it
      renderer.getSceneProperties().setExtrusionExpression("[POP07_SQMI] * 5000");
      extrusionButton.setText("Total Population");
      showTotalPopulation = true;
    }
  });
  extrusionButton.setMaxWidth(Double.MAX_VALUE);
  extrusionButton.fire();
  vBoxControl.getChildren().add(extrusionButton);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:71,代码来源:FeatureLayerExtrusionSample.java

示例10: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

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

    // set title, size, and add scene to stage
    stage.setTitle("Service Feature Table No Cache Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    ArcGISMap map = new ArcGISMap(Basemap.createTopographic());

    // create starting viewpoint for ArcGISMap
    SpatialReference spatialReference = SpatialReferences.getWebMercator();
    Point leftPoint = new Point(-1.30758164047166E7, 4014771.46954516, spatialReference);
    Point rightPoint = new Point(-1.30730056797177E7, 4016869.78617381, spatialReference);
    Envelope envelope = new Envelope(leftPoint, rightPoint);
    Viewpoint viewpoint = new Viewpoint(envelope);

    // set starting viewpoint for ArcGISMap
    map.setInitialViewpoint(viewpoint);

    // create service feature table from URL
    featureTable = new ServiceFeatureTable(SERVICE_FEATURE_URL);

    // set cache mode for table to no caching
    featureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE);
    FeatureLayer featureLayer = new FeatureLayer(featureTable);

    // add feature layer to ArcGISMap
    map.getOperationalLayers().add(featureLayer);

    // create a view for this ArcGISMap and set ArcGISMap to it
    mapView = new MapView();
    mapView.setMap(map);

    // add the map view to stack pane
    stackPane.getChildren().addAll(mapView);

  } catch (Exception e) {
    // on any error, display the stack trace
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:50,代码来源:ServiceFeatureTableNoCacheSample.java

示例11: start

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {

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

    // set title, size, and add scene to stage
    stage.setTitle("Add Graphics with Renderer Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create a map with topographic basemap
    ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 15.169193, 16.333479, 2);

    // set the map to the view
    mapView = new MapView();
    mapView.setMap(map);

    // create a graphics overlay for displaying point graphic
    GraphicsOverlay pointGraphicOverlay = new GraphicsOverlay();
    // create point geometry
    Point point = new Point(40e5, 40e5, SpatialReferences.getWebMercator());
    // create graphic for point
    Graphic pointGraphic = new Graphic(point);
    // red (0xFFFF0000) diamond point symbol
    SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.DIAMOND, 0xFFFF0000, 10);
    // create simple renderer
    SimpleRenderer pointRenderer = new SimpleRenderer(pointSymbol);
    // set renderer on graphics overlay
    pointGraphicOverlay.setRenderer(pointRenderer);
    // add graphic to overlay
    pointGraphicOverlay.getGraphics().add(pointGraphic);
    // add graphics overlay to the MapView
    mapView.getGraphicsOverlays().add(pointGraphicOverlay);

    // solid blue (0xFF0000FF) line graphic
    GraphicsOverlay lineGraphicOverlay = new GraphicsOverlay();
    PolylineBuilder lineGeometry = new PolylineBuilder(SpatialReferences.getWebMercator());
    lineGeometry.addPoint(-10e5, 40e5);
    lineGeometry.addPoint(20e5, 50e5);
    Graphic lineGraphic = new Graphic(lineGeometry.toGeometry());
    lineGraphicOverlay.getGraphics().add(lineGraphic);
    SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF0000FF, 5);
    SimpleRenderer lineRenderer = new SimpleRenderer(lineSymbol);
    lineGraphicOverlay.setRenderer(lineRenderer);
    mapView.getGraphicsOverlays().add(lineGraphicOverlay);

    // solid yellow (0xFFFFFF00) polygon graphic
    GraphicsOverlay polygonGraphicOverlay = new GraphicsOverlay();
    PolygonBuilder polygonGeometry = new PolygonBuilder(SpatialReferences.getWebMercator());
    polygonGeometry.addPoint(-20e5, 20e5);
    polygonGeometry.addPoint(20e5, 20e5);
    polygonGeometry.addPoint(20e5, -20e5);
    polygonGeometry.addPoint(-20e5, -20e5);
    Graphic polygonGraphic = new Graphic(polygonGeometry.toGeometry());
    polygonGraphicOverlay.getGraphics().add(polygonGraphic);
    SimpleFillSymbol polygonSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFFFFFF00, null);
    SimpleRenderer polygonRenderer = new SimpleRenderer(polygonSymbol);
    polygonGraphicOverlay.setRenderer(polygonRenderer);
    mapView.getGraphicsOverlays().add(polygonGraphicOverlay);

    // add the map view to stack pane
    stackPane.getChildren().add(mapView);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:72,代码来源:AddGraphicsWithRendererSample.java

示例12: onCreate

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

  // set flag for showing total population or population density
  showTotalPopulation = true;

  // inflate population type toggle button
  final Button togglePopButton = findViewById(R.id.toggle_button);

  // get us census data as a service feature table
  ServiceFeatureTable statesServiceFeatureTable = new ServiceFeatureTable(
      getResources().getString(R.string.us_census_feature_service));

  // add the service feature table to a feature layer
  final FeatureLayer statesFeatureLayer = new FeatureLayer(statesServiceFeatureTable);
  // set the feature layer to render dynamically to allow extrusion
  statesFeatureLayer.setRenderingMode(FeatureLayer.RenderingMode.DYNAMIC);

  // create a scene and add it to the scene view
  ArcGISScene scene = new ArcGISScene(Basemap.createImagery());
  SceneView sceneView = findViewById(R.id.sceneView);
  sceneView.setScene(scene);

  // add the feature layer to the scene
  scene.getOperationalLayers().add(statesFeatureLayer);

  // define line and fill symbols for a simple renderer
  SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLACK, 1.0f);
  SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.BLUE, lineSymbol);
  final SimpleRenderer renderer = new SimpleRenderer(fillSymbol);
  // set renderer extrusion mode to base height, which includes base height of each vertex in calculating z values
  renderer.getSceneProperties().setExtrusionMode(Renderer.SceneProperties.ExtrusionMode.BASE_HEIGHT);
  // set the simple renderer to the feature layer
  statesFeatureLayer.setRenderer(renderer);

  // define a look at point for the camera at geographical center of the continental US
  Point lookAtPoint = new Point(-10974490, 4814376, 0, SpatialReferences.getWebMercator());
  // add a camera and set it to orbit the look at point
  Camera camera = new Camera(lookAtPoint, 20000000, 0, 55, 0);
  OrbitLocationCameraController orbitCamera = new OrbitLocationCameraController(lookAtPoint, 20000000);
  sceneView.setCameraController(orbitCamera);
  sceneView.setViewpointCamera(camera);

  // set button listener
  togglePopButton.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View v) {
      // set extrusion properties to either show total population or population density based on flag
      if (showTotalPopulation) {
        // divide total population by 10 to make data legible
        renderer.getSceneProperties().setExtrusionExpression("[POP2007] / 10");
        // change text of button to total pop
        togglePopButton.setText(R.string.total_pop);
        showTotalPopulation = false;
      } else {
        // multiple population density by 5000 to make data legible
        renderer.getSceneProperties().setExtrusionExpression("[POP07_SQMI] * 5000");
        // change text of button to pop density
        togglePopButton.setText(R.string.density_pop);
        showTotalPopulation = true;
      }
    }
  });
  // click to set initial state
  togglePopButton.performClick();
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:68,代码来源:MainActivity.java

示例13: onCreate

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的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

示例14: addGraphicsOverlay

import com.esri.arcgisruntime.geometry.SpatialReferences; //导入方法依赖的package包/类
private void addGraphicsOverlay(){
    // point graphic
    Point pointGeometry = new Point(40e5, 40e5, SpatialReferences.getWebMercator());
    // red diamond point symbol
    SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.DIAMOND, Color.RED, 10);
    // create graphic for point
    Graphic pointGraphic = new Graphic(pointGeometry);
    // create a graphic overlay for the point
    GraphicsOverlay pointGraphicOverlay = new GraphicsOverlay();
    // create simple renderer
    SimpleRenderer pointRenderer = new SimpleRenderer(pointSymbol);
    pointGraphicOverlay.setRenderer(pointRenderer);
    // add graphic to overlay
    pointGraphicOverlay.getGraphics().add(pointGraphic);
    // add graphics overlay to the MapView
    mMapView.getGraphicsOverlays().add(pointGraphicOverlay);

    // line graphic
    PolylineBuilder lineGeometry = new PolylineBuilder(SpatialReferences.getWebMercator());
    lineGeometry.addPoint(-10e5, 40e5);
    lineGeometry.addPoint(20e5, 50e5);
    // solid blue line symbol
    SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLUE, 5);
    // create graphic for polyline
    Graphic lineGraphic = new Graphic(lineGeometry.toGeometry());
    // create graphic overlay for polyline
    GraphicsOverlay lineGraphicOverlay = new GraphicsOverlay();
    // create simple renderer
    SimpleRenderer lineRenderer = new SimpleRenderer(lineSymbol);
    // add graphic to overlay
    lineGraphicOverlay.setRenderer(lineRenderer);
    // add graphic to overlay
    lineGraphicOverlay.getGraphics().add(lineGraphic);
    // add graphics overlay to the MapView
    mMapView.getGraphicsOverlays().add(lineGraphicOverlay);

    //polygon graphic
    PolygonBuilder polygonGeometry = new PolygonBuilder(SpatialReferences.getWebMercator());
    polygonGeometry.addPoint(-20e5, 20e5);
    polygonGeometry.addPoint(20e5, 20e5);
    polygonGeometry.addPoint(20e5, -20e5);
    polygonGeometry.addPoint(-20e5, -20e5);
    // solid yellow polygon symbol
    SimpleFillSymbol polygonSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.YELLOW, null);
    // create graphic for polygon
    Graphic polygonGraphic = new Graphic(polygonGeometry.toGeometry());
    // create graphic overlay for polygon
    GraphicsOverlay polygonGraphicOverlay = new GraphicsOverlay();
    // create simple renderer
    SimpleRenderer polygonRenderer = new SimpleRenderer(polygonSymbol);
    // add graphic to overlay
    polygonGraphicOverlay.setRenderer(polygonRenderer);
    // add graphic to overlay
    polygonGraphicOverlay.getGraphics().add(polygonGraphic);
    // add graphics overlay to MapView
    mMapView.getGraphicsOverlays().add(polygonGraphicOverlay);

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

示例15: onCreate

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

    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);

    // inflate MapView from layout
    mMapView = (MapView) findViewById(R.id.mapView);
    // create a map with the Basemap Type topographic
    ArcGISMap map = new ArcGISMap(Basemap.createTopographic());
    // create an envelope
    Envelope targetExtent = new Envelope(-13639984.0, 4537387.0, -13606734.0, 4558866.0, SpatialReferences.getWebMercator());
    // use envelope to set initial viewpoint
    Viewpoint initViewpoint = new Viewpoint(targetExtent);
    // set the initial viewpoint in the map
    map.setInitialViewpoint(initViewpoint);

    // create a feature table from a service url
    ServiceFeatureTable svcFeaturetable = new ServiceFeatureTable(getResources().getString(R.string.service_feature_table_url));
    // create a feature layer
    FeatureLayer featureLayer = new FeatureLayer(svcFeaturetable);
    // add feature layer to map
    map.getOperationalLayers().add(featureLayer);

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

    //[DocRef: Name=Monitor map drawing, Category=Work with maps, Topic=Display a map]
    mMapView.addDrawStatusChangedListener(new DrawStatusChangedListener() {
        @Override
        public void drawStatusChanged(DrawStatusChangedEvent drawStatusChangedEvent) {
            if(drawStatusChangedEvent.getDrawStatus() == DrawStatus.IN_PROGRESS){
                progressBar.setVisibility(View.VISIBLE);
                Log.d("drawStatusChanged", "spinner visible");
            }else if (drawStatusChangedEvent.getDrawStatus() == DrawStatus.COMPLETED){
                progressBar.setVisibility(View.INVISIBLE);
            }
        }
    });
    //[DocRef: END]
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:43,代码来源:MainActivity.java


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