Reusable Accessible Mapping Platform

API Docs for: 5.0.0
Show:

File: src\js\RAMP\Modules\ramp.js

  1. /*global define, RAMP */
  2.  
  3. /**
  4. *
  5. *
  6. * @module RAMP
  7. */
  8.  
  9. /**
  10. * RAMP class.
  11. *
  12. * Module for shared code that need the global configuration object.
  13. * For code that can be of use to any javascript program and do not
  14. * require the global configuration object, place the code in
  15. * util.js
  16. *
  17. * @class RAMP
  18. * @uses dojo/_base/declare
  19. * @uses dojo/query
  20. * @uses dojo/_base/array
  21. * @uses dojo/dom
  22. * @uses dojo/dom-class
  23. * @uses dojo/dom-style
  24. * @uses dojo/dom-construct
  25. * @uses dojo/request/script
  26. * @uses GlobalStorage
  27. * @uses Array
  28. * @uses Dictionary
  29. * @uses Util
  30. * @uses TmplUtil
  31. */
  32.  
  33. define([
  34. // Dojo
  35. "dojo/_base/declare", "dojo/query", "dojo/_base/array", "dojo/dom", "dojo/dom-class", "dojo/dom-style",
  36. "dojo/dom-construct", "dojo/request/script",
  37.  
  38. // RAMP
  39. "ramp/globalStorage", "ramp/map",
  40.  
  41. // Utils
  42. "utils/array", "utils/dictionary", "utils/util", "utils/tmplUtil"],
  43.  
  44. function (
  45. // Dojo
  46. declare, dojoQuery, dojoArray, dom, domClass, domStyle, domConstruct, requestScript,
  47.  
  48. // RAMP
  49. GlobalStorage, RampMap,
  50.  
  51. // Utils,
  52. UtilArray, UtilDict, UtilMisc, UtilTmpl) {
  53. "use strict";
  54. return {
  55. /**
  56. * Updates some of the Strings on the HTML page using the config string resources
  57. *
  58. * @method loadStrings
  59. */
  60. loadStrings: function () {
  61. // doesn't seem to be doing a lot, this function
  62. },
  63. /**
  64. * Returns the feature layer config for the given id
  65. *
  66. * @param {String} id layer id string
  67. * @method getLayerConfigWithId
  68. */
  69. getLayerConfigWithId: function (id) {
  70. return UtilArray.find(RAMP.config.layers.wms.concat(RAMP.config.layers.feature),
  71. function (layerConfig) {
  72. return layerConfig.id === id;
  73. });
  74. },
  75.  
  76. /**
  77. * Given a feature object or a graphic object (or any object that has a getLayer method and an
  78. * attributes field) return the object containing the image URL and legend text for that
  79. * feature/graphic object.
  80. *
  81. * @param {Object} feature
  82. * @return {icon} The default icon used to represent the feature layer
  83. * @method getSymbolForFeature
  84. */
  85. getSymbolForFeature: function (feature) {
  86. var layerConfig = feature.getLayer().ramp.config;
  87.  
  88. //as this function is used by templating, we piggyback the logic here
  89. return UtilTmpl.getGraphicIcon(feature, layerConfig);
  90. },
  91.  
  92. /**
  93. * This method builds a complete service URL callout for a map configuration. The URL is built using a base URL and map ID, and a language culture code.
  94. * @method getServiceURL
  95. * @param {String} rampService The base URL for a web service that provide's valid map JSON configuration data
  96. * @param {Number} mapID a unique identifier for a group of map configuration
  97. * @param {String} language culture code either 'en' or 'fr'
  98. *
  99. */
  100. getServiceURL: function (rampService, mapID, language) {
  101. var serviceURL = rampService + "configservice/map?mapid=" + mapID + "&lang=" + language;
  102. return serviceURL;
  103. }
  104. };
  105. });