AnsweredAssumed Answered

How to zoom to a point in map

Question asked by joby003 on Apr 23, 2012
Latest reply on Apr 30, 2012 by joby003
Hi

I have created an application in silverlight using arcgis api. In that I am saving the location in map using map points.

I got the map points while I try to save the record.

When i try to edit the same record I want to zoom to the particular location. How can I do this

<Grid x:Name="LayoutRoot" Margin="2">
        <Grid.Resources>
            <esri:PictureMarkerSymbol x:Key="PinPictureMarkerSymbol" Source="/UIControls.AccidentRecordForm;component/Images/Delete_2.png" />
        </Grid.Resources>
        <esri:Map MouseClick="Map_MouseClick" x:Name="MyMap">
            <esri:Map.Layers>
                <esri:ArcGISTiledMapServiceLayer Url="http://www.darb.ae/ArcGIS/rest/services/BaseMaps/DOT_StreetMap_En/MapServer"/>
                    <esri:GraphicsLayer ID="MyGraphicsLayer">
                            <esri:GraphicsLayer.Graphics >
                        <esri:Graphic Symbol="{StaticResource PinPictureMarkerSymbol}">
                                </esri:Graphic>
                            </esri:GraphicsLayer.Graphics>
                        </esri:GraphicsLayer>

                    </esri:Map.Layers>
        </esri:Map>
    </Grid>


                    MapPoint mapPoint=new MapPoint(Convert.ToDouble(crashForm.tbLocationEasting.Text), Convert.ToDouble(crashForm.tbLocationNorthing.Text));
                    GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                    Graphic graphic = new Graphic()
                        {
                            Geometry = mercator.FromGeographic(mapPoint),
                            Symbol = LayoutRoot.Resources["PinPictureMarkerSymbol"] as Symbol
                        };
                    graphicsLayer.Graphics.Clear();
                    graphicsLayer.Graphics.Add(graphic);

this is the code where I add graphics to the map whle editting.

How can I zoom or focus to this location?
Please help.

Outcomes