Dynamic Markers

May 20, 2009 at 8:35 PM

I have a method   named LoadMarkers. It runs at Page_Load (!PostBack). But something goes wrong. There is no markers on my map.   I debugged it to control the XML opearitions. XML operations work correctly.

 protected void LoadMarkers()
    {

            Map1.ShowMapTypeControl = true;
            Map1.Longitude = 42.322898;
            Map1.Latitude = 41.164056;
            Map1.Zoom = 12;
            Map1.EnableScrollWheelZoom = true;
            Map1.EnableGoogleBar = true;
            Map1.EnableMarkerManager = true;

            Map1.Markers.Clear();

            XmlDocument doc = new XmlDocument();

            XmlTextReader textReader = new XmlTextReader("C:\Markers.xml");

            doc.Load(textReader);

            XmlNodeList markerList = doc.GetElementsByTagName("marker");

            foreach (XmlNode markerNode in markerList)
            {
                XmlElement markerElement = (XmlElement)markerNode;

                string title = markerElement.GetElementsByTagName("title")[0].InnerText;
                string latitude = markerElement.GetElementsByTagName("latitude")[0].InnerText;
                string longitude = markerElement.GetElementsByTagName("longitude")[0].InnerText;
                string text = markerElement.GetElementsByTagName("text")[0].InnerText;

                GoogleMarker marker = new GoogleMarker(Double.Parse(latitude), Double.Parse(longitude));
                marker.Title = title;
                marker.Text = text;
                marker.Draggable = false;
                Map1.Markers.Add(marker);

            }

}