@Override public void onMouseClicked(MouseEvent e) { Point pt = map.toMapPoint(e.getX(), e.getY()); Geometry buffer = GeometryEngine.buffer( pt, map.getSpatialReference(), 200000, map.getSpatialReference().getUnit()); Graphic g = new Graphic(buffer, bufferSymbol); graphicsLayer.addGraphic(g); }
public OverlayApp() { window = new JFrame(); window.setSize(800, 600); window.setLocationRelativeTo(null); // center on screen window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout(0, 0)); // dispose map just before application window is closed. window.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { super.windowClosing(windowEvent); map.dispose(); } }); // map options allow for a common base map to be chosen MapOptions mapOptions = new MapOptions(MapType.TOPO, 37.77279077295881, -96.44323104731787, 4); // create a map using the map options map = new JMap(mapOptions); window.getContentPane().add(map); // The code below shows how to add a tiled layer if you don't use MapOptions // ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer( // "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); // map.getLayers().add(tiledLayer); featureLayer = new ArcGISFeatureLayer( "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"); map.getLayers().add(featureLayer); graphicsLayer = new GraphicsLayer(); map.getLayers().add(graphicsLayer); map.addMapOverlay(mapOverlay); }