This sample app includes a demo for:
- Streaming device position updates to Amazon Location Service via Kinesis
- Displaying devices and geofences on a map
- Consuming geofence breaching notifications
maplibre-gl
and react-map-gl
: Renders map-related components.
@aws-sdk
: Allows making requests to Amazon Location Service, Amazon SQS and Amazon Kinesis.
@cloudscape-design
: Provides styles and UI components.
@mapbox/mapbox-gl-draw
: Provides drawing capability to help create geofences.
@aws/amazon-location-utilities-auth-helper
:
Javascript AWS authentication helper. Owned by Amazon Location.
See more in package.json
This app has been tested on Node.js v20.11.0 and NPM v9.5.0
- Install commandline dependencies:
Node.js
,AWS CLI
. - Install project dependencies: run
npm install
from the sample app location on your computer. - Follow
AWS CLI credential setup
to configure authentication tokens for your CLI. - Deploy CloudFormation resources via command
./deploy_cloudformation
from the project's root directory. You may need to runchmod +x ./deploy_cloudformation.sh
before running the script for the first time to setup the permission to run it. - Fill in required fields for Amazon Cognito and Amazon Location Service in
src/configuration.js
. The identity pool ids are generated as part of the CloudFormation deployment and can be found in the Output of the TrackingAndGeofencingSample stack. - Start the app: run
npm start
from the sample app location on your computer. - Open http://localhost:8080/ on a browser to access the app.
- Click on the "Run Demo" button to start the demo. For demo purposes, this demo uses mocked device positions near an Amazon warehouse.
This app allows using your customized geofence and device position to execute the demo.
- Go to the "Geofence" tab on the UI.
- Pan the map to find your desired geofence position.
- Click on the "Add" button.
- Start drawing the new polygon geofence. Note the last vertex must overlap the first vertex to enclose the geofence.
Alternatively, go to DemoData.js and put your geofences under DEMO_GEOFENCES
. The geofences will be created on web page refresh.
Device positions for the demo is stored in DemoData.js. Follow the format of device positions there to enter your own data.
This sample app uses two Unauthenticated Cognito Identity Pool roles:
- A read-only role which allows only read access such as
geo:ListGeofences
andsqs:ReceiveMessage
, etc. - A write-only role which allows only write access such as
geo:PutGeofence
andkinesis:PutRecords
, etc.
The separation follows the Principle of Least Privilege.
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.