Select to view content in your preferred language

Move my map

1018
2
11-04-2012 06:09 AM
PabloMartinez
New Contributor
Hello! I am implementing a simple application, where appear a textbox where you can put a city, and the application moves the map to the best location of the city.


                // Get the best match.
                AddressCandidate bestCandidate = args.Results[0];
                foreach (AddressCandidate candidate in args.Results)
                    bestCandidate = (candidate.Score > bestCandidate.Score) ? candidate : bestCandidate;

                // Create a graphic for the match.
                Graphic graphic = new Graphic()
                {
                    Symbol = LayoutRoot.Resources["AddressToLocationSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                    Geometry = bestCandidate.Location
                };

                MyMap.PanTo(graphic.Geometry);



This is working, but only shows the city (for example New York). I would like to ZOOM at the correct place, but I can't find a method that do that.

If somebody has an idea, it would be great!

Thank you!

Pablo
0 Kudos
2 Replies
deleted-user-ATjHIWsdQYmT
Deactivated User
Because your graphic is a point, you can't zoom to it.  It has no envelope.  Try:
MyMap.ZoomTo(graphic.Geometry.Extent.Expand(50));

You might have to adjust the expansion (50) to suit your liking.
0 Kudos
PabloMartinez
New Contributor
Thank you! 😄 It is working now!

Pablo
0 Kudos