|
| 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 | +} |
0 commit comments