I have two questions regarding the search widget:
1) How do you change the graphic style on the result from the new search widget?
This thread describes how to set the style of the graphic when toggling the info window for the returned graphic. I have tried this and it does work when toggling the infoWindow. I am not clear on how to set the style of the graphic returned before clicking on the graphic to open the infoWindow. Any ideas?
2) When I return polygons using the search widget the map zooms in a little farther than I would like most of the time. I would like to be a little further out. How can I correct this? I have tried setting the map zoom on 'select-result' event handler but it seems that this event handler fires a bit too early and I wind up panned to the wrong location on the map.
on(s,'select-result', function(e) {
map.setZoom(8);
});
Setting the zoomScale in the constructor for the search widget works for my point feature layers but for the polygon feature layers it does not work. I believe this is because the polygons have a predefined extent. How can I override this?
Thanks for any guidance.
Rich
Solved! Go to Solution.
Hi Rich,
I've had the same issue as well -- I was able to work around it using the centreAndZoom map function:
s.on("select-result", function (result) {
var pt = result.result.feature.geometry;
globals.map.centerAndZoom(pt, 2); // Change '2' to your appropriate LOD
});
*Edit* You'll need to set 'autoNavigate: false' on your Search object when doing this, otherwise it will attempt to zoom twice and some unexpected behavior can occur...
Hope this helps.
Jonathan
Hi Rich,
I've had the same issue as well -- I was able to work around it using the centreAndZoom map function:
s.on("select-result", function (result) {
var pt = result.result.feature.geometry;
globals.map.centerAndZoom(pt, 2); // Change '2' to your appropriate LOD
});
*Edit* You'll need to set 'autoNavigate: false' on your Search object when doing this, otherwise it will attempt to zoom twice and some unexpected behavior can occur...
Hope this helps.
Jonathan
Jonathan,
Thanks for your reply.
This worked well for me. Since I was dealing with polygons I had to get the centroid from the polygon:
s.on("select-result", function (result) {
var pt = result.result.feature.geometry.getCentroid();
globals.map.centerAndZoom(pt, 2); // Change '2' to your appropriate LOD
});