cmv/cmv-app

How to disable the "No Information Available" popup in Identify widget?

Closed this issue · 14 comments

Hi I was wondering if I can only identify my features in layers, and not random points on my basemap.

In \CIPviewer\js\config\identify.js

Currently I have:

    return {
        map: true,
        mapClickMode: false,
        mapRightClickMenu: true,
        identifyLayerInfos: true,
        identifyTolerance: 5,
        draggable: true,

Which I use the right click to identify, so its more clean for identification.

@gisnovice you can exclude any layer from the identify widget by using:

identifyLayerInfos : {
    exclude: true
},

within the configuration for your layer within the operationalLayers array in viewer.js. https://docs.cmv.io/en/latest/configure/operationalLayers/#identify

I have read that from the documentation, and have implemented in some layers. However, what I was wondering when you click on the basemap and the identify box pops up to show "No information available." is there a way to exclude that?

Duplicate of #305

I tried to follow #305 but I am unable to place the code properly to do this. I am trying to reference the ESRI API https://developers.arcgis.com/javascript/3/jsapi/popup-amd.html

The issue is open. It hasn't been implemented yet, although it would be simple to do. I just closed this issue because there's already an issue about this.

Got it, thanks.

Solution:

//viewer.js
define([
    'esri/units',
    'esri/geometry/Extent',
    'esri/config',
    /*'esri/urlUtils',*/
    'esri/tasks/GeometryService',
    'esri/layers/ImageParameters',
    'gis/plugins/Google',
    'dojo/i18n!./nls/main',
    'dojo/topic',
    'esri/dijit/Popup',
    'put-selector'
], function (units, Extent, esriConfig, /*urlUtils,*/ GeometryService, ImageParameters, GoogleMapsLoader, i18n, topic, Popup, put) {

//. ...........................

        mapOptions: {
            basemap: 'streets',
            center: [-96.59179687497497, 39.09596293629694],
            zoom: 5,
            sliderStyle: 'small',
            infoWindow: new Popup({visibleWhenEmpty: false}, put('div'))
        },

Do I need to add anything more? I tried your solution and now my viewer does not properly load.

No, that would be all. If your app doesn't load at all, you may have a typo.

I did! I forgotten a comma, but now all layers try to disappear. Even the ones I do want to identify.

@roemhildtg when I implemented this with my code, it does indeed hide disable the no information popup, however it also causes all of my popups to close when they are initiated. Is there any reason that you can think of for this behavior?

@drusexton Which approach did you use? The mapOptions code above or use hideEmptyPopop option added in PR #707?

BTW, I just noticed that the hideEmptyPopop option is misspelled in the Identify widget's code. In the future, we should correct that to be Popup not Popop.

@tmcgee used the mapOptions approach. Also if I have the access (?) to change the spelling I can do it...

Here is a link to the viewer where you can check out the behavior I am talking about. Just click on one of the property icons. Also if you click any place the no information popup will appear and then disappear after a brief moment. Below are some snippets from my config where I added the code that should enable the desired functionality.

define([ 'esri/units', 'esri/geometry/Extent', 'esri/config', /*'esri/urlUtils',*/ 'esri/tasks/GeometryService', 'esri/layers/ImageParameters', 'gis/plugins/Google', 'dojo/i18n!./nls/main', 'dojo/topic', 'dojo/sniff', 'esri/dijit/Popup', 'put-selector' ],

function (units, Extent, esriConfig, /*urlUtils,*/ GeometryService, ImageParameters, GoogleMapsLoader, i18n, topic, has, Popup, put)

defaultMapClickMode: 'identify', // map options, passed to map constructor. see: https://developers.arcgis.com/javascript/jsapi/map-amd.html#map1 mapOptions: { navigationmode: 'classic', basemap: 'hybrid', center: [-82.30207, 39.59618], zoom: 8, sliderStyle: 'small', infoWindow: new Popup({visibleWhenEmpty: false}, put('div')) },