POST
|
Hi, I think you can get it to work by doing some manual modification of the SceneBuilder library files. If you go to the SceneBuilder library location (e.g. AppData\Roaming\Scene Builder\Library) and add or modify filter.txt to contain the following com.esri.arcgisruntime.internal.mapping.view.AttributionControl
com.esri.arcgisruntime.mapping.view.Callout
com.esri.arcgisruntime.internal.mapping.view.CalloutDefaultView and then start SceneBuilder you will hopefully see MapView and SceneView as custom controls. Colin
... View more
06-02-2021
06:28 AM
|
1
|
3
|
2606
|
POST
|
You can use the following constructor on Graphic to directly create a graphic from lat/lon values and once it is added to a graphics overlay it should display correctly in the overlay's coordinate system. /**
* Creates a new graphic with a point defined in the WGS 84 SpatialReference.
*
* @param latitude the latitude
* @param longitude the longitude
* @since 100.0.0
*/
public Graphic(double latitude, double longitude) To reproject the point directly I think you need something like Point point = (Point) GeometryEngine.project(new Point(x, y, SpatialReferences.WGS84), SpatialReference.create(102739)); so that the original project of the point is also defined as well as the target projection.
... View more
11-05-2019
01:16 AM
|
0
|
1
|
1574
|
POST
|
It looks like currently the scalebar doesn't support being used from in FXML. Since the source code for the scalebar is available I think if you modify the scalebar constructor to have a named argument public Scalebar(@NamedArg("mapView") MapView mapView) then you should be able to do something like the following in FXML <MapView fx:id="mMapView" prefHeight="400" prefWidth="400"/>
<Scalebar fx:id="mScalebar" mapView="$mMapView"/> and it should now hopefully work.
... View more
09-18-2019
02:46 AM
|
0
|
0
|
651
|
POST
|
My guess would be that since you are using setViewpointAsync the scale is not reached until some time after the call to zoomInFunction rather than on the next line of code where you call getMapScale. Maybe try using setViewPoint which so not async to see if that helps.
... View more
09-17-2019
10:02 AM
|
0
|
0
|
459
|
POST
|
The logic is good. The problem I think is that the view is not zooming out to LOD 0. If you set another LOD e.g. 5 you will see it works. Also if you make your window smaller it becomes possible to zoom to LOD 0.
... View more
09-05-2019
02:58 AM
|
0
|
0
|
774
|
POST
|
I think maybe you are adding the MapView scale listener in the wrong place. Try something like this which should disable the zoom in once you reach LOD 18 and enable it if you zoom back out… import com.esri.arcgisruntime.geometry.Point; import com.esri.arcgisruntime.layers.ArcGISTiledLayer; import com.esri.arcgisruntime.mapping.ArcGISMap; import com.esri.arcgisruntime.mapping.Basemap; import com.esri.arcgisruntime.mapping.Viewpoint; import com.esri.arcgisruntime.mapping.view.MapView; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.stage.Stage; public class App extends Application { MapView mapView = new MapView(); @Override public void start(Stage stage) throws Exception { Platform.setImplicitExit(true); var borderPane = new BorderPane(); var scene = new Scene(borderPane); stage.setScene(scene); stage.setWidth(500); stage.setHeight(500); stage.show(); var map = new ArcGISMap(); var tiledLayer = new ArcGISTiledLayer("http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");; tiledLayer.addDoneLoadingListener(() -> { var lods = tiledLayer.getTileInfo().getLevelsOfDetail(); lods.forEach(lod -> System.out.println(lod.getLevel() + " " + lod.getScale() + " " + lod.getResolution())); //tiledLayer.setMinScale(lods.get(0).getScale()); //tiledLayer.setMaxScale(lods.get(18).getScale()); HBox box = new HBox(); borderPane.setBottom(box); Button zoomIn = new Button("Zoom in"); Button zoomOut = new Button("Zoom out"); zoomIn.setOnAction(a -> { Viewpoint current = mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE); Viewpoint zoomedIn = new Viewpoint((Point) current.getTargetGeometry(), current.getTargetScale() / 2.0); }); zoomOut.setOnAction(a -> { Viewpoint current = mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE); Viewpoint zoomedOut = new Viewpoint((Point) current.getTargetGeometry(), current.getTargetScale() * 2.0); mapView.setViewpointAsync(zoomedOut); }); box.getChildren().addAll(zoomIn, zoomOut); mapView.addMapScaleChangedListener(s -> zoomIn.setDisable(mapView.getMapScale() <= lods.get(18).getScale())); }); Basemap basemap = new Basemap(); basemap.getBaseLayers().add(tiledLayer); map.setBasemap(basemap); mapView.setMap(map); borderPane.setCenter(mapView); } @Override public void stop() throws Exception { if (mapView != null) { mapView.dispose(); } } public static void main(String[] args) { launch(args); } }
... View more
09-04-2019
10:12 AM
|
0
|
0
|
3217
|
POST
|
mapView.setViewpointAsync(zoomedIn) is an async call so you would have to add a done listener if you want to take action when the new scale is reached since it doesn’t happen immediately so something like mapView.setViewpointAsync(zoomedIn).addDoneListener(() -> { // check to see if zoom in or zoom out should be disabled/enabled }); An alternative would be to add a listener for scale changes on the MapView. As an example the following would disable the zoom in when you reach LOD 18 but otherwise enable the button. mapView.addMapScaleChangedListener(s -> zoomIn.setDisable(mapView.getMapScale() <= lods.get(18).getScale()));
... View more
09-04-2019
06:10 AM
|
0
|
0
|
3217
|
POST
|
I think you can do this by setting the min and max scales the the appropriate levels of detail e.g. tiledLayer.setMinScale(lods.get(0).getScale()); tiledLayer.setMaxScale(lods.get(18).getScale());
... View more
09-03-2019
05:50 AM
|
0
|
0
|
3217
|
POST
|
You can access the scale for each LOD something like var tiledLayer = new ArcGISTiledLayer("http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer"); tiledLayer.addDoneLoadingListener(() -> { var lods = tiledLayer.getTileInfo().getLevelsOfDetail(); lods.forEach(lod -> System.out.println(lod.getScale())); }); and use the scale in the zoom in/zoom out buttons.
... View more
09-02-2019
08:13 AM
|
0
|
2
|
3217
|
POST
|
Hi, The methods that you are trying to to use on the MapView refer to JavaFX scaling - literally scaling the size of the control. You can zoom the map by changing the ViewPoint as shown below. Button zoomIn = new Button("Zoom in"); Button zoomOut = new Button("Zoom out"); zoomIn.setOnAction(a -> { Viewpoint current = mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE); Viewpoint zoomedIn = new Viewpoint((Point) current.getTargetGeometry(), current.getTargetScale() / 2.0); mapView.setViewpointAsync(zoomedIn); }); zoomOut.setOnAction(a -> { Viewpoint current = mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE); Viewpoint zoomedOut = new Viewpoint((Point) current.getTargetGeometry(), current.getTargetScale() * 2.0); mapView.setViewpointAsync(zoomedOut); });
... View more
09-02-2019
06:17 AM
|
3
|
4
|
3216
|
POST
|
If you call getAdditionMessage() on the ArcGISRuntimeException that has been thrown it might give you some more information on what the problem is.
... View more
07-02-2019
09:57 AM
|
0
|
1
|
539
|
POST
|
Sorry, zoom box is currently not available for 100.4 but it is quite easy to create the functionality by creating a custom interaction listener e.g. import com.esri.arcgisruntime.geometry.Envelope;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.Viewpoint;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.mapping.view.MapView.DefaultInteractionListener;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Point2D;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class ZoomBoxTest extends Application {
private MapView mapView = new MapView();
@Override
public void start(Stage stage) throws Exception {
Platform.setImplicitExit(true);
BorderPane borderPane = new BorderPane();
javafx.scene.Scene fxScene = new javafx.scene.Scene(borderPane);
stage.setWidth(500);
stage.setHeight(500);
stage.setScene(fxScene);
stage.show();
stage.show();
ArcGISMap map = new ArcGISMap(Basemap.createDarkGrayCanvasVector());
mapView.setMap(map);
borderPane.setCenter(mapView);
mapView.setInteractionListener(new ZoomBoxInteraction(mapView));
}
@Override
public void stop() {
if (mapView != null) {
mapView.dispose();
}
}
public static void main(String[] args) {
Application.launch(args);
}
/**
* Creates an interaction listener that allows you to zoom in by defining an envelope by dragging the mouse.
*/
class ZoomBoxInteraction extends DefaultInteractionListener {
private GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
private Graphic boxGraphic;
private Envelope box;
Point firstPoint;
Point lastPoint;
ZoomBoxInteraction(MapView mapView) {
super(mapView);
}
@Override
public void onMousePressed(MouseEvent e) {
mapView.getGraphicsOverlays().add(graphicsOverlay);
boxGraphic = new Graphic();
graphicsOverlay.getGraphics().add(boxGraphic);
boxGraphic.setSymbol(new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0x88FF0000, null));
firstPoint = mapView.screenToLocation(new Point2D(e.getX(), e.getY()));
lastPoint = firstPoint;
box = new Envelope(firstPoint, lastPoint);
boxGraphic.setGeometry(box);
}
@Override
public void onMouseReleased(MouseEvent e) {
mapView.setViewpoint(new Viewpoint(box));
mapView.getGraphicsOverlays().remove(graphicsOverlay);
graphicsOverlay.getGraphics().clear();
firstPoint = null;
lastPoint = null;
box = null;
boxGraphic = null;
}
@Override
public void onMouseDragged(MouseEvent e) {
lastPoint = mapView.screenToLocation(new Point2D(e.getX(), e.getY()));
box = new Envelope(firstPoint, lastPoint);
boxGraphic.setGeometry(box);
}
}
} What is mapview.setEnableTouchZoom(true). This enables/disables zooming in/out by using a pinching touch gesture on touch enabled devices.
... View more
03-04-2019
05:31 AM
|
0
|
0
|
295
|
POST
|
I think all you need to do is to use Graphic (double latitude, double longitude) which will create a graphic from your lat, lon point. The graphic should automatically re-project to match your map when you add it to the graphics overlay. Something like... SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.DIAMOND, 0xFFFF0000, 12);
Graphic graphic = new Graphic(lat, lon);
graphicsOverlay.getGraphics().add(graphic);
... View more
10-26-2018
01:36 AM
|
0
|
0
|
344
|
POST
|
Here is how you can create a feature collection table and add a feature to use with Geoprocessing. In a future release it should be possible to get default parameter values from the service reducing how much code you would need but at 100.0.0 the following is what you need. GeoprocessingFeatures featuresParam = new GeoprocessingFeatures(); // create a table final ArrayList<Field> fields = new ArrayList<Field>(); fields.add(Field.createString("MyString", "MyString", 50)); fields.add(Field.createShort("MyShortInt", "MyShortInt")); fields.add(Field.createInteger("MyLongInt", "MyLongInt")); fields.add(Field.createFloat("MyFloat", "MyFloat")); fields.add(Field.createDouble("MyDouble", "MyDouble")); fields.add(Field.createDate("MyDate", "MyDate")); FeatureCollectionTable table = new FeatureCollectionTable(fields, GeometryType.POINT, SpatialReferences.getWebMercator()); // create a feature in the table Feature feature = table.createFeature(); feature.setGeometry(new Point(0.0, 0.0, SpatialReferences.getWebMercator())); feature.getAttributes().put("MyString", "string"); feature.getAttributes().put("MyShortInt", (short) 1); feature.getAttributes().put("MyLongInt", 100); feature.getAttributes().put("MyFloat", 1.5f); feature.getAttributes().put("MyDouble", 100.5); feature.getAttributes().put("MyDate", new GregorianCalendar()); try { table.addFeatureAsync(feature).get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } // set the table into the GP parameter featuresParam.setFeatures(table);
... View more
12-09-2016
10:24 AM
|
1
|
1
|
657
|
POST
|
Hi, I think your problem is that the first JMap you create is not created on the Swing UI thread. If you do your first addMap like SwingUtilities.invokeAndWait(() -> addMap()) your app should work ok. Remember as a Swing component JMaps should only be created/accessed on the UI thread. Colin
... View more
12-09-2016
09:50 AM
|
1
|
1
|
550
|
Title | Kudos | Posted |
---|---|---|
1 | 03-08-2022 09:26 AM | |
1 | 12-09-2021 10:22 AM | |
1 | 11-24-2021 03:05 AM | |
1 | 06-07-2021 09:38 AM | |
1 | 06-07-2021 01:29 AM |
Online Status |
Offline
|
Date Last Visited |
03-19-2024
02:46 PM
|