Skip to content

Commit dd2ffab

Browse files
authored
open street map layer (#274)
* created OpenStreetMapLayerSample using OPEN_STREET_MAP basemap * Converted README.md to HTML and renamed image * Recaptured OpenStreetMapLayer.png and lightly edited README.md * Update OpenStreetMapLayerSample.java changed copyright to 2018 * Update OpenStreetMapLayerSample.java removed extra newline * Update OpenStreetMapLayerSample.java * Changed call from addAll(mapView) to stackPane.getChildren().add(mapView) Corrected typos in code comments Standardized README text to match existing READMEs in Samples repo * changed Tags heading to <H2>
1 parent 1fc3d69 commit dd2ffab

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed
466 KB
Loading
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright 2018 Esri.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package com.esri.samples.ogc.open_street_map_layer;
18+
19+
import javafx.application.Application;
20+
import javafx.scene.Scene;
21+
import javafx.scene.layout.StackPane;
22+
import javafx.stage.Stage;
23+
24+
import com.esri.arcgisruntime.mapping.ArcGISMap;
25+
import com.esri.arcgisruntime.mapping.Basemap;
26+
import com.esri.arcgisruntime.mapping.view.MapView;
27+
28+
public class OpenStreetMapLayerSample extends Application {
29+
30+
private MapView mapView;
31+
32+
@Override
33+
public void start(Stage stage) {
34+
35+
try {
36+
// create stack pane and application scene
37+
StackPane stackPane = new StackPane();
38+
Scene scene = new Scene(stackPane);
39+
40+
// set title, size, and add scene to stage
41+
stage.setTitle("Open Street Map Sample");
42+
stage.setWidth(800);
43+
stage.setHeight(700);
44+
stage.setScene(scene);
45+
stage.show();
46+
47+
// create map with an OpenStreetMap basemap
48+
ArcGISMap map = new ArcGISMap(Basemap.Type.OPEN_STREET_MAP, 34.056295, -117.195800, 10);
49+
50+
// set the map to a map view
51+
mapView = new MapView();
52+
mapView.setMap(map);
53+
54+
// add the map view to stack pane
55+
stackPane.getChildren().add(mapView);
56+
} catch (Exception e) {
57+
// on any error, display the stack trace.
58+
e.printStackTrace();
59+
}
60+
}
61+
62+
/**
63+
* Stops and releases all resources used in application.
64+
*/
65+
@Override
66+
public void stop() {
67+
68+
if (mapView != null) {
69+
mapView.dispose();
70+
}
71+
}
72+
73+
/**
74+
* Opens and runs application.
75+
*
76+
* @param args arguments passed to this application
77+
*/
78+
public static void main(String[] args) {
79+
80+
Application.launch(args);
81+
}
82+
83+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<h1>OpenStreetMap Layer</h1>
2+
3+
<p>Add the OpenStreetMap layer to a map as a Basemap.</p>
4+
5+
<p><img src="OpenStreetMapLayer.png"/></p>
6+
7+
<h2>How it works</h2>
8+
<p>To create a map with an OpenStreetMap basemap:</p>
9+
<ol>
10+
<li>Create an <code>ArcGISMap</code> with a <code>Basemap.Type.OPEN_STREET_MAP</code>.</li>
11+
<li>Set the map to a <code>MapView</code>.</li>
12+
</ol>
13+
14+
<h2>Relevant API</h2>
15+
16+
<ul>
17+
<li>ArcGISMap</li>
18+
<li>Basemap</li>
19+
<li>Basemap.Type</li>
20+
<li>MapView</li>
21+
</ul>
22+
23+
<h2>Tags</h2>
24+
<p>Layers</p>
25+
<p>OpenStreetMap</p>

0 commit comments

Comments
 (0)