Hey,I'm just starting with ESRI, and have been using Silverlight with Bing Maps for some time now. I'm trying to add MapPoint elements to a graphics layer within the ESRI map, and at one point I was successful with this.I haven't been able to get the dots to show up ever since I tried setting the Extent of my map based on an area defined in an Envelope. Here are some code segments of what I'm doing, and perhaps someone will see what I am not.Here is the XAML markup:
<esri:Map Name="MyMap" Width="800" Height="600" >
<esri:Map.Layers>
<esri:ArcGISTiledMapServiceLayer ID="BaseLayer" x:Name="BaseLayer"
Url="http://server.arcgisonline.com/arcgis/services/World_Street_Map/MapServer" />
<esri:GraphicsLayer ID="DataLayer" />
</esri:Map.Layers>
</esri:Map>
Here is where I add the graphics and set the extents. The "data" object is what i'm receiving back from my web service call, so pretend that looks like a real data collection with each item having a Latitude and Longitude. Also, the "center" map point is where I want to center the map, which comes back from the web service as well.
GraphicsLayer dataLayer = DUMap.Layers["DataLayer"] as GraphicsLayer;
dataLayer.Graphics.Clear();
if (dataLayer != null)
{
List<object> data = new List<object>();
foreach (object o in data)
{
MapPoint point = new MapPoint(o.Longitude, o.Latitude);
Graphic graphic = new Graphic();
graphic.Symbol = new SimpleMarkerSymbol();
graphic.Geometry = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(point);
dataLayer.Graphics.Add(graphic);
}
MapPoint center = new MapPoint(data.center_long, data.center_lat);
ESRI.ArcGIS.Client.Geometry.Geometry g = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(center);
g.SpatialReference = DUMap.SpatialReference;
double width = 4;
Envelope envelope = new Envelope()
{
XMin = center.X - width,
YMin = center.Y - width,
XMax = center.X + width,
YMax = center.Y + width,
SpatialReference = MyMap.SpatialReference
};
MyMap.Extent = envelope;
dataLayer.Refresh();
}
If I've left anything out that is important, please let me know. I had the dots showing on the map before I tried messing with the extent by adding a custom envelope, so that's where I'm guessing I'm going wrong.Thanks so much!Kevin