I am trying to duplicate the zoom process of the search widget of the Flex Viewer. When you enter a street name and click one of the results it zooms to the particular graphic on the map. Like the Search widget, I am trying to zoom to a particular point on the map ina custom widget that I have created.Click handler below from the Search Widget:
private function clickSearchResult(event:Event):void
{
var searchResult:SearchResult = ItemRenderer(event.target).data as SearchResult;
if (searchResult.geometry)
{
if (searchResult.geometry.type == Geometry.MAPPOINT)
{
if (map.scale > zoomScale)
{
map.scale = zoomScale;
}
map.centerAt(searchResult.point);
}
else
{
map.extent = searchResult.geometry.extent;
if (!map.extent.contains(searchResult.geometry))
{
map.level--;
}
}
}
clearTimeout(hitimer);
hitimer = setTimeout(showHighlight, 300, [ searchResult ]);
}
The above code works. It zooms to the feature point given. I have a sex offender widget that basically does the same thing It selects a group of features and displays them via a custom item renderer within the widget. I am trying to zoom to the feature on the map by clicking one of the results, same as the Search widget. My code bombs on the highlighted line below.
private function clickHandler(event:Event):void
{
var bufferResult:HCSexOffenderResult = ItemRenderer(event.target).data as HCSexOffenderResult;
if (bufferResult.geometry)
{
if (bufferResult.geometry.type == Geometry.MAPPOINT)
{
if (map.scale > zoomScale)
{
map.scale = zoomScale;
}
map.centerAt(bufferResult.point);
}
}
else
{
Alert.show("I am in else");
}
clearTimeout(hitimer);
hitimer = setTimeout(showHighlight, 300, [bufferResult]);
}
Does anybody have any ideas about whats going on? Let me know if you need more information. Thanks