Select to view content in your preferred language

Mouse Hover To Show Data In WAB App

2630
15
06-05-2019 09:13 AM
joerodmey
MVP Alum

I have an app built in WAB that I want the mouse to trigger popups on hover. Been playing around with it a bit and trying to add code to MapManager.js in the publishMapEvent function

Tried using info window and mouse over but not luck.

Any ideas?

0 Kudos
15 Replies
joerodmey
MVP Alum

Where/what would I add into my code? Also how do I get the popup to only fire once when it hits a polygon? Right now it keeps firing every time it hits my polygon and I would like to see the popup to only show once and will only fire again if I manually close it.

Here is a snippet of my publish map event function

require([
          'esri/graphic',
          'esri/symbols/SimpleMarkerSymbol',
          'esri/symbols/SimpleLineSymbol',
          'esri/Color'
        ],
		lang.hitch(this, function(Graphic, SimpleMarkerSymbol, SimpleLineSymbol, Color){
          var symbol = new SimpleMarkerSymbol(
         SimpleMarkerSymbol.STYLE_CIRCLE, 0.01,
          new SimpleLineSymbol(
            SimpleLineSymbol.STYLE_CIRCLE,
            new Color([207, 16, 45, 0.9]),
            1
          ),
          new Color([207, 16, 45, 0.9])
        );
		
          map.on("click", lang.hitch(this, function(evt){
            var gra = new Graphic(evt.mapPoint, symbol);
            setTimeout(lang.hitch(this, function(){
              var selFeats = map.infoWindow.features;
              if(!selFeats){
                map.graphics.clear();
                map.graphics.add(gra);
				
				//PopupCenter('http://www.xtf.dk','xtf','900','500');  
				
				
				
                map.infoWindow.setContent('<a href="https://survey123.arcgis.com/share/Survey123 ID?center='+ evt.mapPoint.getLatitude().toString() + ','+ evt.mapPoint.getLongitude().toString() + '&field:Floor_Selection=' + this.SERVICE_ID.split('_')[1]+"_Floor " + '" target="_"><font size="4">Click here to submit a service request</font></a>');
				
				SERVICE_ID: null;
				
                map.infoWindow.show(evt.mapPoint);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
joerodmey
MVP Alum

How would I make this widget allow multiple layers to be included for hover popups?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Each FeatureLayer has it's own mouse event so that is not practical.

0 Kudos
joerodmey
MVP Alum

Good to know.

How do I get the popup to only fire once when it hits a polygon? Right now it keeps firing every time it hits my polygon and I would like to see the popup to only show once and will only fire again if I manually close it.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I thought you were going to use a tooltip dijit, not a popup?... A tooltip does not have a close.

0 Kudos
JohnRogers541
New Contributor

Hi, how do you import this widget into WAB after downloading?

0 Kudos