I'm relatively new to silverlight and have been asked to try and figure out how to map some points using the ESRI silverlight maps.I have a xml file that contains lat and long attributes. I'm trying to loop through the xml doc and add the lat/long to a layer. I had some issues with the code so now I'm just trying to add the first lat/long in the xml doc as a single point in the layer. My problem is that the map will load (display) but the points or point will not display. Please help.Here is the c#using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Windows.Controls;
using System.Windows.Media;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Symbols;
using System.Xml;
using ESRI.ArcGIS.Client.Graphics;
namespace addpointsfromxml
{
public partial class MainPage : UserControl
{
private static ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
public MainPage()
{
InitializeComponent();
AddMarkerGraphics();
}
void AddMarkerGraphics()
{
GraphicsLayer point = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
XmlReader reader = XmlReader.Create("crashLoc.xml");
while (reader.ReadToFollowing("marker"))
{
Graphic g = new Graphic();
{
double x = Convert.ToDouble(reader.GetAttribute("lat"));
double y = Convert.ToDouble(reader.GetAttribute("lng"));
ESRI.ArcGIS.Client.Geometry.Geometry geo = new MapPoint(x, y);
g.Attributes.Add("Latitute", x);
g.Attributes.Add("Longitutde", y);
point.Graphics.Add(g);
//reader.ReadToDescendant("marker");
}
}
MyMap.Layers.Add(point);
}
}
}
and here is the xaml:<UserControl x:Class="addpointsfromxml.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<esriSymbols:SimpleMarkerSymbol x:Key="RedMarkerSymbol" Color="Red" Size="12" Style="Circle" />
<esriSymbols:SimpleMarkerSymbol x:Key="BlackMarkerSymbol" Color="Black" Size="14" Style="Diamond" />
<esriSymbols:PictureMarkerSymbol x:Key="GlobePictureSymbol" OffsetX="8" OffsetY="8"
Source="/Assets/images/globe-16x16.png" />
<esriSymbols:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="Green" Style="DashDot" Width="4" />
<esriSymbols:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="Green" BorderBrush="Blue"
BorderThickness="3" />
</Grid.Resources>
<esri:Map x:Name="MyMap" WrapAround="True" Background="White">
<esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
<esri:GraphicsLayer ID="MyGraphicsLayer" />
</esri:Map>
</Grid>
</UserControl>
this is a part of the xml I am getting the lat/lng from:<?xml version="1.0" encoding="utf-8"?>
<Markers>
<marker lat="35.1628834" lng="-89.8608" address="6069 MACON" Date_time="2011-08-01T11:12:35" Crash_number="-2145850900" />
<marker lat="35.145575" lng="-90.054077" address="67 MADISON" Date_time="2011-08-01T11:25:44" Crash_number="-2145850883" />
<marker lat="35.095578" lng="-90.012385" address="1843 MEADOWHILL" Date_time="2011-08-01T19:27:42" Crash_number="-2145850299" />
<marker lat="35.130815" lng="-89.860618" address="6019 WALNUT GROVE" Date_time="2011-08-01T08:52:54" Crash_number="-2145851066" />
<marker lat="35.044939" lng="-89.866404" address="3830 HICKORY HILL" Date_time="2011-08-02T00:03:48" Crash_number="-2145849937" />
<marker lat="35.021242" lng="-90.063027" address="32 SHELBY" Date_time="2011-08-02T02:05:40" Crash_number="-2145849833" />
<marker lat="35.0290315" lng="-89.869286" address="5812 SUNNY MORNING" Date_time="2011-08-02T05:44:55" Crash_number="-2145849698" />