Skip to content

Commit

Permalink
Allow mapStartBasemap & basemapsToShow as optional in basemap wid…
Browse files Browse the repository at this point in the history
…get.

Also clean up some unused properties and code.
  • Loading branch information
tmcgee committed Sep 9, 2015
1 parent e48424a commit 023f5f4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
18 changes: 13 additions & 5 deletions viewer/js/config/basemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ define([
return {
map: true, // needs a refrence to the map
mode: 'agol', //must be either 'agol' or 'custom'
title: 'Basemaps', // tilte for widget
mapStartBasemap: 'streets', // must match one of the basemap keys below
//basemaps to show in menu. define in basemaps object below and reference by name here
// TODO Is this array necessary when the same keys are explicitly included/excluded below?
basemapsToShow: ['streets', 'satellite', 'hybrid', 'topo', 'lightGray', 'gray', 'national-geographic', 'osm', 'oceans'],
title: 'Basemaps', // title for widget

/* optional starting basemap
/ otherwise uses the basemap from the map
/ must match one of the keys in basemaps object below
*/
//mapStartBasemap: 'streets',

/* optional array of basemaps to show in menu.
/ otherwise uses keys in basemaps object below
/ values in array must match keys in basemaps object
*/
//basemapsToShow: ['streets', 'satellite', 'hybrid', 'topo', 'lightGray', 'gray', 'national-geographic', 'osm', 'oceans'],

// define all valid custom basemaps here. Object of Basemap objects. For custom basemaps, the key name and basemap id must match.
basemaps: { // agol basemaps
Expand Down
35 changes: 24 additions & 11 deletions viewer/js/gis/dijit/Basemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,31 @@ define([
i18n: i18n,
mode: 'agol',
title: i18n.title,
//baseClass: 'gis_Basemaps_Dijit',
//buttonClass: 'gis_Basemaps_Button',
//menuClass: 'gis_Basemaps_Menu',
mapStartBasemap: 'streets',
basemapsToShow: ['streets', 'satellite', 'hybrid', 'topo', 'gray', 'oceans', 'national-geographic', 'osm'],
validBasemaps: [],

mapStartBasemap: null,
basemapsToShow: null,

postCreate: function () {
this.inherited(arguments);

// if the basemaps to show is not explicitly set,
// get them from the basemap object
if (!this.basemapsToShow) {
this.basemapsToShow = Object.keys(this.basemaps);
}

// if the starting basemap is not explicitly set,
// get it from the map
if (!this.mapStartBasemap) {
this.mapStartBasemap = this.map.getBasemap();
}

// check to make sure the starting basemap
// is found in the basemaps object
if (!this.basemaps.hasOwnProperty(this.mapStartBasemap)) {
this.mapStartBasemap = this.basemapsToShow[0];
}

this.currentBasemap = this.mapStartBasemap || null;

if (this.mode === 'custom') {
Expand All @@ -41,15 +58,11 @@ define([
return map.basemap;
})
});
// if (this.map.getBasemap() !== this.mapStartBasemap) { //based off the title of custom basemaps in viewer.js config
// this.gallery.select(this.mapStartBasemap);
// }
this.gallery.startup();
}

this.menu = new DropDownMenu({
style: 'display: none;' //,
//baseClass: this.menuClass
style: 'display: none;'
});

array.forEach(this.basemapsToShow, function (basemap) {
Expand Down

0 comments on commit 023f5f4

Please sign in to comment.