Draw many ajaxMaps on the one Page

Topics: Web Controls
Dec 8, 2008 at 3:06 AM
Hi all,
I have a situation following:
I use ajaxMap to draw many maps per Page. but in the Page only 1 maps can zoom, and other maps can't zoom. Please help me.
Here is my Code :

public partial class MapViewer : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            phMap.Controls.Clear();
            GetMap(0);
            GetMap(1);
            GetMap(2);
            GetMap(3);
        }

        #region BuildMap

        private void InitializeMap(AjaxMapControl ajaxMap)
        {
            ajaxMap.DisplayStatusBar = true;
            ajaxMap.FadeSpeed = 3;
            ajaxMap.ZoomSpeed = 3;
            ajaxMap.HasLegend = true;
            ajaxMap.Map.MaximumZoom = 43;
            ajaxMap.Map.MinimumZoom = 0.5;
            ajaxMap.Map.Zoom = 43;
            ajaxMap.Map.Center = new SharpMap.Geometries.Point(103, 15);
        }

        protected void GetMap(int i)
        {
            string sTableLayer = MapConstants.DISTRICT_LAYER;
            hfTableNameInfo.Value = MapConstants.DISTRICT_LAYER;

            AjaxMapControl ajaxMap = new AjaxMapControl();
            ajaxMap.ID = "ajaxMap" + i.ToString();

            ajaxMap.Map = MapHelper.InitializeMap(new System.Drawing.Size(10, 10), sTableLayer, string.Empty, string.Empty);
            ajaxMap.TableInforName = MapConstants.DISTRICT_LAYER;
            ajaxMap.TableLayerName = sTableLayer;

            string sResponseFormat = MapConstants.MAP_RESPONSE_FORMAT_FILE;
            sResponseFormat += "?" + MapConstants.PARA_NAME_TABLE_LAYER_NAME + "=" + sTableLayer;
            sResponseFormat += "&" + MapConstants.PARA_NAME_TABLE_INFO + "=" + MapConstants.PARA_TABLEINFO;
            sResponseFormat += "&" + MapConstants.PARA_NAME_WIDTH + "=" + MapConstants.PARA_WIDTH;
            sResponseFormat += "&" + MapConstants.PARA_NAME_HEIGHT + "=" + MapConstants.PARA_HEIGHT;
            sResponseFormat += "&" + MapConstants.PARA_NAME_ZOOM + "=" + MapConstants.PARA_ZOOM;
            sResponseFormat += "&" + MapConstants.PARA_NAME_PROJECTIDS + "=" + MapConstants.PARA_PROJECTIDS;
            sResponseFormat += "&" + MapConstants.PARA_NAME_COLOR_CODE + "=" + MapConstants.PARA_COLOR_CODE;
            sResponseFormat += "&" + MapConstants.PARA_NAME_X + "=" + MapConstants.PARA_X;
            sResponseFormat += "&" + MapConstants.PARA_NAME_Y + "=" + MapConstants.PARA_Y;

            ajaxMap.ResponseFormat = sResponseFormat + "&rnd=" + RandomString(20, true);
            ajaxMap.Width = Unit.Percentage(45);
            ajaxMap.Height = Unit.Pixel(500);

            if (!IsPostBack)
            {
                InitializeMap(ajaxMap);
            }
            phMap.Controls.Add(new LiteralControl("\n\n\n"));
            phMap.Controls.Add(ajaxMap);
        }

        private string RandomString(int size, bool lowerCase)
        {
            StringBuilder builder = new StringBuilder();
            Random random = new Random();
            char ch;
            for (int i = 0; i < size; i++)
            {
                ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                builder.Append(ch);
            }
            if (lowerCase)
                return builder.ToString().ToLower();
            return builder.ToString();
        }
        #endregion BuildMap
Dec 8, 2008 at 3:45 AM
Hi all,
I found the reason. It can't get Center point.
But i have not a solution for this case. Please help me!