Select to view content in your preferred language

TooltipDialog is not a constructor

2750
4
Jump to solution
09-23-2016 08:09 AM
AshleyPeters
Occasional Contributor III

I am trying to add the tooltips feature to my map, following the sample code for the Feature Layer Hover. I have everything added in, but I am receiving an error that states 'TooltipDialog is not a constructor'. I've double-checked my require and function statements at the beginning of my .js file and all of the necessary items are listed. Has anyone else run into this with this particular sample?

Here's the bulk of my code for the feature layer hover. I've called in the feature layer and created the necessary symbols in other portions of my .js file.

tooltips.setRenderer(new SimpleRenderer(tooltipFill));

var dialog = new TooltipDialog({
          id: "tooltipDialog",
          style: "position: absolute; width: 250px; font: normal normal normal 10pt Helvetica;z-index:100"
        });
        dialog.startup();

mapMain.on("load", function (){
     mapMain.graphics.enableMouseEvents();
     mapMain.graphics.on("mouse-out", closeDialog);
});

tooltips.on("mouse-over", function (evt){
     var parksTooltips = "${NAME}";
     var content = esriLang.substitute(evt.graphic.attributes, parksTooltips);
     var highlightGraphic = new Graphic(evt.graphic.geometry, tooltipFill);
     mapMain.graphics.add(highlightGraphic);

dialog.setContent(content);

domStyle.set(dialog.domNode, "opacity", 0.85);
dijitPopup.open({
     popup: dialog,
     x: evt.pageX,
     y: evt.pageY
     });
});

function closeDialog() {
     mapMain.graphics.clear();
     dijitPopup.close(dialog);
     }
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ashley,

   Your require are out of order because of 

"dojo/domReady!",

being before 

"dijit/TooltipDialog",

best practices is to always have dojo/domReady! as the very last require.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Ashley,

   I would have to see more of your code.

0 Kudos
AshleyPeters
Occasional Contributor III

Robert,

Thanks for taking a moment to look this over. Here are the sections of code that I've added for the tooltip:

Require and function statements:

require([
     "dojo/dom-construct",
     "esri/map",
     "esri/Color",
     "dojo/keys",
    "esri/sniff",
    "esri/SnappingManager",
    "esri/renderers/SimpleRenderer",
     "esri/config",
     "esri/graphic",
     "esri/lang",
     "esri/geometry/Extent",
     "esri/geometry/webMercatorUtils",
     "esri/geometry/Point",
     "esri/dijit/BasemapGallery",
     "esri/dijit/HomeButton",
     "esri/dijit/Search",
     "esri/dijit/Popup",
     "esri/dijit/PopupTemplate",
     "esri/dijit/Scalebar",
     "esri/dijit/Print",
     "esri/dijit/Measurement",
     "esri/InfoTemplate",
     "esri/layers/ArcGISDynamicMapServiceLayer",
     "esri/layers/FeatureLayer",
    "esri/tasks/GeometryService",
     "esri/tasks/PrintTemplate",
     "esri/symbols/SimpleFillSymbol",
     "esri/symbols/SimpleLineSymbol",
     "esri/symbols/SimpleMarkerSymbol",
     "esri/symbols/PictureMarkerSymbol",
     "esri/toolbars/draw",
     "esri/graphic",
     "esri/urlUtils",
     "esri/request",
     "esri/SpatialReference",
     "agsjs/dijit/TOC",
     "dojo/_base/array",
     "dojo/aspect",
     "dojo/dom",
     "dojo/dom-style",
     "dojo/ready",
     "dojo/on",
     "dojo/domReady!",
     "dijit/TooltipDialog",
     "dijit/popup",
     "dijit/layout/BorderContainer",
     "dijit/layout/ContentPane",
     "dijit/TitlePane",
     "dijit/form/Button"],

function (domConstruct, Map, Color, keys, has, SnappingManager, SimpleRenderer, esriConfig, Graphic, esriLang, Extent, webMercatorUtils, Point, BasemapGallery, HomeButton, Search, Popup, PopupTemplate, Scalebar, Print, Measurement, InfoTemplate, ArcGISDynamicMapServiceLayer, FeatureLayer, GeometryService, PrintTemplate, SimpleFillSymbol, SimpleLineSymbol, SimpleMarkerSymbol, PictureMarkerSymbol, Draw, Graphic, urlUtils, esriRequest, SpatialReference, TOC, array, aspect, dom, domStyle, ready, on, TooltipDialog, dijitPopup

)

Symbol creation:

var tooltipFill = new SimpleFillSymbol ("solid", new Color([0, 0, 0, 1.25]));

URL call:

var tooltipURL = "https://conservationgis.alabama.gov/adcnrweb/rest/services/StateParksInfo/MapServer/2";

Feature layer:

var tooltips = new FeatureLayer(tooltipURL, {
    mode: FeatureLayer.MODE_SNAPSHOT,
    outFields: ["NAME"]
    });

Add layers to map:

mapMain.addLayers([boundaries, parks, photos, tooltips]);

The code in my original post would be further down in my .js file. If needed, I can send you the entire file.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ashley,

   Your require are out of order because of 

"dojo/domReady!",

being before 

"dijit/TooltipDialog",

best practices is to always have dojo/domReady! as the very last require.

AshleyPeters
Occasional Contributor III

Thanks Robert! My hover still isn't working, but that at least helps me move forward from this issue.

0 Kudos