本文整理汇总了Java中com.esri.arcgisruntime.mapping.view.GraphicsOverlay类的典型用法代码示例。如果您正苦于以下问题:Java GraphicsOverlay类的具体用法?Java GraphicsOverlay怎么用?Java GraphicsOverlay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsOverlay类属于com.esri.arcgisruntime.mapping.view包,在下文中一共展示了GraphicsOverlay类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGraphics
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
/**
* Create red and green triangle graphics and displays them to the view.
*/
private void createGraphics() {
// applies graphics to the view who's altitude is increased by surface's elevation
GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
graphicsOverlay.getSceneProperties().setSurfacePlacement(SurfacePlacement.ABSOLUTE);
sceneView.getGraphicsOverlays().add(graphicsOverlay);
// creating graphics for view
redPoint = new Point(-77.69531409620706, 40.25390707699415, 900, sr);
redSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.TRIANGLE, 0xFFFF0000, 20);
redGraphic = new Graphic(redPoint, redSymbol);
graphicsOverlay.getGraphics().add(redGraphic);
greenPoint = new Point(-120.05859621653715, 38.847657048103514, 1000, sr);
greenSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.TRIANGLE, 0xFF00FF00, 20);
greenSymbol.setAngle(30);
greenGraphic = new Graphic(greenPoint, greenSymbol);
graphicsOverlay.getGraphics().add(greenGraphic);
}
示例2: onCreate
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的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 BasemapType topographic
ArcGISMap map = new ArcGISMap(Basemap.Type.OCEANS, 56.075844, -2.681572, 11);
// set the map to be displayed in this view
mMapView.setMap(map);
// add graphics overlay to MapView.
GraphicsOverlay graphicsOverlay = addGraphicsOverlay(mMapView);
//add some buoy positions to the graphics overlay
addBuoyPoints(graphicsOverlay);
//add boat trip polyline to graphics overlay
addBoatTrip(graphicsOverlay);
//add nesting ground polygon to graphics overlay
addNestingGround(graphicsOverlay);
//add text symbols and points to graphics overlay
addText(graphicsOverlay);
}
示例3: addBuoyPoints
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
private void addBuoyPoints(GraphicsOverlay graphicOverlay) {
//define the buoy locations
Point buoy1Loc = new Point(-2.712642647560347, 56.062812566811544, wgs84);
Point buoy2Loc = new Point(-2.6908416959572303, 56.06444173689877, wgs84);
Point buoy3Loc = new Point(-2.6697273884990937, 56.064250073402874, wgs84);
Point buoy4Loc = new Point(-2.6395150461199726, 56.06127916736989, wgs84);
//create a marker symbol
SimpleMarkerSymbol buoyMarker = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10);
//create graphics
Graphic buoyGraphic1 = new Graphic(buoy1Loc, buoyMarker);
Graphic buoyGraphic2 = new Graphic(buoy2Loc, buoyMarker);
Graphic buoyGraphic3 = new Graphic(buoy3Loc, buoyMarker);
Graphic buoyGraphic4 = new Graphic(buoy4Loc, buoyMarker);
//add the graphics to the graphics overlay
graphicOverlay.getGraphics().add(buoyGraphic1);
graphicOverlay.getGraphics().add(buoyGraphic2);
graphicOverlay.getGraphics().add(buoyGraphic3);
graphicOverlay.getGraphics().add(buoyGraphic4);
}
示例4: addText
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
private void addText(GraphicsOverlay graphicOverlay) {
//create a point geometry
Point bassLocation = new Point(-2.640631, 56.078083,wgs84);
Point craigleithLocation = new Point (-2.720324, 56.073569,wgs84);
//create text symbols
TextSymbol bassRockSymbol =
new TextSymbol(10, "Bass Rock", Color.rgb(0, 0, 230),
TextSymbol.HorizontalAlignment.LEFT, TextSymbol.VerticalAlignment.BOTTOM);
TextSymbol craigleithSymbol = new TextSymbol(10, "Craigleith", Color.rgb(0, 0, 230),
TextSymbol.HorizontalAlignment.RIGHT, TextSymbol.VerticalAlignment.TOP);
//define a graphic from the geometry and symbol
Graphic bassRockGraphic = new Graphic(bassLocation, bassRockSymbol);
Graphic craigleithGraphic = new Graphic(craigleithLocation, craigleithSymbol);
//add the text to the graphics overlay
graphicOverlay.getGraphics().add(bassRockGraphic);
graphicOverlay.getGraphics().add(craigleithGraphic);
}
示例5: addGraphicsOverlay
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的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);
}
示例6: addLayer
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
/**
* Add an operational layer to the map
* @param layer - A Layer to add
*/
@Override public void addLayer(final Layer layer) {
// Create and add layers that need to be visible in the map
mGraphicOverlay = new GraphicsOverlay();
mMapView.getGraphicsOverlays().add(mGraphicOverlay);
mMap.getOperationalLayers().add(layer);
}
示例7: initialize
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
public void initialize() {
// create a scene and add a basemap to it
ArcGISScene scene = new ArcGISScene();
scene.setBasemap(Basemap.createImagery());
// add the SceneView to the stack pane
sceneView.setArcGISScene(scene);
// add a camera and initial camera position
Point point = new Point(83.9, 28.4, 1000, SpatialReferences.getWgs84());
Camera camera = new Camera(point, 1000, 0, 50, 0);
sceneView.setViewpointCamera(camera);
// create a graphics overlay
GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
graphicsOverlay.getSceneProperties().setSurfacePlacement(LayerSceneProperties.SurfacePlacement.RELATIVE);
sceneView.getGraphicsOverlays().add(graphicsOverlay);
// add renderer using rotation expressions
SimpleRenderer renderer = new SimpleRenderer();
renderer.getSceneProperties().setHeadingExpression("[HEADING]");
renderer.getSceneProperties().setPitchExpression("[PITCH]");
graphicsOverlay.setRenderer(renderer);
// create a red (0xFFFF0000) cone graphic
SimpleMarkerSceneSymbol coneSymbol = SimpleMarkerSceneSymbol.createCone(0xFFFF0000, 100, 100);
coneSymbol.setPitch(-90); // correct symbol's default pitch
Graphic cone = new Graphic(new Point(83.9, 28.41, 200, SpatialReferences.getWgs84()), coneSymbol);
graphicsOverlay.getGraphics().add(cone);
// bind attribute values to sliders
headingSlider.valueProperty().addListener(o -> cone.getAttributes().put("HEADING", headingSlider.getValue()));
pitchSlider.valueProperty().addListener(o -> cone.getAttributes().put("PITCH", pitchSlider.getValue()));
}
示例8: addGraphicsOverlay
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
private GraphicsOverlay addGraphicsOverlay(MapView mapView) {
//create the graphics overlay
GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
//add the overlay to the map view
mapView.getGraphicsOverlays().add(graphicsOverlay);
return graphicsOverlay;
}
示例9: addNestingGround
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
private void addNestingGround(GraphicsOverlay graphicOverlay) {
//define the polygon for the nesting ground
Polygon nestingGround = getNestingGroundGeometry();
//define the fill symbol and outline
SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH, Color.rgb(0, 0, 128), 1);
SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.DIAGONAL_CROSS, Color.rgb(0, 80, 0), outlineSymbol);
//define graphic
Graphic nestingGraphic = new Graphic(nestingGround,fillSymbol);
//add to graphics overlay
graphicOverlay.getGraphics().add(nestingGraphic);
}
示例10: onCreate
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//initialize reverse geocode params
mReverseGeocodeParameters = new ReverseGeocodeParameters();
mReverseGeocodeParameters.setMaxResults(1);
mReverseGeocodeParameters.getResultAttributeNames().add("*");
//retrieve the MapView from layout
mMapView = (MapView) findViewById(R.id.mapView);
//add route and marker overlays to map view
mMarkerGraphicsOverlay = new GraphicsOverlay();
mRouteGraphicsOverlay = new GraphicsOverlay();
mMapView.getGraphicsOverlays().add(mRouteGraphicsOverlay);
mMapView.getGraphicsOverlays().add(mMarkerGraphicsOverlay);
// build the file path to access the mobile map package
String filePathMMPk = buildMMPkPath();
// add the map from the mobile map package to the MapView
loadMobileMapPackage(filePathMMPk);
mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) {
@Override
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
Log.d(TAG, "onSingleTapConfirmed: " + motionEvent.toString());
// get the point that was clicked and convert it to a point in map coordinates
android.graphics.Point screenPoint = new android.graphics.Point(
Math.round(motionEvent.getX()),
Math.round(motionEvent.getY()));
// create a map point from screen point
Point mapPoint = mMapView.screenToLocation(screenPoint);
geoView(screenPoint, mapPoint);
return true;
}
});
}
示例11: onCreate
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的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]
}
示例12: onCreate
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get MapView from layout
MapView mMapView = (MapView) findViewById(R.id.mapView);
// create a map with the BasemapType topographic
final ArcGISMap mMap = new ArcGISMap(Basemap.createTopographic());
// set the map to be displayed in this view
mMapView.setMap(mMap);
// create color and symbols for drawing graphics
SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.TRIANGLE, Color.BLUE, 14);
SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.CROSS, Color.BLUE, null);
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLUE, 3);
// add a graphic of point, multipoint, polyline and polygon.
GraphicsOverlay overlay = new GraphicsOverlay();
mMapView.getGraphicsOverlays().add(overlay);
overlay.getGraphics().add(new Graphic(createPolygon(), fillSymbol));
overlay.getGraphics().add(new Graphic(createPolyline(), lineSymbol));
overlay.getGraphics().add(new Graphic(createMultipoint(), markerSymbol));
overlay.getGraphics().add(new Graphic(createPoint(), markerSymbol));
// use the envelope to set the map viewpoint
mMapView.setViewpointGeometryAsync(createEnvelope(), getResources().getDimension(R.dimen.viewpoint_padding));
}
示例13: addGraphic
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
/**
* Add a new Graphic to a GraphicsOverlay in the MapView contained in the layout. Creates and adds a
* new GraphicsOverlay to the MapView's collection, if required.
*
* @param graphicGeometry a Point to be used as the Geometry of the new Graphic
* @param color integer representing the color of the new Symbol
* @return the Graphic which was added to an overlay
*/
private Graphic addGraphic(Point graphicGeometry, int color, SimpleMarkerSymbol.Style style) {
if (mMapView.getGraphicsOverlays().size() < 1) {
mMapView.getGraphicsOverlays().add(new GraphicsOverlay());
}
SimpleMarkerSymbol sym = new SimpleMarkerSymbol(style, color, 15.0f);
Graphic g = new Graphic(graphicGeometry, sym);
mMapView.getGraphicsOverlays().get(0).getGraphics().add(g);
return g;
}
示例14: onCreate
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// define symbols
mPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.SQUARE, 0xFFFF0000, 20);
mLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFFFF8800, 4);
mFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.CROSS, 0x40FFA9A9, mLineSymbol);
// inflate map view from layout
mMapView = findViewById(R.id.mapView);
// create a map with the Basemap Type topographic
ArcGISMap map = new ArcGISMap(Basemap.Type.LIGHT_GRAY_CANVAS, 34.056295, -117.195800, 16);
// set the map to be displayed in this view
mMapView.setMap(map);
mGraphicsOverlay = new GraphicsOverlay();
mMapView.getGraphicsOverlays().add(mGraphicsOverlay);
// create a new sketch editor and add it to the map view
mSketchEditor = new SketchEditor();
mMapView.setSketchEditor(mSketchEditor);
// get buttons from layouts
mPointButton = findViewById(R.id.pointButton);
mMultiPointButton = findViewById(R.id.pointsButton);
mPolylineButton = findViewById(R.id.polylineButton);
mPolygonButton = findViewById(R.id.polygonButton);
mFreehandLineButton = findViewById(R.id.freehandLineButton);
mFreehandPolygonButton = findViewById(R.id.freehandPolygonButton);
// add click listeners
mPointButton.setOnClickListener(view -> createModePoint());
mMultiPointButton.setOnClickListener(view -> createModeMultipoint());
mPolylineButton.setOnClickListener(view -> createModePolyline());
mPolygonButton.setOnClickListener(view -> createModePolygon());
mFreehandLineButton.setOnClickListener(view -> createModeFreehandLine());
mFreehandPolygonButton.setOnClickListener(view -> createModeFreehandPolygon());
}
示例15: onCreate
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mInputGraphicsOverlay = new GraphicsOverlay();
mResultGraphicsOverlay = new GraphicsOverlay();
// inflate MapView from layout
mMapView = (MapView) findViewById(R.id.mapView);
// create a map with the BasemapType topographic
ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 45.3790902612337, 6.84905317262762, 12);
// set the map to be displayed in this view
mMapView.setMap(map);
// renderer for graphics overlays
SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10);
SimpleRenderer renderer = new SimpleRenderer(pointSymbol);
mInputGraphicsOverlay.setRenderer(renderer);
int fillColor = Color.argb(120, 226, 119, 40);
FillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, fillColor, null);
mResultGraphicsOverlay.setRenderer(new SimpleRenderer(fillSymbol));
// add graphics overlays to the map view
mMapView.getGraphicsOverlays().add(mResultGraphicsOverlay);
mMapView.getGraphicsOverlays().add(mInputGraphicsOverlay);
mGeoprocessingTask = new GeoprocessingTask(getString(R.string.viewshed_service));
mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(getApplicationContext(), mMapView) {
@Override public boolean onSingleTapConfirmed(MotionEvent e) {
android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY()));
Point mapPoint = mMapView.screenToLocation(screenPoint);
addGraphicForPoint(mapPoint);
calculateViewshedAt(mapPoint);
return super.onSingleTapConfirmed(e);
}
});
}