Skip to content

Commit 31137f0

Browse files
Merge pull request #82 from Esri/PaulAllanSturm/showDeviceLocation
"Show device location" sample
2 parents 48a7370 + 8081b48 commit 31137f0

File tree

6 files changed

+247
-115
lines changed

6 files changed

+247
-115
lines changed

assets/generated_samples_list.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,11 +894,31 @@
894894
"category": "Maps",
895895
"description": "Display your current position on the map, as well as switch between different types of auto pan modes.",
896896
"ignore": false,
897-
"images": [],
898-
"keywords": [],
897+
"images": [
898+
"show_device_location.png"
899+
],
900+
"keywords": [
901+
"GPS",
902+
"compass",
903+
"location",
904+
"map",
905+
"mobile",
906+
"navigation",
907+
"ArcGISMap",
908+
"ArcGISMapView",
909+
"LocationDisplay",
910+
"LocationDisplay.autoPanMode"
911+
],
899912
"redirect_from": [],
900-
"relevant_apis": [],
901-
"snippets": [],
913+
"relevant_apis": [
914+
"ArcGISMap",
915+
"ArcGISMapView",
916+
"LocationDisplay",
917+
"LocationDisplay.autoPanMode"
918+
],
919+
"snippets": [
920+
"show_device_location_sample.dart"
921+
],
902922
"title": "Show device location",
903923
"key": "show_device_location"
904924
},

lib/samples/densify_and_generalize_geometry/densify_and_generalize_geometry_sample.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// limitations under the License.
1515
//
1616

17+
import 'dart:math';
1718
import 'package:arcgis_maps/arcgis_maps.dart';
1819
import 'package:flutter/material.dart';
1920

@@ -104,7 +105,11 @@ class _DensifyAndGeneralizeGeometrySampleState
104105
20.0,
105106
0.0,
106107
20.0,
107-
View.of(context).viewPadding.bottom / View.of(context).devicePixelRatio,
108+
max(
109+
20.0,
110+
View.of(context).viewPadding.bottom /
111+
View.of(context).devicePixelRatio,
112+
),
108113
),
109114
child: Column(
110115
mainAxisSize: MainAxisSize.min,
@@ -286,10 +291,10 @@ class _DensifyAndGeneralizeGeometrySampleState
286291

287292
// Create a map with a basemap style and an initial viewpoint to show the extent of the polyline.
288293
final map = ArcGISMap.withBasemapStyle(BasemapStyle.arcGISStreetsNight)
289-
..initialViewpoint = Viewpoint.fromCenter(
290-
_originalPolyline.extent.center,
291-
scale: 65907,
292-
);
294+
..initialViewpoint = Viewpoint.fromCenter(
295+
_originalPolyline.extent.center,
296+
scale: 65907,
297+
);
293298
_mapViewController.arcGISMap = map;
294299

295300
// Set the ready state variable to true to enable the sample UI.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Show device location
2+
3+
Display your current position on the map, as well as switch between different types of auto pan modes.
4+
5+
![Image of show device location](show_device_location.png)
6+
7+
## Use case
8+
9+
When using a map within a GIS, it may be helpful for a user to know their own location within a map, whether that's to aid the user's navigation or to provide an easy means of identifying/collecting geospatial information at their location.
10+
11+
## How to use the sample
12+
13+
Tap the "Location Settings" button to open the settings. Toggle "Show Location" to turn on or off the location display. The "Auto-Pan Mode" menu has the following options to control how the viewpoint changes as the location changes:
14+
15+
* Off - Turns off `autoPanMode`.
16+
* Re-Center - Sets the `autoPanMode` to `recenter`.
17+
* Navigation - Sets the `autoPanMode` to `navigation`.
18+
* Compass - Sets the `autoPanMode` to `compassNavigation`.
19+
20+
## How it works
21+
22+
1. Create an `ArcGISMapViewController`.
23+
2. Get the `LocationDisplay` object from the `locationDisplay` property on the controller.
24+
3. Use `start()` and `stop()` on the `LocationDisplay` object as necessary.
25+
26+
## Relevant API
27+
28+
* ArcGISMap
29+
* ArcGISMapViewController
30+
* LocationDisplay
31+
* LocationDisplay.autoPanMode
32+
33+
## Additional information
34+
35+
Location permissions are required for this sample.
36+
37+
## Tags
38+
39+
compass, GPS, location, map, mobile, navigation

lib/samples/show_device_location/README.metadata.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,30 @@
22
"category": "Maps",
33
"description": "Display your current position on the map, as well as switch between different types of auto pan modes.",
44
"ignore": false,
5-
"images": [],
6-
"keywords": [],
5+
"images": [
6+
"show_device_location.png"
7+
],
8+
"keywords": [
9+
"GPS",
10+
"compass",
11+
"location",
12+
"map",
13+
"mobile",
14+
"navigation",
15+
"ArcGISMap",
16+
"ArcGISMapView",
17+
"LocationDisplay",
18+
"LocationDisplay.autoPanMode"
19+
],
720
"redirect_from": [],
8-
"relevant_apis": [],
9-
"snippets": [],
21+
"relevant_apis": [
22+
"ArcGISMap",
23+
"ArcGISMapView",
24+
"LocationDisplay",
25+
"LocationDisplay.autoPanMode"
26+
],
27+
"snippets": [
28+
"show_device_location_sample.dart"
29+
],
1030
"title": "Show device location"
1131
}
155 KB
Loading

0 commit comments

Comments
 (0)