Search Widget - Zoom to result is too close, is there a way to customize it?

5585
12
Jump to solution
04-21-2016 06:06 PM
WilsonLee
Occasional Contributor

Hi All,

I have a search widget and it's using our own layer source (feature service, polygon). When I click the search result it will zoom to the selected polygon extent and the polygon occupied the whole map content screen. Can the search result not to zoom in too close? is there anyway to customize it?

thanks,

Wilson

0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus

Normally that means you have introduced a syntax error in the changes you made.

0 Kudos
CCWeedcontrol
Occasional Contributor III

that's what i figured but i can't see to figure out where. All i did was add these two lines.

Went from

if (result &&
              result.name &&
              title === result.name.toString() &&
              dIdx === dataIndex.toString() &&
              dsIndex === dataSourceIndex.toString()) {
              html.addClass(li, 'result-item-selected');
            }
          }));

        //var layer = this.map.getLayer(sourceLayerId);
        var layerInfo = this.layerInfosObj.getLayerInfoById(sourceLayerId);

To this.

if (result &&
              result.name &&
              title === result.name.toString() &&
              dIdx === dataIndex.toString() &&
              dsIndex === dataSourceIndex.toString()) {
              html.addClass(li, 'result-item-selected');
            }
          }));
          var pt = result.feature.geometry.getCentroid();
          this.map.centerAndZoom(pt, 2); //Change this to suit your needs
      },
        //var layer = this.map.getLayer(sourceLayerId);
        var layerInfo = this.layerInfosObj.getLayerInfoById(sourceLayerId);
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

CC Weedcontrol,

So the issue is this line 10 in your new code then. notice that "}," was not at that location in you original code.

0 Kudos