JavaScript examples

Overview

The following examples show common usages of the SDK using JavaScript. We recommend that you examine the examples in the following order to learn more about build great web applications using the Geotab JavaScript API. These examples are stand-alone HTML, JavaScript and CSS written so you can extract them and “run” them without having your own Web server.

You can also use the Runner option on the left to see some code snippets that you can run directly against a database.

Downloadable examples

Click here to download the examples ZIP file and extract the contents to your local drive.

addDriver.html, addZone.html

Demonstrates how to add Drivers and Zones (geofences) to the system.

dataFeed.html

How to use the GetFeed method and retrieve a continuous stream of GPS, Engine Status and Fault data. This is the most efficient and recommended way of getting a copy of this data.

displayOdometer.html

Shows how to display a vehicle's odometer readings over time.

getCount.html

This example demonstrates how to retrieve the number of vehicles and users in your account. This does not use API.js; it has been designed to show you a simple integration example.

getLocation.html

This examples shows how to obtain the location of a vehicle.

importDevices.html, importGroups.html, importHosLogs.html, importRoutePlan.html, importRoutes.html, importUsers.html, importZones.html

Tools that demonstrate how to bulk import different entity types into MyGeotab via comma-delimited text values.

moveZone.html

Shows how to move an existing zone to a new address using reverse geocoding.

pollTextMessages.html

This example illustrates how to poll the system for new text messages to and from compatible GO devices equipped with Garmin navigation systems.

sendTextMessage.html

This example demonstrates how to send text messages to compatible GO devices equipped with Garmin navigation systems.

showTrips.html

Building upon the showVehicleToday.html example, this demonstrates some of the features of MyGeotab. You will learn how to retrieve vehicles and their trips for any date and show the trips on a map.

showVehicleToday.html

Shows the current location of a vehicle on a map. This is a great starting point if you want to see a complete example of how to use the API for real-world applications.

singleSignOn.html

This example demonstrates how you can embed MyGeotab functionality into your own web applications. This is an excellent way to see how to embed your own vehicles on a map inside your projects.

starterKit.html

This is where we recommend you begin your projects. Use the starter kit to learn how to authenticate with Geotab and how to create simple API calls to retrieve information about your fleet. This example can be used as a base to continue building on or starting your own custom projects.

statusDataSampler.html

Shows how to retrieve the engine status data for a vehicle.

GitHub examples

Customer Registration

This example illustrates how to create a custom registration page. With this example, you will be able to: determine if a database name is available; register a new database; perform post-registration setup on the new database; send a confirmation email; and redirect a user to the new database. This is an advanced example and is designed for resellers.

 on GitHub