Skip to content

Commit e87698c

Browse files
authored
Merge pull request #238 from Esri/map-rotation-compass
Map rotation compass
2 parents e9c3a24 + fe0283d commit e87698c

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ eclipse.classpath.downloadJavadoc = true
2121

2222
compileJava.options.encoding = 'UTF-8'
2323

24+
repositories {
25+
maven {
26+
url 'https://esri.bintray.com/arcgis'
27+
}
28+
}
29+
2430
dependencies {
31+
compile 'com.esri.arcgisruntime:arcgis-java-toolkit:100.2.1'
2532
compile 'commons-io:commons-io:2.4'
2633
compile 'org.jooq:joox:1.4.0'
2734
}
50.3 KB
Loading

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 Esri.
2+
* Copyright 2018 Esri.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy of
@@ -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);
@@ -95,10 +103,12 @@ public void start(Stage stage) throws Exception {
95103
// set viewpoint to the map view
96104
mapView.setViewpointAsync(viewpoint);
97105

98-
// add map view and control panel to stack pane
99-
stackPane.getChildren().addAll(mapView, slider);
106+
// add the map view, slider, and compass to the stack pane
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();

src/main/java/com/esri/samples/mapview/map_rotation/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
<h1>Map Rotation</h1>
22

3-
<p>Demonstrates how to rotate an ArcGISMap.</p>
3+
<p>Demonstrates how to rotate a map.</p>
44

55
<p><img src="MapRotation.png"/></p>
66

77
<h2>How to use the sample</h2>
88

9-
<p>The slider changes the rotation of the ArcGISMap.</p>
9+
<p>Use the slider to rotate the map. If the map is not pointed north, the compass will display the current heading.
10+
Click the compass to set the map's heading to north.</p>
1011

1112
<h2>How it works</h2>
1213

13-
<p>To rotate an <code>ArcGISMap</code>:</p>
14+
<p>To rotate a map:</p>
1415

1516
<ol>
16-
<li>Create an ArcGIS map. </li>
17-
<li>Add the map to the <code>MapView</code>, <code>MapView.setMap()</code>. </li>
17+
<li>Create an <code>ArcGISMap</code>.</li>
18+
<li>Add the map to a <code>MapView</code>.</li>
1819
<li>Use <code>MapView.setViewpointRotationAsync</code> to indicate the rotation angle.</li>
1920
</ol>
2021

2122
<h2>Features</h2>
2223

2324
<ul>
2425
<li>ArcGISMap</li>
26+
<li>Compass</li>
2527
<li>Envelope</li>
2628
<li>MapView</li>
2729
<li>Point</li>

0 commit comments

Comments
 (0)