/* * Copyright (C) 2014 United States Government as represented by the Administrator of the * National Aeronautics and Space Administration. All Rights Reserved. */ /** * @exports ProjectionMenu * @version $Id: ProjectionMenu.js 3185 2015-06-12 19:12:09Z tgaskins $ */ define(function () { "use strict"; /** * Constructs a projection menu for a specified {@link WorldWindow}. * @alias ProjectionMenu * @constructor * @classdesc Provides a projection menu to select the projection for a World Window. * @param {WorldWindow} worldWindow The World Window to associate this projection menu with. */ var ProjectionMenu = function (worldWindow) { var thisExplorer = this; this.wwd = worldWindow; this.roundGlobe = this.wwd.globe; this.createProjectionList(); $("#projectionDropdown").find(" li").on("click", function (e) { thisExplorer.onProjectionClick(e); }); }; ProjectionMenu.prototype.onProjectionClick = function (event) { var projectionName = event.target.innerText || event.target.innerHTML; $("#projectionDropdownTitle").html(projectionName + ""); if (projectionName === "3D") { if (!this.roundGlobe) { this.roundGlobe = new WorldWind.Globe(new WorldWind.EarthElevationModel()); } if (this.wwd.globe !== this.roundGlobe) { this.wwd.globe = this.roundGlobe; } } else { if (!this.flatGlobe) { this.flatGlobe = new WorldWind.Globe2D(); } if (projectionName === "Equirectangular") { this.flatGlobe.projection = new WorldWind.ProjectionEquirectangular(); } else if (projectionName === "Mercator") { this.flatGlobe.projection = new WorldWind.ProjectionMercator(); } else if (projectionName === "North Polar") { this.flatGlobe.projection = new WorldWind.ProjectionPolarEquidistant("North"); } else if (projectionName === "South Polar") { this.flatGlobe.projection = new WorldWind.ProjectionPolarEquidistant("South"); } else if (projectionName === "North UPS") { this.flatGlobe.projection = new WorldWind.ProjectionUPS("North"); } else if (projectionName === "South UPS") { this.flatGlobe.projection = new WorldWind.ProjectionUPS("South"); } else if (projectionName === "North Gnomonic") { this.flatGlobe.projection = new WorldWind.ProjectionGnomonic("North"); } else if (projectionName === "South Gnomonic") { this.flatGlobe.projection = new WorldWind.ProjectionGnomonic("South"); } if (this.wwd.globe !== this.flatGlobe) { this.wwd.globe = this.flatGlobe; } } this.wwd.redraw(); }; ProjectionMenu.prototype.createProjectionList = function () { var projectionNames = [ "3D", "Equirectangular", "Mercator", "North Polar", "South Polar", "North UPS", "South UPS", "North Gnomonic", "South Gnomonic" ]; var projectionDropdown = $("#projectionDropdown"); var ulItem = $('
'); projectionDropdown.append(ulItem); for (var i = 0; i < projectionNames.length; i++) { var projectionItem = $('