Hello!
I have made a webmap with functionalities like basic toolbar (zoom in/out, print out etc), find information and search in map by writing an address.
When I search in my map by writing address and get a list of possible addresses, I can select any post to get it zoomed in my map without any problem. My ???Find information??? function works fine too but when getting back to the address list (searched earlier) if I try to pick any post (from 2nd to the last in the list) it gives an error ???Index was out of range. Must be no-negative and less than the size of collection. Paranetername: index??? at this code line "MapPoint candidatePoint = _candidateGraphicsLayer.Graphics[index].Geometry as MapPoint;"
This happens only when both find an address and find information are working at the same time.
Code is
GraphicsLayer _candidateGraphicsLayer;
void _candidateListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = (sender as ListBox).SelectedIndex;
if (index >= 0)
{
MapPoint candidatePoint = _candidateGraphicsLayer.Graphics[index].Geometry as MapPoint;
double displaySize = MyMap.MaximumResolution * 0.27;
ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
candidatePoint.X - (displaySize / 2),
candidatePoint.Y - (displaySize / 2),
candidatePoint.X + (displaySize / 2),
candidatePoint.Y + (displaySize / 2));
MyMap.ZoomTo(displayExtent);
}
}
Any solution?
Thanks in advance!