highlight options within MapView

1052
5
Jump to solution
10-03-2018 08:58 AM
City_of_Greenville__SCGIS
New Contributor III

I'm trying to turn on the highlight settings for layers that are clicked on and came across the highlightOptions setting within the MapView but I can't get it to work.

I added the following but nothing happens:

var view = new MapView({
               map: webmap,
               rotation: 340,
               highlightOptions: {
                    color: [255, 255, 0, 1],
                    haloOpacity: 0.9,
                    fillOpacity: 0.2
               },

What am I missing?

Scott

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Honored Contributor

Here's some code to start with. I took this sample and added code to highlight the symbols as you mouse over them

JS Bin - Collaborative JavaScript Debugging 

View solution in original post

5 Replies
KenBuja
MVP Honored Contributor

Are you also adding the highlight method on the FeatureLayerView? Take a look at this sample: ArcGIS API for JavaScript Sandbox 

0 Kudos
City_of_Greenville__SCGIS
New Contributor III

I think so but that example loses me.

Here's what I have so far (I'm not sure what the syntax tool ins't working accurately here):

var featureLayerhighlight = new FeatureLayer({
     url: "https://services.arcgis.com/s8BzdTejnTIG3ix6/ArcGIS/rest/services/FFG2018POI_z/FeatureServer/0"
});

webmap.add(featureLayerhighlight);

view.on("pointer-move", function(event){
            view.hitTest(event).then(function(response){
              if (response.results.length) {
                var graphic = response.results.filter(function (result) {
                  return result.graphic.layer === featureLayerhighlight;
                })[0].graphic;

               view.whenLayerView(graphic.layer).then(function(layerView){
                 layerView.highlight(graphic);
               });
              }
            });
          });
0 Kudos
KenBuja
MVP Honored Contributor

Here's some code to start with. I took this sample and added code to highlight the symbols as you mouse over them

JS Bin - Collaborative JavaScript Debugging 

View solution in original post

City_of_Greenville__SCGIS
New Contributor III

Ken, 

Thanks so much, this did it.  Unfortunately it produces another issue (detailed below) but I'm going to mark this correct.

Is highlight option new in 4.9?  It doesn't run in 4.8.  Which brings me to the issue.  This map has a fairly complex symbology setup which stems from the AGO's inability to maintain a reference scale.  Since it's also an event map I've rotated the map so that it reads in a more user friendly up/down orientation.  However something about 4.9 doesn't like the way I've symbolized things and rotated.  You can see the two versions below.  There might not be anything to be down here given my time constraints but if you notice anything I can do I'd love to hear it.

JS BIN 4.8 Version

JS Bin 4.9 Version

Scott

0 Kudos
KenBuja
MVP Honored Contributor

According to the documentation, highlight was added in 4.4 and highlightOptions was added in 4.5. However, changing the sample from my answer to earlier versions on the API makes the highlighting fail. I'm not seeing anything in the Bug Fixes and Enhancements about this getting fixed

0 Kudos