Reusable Accessible Mapping Platform

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