Send Waypoint (Advanced)

The plug-in can send data to a connected Garmin device in GPX format. This example finds all connected devices and writes waypoint data in GPX format to the selected device. A helper class GarminDeviceControlDemo is used to encapsulate all communication with the plugin. Refer to Find Device to learn more about call-back communication associated with finding devices.

writeToDevice method is invoked on the plugin to start writing waypoints to the selected device:

this.garminController.writeToDevice(this.writeDataText.value, this.writeDataFilename.value);

The two steps typical of handling call-back communication with the plugin are:

1. Create the helper class with call-back methods of interest, in this case the method isĀ onFinishWriteToDevice:

var GarminDeviceControlDemo = Class.create();
GarminDeviceControlDemo.prototype = {
    onFinishWriteToDevice: function(json) {
    ... }}

2. Register an instance of the helper class with the control. In this example, the registration is done as part of the initialization function.

    _intializeController: function() {
        ...
        this.garminController.register(this);
        ...
        }

Complete cut-and-paste example

1. Create a file called SendWaypoint.html and paste the code below.
2. Replace ‘http://mydomain.com/’ with your website base URL.
3. Replace ‘yourKeyGoesHere’ with key provided by Garmin for your website base URL.
4. Load in your browser.
5. Plug in a GPS device using a USB cable and turn it on
6. Click on the Find Devices button (it may take a few seconds to find devices).
7. Click on the Write To Device button to send GPX data in the text box to selected device.

















 




Write GPX Data to Garmin GPS

Status Text



Filename:
Write Contents:

Developer Resources