AnsweredAssumed Answered

Custom widget for deployed web app - for a beginner

Question asked by ascullyCOT on Jun 2, 2017
Latest reply on Jun 5, 2017 by rastrauch

I'm dipping my toes into the Custom widget waters, so apologies for the amateur question.  Basically we have deployed an app configured in Web Appbuilder (via AGOL) onto one of our application servers (development environment).  I want to add a simple widget that toggles from basemap to aerials.  I've found the relevant code in the Javascript API (ArcGIS API for JavaScript Sandbox).

My plan is to use this code and work it into a version of the CustomWidgetTemplate files from Web AppBuilder Developers edition (from the stmapp/widgets directory) and then add a reference to it in the config.js file for the app (putting the new widget code in the correct spot in the app's widgets folder). 

First - is this a valid way to go?

Second, if so, then how to reconcile the very basic code from the API into the CustomWidgetTemplate widget.js file?  

the toggle widget code is:

var map;
], function(
Map, BasemapToggle
) {

map = new Map("map", {
center: [-70.6508, 43.1452],
zoom: 16,
basemap: "topo"

var toggle = new BasemapToggle({
map: map,
basemap: "satellite"
}, "BasemapToggle");



So I'm not sure what part of this is relevant and needed to put into the widget.js file for my new custom widget.


I know there are ways around this that don't involve a custom widget but would like to learn how to be able to do this process.


Thanks -