Skip to content

Commit 654bf01

Browse files
committed
add toolkit compass use back in
1 parent e95936f commit 654bf01

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ eclipse.classpath.downloadJavadoc = true
2323
compileJava.options.encoding = 'UTF-8'
2424

2525
dependencies {
26+
compile 'com.esri.arcgisruntime:arcgis-java-toolkit:100.2.1'
2627
compile 'commons-io:commons-io:2.4'
2728
compile 'org.jooq:joox:1.4.0'
2829
}

src/main/java/com/esri/samples/mapview/map_rotation/MapRotationSample.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.esri.arcgisruntime.mapping.Basemap;
3535
import com.esri.arcgisruntime.mapping.Viewpoint;
3636
import com.esri.arcgisruntime.mapping.view.MapView;
37+
import com.esri.arcgisruntime.toolkit.Compass;
3738

3839
public class MapRotationSample extends Application {
3940

@@ -85,6 +86,13 @@ public void start(Stage stage) throws Exception {
8586
mapView = new MapView();
8687
mapView.setMap(map);
8788

89+
// create a compass to show the current heading when rotated
90+
Compass compass = new Compass(mapView);
91+
92+
// clicking the compass sets the map's heading to 0.0
93+
// add a listener to reset the slider when this happens
94+
compass.setOnMouseClicked(e -> slider.setValue(0.0));
95+
8896
// create a starting viewpoint for the map view
8997
SpatialReference spatialReference = SpatialReferences.getWebMercator();
9098
Point pointBottomLeft = new Point(-13639984.0, 4537387.0, spatialReference);
@@ -96,9 +104,11 @@ public void start(Stage stage) throws Exception {
96104
mapView.setViewpointAsync(viewpoint);
97105

98106
// add the map view, slider, and compass to the stack pane
99-
stackPane.getChildren().addAll(mapView, slider);
107+
stackPane.getChildren().addAll(mapView, slider, compass);
100108
StackPane.setAlignment(slider, Pos.TOP_LEFT);
109+
StackPane.setAlignment(compass, Pos.TOP_RIGHT);
101110
StackPane.setMargin(slider, new Insets(10, 0, 0, 10));
111+
StackPane.setMargin(compass, new Insets(10, 10, 0, 0));
102112
} catch (Exception e) {
103113
// on any error, display the stack trace
104114
e.printStackTrace();

0 commit comments

Comments
 (0)