Skip to content

Commit

Permalink
Added GPS functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
esride-ale committed Nov 12, 2024
1 parent bc43155 commit 2ad4c40
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 10 deletions.
2 changes: 2 additions & 0 deletions native-apps/urban-heat-notifier/urban_heat_notifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ cd urban_heat_notifier
```

Use `flutter pub upgrade` to configure the dependencies.
Use `dart run arcgis_maps install` to install arcgis_maps_core.

```
flutter pub upgrade
dart run arcgis_maps install
```

Step 2: Configure environment variables (based on [ENVied](https://pub.dev/packages/envied))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>
69 changes: 62 additions & 7 deletions native-apps/urban-heat-notifier/urban_heat_notifier/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,77 @@ import 'package:arcgis_maps/arcgis_maps.dart';
import 'env/env.dart';

void main() {

ArcGISEnvironment.apiKey = Env.apikey;

runApp(const MaterialApp(home: MyApp()));
runApp(MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MapScreen(),
);
}
}

class MapScreen extends StatefulWidget {
@override
_MapScreenState createState() => _MapScreenState();
}

class _MapScreenState extends State<MapScreen> {
bool _switchValue = false;
final _mapViewController = ArcGISMapView.createController();

@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: ArcGISMapView(
controllerProvider: () => ArcGISMapView.createController()
..arcGISMap = ArcGISMap.withBasemapStyle(BasemapStyle.arcGISTopographic),
body: Stack(
children: [
ArcGISMapView(
controllerProvider: () => _mapViewController,
onMapViewReady: onMapViewReady
),
Positioned(
bottom: 25,
right: 16,
child: Row(
children: [
Text('Show Location'),
Switch(
value: _switchValue,
onChanged: (value) {
setState(() {
_switchValue = value;
_toggleUserLocation();
});
},
),
],
),
),
])
);
}

void onMapViewReady() {
_mapViewController.arcGISMap = ArcGISMap.withBasemapStyle(BasemapStyle.arcGISLightGray);

// Set the initial system location data source and auto-pan mode.
_mapViewController.locationDisplay.dataSource = SystemLocationDataSource();
_mapViewController.locationDisplay.autoPanMode = LocationDisplayAutoPanMode.compassNavigation;
}

void _toggleUserLocation() {
if (_switchValue) {
_mapViewController.locationDisplay.start();
} else {
_mapViewController.locationDisplay.stop();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,10 @@ packages:
dependency: transitive
description:
name: package_info_plus
sha256: df3eb3e0aed5c1107bb0fdb80a8e82e778114958b1c5ac5644fb1ac9cae8a998
sha256: da8d9ac8c4b1df253d1a328b7bf01ae77ef132833479ab40763334db13b91cce
url: "https://pub.dev"
source: hosted
version: "8.1.0"
version: "8.1.1"
package_info_plus_platform_interface:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:urban_heat_notifier/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
await tester.pumpWidget(MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
Expand Down

0 comments on commit 2ad4c40

Please sign in to comment.