Disable popup menu items and popup selection symbol

2032
7
Jump to solution
07-11-2019 08:56 AM
SimonFonji
New Contributor III

Hello Robert, first I want to be able to remove ‘add a marker’. I do not really have a problem with ‘zoom to’. Secondly is there a way to show pop-up without the square highlight next to the feature? The reason I am asking is because even when the feature is no longer visible on the map the highlight of the feature remains and with continuous zooming one can actually see the exact location of the feature at the street level or house level via the highlight.

With continuous zooming the red triangle disappear (based on scale range) but the highlighted square remains. I do not want customers to know the exact location of the complaint. For the same reason I do not want customers to be able to ‘add a maker’. Is there a way to limit the visibility of the pop-up window (not the layer)?

Thanks for your time and help.

Simon.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Simon,

   Sure hiding the popup is even easier.

          map.on('extent-change', lang.hitch(this, function(evt){
            var sFeat = map.infoWindow.getSelectedFeature();
            if(map.getScale() < 10000 && sFeat && sFeat._layer.id === 'Crimes_8530'){
              map.infoWindow.hide();
            }
          }));

I have no idea why hiding the add a marker would affect the Near Me widget though.

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Simon,

   Do you want to eliminate the 'add a marker' and selection symbol for all layers in your app or just a certain layer?

0 Kudos
SimonFonji
New Contributor III

Hi Robert, I want to do it for a certain layer but it would be nice to know how to do it for all the layers as well.

Thanks,

Simon.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Simon,

   OK, for the popup highlight this is what I have to hide the highlight for a certain layer at a certain scale. In the jimu.js\MapManager.js file add line 51 -59:

      _show2DWebMap: function(appConfig) {
        //should use appConfig instead of this.appConfig, because appConfig is new.
        // if (appConfig.portalUrl) {
        //   var url = portalUrlUtils.getStandardPortalUrl(appConfig.portalUrl);
        //   agolUtils.arcgisUrl = url + "/sharing/content/items/";
        // }
        if(!appConfig.map.mapOptions){
          appConfig.map.mapOptions = {};
        }
        var mapOptions = this._processMapOptions(appConfig.map.mapOptions) || {};
        mapOptions.isZoomSlider = false;

        var webMapPortalUrl = appConfig.map.portalUrl;
        var webMapItemId = appConfig.map.itemId;
        var webMapOptions = {
          mapOptions: mapOptions,
          bingMapsKey: appConfig.bingMapsKey,
          usePopupManager: true
        };

        if(!window.isBuilder && !appConfig.mode && appConfig.map.appProxy &&
            appConfig.map.appProxy.mapItemId === appConfig.map.itemId) {
          var layerMixins = [];
          array.forEach(appConfig.map.appProxy.proxyItems, function(proxyItem){
            if (proxyItem.useProxy && proxyItem.proxyUrl) {
              layerMixins.push({
                url: proxyItem.sourceUrl,
                mixin: {
                  url: proxyItem.proxyUrl
                }
              });
            }
          });

          if(layerMixins.length > 0) {
            webMapOptions.layerMixins = layerMixins;
          }
        }

        var mapDeferred = this._createWebMapRaw(webMapPortalUrl, webMapItemId, this.mapDivId, webMapOptions);

        mapDeferred.then(lang.hitch(this, function(response) {
          var map = response.map;

          //hide the default zoom slider
          map.hideZoomSlider();

          // set default size of infoWindow.
          map.infoWindow.resize(270, 316);

          map.on('extent-change', lang.hitch(this, function(evt){
            console.info(map.getScale());
            var sFeat = map.infoWindow.getSelectedFeature();
            if(map.getScale() < 10000 && sFeat && sFeat._layer.id === 'Crimes_8530'){
              html.setStyle(document.getElementById("map_graphics_layer"), 'display', 'none');
            }else{
              html.setStyle(document.getElementById("map_graphics_layer"), 'display', 'block');
            }
          }));
...

Of course you need to replace the "Crimes_8530" layer Id with your own layers Id. To find your layers Id open the LayerList widget and right click on the layer in the list and choose Inspect. Look for the tr element with the layernodeid attribute (ie. layertrnodeid="Crimes_8530"). 

For the Add a Marker in the jimu.js\featureActions\AddMarker.js file. I added "&&" to line 5 and then added line 6

    isFeatureSupported: function(featureSet) {
      this._getMarkerLayer();
      if(featureSet);
      return this._isSupportType(featureSet) && featureSet.features.length > 0 &&
          featureSet.features[0] && featureSet.features[0].geometry &&
          featureSet.features[0]._layer.id !== "Crimes_8530" &&
          false === this._isFeatureInMarkerFeatureActionLayer(featureSet/*, this._markerLayer*/);
    },

Again you need your layers Id.

0 Kudos
SimonFonji
New Contributor III

Hello Robert,

I modified the files you mentioned. It works as expected. When I modified the ‘AddMarker.js file’ the ‘add a maker’ disappear as expected but it affects my near me widget (near me widget does not work at all). I also realized that even though the pop-up highlight for a feature disappears, the pop-up window remains and clients can still zoom in to street or house level to see where the complaints are coming from.

Is there a way to make this pop-up window disappear at a certain zoom level? That is, instead of making the pop-up highlight disappear if we can make the pop window disappear I think that would solve the problem.

Thanks for your time and help.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Simon,

   Sure hiding the popup is even easier.

          map.on('extent-change', lang.hitch(this, function(evt){
            var sFeat = map.infoWindow.getSelectedFeature();
            if(map.getScale() < 10000 && sFeat && sFeat._layer.id === 'Crimes_8530'){
              map.infoWindow.hide();
            }
          }));

I have no idea why hiding the add a marker would affect the Near Me widget though.

SimonFonji
New Contributor III

Hello Robert,

Thanks very much. It works fine for me.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Simon,

   You should mark the reply that answered your question as the correct answer (right now you have your reply back to me marked as the correct answer).

0 Kudos