A fairly basic example of sending a waypoint (coordinates & name) to the device. Try it out.
Data
The waypoint data can be provided in two forms to allow for flexibility.
Javascript Object
This is the simplest way to provide the waypoint to the device since the Javascript object formats the data into GPX.
var display = new Garmin.DeviceDisplay("garminDisplay", { hideIfBrowserNotSupported: true, showStatusElement: false, //provide minimal feedback autoFindDevices: false, //it will search for devices upon action findDevicesButtonText: "Upload Waypoint", //allows you to customize the action text showCancelFindDevicesButton: false, //no need to cancel small data transfers showDeviceSelectOnLoad: false, // showDeviceSelectNoDevice: false, //autoReadData: false, //don't automatically read the tracks/etc autoWriteData: true, //automatically write the data once devices found showReadDataElement: false, /** * This is where the waypoint object is created and the necessary GPX is created. * The plugin speaks GPX, but you (the developer) may not so simply use the * Waypoint data structure to produce the GPX. **/ getWriteData: function() { var waypoint = new Garmin.WayPoint("37.828567", "-122.49875", null, "Geocache", "go find it..."); var factory = new Garmin.GpsDataFactory(); var gpx = factory.produceGpxString(null, [waypoint]); return gpx; }, afterFinishWriteToDevice: function() { alert("Geocache saved successfully"); } });
GPX XML String
For developers who already have GPX this may be a preferred method of sending waypoint data to the device. This approach is more error-prone since the GPX may contain information that the plugin does not parse.
var display = new Garmin.DeviceDisplay("garminDisplay", { unlockOnPageLoad: false, hideIfBrowserNotSupported: true, showStatusElement: false, autoFindDevices: false, findDevicesButtonText: "Upload Waypoint", showCancelFindDevicesButton: false, showDeviceSelectOnLoad: false, showDeviceSelectNoDevice: false, autoReadData: false, autoWriteData: true, showReadDataElement: false, getWriteData: function() { return $("dataString").value; } });
<textarea id="dataString" rows="22" cols="50">
<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Garmin">
<wpt lat="37.828567" lon="-122.49875">
<ele>100</ele>
<time>2002-11-12T00:00:00.0000000-08:00</time>
<name>MM5MM</name>
<desc>SpiderTracks</desc>
</wpt>
</gpx>
</textarea>
User Interface
The user interface can be extremely simple…as small as a link using only dialog boxes to provide feedback.
Buttons and Status Area

The examples above use the more verbose buttons and status feedback, but since sending waypoints is fairly simply this extra user interface may be a bit overkill.
Links and Dialog Boxes
Similar to code above, but use the useLinks: true, configuration.

