Reusable Accessible Mapping Platform

API Docs for: 5.0.0
Show:

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

  1. /* global define, i18n, $ */
  2.  
  3. /**
  4. *
  5. *
  6. * @module RAMP
  7. * @submodule Map
  8. */
  9.  
  10. /**
  11. * Feature click handler class.
  12. *
  13. * The featureClickHandler uses Dojo/Topic to publish centralized global mouse event messages
  14. * related to feature selection. Any function subscribes to the topic will be able handle the
  15. * specific event.
  16. *
  17. * @class FeatureClickHandler
  18. * @static
  19. * @uses GraphicExtension
  20. * @uses EventManager
  21. * @uses dojo/topic
  22. * @uses dojo/dom-construct
  23. * @uses Util
  24. */
  25.  
  26. define([
  27. /* RAMP */
  28. "ramp/graphicExtension", "ramp/eventManager",
  29.  
  30. /* Dojo */
  31. "dojo/topic", "dojo/dom-construct",
  32.  
  33. /* Utils */
  34. "utils/util"],
  35.  
  36. function (
  37. /* RAMP */
  38. GraphicExtension, EventManager,
  39.  
  40. /* Dojo */
  41. topic, domConstruct,
  42.  
  43. /* Utils */
  44. UtilMisc) {
  45. "use strict";
  46. return {
  47. /**
  48. * This function is called whenever the feature on the map is clicked/selected by the user.
  49. * Publish the "Gui/subPanelOpen" message to indicate a feature has been selected. Panel content
  50. * and Panel event handler information is passed in as the additional object for the event handler.
  51. *
  52. * @method onFeatureSelect
  53. * @param {Object} evt
  54. * @param {Object} evt.graphic ESRI graphic object
  55. */
  56. onFeatureSelect: function (evt) {
  57. var selectedGraphic = evt.graphic;
  58.  
  59. topic.publish(EventManager.GUI.SUBPANEL_OPEN, {
  60. panelName: i18n.t('datagrid.details'),
  61. title: GraphicExtension.getGraphicTitle(selectedGraphic),
  62. content: GraphicExtension.getTextContent(selectedGraphic),
  63. target: $("#map-div"),
  64. origin: "rampPopup",
  65. consumeOrigin: "datagrid",
  66. guid: UtilMisc.guid(),
  67. showChars: 70,
  68. doOnOpen: function () {
  69. //topic.publish(EventManager.Datagrid.HIGHLIGHTROW_SHOW, {
  70. // graphic: selectedGraphic
  71. //});
  72.  
  73. UtilMisc.subscribeOnce(EventManager.Maptips.EXTENT_CHANGE, function (evt) {
  74. var scroll = evt.scroll;
  75. topic.publish(EventManager.Datagrid.HIGHLIGHTROW_SHOW, {
  76. graphic: selectedGraphic,
  77. scroll: scroll
  78. });
  79. });
  80.  
  81. // Note: the following will in turn trigger maptip/showInteractive
  82. topic.publish(EventManager.FeatureHighlighter.HIGHLIGHT_SHOW, {
  83. graphic: selectedGraphic
  84. });
  85. },
  86. doOnHide: function () {
  87. topic.publish(EventManager.Datagrid.HIGHLIGHTROW_HIDE);
  88. },
  89. doOnDestroy: function () {
  90. selectedGraphic = null;
  91.  
  92. //topic.publish(EventManager.FeatureHighlighter.HIGHLIGHT_HIDE);
  93. }
  94. });
  95. },
  96.  
  97. /**
  98. * This function is called whenever the "Details" button is deselected (either by the user click on
  99. * another "Details" button, clicking on another point, or by clicking on an already highlighted
  100. * "Details" button, or clicking somewhere on the map where is no features present).
  101. *
  102. * @method onFeatureDeselect
  103. */
  104. onFeatureDeselect: function () {
  105. topic.publish(EventManager.GUI.SUBPANEL_CLOSE, {
  106. origin: "rampPopup,datagrid"
  107. });
  108. },
  109.  
  110. /**
  111. * This function is called whenever the user hovers over a feature on the map when another feature already has been selected.
  112. *
  113. * @method onFeatureMouseOver
  114. * @param {Object} evt [description]
  115. * @param {Object} evt.graphic ESRI graphic object that is being hovered over
  116. */
  117. onFeatureMouseOver: function (evt) {
  118. topic.publish(EventManager.Maptips.SHOW, evt);
  119. topic.publish(EventManager.FeatureHighlighter.HOVERLIGHT_SHOW, evt);
  120. },
  121.  
  122. /**
  123. * This function is called whenever the user moves the mouse away from a feature being hovered over.
  124. *
  125. * @method onFeatureMouseOut
  126. * @param {Object} evt [description]
  127. * @param {Object} evt.graphic ESRI graphic object that is moved away from
  128. */
  129. onFeatureMouseOut: function (evt) {
  130. //topic.publish(EventManager.Maptips.HIDE, {});
  131. topic.publish(EventManager.FeatureHighlighter.HOVERLIGHT_HIDE, evt);
  132. }
  133. };
  134. });